Oracle

Used to get FRAX-collateral and FXS-collateral price data.

Deployment

The Chainlink price consumer contract is deployed at: 0xBa6C6EaC41a24F9D39032513f66D738B3559f15a

The FRAX-ETH Uniswap pair oracle is deployed at: 0xD18660Ab8d4eF5bE062652133fe4348e0cB996DA

The FRAX-USDC Uniswap pair oracle is deployed at: 0x2AD064cEBA948A2B062ba9AfF91c98B9F0a1f608

The FRAX-USDT Uniswap pair oracle is deployed at: 0x97587c990617f65A83CAb4f08b23F78472a0413b

The FRAX-FXS Uniswap pair oracle is deployed at: 0xD0435BF68dF2B516C6382caE8847Ab5cdC5c3Ea7

The FXS-ETH Uniswap pair oracle is deployed at: 0x9e483C76D7a66F7E1feeBEAb54c349Df2F00eBdE

The FXS-USDC Uniswap pair oracle is deployed at: 0x28fdA30a6Cf71d5fC7Ce17D6d20c788D98Ff2c46

The FXS-USDT Uniswap pair oracle is deployed at: 0x4FCb1759BD13950E7e73eEd650eb5bB355bC1CBC

Description

The Frax system takes price feeds from two external systems: Chainlink and Uniswap. The system records the ETH-USD price from Chainlink and applies it to the FRAX-wETH and FXS-wETH pool balances from Uniswap in order to get an accurate FRAX-USD and FXS-USD price. This allows FRAX to follow the true price of USD and not a basket of onchain stablecoins (which could deviate significantly). The Chainlink oracle is a time weighted average of the ETH-USD price updated every hour.

The ChainlinkETHUSDPriceConsumer contract is responsible for getting the price of ETH in terms of USD. To get the price of ETH in USD from this contract, call getLatestPrice() and divide by getDecimals().

Uniswap

The Uniswap V2 system includes price oracles that use a time-weighted average price in order to robustly calculate an accurate price for tokens within the Uniswap pools. Frax uses these oracles over a 1 hour time-weighted average price on its Uniswap pools to get price information for FRAX, FXS, and the collateral tokens in the system. The period of the time-weighted average price is changeable as a system parameter through a governance proposal.

The UniswapPairOracle contract allows one to get the price of a token within the system from its pool balance. To get the price of a token from a pair, call consult(address token, uint amountIn) on the pair's UniswapPairOracle instance with the token's address and requested quantity.

Last updated