🔱Oracles - Getting Price Feeds

Oracle - Getting Price Feeds

1. Introduction

The Oracle contracts allow the protocol to get access to the price of a collateral with respect to a stablecoin. There is one Oracle contract per collateral/stablecoin pair. As such different VaultManager contract may use a similar oracle contract.

Different contracts may be deployed depending on the pair looked at: this allows for addresses to be hard coded and save some gas costs when reading a price feed through the read function (all oracle contracts implement this interface).

Angle uses Chainlink price feeds for this borrowing module, and may sometimes also rely on on-chain data. For the case of WStETH, the protocol for instance needs to call, besides Chainlink feeds, the getPooledEthByShares of the StETH contract to get the EUR price of WStETH.

Some contracts may support different routes to access to the price of an asset in stablecoin: for instance for a USDC-EUR feed, only the Chainlink USD/EUR feed may by used, while for the ETH-EUR feed, the protocol will use Chainlink's ETH/USD and USD/EUR.

2. Contracts Details

Interfaces

Each oracle contract implements the abstract BaseOracleChainlinkMulti contract.

Parameters

BaseOracleChainlinkMulti contracts have two parameters:

  • treasury: Reference to a treasury contract for access control purposes (to change the stale period)

  • stalePeriod: Represents the maximum amount of time (in seconds) between each Chainlink update before the price feed is considered stale

3. Key Mechanisms & Concepts

read

function read() external view returns (uint256 quoteAmount);

Reads the rate from the Chainlink circuit and data provided in the contract. This function returns the current rate between the in-currency of the oracle contract (like the collateral) and the out-currency (like the stablecoin) in the base of the out currency. As Angle protocol stablecoins are in base 10**18, most often, the base of the returned value is going to be 10**18

In each oracle implementation, the read function may contain several hard coded data like the addresses involved in the Chainlink circuit, or the decimals of Chainlink feeds.

Governance Functions

Each oracle contract has functions available to governance:

  • changeStalePeriod: For a guardian to change the stale period

  • setTreasury: To notify the oracle contract of a Treasury change in case of

Last updated