DeFiAaveDecentralized FinanceETH

Beneath Aave V3 Data with Bitquery APIs​

Query Aave V3 data with Bitquery APIs: daily users, borrow and supply volume, APY, unique users and flash loans, with a query for each.

Cover Image for Beneath Aave V3 Data with Bitquery APIs​

Bitquery APIs can pull the data of Aave, the top lending protocol on Ethereum, which runs on other chains too. Users of the protocol can deposit funds or borrow them, and no one else takes custody of those funds. People who deposit add funds to the market to earn a passive income. Borrowers can take loans with more collateral than the loan, with no time limit, or with less collateral, for a loan that lasts one block.

Version 3 keeps the core parts of the protocol (aTokens, instant liquidity, stable rate borrowing, credit delegation, etc.) and adds new features: Portal (to move funds between chains), eMode, Isolation mode and more.

Anyone can see the basic analysis without writing a line of code in Bitquery Explorer. To learn more about what Bitquery can do, read our article about how to track liquidity for any token pair on Uniswap.

Note - We use Streaming APIs (v2) for the data below; you can also turn the queries into a WebSocket feed with a Graphql Subscription.

You can run the following queries in the Bitquery GraphQL IDE.

Aave V3 API's

V3 Daily User Activities on Ethereum

The main functions a user calls are "Supply", "Borrow", "Withdraw" and "Repay". The query below counts these events and the unique addresses behind them for each day, grouped by event and block time.

query ($network: EthereumNetwork!, $address: String!, $limit: Int, $offset: Int, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractEvents(
      options: {desc: "count", limit: $limit, offset: $offset}
      date: {since: $from, till: $till}
      smartContractAddress: {is: $address}
      smartContractEvent: {in: ["Supply", "Borrow", "Withdraw", "Repay"]}
    ) {
      smartContractEvent {
        name
      }
      block {
        timestamp {
          time(format: "%Y-%m-%d")
        }
      }
      count(uniq: callers)
    }
  }
}

Parameters:

{
  "limit": 1000000,
  "offset": 0,
  "network": "ethereum",
  "address": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
  "from": "2022-10-15",
  "till": "2023-10-22T23:59:59",
  "dateFormat": "%Y-%m-%d"
}

Count of Different Activities on Aave V3

Borrow Volume of an Asset on V3

For the borrow volume of an asset (USDC) on one chain (ETH), the query below reads the transfers dataset, filters it by the USDC and Aave v3 contract addresses, then groups the results by date.

query ($network: EthereumNetwork!, $token: String!, $dateFormat: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    transfers(
      currency: {is: $token}
      height: {gt: 0}
      amount: {gt: 0}
      date: {since: $from, till: $till}
      any: {sender: {is: "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c"}}
    ) {
      date {
        date(format: $dateFormat)
      }
      count: countBigInt
      amount
    }
  }
}

Parameters:

{
  "limit": 10,
  "offset": 0,
  "network": "ethereum",
  "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  "from": "2023-10-15",
  "till": "2023-10-22T23:59:59",
  "dateFormat": "%Y-%m-%d"
}

Borrow Volume of USDC on Ethereum on Aave V3

Supplied Volume of an Asset on V3

On V3, the USDC supplied comes from Events data, filtered by the contract address and "Mint" event of Aave Ethereum USDC (aEthUSDC), in the query below.

query ($network: EthereumNetwork!, $address: String!, $limit: Int, $offset: Int, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractEvents(
      options: {limit: $limit, offset: $offset}
      date: {since: $from, till: $till}
      smartContractAddress: {is: $address}
      any: {smartContractEvent: {is: "Mint"}}
    ) {
      arguments {
        argument
        value
      }
      block {
        timestamp {
          time
        }
      }
    }
  }
}

Parameters:

{
  "limit": 1000000000,
  "offset": 0,
  "network": "ethereum",
  "address": "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c",
  "from": "2023-08-01",
  "till": "2023-10-24T23:59:59",
  "dateFormat": "%Y-%m-%d"
}

USDC deposited on Aave V3 since August 1

Current and Historical Supply APY and Borrow Rate

The Supply APY and Borrow Rate for DAI (or any asset) come from the events that the Aave V3 contract emits. First filter by the Log Signature, then by the DAI contract, as done in the query below.

{
  EVM(dataset: combined, network: eth) {
    Events(
      orderBy: {descending: Block_Number}
      limit: {count: 10}
      where: {Transaction: {To: {is: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2"}},
        Log: {Signature: {Name: {is: "ReserveDataUpdated"}}},
        Arguments: {includes: {Value: {Address: {is: "0x6B175474E89094C44Da98b954EedeAC495271d0F"}}}}}
    ) {
      Log {
        Signature {
          Name
        }
      }
      Block {
        Date
        Time
      }
      Arguments {
        Name
        Value {
          ... on EVM_ABI_Integer_Value_Arg {
            integer
          }
          ... on EVM_ABI_BigInt_Value_Arg {
            bigInteger
          }
          ... on EVM_ABI_Address_Value_Arg {
            address
          }
        }
      }
    }
  }
}

Parameters:

{}

History of Supply Rate, Stable Borrow Rate, and variable borrow rate of DAI

Unique Users

The query below counts the unique users of V3 for each day: it filters the Calls made to the contract and groups them by date.

query ($network: EthereumNetwork!, $dateFormat: String!, $address: String!, $from: ISO8601DateTime, $till: ISO8601DateTime) {
  ethereum(network: $network) {
    smartContractCalls(
      date: {since: $from, till: $till}
      any: {smartContractAddress: {is: $address}}
    ) {
      count: countBigInt(uniq: callers)
      date {
        date(format: $dateFormat)
      }
    }
  }
}

Parameters:

{
  "limit": 10,
  "offset": 0,
  "network": "ethereum",
  "address": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
  "from": "2023-08-01",
  "till": "2023-10-25T23:59:59",
  "dateFormat": "%Y-%m-%d"
}

Unique Users each day from August

FlashLoan Stats on V3

Bitquery Streaming APIs give the total FlashLoan volume when you filter the Calls dataset by Call Signature and the Aave contract, as done in the query below.

{
  EVM(dataset: combined, network: eth) {
    Calls(
      limit: {count: 10000000}
      where: {Call: {To: {is: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2"}, Signature: {Name: {is: "flashLoanSimple"}}}, Block: {Date: {after: "2023-08-01", before: "2023-10-25"}}}
      orderBy: {descending: Block_Number}
    ) {
      Call {
        Signature {
          Name
          Signature
          SignatureHash
        }
      }
      Arguments {
        Name
        Path {
          Index
          Type
          Name
        }
        Index
        Type
        Value {
          ... on EVM_ABI_Address_Value_Arg {
            address
          }
          ... on EVM_ABI_BigInt_Value_Arg {
            bigInteger
          }
        }
      }
      Transaction {
        Hash
      }
    }
  }
}

Parameters:

{}

Running total of WETH flash loans taken from Aave since August

Miner Rewards and Priority Fee in FlashLoan Transactions on V3

Flash loan trades chase arbitrage or small profits in DeFi. The main problem for developers who use them is the priority fee needed to land in a block. Bitquery returns the gas stats when you filter the Calls dataset by the Aave contract address and the call signature, then read the gas fee stats in the query below.

{
  EVM(dataset: combined, network: eth) {
    Calls(
      limit: {count: 10000000}
      where: {Call: {To: {is: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2"}, Signature: {Name: {is: "flashLoanSimple"}}}, Block: {Date: {after: "2023-08-01", before: "2023-10-25"}}}
      orderBy: {descending: Block_Number}
    ) {
      Call {
        Signature {
          Name
        }
      }
      Transaction {
        Hash
      }
      Fee {
        SenderFee
        Savings
        PriorityFeePerGas
        MinerReward
        EffectiveGasPrice
        Burnt
      }
      Receipt {
        GasUsed
      }
    }
  }
}

Parameters:

{}

Total Miner reward vs Priority fees

That's it folks, another protocol another time :]

About Bitquery

Bitquery is a toolkit built for developers that makes blockchain data easy to reach. Our products are practical and flexible.

  • APIs - Explore API: Pull precise real-time and past data for 28 blockchains with GraphQL. Add the results to your apps and base your decisions on them.

  • Data in Cloud - Try Demo Bucket: Use indexed blockchain data at low cost and at scale for your pipeline. We support Ethereum, BSC and Solana now, with more chains to come.

  • Explorer - Try Explorer: An easy site for exploring data from 28 blockchains. Draw charts, build queries and add them to your apps.

Bitquery gives developers simple blockchain data tools. If you have questions or need help, reach us on our Telegram channel. To keep up with the latest in crypto, subscribe to our newsletter below.

This blog was written by guest author Nitin.

Updated on 27 November 2026 by the Bitquery team, with help from AI tools: the query-runner link was updated, and the text was edited for clarity.

Subscribe to our newsletter

Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.