# Aave v3: Query user positions and reserves # # Endpoint: https://api.thegraph.com/subgraphs/name/aave/aave-v3-[chain] # Replace [chain] with: ethereum, base, arbitrum, etc. # # Example queries for: # - User positions (supplies, borrows) # - Reserve data # - Historical data # Query user position (supplies and borrows) query GetUserPosition($userAddress: String!) { user(id: $userAddress) { id reserves { id reserve { id symbol name decimals underlyingAsset liquidityRate variableBorrowRate stableBorrowRate aToken { id } vToken { id } sToken { id } } currentATokenBalance currentStableDebt currentVariableDebt principalStableDebt scaledVariableDebt liquidityRate usageAsCollateralEnabledOnUser reserve { price { priceInEth priceInUsd } } } } } # Query reserve data query GetReserves($first: Int = 100) { reserves( orderBy: totalLiquidity orderDirection: desc first: $first ) { id symbol name decimals underlyingAsset pool { id } price { priceInEth priceInUsd } totalLiquidity availableLiquidity totalATokenSupply totalCurrentVariableDebt totalStableDebt liquidityRate variableBorrowRate stableBorrowRate utilizationRate baseLTVasCollateral liquidationThreshold liquidationBonus reserveLiquidationThreshold reserveLiquidationBonus reserveFactor aToken { id } vToken { id } sToken { id } } } # Query user transaction history query GetUserTransactions($userAddress: String!, $first: Int = 100) { userTransactions( where: { user: $userAddress } orderBy: timestamp orderDirection: desc first: $first ) { id timestamp pool { id } user { id } reserve { symbol underlyingAsset } action amount referrer onBehalfOf } } # Query deposits query GetDeposits($userAddress: String!, $first: Int = 100) { deposits( where: { user: $userAddress } orderBy: timestamp orderDirection: desc first: $first ) { id timestamp user { id } reserve { symbol underlyingAsset } amount onBehalfOf referrer } } # Query borrows query GetBorrows($userAddress: String!, $first: Int = 100) { borrows( where: { user: $userAddress } orderBy: timestamp orderDirection: desc first: $first ) { id timestamp user { id } reserve { symbol underlyingAsset } amount borrowRate borrowRateMode onBehalfOf referrer } } # Query repays query GetRepays($userAddress: String!, $first: Int = 100) { repays( where: { user: $userAddress } orderBy: timestamp orderDirection: desc first: $first ) { id timestamp user { id } reserve { symbol underlyingAsset } amount useATokens onBehalfOf } } # Query liquidations query GetLiquidations($first: Int = 100) { liquidations( orderBy: timestamp orderDirection: desc first: $first ) { id timestamp pool { id } user { id } collateralReserve { symbol underlyingAsset } collateralAmount principalReserve { symbol underlyingAsset } principalAmount liquidator } }