Overview of Oracles Used in the RAI Protocol
RAI uses several oracles to function, some are core to the system while others are not critical.
This post will describe each oracle used in the RAI protocol and the contracts that depend on them.
All oracles (for compatibility reasons) use the same interface, forked from DS-Value, but with easier to understand function names.
ETH-USD
Name on changelog: MEDIANIZER_ETH
Current Address: 0xb825e25856bD98b3f2FAF2aEb6Cb8742B38C4025
Current Implementation: ChainlinkRelayer
One of the two key oracle components in the system, the FSM (Feed Security Module) will take prices from the ETH oracle and force a 1 hour delay between consecutive updates.
The Oracle Relayer contract consumes the delayed price, divides it by the redemption price and then divides the result again by the Safe liquidation ratio before pushing the final output in the core system.
Contracts that use it:
FEED_SECURITY_MODULE_ETH
GEB_ORACLE_RELAYER (indirectly through FSM)
GEB_DEBT_FLOOR_ADJUSTER
GEB_FIXED_REWARDS_ADJUSTER
GEB_MINMAX_REWARDS_ADJUSTER
RAI-USD
Name on changelog: MEDIANIZER_RAI
Current Address: 0x92dC9b16be52De059279916c1eF810877f85F960
Current Implementation: ChainlinkTWAP
This is the second core oracle used in the system. It produces a RAI-USD time weighted average price and is consumed by the RAI controller, and therefore is key in periodically recalculating the redemption rate.
Contracts that use it:
GEB_RRFM_SETTER
GEB_COLLATERAL_AUCTION_HOUSE_ETH_A
GEB_COIN_ETH_UNISWAP_V2_POOL_SAVIOUR
GEB_DEBT_AUCTION_INITIAL_PARAM_SETTER
FLX-USD
Name on changelog: GEB_PROT_TOKEN_ORACLE
Current Address: 0xF0b9A234C273250F8D3cE047D8b9cea773Ae3adE
Current Implementation: DSValue
This is an auxiliary oracle, used only by periphery contracts. It is currently fixed at 300 USD (a value that can be changed by governance). It could be switched to a proper oracle once a reliable and easy to maintain feed is available.
Contracts that use it:
GEB_DEBT_AUCTION_INITIAL_PARAM_SETTER
Gas Price
Name on changelog: GEB_GAS_PRICE_ORACLE
Current Address: 0x3a3e9d4D1AfC6f9d7e0E9A4032a7ddBc1500D7a5
Current Implementation: DSValue
This is an auxiliary oracle, used only by periphery contracts. It is currently fixed at 150 gwei. Although Chainlink provides a gas price oracle, they do not offer a gas price TWAP. A TWAP would be needed to avoid attacks against the system (overpaying oracles with rewards set at gas price peaks).
Since the contracts using it are non critical, the gas oracle can use a fixed price.
Contracts that use it:
GEB_DEBT_FLOOR_ADJUSTER
GEB_FIXED_REWARDS_ADJUSTER
GEB_MINMAX_REWARDS_ADJUSTER
Implementations
These are implementations used for each of the oracles:
- DSValue: stores a fixed price that can be changed by an authed address (governance).
- ChainlinkRelayer: relays a Chainlink aggregator’s result to another contract.
- ChainlinkTWAP: creates and returns a TWAP formed from several Chainlink feed updates.
- ChainlinkPriceFeedMedianizer: reads, stores and returns the price feed fetched from a Chainlink aggregator.
- GovernanceLedPriceFeedMedianizer: median price feed formed from aggregating multiple price feeds submitted by whitelisted providers.
- UniswapConsecutiveSlotsPriceFeedMedianizer: forms and exposes a TWAP from a Uniswap v2 pair.
- UniswapConverterBasicAveragePriceFeedMedianizer: forms and exposes a TWAP from a Uniswap v2 pair.
- UniswapV3Medianizer: forms and exposes a TWAP from a Uniswap v3 pair.