Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

AaveOracle

Contract used by Pool (via PoolAddressesProvider.getPriceOracle()) to look up asset prices. AaveOracle itself implements a thin per-asset routing layer: each asset is mapped to a Chainlink-compatible AggregatorInterface source. The source contract is expected to return prices in the units of BASE_CURRENCY_UNIT (typically 1e8 for USD-denominated markets).

For SparkLend, the per-asset source addresses point at redundant aggregator contracts (e.g. Aggor) that internally combine Chainlink, Chronicle, and RedStone feeds. The aggregation logic lives in those source contracts, not in AaveOracle.

Resolution rules in getAssetPrice(asset):

  1. If asset == BASE_CURRENCY, returns BASE_CURRENCY_UNIT.
  2. Else if a source is configured, calls source.latestAnswer(). If the answer is > 0, returns it. Otherwise, falls through to the fallback oracle.
  3. Else (no source configured), calls the fallback oracle.

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.