Skip to content

Instantly share code, notes, and snippets.

@dbeal-eth
Last active September 17, 2024 11:28
Show Gist options
  • Save dbeal-eth/2dae27dbdaed0a6c3973fe87d45a890c to your computer and use it in GitHub Desktop.
Save dbeal-eth/2dae27dbdaed0a6c3973fe87d45a890c to your computer and use it in GitHub Desktop.
explanation of erc7412 changes

ERC7412 has been used by Synthetix to allow users to push their own price updates to complete on-chain operations.

The protocol has been difficult to maintain as the number of markets have increased on the perps platform, and it is no longer possible/practical to apply price updates using the reccomended call pattern due to hundreds of necessary simulation calls,

To resolve this problem, ERC7412 errors will now be returned in large batches.

A summary of the interface changes to ERC7412 can be on the reference impl repo.

Explanation of Changes

Batching of OracleDataRequired

A new custom error, error Errors(bytes[]) has been created. This error has the capability to contain many encoded OracleDataRequired custom errors, as well as any other errors that may be encountered during the oracle resolution process. In some cases, there may even be Errors nested, necessitating the use of recursion to find all the errors.

Note that a mixture of many different types of oracleContracts may be returned by the object. A compliant erc7412 implementation should be able to batch these required oracle datas together into a single cohesive call for each necessary oracle provider.

However, For the time being, Synthetix is still only using the PYTH oracle provider.

Optional OracleDataRequired fee parameter

To prevent the additional call necessary to compute the required fee, the OracleDataRequired error can now optionally include an additional fee parameter. In total, the oracle data error definition now looks like this:

error OracleDataRequired(address oracleContract, bytes oracleQuery, uint256 feePool);

If no fee is supplied by OracleDataRequired, then the defualt fee for the provider should be used instead.

Reference Implementation of Changes

The ERC7412 changes have been applied to the Python SDK of Synthetix. This can be used as a reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment