Skip to content

Oracle Contract Interface

Contract to get asset prices, manage price sources and update the fallback oracle

Functions

ADDRESSES_PROVIDER

solidity
contract IPoolAddressesProvider ADDRESSES_PROVIDER

Returns the PoolAddressesProvider

Return Values

NameTypeDescription

BASE_CURRENCY

solidity
address BASE_CURRENCY

Returns the base currency address

Address 0x0 is reserved for USD as base currency.

Return Values

NameTypeDescription

BASE_CURRENCY_UNIT

solidity
uint256 BASE_CURRENCY_UNIT

Returns the base currency unit

1 ether for ETH, 1e8 for USD.

Return Values

NameTypeDescription

onlyAssetListingOrPoolAdmins

solidity
modifier onlyAssetListingOrPoolAdmins()

Only asset listing or pool admin can call functions marked by this modifier.

constructor

solidity
constructor(contract IPoolAddressesProvider provider, address[] assets, address[] sources, address fallbackOracle, address baseCurrency, uint256 baseCurrencyUnit) public

Constructor

Parameters

NameTypeDescription
providercontract IPoolAddressesProviderThe address of the new PoolAddressesProvider
assetsaddress[]The addresses of the assets
sourcesaddress[]The address of the source of each asset
fallbackOracleaddressThe address of the fallback oracle to use if the data of an aggregator is not consistent
baseCurrencyaddressThe base currency used for the price quotes. If USD is used, base currency is 0x0
baseCurrencyUnituint256The unit of the base currency

setAssetSources

solidity
function setAssetSources(address[] assets, address[] sources) external

Sets or replaces price sources of assets

Parameters

NameTypeDescription
assetsaddress[]The addresses of the assets
sourcesaddress[]The addresses of the price sources

setFallbackOracle

solidity
function setFallbackOracle(address fallbackOracle) external

Sets the fallback oracle

Parameters

NameTypeDescription
fallbackOracleaddressThe address of the fallback oracle

getAssetPrice

solidity
function getAssetPrice(address asset) public view returns (uint256)

Returns the asset price in the base currency

Parameters

NameTypeDescription
assetaddressThe address of the asset

Return Values

NameTypeDescription
[0]uint256The price of the asset

getAssetsPrices

solidity
function getAssetsPrices(address[] assets) external view returns (uint256[])

Returns a list of prices from a list of assets addresses

Parameters

NameTypeDescription
assetsaddress[]The list of assets addresses

Return Values

NameTypeDescription
[0]uint256[]The prices of the given assets

getSourceOfAsset

solidity
function getSourceOfAsset(address asset) external view returns (address)

Returns the address of the source for an asset address

Parameters

NameTypeDescription
assetaddressThe address of the asset

Return Values

NameTypeDescription
[0]addressThe address of the source

getFallbackOracle

solidity
function getFallbackOracle() external view returns (address)

Returns the address of the fallback oracle

Return Values

NameTypeDescription
[0]addressThe address of the fallback oracle