OracleManager.sol

OracleManager

The Oracle Manager stores oracle implementations. External contracts can call getPrice to get the price of an asset.

oracles

contract IBasePriceOracle[] oracles

Active oracle implementations.

Stored in priority order.

numOracles

uint256 numOracles

The number of active oracle implementations.

quoteAsset

address quoteAsset

The ERC20 in which the price is quoted.

MIN_SUPPORTED_ORACLES

uint256 MIN_SUPPORTED_ORACLES

The minimum number of supported oracles.

MAX_SUPPORTED_ORACLES

uint256 MAX_SUPPORTED_ORACLES

The maximum number of supported oracles.

constructor

constructor(address _quoteAsset) public

Sets the ERC20 in which the price is quoted.

Parameters

NameTypeDescription

_quoteAsset

address

the address of the quote token.

getPrice

function getPrice(address _asset) external view returns (uint256)

Returns the price of the asset quoted in terms of the base asset.

Iterates through oracles in order, and calls IBasePriceOracle.getPrice() if the oracle supports the asset. Reverts if no oracle supports by asset.

Parameters

NameTypeDescription

_asset

address

the address of the asset to quote.

Return Values

NameTypeDescription

[0]

uint256

The price of the asset in WAD.

setOracles

function setOracles(contract IBasePriceOracle[] _oracles) external

Sets the oracle implementations.

First it zeroes out the oracles array in storage. It copies elements from _oracles then updates numOracles. 10 >= number of oracles > 0. Can be called only by the owner.

Parameters

NameTypeDescription

_oracles

contract IBasePriceOracle[]

an array of IBasePriceOracle implementations.

getOracles

function getOracles() external view returns (contract IBasePriceOracle[] _oracles)

Retrieves the oracle implementations.

Used for off-chain data retrieval.

Return Values

NameTypeDescription

_oracles

contract IBasePriceOracle[]

The current active oracle implementations in iteration order.

Last updated