# ETH0 Classical Oracle

## High-Level Overview

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.

### Contract Summary

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

### Inherited Contracts

* **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.

## Functionality Breakdown

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.

#### Flow Diagram

<figure><img src="/files/SyIYgphomAarrDz9XQgQ" alt=""><figcaption></figcaption></figure>

### Functions Description

#### Public/External Functions

* **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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tech.usual.money/smart-contracts/utility-contracts/eth0/eth0-classical-oracle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
