Skip to content

AaveOracle

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

SparkLend utilizes a redundant oracle aggregator (Aggor) that leverages price feeds from Chronicle, Chainlink and Redstone for its lending markets.

The oracle uses Chainlink Aggregators as the first source of price. If the returned price by a Chainlink aggregator is <= 0, the call is forwarded to a fallback oracle. If the asset is the BASE_CURRENCY, it returns BASE_CURRENCY_UNIT directly.

State Variables

NameTypeDescription
BASE_CURRENCYaddressThe base currency used for price quotes (if USD is used, base currency is 0x0)
BASE_CURRENCY_UNITuint256The unit of the base currency

Constructor

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

Initializes the oracle with:

  • PoolAddressesProvider
  • Initial list of assets and their price sources
  • Fallback oracle address
  • Base currency and its unit

Methods

View

getAssetPrice

function getAssetPrice(address asset)

Returns the price of the supported asset in BASE_CURRENCY of SparkLend Market in wei.

  • If the asset is BASE_CURRENCY, returns BASE_CURRENCY_UNIT
  • Otherwise, tries to get price from price oracle (Aggor).

Return Value

TypeDescription
uint256Price in BASE_CURRENCY of the Spark market in wei.

getAssetsPrices

function getAssetsPrices(address[] calldata assets)

Returns the prices of the supported assets in BASE_CURRENCY of the Spark Market. All prices are in wei.

Call Params

NameTypeDescription
assetsaddress[]The addresses of the assets for which price is being queried.

Return Value

TypeDescription
uint256[]Prices in BASE_CURRENCY of the Spark market in wei.

getSourceOfAsset

function getSourceOfAsset(address asset)

Returns the address of the price source for asset.

getFallbackOracle

function getFallbackOracle()

Returns the address of the fallback oracle.

Write

setAssetSources

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

Sets the price source for given list of assets.

Call Params

NameTypeDescription
assetsaddress[]The addresses of the assets for which source is being set.
sourcesaddress[]The address of the source of each asset. Length of assets and sources array should be same.

setFallbackOracle

function setFallbackOracle(address fallbackOracle)

Sets/updates the fallback oracle.

Call Params

NameTypeDescription
fallbackOracleaddressThe address of the fallback oracle.