ParaSpaceOracle

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

  • Use of Chainlink Aggregators as first source of price

  • If the returned price by a Chainlink aggregator is <= 0, the call is forwarded to a fallback oracle

  • Owned by the ParaSpace governance

ADDRESSES_PROVIDER

contract IPoolAddressesProvider ADDRESSES_PROVIDER

Returns the PoolAddressesProvider

Return Values

assetsSources

mapping(address => address) assetsSources

_fallbackOracle

contract IPriceOracleGetter _fallbackOracle

BASE_CURRENCY

address BASE_CURRENCY

Returns the base currency address

Address 0x0 is reserved for USD as base currency.

Return Values

BASE_CURRENCY_UNIT

uint256 BASE_CURRENCY_UNIT

Returns the base currency unit

1 ether for ETH, 1e8 for USD.

Return Values

onlyAssetListingOrPoolAdmins

modifier onlyAssetListingOrPoolAdmins()

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

constructor

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

Constructor

Parameters

Name
Type
Description

provider

contract IPoolAddressesProvider

The address of the new PoolAddressesProvider

assets

address[]

The addresses of the assets

sources

address[]

The address of the source of each asset

fallbackOracle

address

The address of the fallback oracle to use if the data of an aggregator is not consistent

baseCurrency

address

The base currency used for the price quotes. If USD is used, base currency is 0x0

baseCurrencyUnit

uint256

The unit of the base currency

setAssetSources

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

Sets or replaces price sources of assets

Parameters

Name
Type
Description

assets

address[]

The addresses of the assets

sources

address[]

The addresses of the price sources

setFallbackOracle

function setFallbackOracle(address fallbackOracle) external

Sets the fallback oracle

Parameters

Name
Type
Description

fallbackOracle

address

The address of the fallback oracle

_setAssetsSources

function _setAssetsSources(address[] assets, address[] sources) internal

Internal function to set the sources for each asset

Parameters

Name
Type
Description

assets

address[]

The addresses of the assets

sources

address[]

The address of the source of each asset

_setFallbackOracle

function _setFallbackOracle(address fallbackOracle) internal

Internal function to set the fallback oracle

Parameters

Name
Type
Description

fallbackOracle

address

The address of the fallback oracle

getAssetPrice

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

Returns the asset price in the base currency

Parameters

Name
Type
Description

asset

address

The address of the asset

Return Values

Name
Type
Description

[0]

uint256

The price of the asset

getTokenPrice

function getTokenPrice(address asset, uint256 tokenId) external view returns (uint256)

Returns the price of a token

Parameters

Name
Type
Description

asset

address

the asset address

tokenId

uint256

the token id

Return Values

Name
Type
Description

[0]

uint256

The price of the given token

getTokensPrices

function getTokensPrices(address asset, uint256[] tokenIds) external view returns (uint256[])

Returns a list of prices from a list of tokenIds

Parameters

Name
Type
Description

asset

address

the asset address

tokenIds

uint256[]

The list of token ids

Return Values

Name
Type
Description

[0]

uint256[]

The prices of the given tokens

getTokensPricesSum

function getTokensPricesSum(address asset, uint256[] tokenIds) external view returns (uint256)

Returns the sum of prices for list of tokenIds

Parameters

Name
Type
Description

asset

address

the asset address

tokenIds

uint256[]

The list of token ids

Return Values

Name
Type
Description

[0]

uint256

The prices of the given tokens

getAssetsPrices

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

Returns a list of prices from a list of assets addresses

Parameters

Name
Type
Description

assets

address[]

The list of assets addresses

Return Values

Name
Type
Description

[0]

uint256[]

The prices of the given assets

getSourceOfAsset

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

Returns the address of the source for an asset address

Parameters

Name
Type
Description

asset

address

The address of the asset

Return Values

Name
Type
Description

[0]

address

The address of the source

getFallbackOracle

function getFallbackOracle() external view returns (address)

Returns the address of the fallback oracle

Return Values

Name
Type
Description

[0]

address

The address of the fallback oracle

_onlyAssetListingOrPoolAdmins

function _onlyAssetListingOrPoolAdmins() internal view