ETH0 Classical Oracle
Last updated
Was this helpful?
Last updated
Was this helpful?
The ClassicalOracle contract is used by DaoCollateral to fetch the price of external tokens. The price of tokens is used for minting and redeeming the right amount of ETH0. It is an upgradable contract.
Most of the contract’s logic is inherited from AbstractOracle. Two responsibilities remain in ClassicalOracle itself:
Initializing tokenToOracleInfo
for each supported token with a ChainlinkV3Aggregator-compatible price feed
Interacting with the aggregator to fetch the latest price and its number of decimals
IOracle: Common interface used by other contracts and external service (e.g. the dApp) to interact with the ClassicalOracle. Ensures function signatures are the ones expected by these external actors.
AbstractOracle: Encapsulates most of the logic and the implementation of public/external functions from IOracle.
After deploying the contract, the administrator should initialize the price feed for all supported collateral.
When another contract or external service calls getPrice
or getQuote
, the inherited AbstractOracle contract calls the virtual function _latestRoundData
passing the desired token as parameter. This function is implemented in ClassicalOracle and retrieves the associated price aggregator for this token, then calls decimals
and latestRoundData
which are returned to AbstractOracle.
initializeTokenOracle(address token, address dataSource, uint64 timeout, bool isStablecoin): Registers a new supported token or updates the data source (price aggregator) for an existing token. The new price feed must have been last updated within the last timeout
seconds. This check is only performed once. If isStablecoin
is true, the depeg check will be enabled and getPrice
/getQuote
will revert if the price is not around $1.
Also see AbstractOracle for the other public/external functions.