Examples
- Base Currency
- Historical Data
- Data of All Reserves
- Data of Specific Reserve
- Detailed Data of a Specific Reserve
- Historic Interest Rate for a Specific Reserve
- User Reserve Data
- All Reserves of an User
- Recent Deposits for a Particular Asset
- Recent Borrows for a Particular Asset
- Recent Flash Loans
- User Transaction History
Base Currency
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: "0xacc030ef66f9dfeae9cbb0cd1b25654b82cfa8d5"}) { # 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: "0x514910771af9ca656af840dff83e8264ecf986ca0xb53c1a33016b2dc2ff3653530bff1848a515c8c5" # 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: "0x0000000000007f150bd6f54c40a34d7c3d5e9f56"}) { # provide user's address here
reserve {
id
symbol
underlyingAsset
}
scaledATokenBalance
usageAsCollateralEnabledOnUser
stableBorrowRate
scaledVariableDebt
principalStableDebt
stableBorrowLastUpdateTimestamp
user {
id
}
}
}
Recent Deposits for a Particular Asset
We can fetch recent deposits for a particular asset using the query below.
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: "0xc4a936b003bc223df757b35ee52f6da66b062935"} # provide user address here
orderBy: timestamp
orderDirection: desc
) {
id
timestamp
txHash
action
... on Deposit {
amount
reserve {
symbol
decimals
}
assetPriceUSD
}
... 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 Swap {
borrowRateModeFrom
borrowRateModeTo
variableBorrowRate
stableBorrowRate
reserve {
symbol
decimals
}
}
... on LiquidationCall {
collateralAmount
collateralReserve {
symbol
decimals
}
principalAmount
principalReserve {
symbol
decimals
}
collateralAssetPriceUSD
borrowAssetPriceUSD
}
}
}