How It Works

Prior Work

See https://docs.chain.link/data-feeds/api-reference#aggregatorv3interface for documentation on the Chainlink Oracle interface.

Supported Frax Assets

Currently frxEth/ETH and sfrxEth/ETH are supported.

Frax Dual Oracle Price Logic

frxEth

The frxEth price is determined from two onchain price sources. The first price source is the frxEth / ETH Curve pool EMA Oracle - 0xa1f8a6807c402e4a15ef4eba36528a3fed24e577. This price is bounded to be 0.7 at the lowest (0.7 frxEth = 1 ETH) and 1 at the highest (1 frxEth = 1 ETH).

The second price source comes from the Uniswap frxEth / FRAX pool TWAP oracle - 0x36C060Cc4b088c830a561E959A679A58205D3F56. We then retrieve the price of ETH in USD from this chainlink oracle (0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419) and the price of FRAX in USD from this chainlink oracle (0xB9E1E3A9feFf48998E45Fa90847ed4D467E8BcfD). These chainlink prices are used to convert the frxEth / FRAX pool price into a frxEth / ETH price using the following equation:

ethPerFrxEth = (fraxPerFrxEthUniswapTwap * usdPerFraxChainlink) / usdPerEthChainlink;

This price from Uniswap is similarly bounded between 0.7 and 1, mirroring the Curve price. The lower of these prices is returned as priceLow and the higher is returned as priceHigh. These prices are then written to the frxEth / ETH Frax Oracle.

sfrxEth

Simply retrieves the pricePerShare() from the sfrxEth contract, retrieves the priceHigh and priceLow in the same manner as the frxEth Dual Oracle outlined above, and returns the following equation:

priceLow =  (SFRXETH_ERC4626.pricePerShare() * frxEthEthPriceLow) / 1e18;
priceHigh = (SFRXETH_ERC4626.pricePerShare() * frxEthEthPriceHigh) / 1e18;

This works because pricePerShare() returns how many frxEth a single sfrxEth is worth. pricePerShare() goes up over time.

These prices are then written to the sfrxEth / ETH Frax Oracle.

Simply call https://docs.chain.link/data-feeds/api-reference#getrounddata or https://docs.chain.link/data-feeds/api-reference#latestrounddata on the Frax Oracle contract for the asset you want the price of.

Frax Oracle on L2

Coming soon

Last updated