Queries

Sample Subgraph Queries

Querying

Below are some sample queries you can use to gather information from the Hop contracts.

You can build your own queries using a GraphQL Explorer and enter your endpoint to limit the data to exactly what you need.

Transfers

  • Get transfer root info

{
  transfersCommitteds(
    where: {
      rootHash: "0xdda1a36c3cd03b88089659e3c949de2f7bc9e855cb1bdb08b754af765914b4f6"
    }
  ) {
    totalAmount
    transactionHash
    token
    timestamp
  }
}
  • Get list of transfer roots

  • Get source transfer info

    • L2>L1 or L2>L2

  • Getting transferId by transaction hash

  • Get list of transfers

    • L2>L2 or L2>L1

      • Use L2 subgraphs for these queries (the subgraph used is the origin chain)

  • L1->L2

    • Use L1 mainnet subgraph for these queries (the L1 subgraph is the origin chain)

      • Note: there is no transferId for L1->L2 transfers. The id is not the same as a transferId.

  • Get list of transfers that were bonded at destination chain

  • Use the destination chain subgraph for these queries

Note: The WithdrawalBonded event does not contain the recipient or the original sender, so a lookup using the transferId will need to be used on TransferSent (origin from L2) or TransferSentToL2 (origin from L1) to retrieve those values.

Volume

  • Cumulative volume

  • Manual calculation

    • The amount on transferSents (xdai, polygon, arbitrum, optimism) and transferSentToL2S (mainnet) entities can be added up to get overall tx volume on each chain.

  • Daily Volume

The date range is calculated as such:

TVL

⚠️ currently the TVL entities don't report fully accurate data because it's only using add/remove liquidity events instead of tracking transfer events. Use defillama to view accurate TVL.

  • Cumutative TVL

  • Cumulative AMM TVL

Fees

  • Cumulative AMM Fees

  • Cumulative Bonder Fees

Manual calculation The bonder fee can be calculated by adding the bonderFee value from transferSents entities

  • LP fees

    • The LP fees can be calculated by adding up tokensSold0.0004* from *tokenSwaps* entities

Pagination

JavaScript fetch example

FAQ

Why are there multiple subgraphs? At the moment a subgraph with TheGraph can only be tied to one chain meaning it doesn't have the context or events from the other chains, hence the chain specific subgraph urls. Maybe in the future TheGraph will support multi-chain subgraphs.

Last updated