Skip to Content
docs

Aave V4 GraphQL Quickstart

AaveKit API is a GraphQL interface to query liquidity data and user positions and to prepare transactions. Use it for custom integrations and data analysis where the TypeScript SDK does not fit.

Getting Started

AaveKit API for Aave V4 is available at https://api.v4.aave.com/graphql.

The URL above is also a GraphQL playground for testing queries.

You can query the API directly using any HTTP client. Here’s a basic example using curl to query supported chains:

Terminal
curl -X POST https://api.v4.aave.com/graphql \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query Chains { chains(request: { query: { filter: ALL } }) { name chainId icon } }"
  }'

Query Operations

AaveKit API has two types of queries:

  • Read queries – queries that return data from the Aave Protocol.
  • Transaction queries – queries that prepare transactions to be executed on the Aave Protocol.

Transaction queries are in turn divided into two categories:

  • Simple transactions – single-step transactions that can be sent directly to the wallet.
  • Complex transactions – transactions that may require prior approvals before they can be executed.

Simple Transactions

Simple transactions query returns a TransactionRequest object that can be used to send the transaction to the wallet.

TransactionRequest
type TransactionRequest {
  to: EvmAddress!
  from: EvmAddress!
  data: BlockchainData!
  value: BigInt!
  chainId: ChainId!
  operations: [OperationType!]
}

Complex Transactions

Complex transactions query returns an ExecutionPlan union.

The ExecutionPlan union represents the different scenarios that can occur when preparing a transaction:

  • TransactionRequest: The transaction can be executed directly.
  • Erc20ApprovalRequired: One or more ERC-20 approvals are required first, then the original transaction can be executed.
  • PreContractActionRequired: A pre-contract action must be sent first, then the original transaction can be executed.
  • InsufficientBalanceError: The user doesn’t have enough balance of the token to be used in the transaction.
union ExecutionPlan =
  | TransactionRequest
  | Erc20ApprovalRequired
  | PreContractActionRequired
  | InsufficientBalanceError

Multiple Approvals: Some tokens, like USDT, don’t allow raising an existing allowance. For these, the API returns two approvals: reset to 0, then set the required amount.

Transaction Monitoring

After sending a transaction, AaveKit API may take a short time to process and reflect the new state in its responses due to caching and background invalidation. To reliably know when your transaction has been processed and data is up to date, use the hasProcessedKnownTransaction query.

This query lets you check if a transaction (by hash and operations type) has been indexed and processed by the API, so you can safely fetch updated user or market data. Note that this can only be used with transactions where the TransactionRequest has a non-null operations field.

query {
  value: hasProcessedKnownTransaction(
    request: { operations: [SPOKE_SUPPLY], txHash: "0x1234…" }
  )
}
  • Returns true if the transaction has been processed and data is fresh.
  • Returns false if the transaction is not yet processed (wait and retry).

After sending a transaction, poll this query until it returns true before fetching updated positions or balances. This avoids race conditions with cached data.


Scalars

A non-exhaustive list of custom scalars used in the AaveKit API.

A string representing binary data as a hex string.

Plain text
0x0000000000000000000000000000000000000000000000000000000000000020

Common Types

Some of the common types used in the Aave Protocol GraphQL API.

A DecimalNumber object represents a decimal value with arbitrary precision.

GraphQL
type DecimalNumber {
  """
  The on-chain representation of `value`, stored as an integer.
  """
  onChainValue: BigInt!

  """
  The number of decimals defining how many fractional digits the number supports.
  """
  decimals: Int!

  """
  The normalized value computed as `onChainValue / 10^decimals`.
  """
  value: BigDecimal!
}

Next Steps