The Aave Protocol has several view contracts to assist with querying onchain data.
Contract that returns an array of all reserve or user data for a particular market (for example, liquidity, token addresses, rate strategy), used by the Aave Interface to display Markets and Dashboard data. Compatible with both V2 and V3 of the Aave Protocol.
The Aave Utilities SDK includes an interface to make calls to this contract, and functions to format the response for frontend use-cases.
The source code is available on GitHub .
function getReservesList ( IPoolAddressesProvider provider ) public view override returns ( address [ ] memory )
Returns the list of initialised reserves in the Pool associated with the given provider .
Name Type Description provider IPoolAddressesProvider The given provider for the associated pool
Type Description address[] The list of initialised reserves in the Pool
function getReservesData ( IPoolAddressesProvider provider ) public view override returns ( AggregatedReserveData [ ] memory , BaseCurrencyInfo memory )
Returns BaseCurrencyInfo of the Pool and AggregatedReserveData[] for all the initialised reserves in the Pool associated with the given provider .
Name Type Description provider IPoolAddressesProvider The given provider for the associated pool
Type Description BaseCurrencyInfo The base currency information AggregatedReserveData[] The aggregated reserve data
The BaseCurrencyInfo struct is composed of the following fields:
Name Type Description marketReferenceCurrencyUnit uint256 Reference aka base currency of the Aave market marketReferenceCurrencyPriceInUsd int256 Price of reference aka base currency in USD networkBaseTokenPriceInUsd int256 Price of native token of the network/chain in USD networkBaseTokenPriceDecimals uint8 Decimals of native token of the network/chain
The AggregatedReserveData struct is composed of the following fields:
Name Type Description underlyingAsset address The address of the underlying asset of the reserve name string The name of the underlying reserve asset symbol string The symbol of the underlying reserve asset decimals uint256 The number of decimals of the reserve baseLTVasCollateral uint256 The ltv of the reserve reserveLiquidationThreshold uint256 The liquidation threshold of the reserve reserveLiquidationBonus uint256 The liquidation bonus of the resurve reserveFactor uint256 The reserve factor of the reserve usageAsCollateralEnabled bool true if the asset is enabled to be used as collateral, false otherwiseborrowingEnabled bool true if borrowing is enabled, false otherwiseisActive bool true if reserve is active, false otherwiseisFrozen bool true if reserve is frozen, false otherwiseBASE DATA liquidityIndex uint128 The liquidity index of the reserve variableBorrowIndex uint128 The variable borrow index of the reserve liquidityRate uint128 The liquidity rate of the reserve variableBorrowRate uint128 The variable borrow rate of the reserve lastUpdateTimestamp uint40 The timestamp of the last update of the reserve aTokenAddress address The AToken address of the reserve variableDebtTokenAddress address The VariableDebtToken address of the reserve interestRateStrategyAddress address The address of the Interest Rate strategy availableLiquidity uint256 The liquidity available totalScaledVariableDebt uint256 The total scaled variable debt priceInMarketReferenceCurrency uint256 Price of reference aka base currency of Aave market priceOracle address The address of the price oracle used by the associated market variableRateSlope1 uint256 The variable rate slope variableRateSlope2 uint256 The variable rate slope baseVariableBorrowRate uint256 The base variable borrow rate, expressed in ray optimalUsageRatio uint256 The optimal usage ratio V3 ONLY isPaused bool true if the pool is paused, false otherwiseisSiloedBorrowing bool true if the asset is siloed for borrowingaccruedToTreasury uint128 The amount of tokens accrued to treasury that is to be minted unbacked uint128 The amount of unbacked aTokens of the reserve isolationModeTotalDebt uint128 The outstanding debt borrowed against this asset in isolation mode flashLoanEnabled bool true is asset is available to borrow in flash loan transactiondebtCeiling uint256 The debt ceiling of the reserve debtCeilingDecimals uint256 The debt ceiling decimals eModeCategoryId uint8 The eMode id of the reserve borrowCap uint256 The borrow cap of the reserve supplyCap uint256 The supply cap of the reserve borrowableInIsolation bool true is asset available to borrow against isolated collateral assetsv3.1 virtualAccActive bool true if virtual accounting is enabled for a reservevirtualUnderlyingBalance uint128 Balance of reserve if virtual accounting is used
function getUserReservesData ( IPoolAddressesProvider provider , address user ) external view override returns ( UserReserveData [ ] memory , uint8 )
Returns UserReserveData[] for all user reserves in the Pool associated with the given provider .
Name Type Description provider IPoolAddressesProvider The given provider for the associated pool user address The address of the user
Type Description UserReserveData[] The user reserve data
The UserReserveData struct is composed of the following fields:
Name Type Description underlyingAsset address The address of the underlying asset supplied/borrowed scaledATokenBalance uint256 The scaled balance of the aToken. scaledBalance = balance/liquidityIndex usageAsCollateralEnabledOnUser bool true if the supplied asset is enabled to be used as collateral, false otherwisestableBorrowRate uint256 The stable rate at which underlying asset is borrowed by the user (deprecated)
Fetches tokens balances for all underlying tokens of Aave reserves for one user address.
This contract is not used within the Aave Protocol. It is an accessory
contract used to reduce the number of calls towards the blockchain from the
Aave backend.
For getting ETH (native chain token) balance use MOCK_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE .
The source code is available on GitHub .
function balanceOf ( address user , address token ) public view returns ( uint256 )
Checks the token balance of a wallet in a token contract. Returns the balance of the token for user (ETH included with MOCK_ETH_ADDRESS ).
Name Type Description user address The address of the user token address The address of the token
Type Description uint256 The balance of the token for user. Returns 0 for a non-contract address
function batchBalanceOf ( address [ ] calldata users , address [ ] calldata tokens ) external view returns ( uint256 [ ] memory )
Returns balances for a list of users and tokens (ETH included with MOCK_ETH_ADDRESS ).
Name Type Description users address[] The list of users tokens address[] The list of tokens
Type Description uint256[] A list of balances for each user
function getUserWalletBalances ( address provider , address user ) external view returns ( address [ ] memory , uint256 [ ] memory )
Provides balances of user wallet for all reserves available on the pool.
Name Type Description provider address The address of the provider user address The address of the user
Type Description address[] A list of user wallets uint256[] A list of balances for each user
UiIncentiveDataProviderV3
Contract that returns an array of all reserve incentives or user claimable rewards within a particular market, used by the Aave Labs Interface to display incentives data. Compatible with both V2 and V3 of the Aave Protocol.
The Aave Utilities SDK includes an interface to make calls to this contract, and functions to format the response for frontend use-cases.
The source code is available on GitHub .
getFullReservesIncentiveData
function getFullReservesIncentiveData ( IPoolAddressesProvider provider , address user ) external view override returns ( AggregatedReserveIncentiveData [ ] memory , UserReserveIncentiveData [ ] memory )
Returns both AggregatedReserveIncentiveData[] and UserReserveIncentiveData[] for the given user for the pool associated with the given provider .
Name Type Description provider IPoolAddressesProvider The given provider for the associated pool user address The address of the user
Type Description AggregatedReserveIncentiveData[] The aggregated reserve incentive data UserReserveIncentiveData[] The user reserve incentive data
The AggregatedReserveIncentiveData struct is composed of the following fields:
Name Type Description underlyingAsset address Address of the asset supplied/borrowed in Pool aIncentiveData IncentiveData Details of rewards distributed for supplying to Aave Pool i.e. rewards for aToken holders vIncentiveData IncentiveData Details of rewards distributed for variable debt borrowed from Aave Pool i.e. rewards for vToken holders
The UserReserveIncentiveData struct is composed of the following fields:
Name Type Description underlyingAsset address Address of the asset supplied/borrowed in Pool aTokenIncentivesUserData UserIncentiveData Details of user rewards received for supplying to Aave Pool i.e. rewards for aToken vTokenIncentivesUserData UserIncentiveData Details of user rewards received for borrowing at variable rate from Aave Pool i.e. rewards for vToken
getReservesIncentivesData
function getReservesIncentivesData ( IPoolAddressesProvider provider ) external view override returns ( AggregatedReserveIncentiveData [ ] memory )
Returns AggregatedReserveIncentiveData[] for the pool associated with the given provider .
Name Type Description provider IPoolAddressesProvider The given provider for the associated pool
Type Description AggregatedReserveIncentiveData[] The aggregated reserve incentive data
The AggregatedReserveIncentiveData struct is composed of the following fields:
Name Type Description underlyingAsset address Address of the asset supplied/borrowed in Pool aIncentiveData IncentiveData Details of rewards distributed for supplying to Aave Pool i.e. rewards for aToken holders vIncentiveData IncentiveData Details of rewards distributed for variable debt borrowed from Aave Pool i.e. rewards for vToken holders
getUserReservesIncentivesData
function getUserReservesIncentivesData ( IPoolAddressesProvider provider , address user ) external view override returns ( UserReserveIncentiveData [ ] memory )
Returns the UserReserveIncentiveData[] for the given user for the pool associated with the given provider .
Name Type Description provider IPoolAddressesProvider The given provider for the associated pool
Type Description UserReserveIncentiveData[] The user reserve incentive data
The UserReserveIncentiveData struct is composed of the following fields:
Name Type Description underlyingAsset address Address of the asset supplied/borrowed in Pool aTokenIncentivesUserData UserIncentiveData Details of user rewards received for supplying to Aave Pool i.e. rewards for aToken vTokenIncentivesUserData UserIncentiveData Details of user rewards received for borrowing at variable rate from Aave Pool i.e. rewards for vToken
The AaveProtocolDataProvider is a peripheral contract to collect and pre-process information from the Pool . This contract contains methods for querying token addresses, reserve parameters, and user account information. The methods of the PoolDataProvider are more granular than the UiPoolDataProvider , which queries data for reserve tokens or user balances simultaneously.
The source code is available on GitHub .
function getAllReservesTokens ( ) external view returns ( TokenData [ ] memory )
Returns a list of the existing reserves in the pool, pairs include the symbol and tokenAddress . Handles MKR and ETH in a different way since they do not have standard symbol functions.
Type Description TokenData[] The list of reserves, pairs of symbols and addresses
The TokenData struct is composed of the following fields:
Name Type Description symbol string The symbol of the underlying reserve asset tokenAddress address The address of the underlying reserve asset
function getAllATokens ( ) external view returns ( TokenData [ ] memory )
Returns a list of the existing ATokens in the pool, pairs include the symbol and tokenAddress .
Type Description TokenData[] The list of ATokens, pairs of symbols and addresses
The TokenData struct is composed of the following fields:
Name Type Description symbol string The symbol of aToken of the reserve tokenAddress address The address of aToken of the reserve
getReserveConfigurationData
function getReserveConfigurationData ( address asset ) external view returns ( uint256 decimals , uint256 ltv , uint256 liquidationThreshold , uint256 liquidationBonus , uint256 reserveFactor , bool usageAsCollateralEnabled , bool borrowingEnabled , bool stableBorrowRateEnabled , bool isActive , bool isFrozen )
Returns the configuration data of the reserve as described below. Does not return borrow and supply caps, nor pause flag for compatibility.
Name Type Description asset address The address of the underlying asset of the reserve
Name Type Description decimals uint256 The number of decimals of the reserve ltv uint256 The ltv of the reserve liquidationThreshold uint256 The liquidation threshold of the reserve liquidationBonus uint256 The liquidation bonus of the reserve reserveFactor uint256 The reserve factor of the reserve usageAsCollateralEnabled bool true if the usage as collateral is enabled, false otherwiseborrowingEnabled bool true if borrowing is enabled, false otherwisestableBorrowRateEnabled bool Always false (deprecated) isActive bool true if reserve is active, false otherwiseisFrozen bool true if reserve is frozen, false otherwise
function getReserveCaps ( address asset ) external view returns ( uint256 borrowCap , uint256 supplyCap )
Returns the caps parameters of the reserve.
Name Type Description asset address The address of the underlying asset of the reserve
Name Type Description borrowCap uint256 The borrow cap of the reserve supplyCap uint256 The supply cap of the reserve
function getPaused ( address asset ) external view returns ( bool isPaused )
Returns true if the pool isPaused .
Name Type Description asset address The address of the underlying asset of the reserve
Name Type Description isPaused bool true if the pool is paused, false otherwise
function getSiloedBorrowing ( address asset ) external view override returns ( bool )
Returns the siloed borrowing flag. It returns true if the asset is siloed for borrowing .
Name Type Description asset address The address of the underlying asset of the reserve
Type Description bool true if the asset is siloed for borrowing
getLiquidationProtocolFee
function getLiquidationProtocolFee ( address asset ) external view override returns ( uint256 )
Returns the protocol fee on the liquidation bonus.
Name Type Description asset address The address of the underlying asset of the reserve
Type Description uint256 The protocol fee on liquidation
function getUnbackedMintCap ( address asset ) external view override returns ( uint256 )
Returns the unbacked mint cap of the reserve.
Name Type Description asset address The address of the underlying asset of the reserve
Type Description uint256 The unbacked mint cap of the reserve
function getDebtCeiling ( address asset ) external view override returns ( uint256 )
Returns the debt ceiling of the reserve.
Name Type Description asset address The address of the underlying asset of the reserve
Type Description uint256 The debt ceiling of the reserve
function getReserveData ( address asset ) external view override returns ( uint256 unbacked , uint256 accruedToTreasuryScaled , uint256 totalAToken , uint256 totalStableDebt , uint256 totalVariableDebt , uint256 liquidityRate , uint256 variableBorrowRate , uint256 stableBorrowRate , uint256 averageStableBorrowRate , uint256 liquidityIndex , uint256 variableBorrowIndex , uint40 lastUpdateTimestamp )
Returns the reserve data.
Name Type Description asset address The address of the underlying asset of the reserve
Name Type Description unbacked uint256 The amount of unbacked aTokens of the reserve accruedToTreasuryScaled uint256 The scaled amount of tokens accrued to treasury that is to be minted totalAToken uint256 The total supply of the aToken totalStableDebt uint256 The total stable debt of the reserve (deprecated) totalVariableDebt uint256 The total variable debt of the reserve liquidityRate uint256 The liquidity rate of the reserve variableBorrowRate uint256 The variable borrow rate of the reserve stableBorrowRate uint256 The stable borrow rate of the reserve (deprecated) averageStableBorrowRate uint256 The average stable borrow rate of the reserve (deprecated) liquidityIndex uint256 The liquidity index of the reserve variableBorrowIndex uint256 The variable borrow index of the reserve lastUpdateTimestamp uint40 The timestamp of the last update of the reserve
function getATokenTotalSupply ( address asset ) external view override returns ( uint256 )
Returns the total supply of aTokens for a given asset .
Name Type Description asset address The address of the underlying asset of the reserve
Type Description uint256 The total supply of the aToken
function getTotalDebt ( address asset ) external view override returns ( uint256 )
Returns the total debt for a given asset .
Name Type Description asset address The address of the underlying asset of the reserve
Type Description uint256 The total borrows for an asset
function getUserReserveData ( address asset , address user ) external view returns ( uint256 currentATokenBalance , uint256 currentStableDebt , uint256 currentVariableDebt , uint256 principalStableDebt , uint256 scaledVariableDebt , uint256 stableBorrowRate , uint256 liquidityRate , uint40 stableRateLastUpdated , bool usageAsCollateralEnabled )
Returns the following user reserve data.
Name Type Description asset address The address of the underlying asset of the reserve user address The address of the user
Name Type Description currentATokenBalance uint256 The current AToken balance of the user currentStableDebt uint256 The current stable debt of the user (deprecated) currentVariableDebt uint256 The current variable debt of the user principalStableDebt uint256 The principal stable debt of the user (deprecated) scaledVariableDebt uint256 The scaled variable debt of the user stableBorrowRate uint256 The stable borrow rate of the user (deprecated) liquidityRate uint256 The liquidity rate of the reserve stableRateLastUpdated uint40 The timestamp of the last update of the user stable rate (deprecated) usageAsCollateralEnabled bool true if the user is using the asset as collateral, else false
getReserveTokensAddresses
function getReserveTokensAddresses ( address asset ) external view override returns ( address aTokenAddress , address stableDebtTokenAddress , address variableDebtTokenAddress )
Returns the addresses of the aToken , stableDebtToken and variableDebtToken of the reserve.
Name Type Description asset address The address of the underlying asset of the reserve
Name Type Description aTokenAddress address The AToken address of the reserve stableDebtTokenAddress address The StableDebtToken address of the reserve (deprecated) variableDebtTokenAddress address The VariableDebtToken address of the reserve
getInterestRateStrategyAddress
function getInterestRateStrategyAddress ( address asset ) external view override returns ( address irStrategyAddress )
Returns the address of the Interest Rate strategy.
Name Type Description asset address The address of the underlying asset of the reserve
Name Type Description irStrategyAddress address The address of the Interest Rate strategy
function getDebtCeilingDecimals ( ) external pure override returns ( uint256 )
Returns the debt ceiling decimals.
Type Description uint256 The debt ceiling decimals