> For the complete documentation index, see [llms.txt](https://tech.usual.money/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tech.usual.money/smart-contracts/utility-contracts/usd0/usd0-classicaloracle.md).

# USD0 ClassicalOracle

{% hint style="info" %}
Pricefeeds:

Chainlink USDC ETH: 0x8fffffd4afb6115b954bd326cbe7b4ba576818f6

Hashnote Oracle USYC ETH: 0x4c48bcb2160f8e0adbf9d4f3b034f1e36d1f8b3e
{% endhint %}

## High-Level Overview

The ClassicalOracle contract is used by DaoCollateral and the swapperEngine  to fetch the price of external tokens, i.e. RWAs and stablecoins.

The price of tokens is used for minting and redeeming the right amount of USD0.

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 UsualOracle and 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 RWAs and stablecoins (i.e. USYC, USDC, and USDT).

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.
