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):
- If
asset == BASE_CURRENCY, returnsBASE_CURRENCY_UNIT. - Else if a source is configured, calls
source.latestAnswer(). If the answer is> 0, returns it. Otherwise, falls through to the fallback oracle. - Else (no source configured), calls the fallback oracle.
State Variables
| Name | Type | Description |
|---|---|---|
BASE_CURRENCY | address | The base currency used for price quotes (if USD is used, base currency is 0x0) |
BASE_CURRENCY_UNIT | uint256 | The 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
| Type | Description |
|---|---|
| uint256 | Price 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
| Name | Type | Description |
|---|---|---|
| assets | address[] | The addresses of the assets for which price is being queried. |
Return Value
| Type | Description |
|---|---|
| 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
| Name | Type | Description |
|---|---|---|
| assets | address[] | The addresses of the assets for which source is being set. |
| sources | address[] | 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
| Name | Type | Description |
|---|---|---|
| fallbackOracle | address | The address of the fallback oracle. |