Examples
Historical Data
We can fetch historical data by specifying a block number.
Data of All Reserves
We can get a list of all the reserves that are able to be used as collateral, along with each reserve's interest rate details.
Data of Specific Reserve
We can fetch data for a specific reserve using reserve's ERC20 token address. E.g. for the Chainlink reserve.
Detailed Data of a Specific Reserve
We can fetch detailed data for a specific reserve by `lendingPoolAddressProvider` address for the market you are querying data for using the query below.
{
reserves(where: {pool: "0xa97684ead0e402dc232d5a977953df7ecbab3cdb"}) { # provide pool address here
id
symbol
name
decimals
underlyingAsset
usageAsCollateralEnabled
reserveFactor
baseLTVasCollateral
averageStableRate
stableDebtLastUpdateTimestamp
liquidityIndex
reserveLiquidationThreshold
reserveLiquidationBonus
variableBorrowIndex
variableBorrowRate
liquidityRate
totalPrincipalStableDebt
totalScaledVariableDebt
lastUpdateTimestamp
availableLiquidity
stableBorrowRate
totalLiquidity
price {
priceInEth
}
}
}
Historic Interest Rate for a Specific Reserve
We can fetch historic interest rate data for a particular reserve and paginate through the records using the queery below.
{
reserve(
id: "0x63a72806098bd3d9520cc43356dd78afe5d386d90xa97684ead0e402dc232d5a977953df7ecbab3cdb" # provide reserve address here
) {
id
paramsHistory(skip: 1000, first: 1000) {
id
variableBorrowRate
utilizationRate
liquidityRate
timestamp
}
}
}
User Reserve Data
We can fetch the details of a particular user reserve. When an address interacts with the Aave Protocol, an user reserve is created with the user ID being the user's address + the reserve's ID (which is the ERC20 token address).
All Reserves of an User
We can fetch all the reserves (i.e. positions) that a specific user has using the query below.
{
userReserves(where: {user: "0x00067c68c96f8bf2d2258630badf8e4379234179"}) { # provide user's address here
reserve {
id
symbol
underlyingAsset
}
scaledATokenBalance
usageAsCollateralEnabledOnUser
stableBorrowRate
scaledVariableDebt
principalStableDebt
stableBorrowLastUpdateTimestamp
user {
id
}
}
}
Recent Borrows for a Particular Asset
We can fetch recent borrows for a particular asset using the query below.
Recent Flash Loans
We can fetch the 5 most recent Flash Loans using the query below.
User Transaction History
We can use the query below to get transaction history of a Aave user.
{
userTransactions(
where: {user: "0x00067c68c96f8bf2d2258630badf8e4379234179"} # provide user address here
orderBy: timestamp
orderDirection: desc
) {
id
timestamp
txHash
action
... on RedeemUnderlying {
amount
reserve {
symbol
decimals
}
assetPriceUSD
}
... on Borrow {
amount
borrowRateMode
borrowRate
stableTokenDebt
variableTokenDebt
reserve {
symbol
decimals
}
assetPriceUSD
}
... on UsageAsCollateral {
fromState
toState
reserve {
symbol
}
}
... on Repay {
amount
reserve {
symbol
decimals
}
assetPriceUSD
}
... on LiquidationCall {
collateralAmount
collateralReserve {
symbol
decimals
}
principalAmount
principalReserve {
symbol
decimals
}
collateralAssetPriceUSD
borrowAssetPriceUSD
}
}
}