Query Examples
This document demonstrates how to query Storyhunt V3 analytics using GraphQL on the subgraph.
Subgraph Query Examples
This document demonstrates how to query Storyhunt V3 analytics using GraphQL on the subgraph. Queries can fetch data points such as:
Collected fees for a position
Current liquidity of a pool
Volume on a specific day
Below are example queries. Copy and paste them into a GraphQL explorer to retrieve live data.
Global Data
Global data refers to analytics about the Storyhunt V3 protocol as a whole. Examples include total value locked, number of pools, or transaction counts. To query global data, pass the FACTORY_ADDRESS and specify the desired fields.
Current Global Data
{
factory(id: "FACTORY_ADDRESS") {
poolCount
txCount
totalVolumeUSD
totalVolumeETH
}
}Historical Global Data
Specify a block number to query historical data:
Pool Data
To query a specific pool, pass the POOL_ADDRESS and adjust the query fields as needed.
General Pool Query
This query fetches the fee tier, spot price, and liquidity for a specific pool:
All Possible Pools
To retrieve pools in batches, use the skip variable:
Skipping First 1000 Pools
Creating a Skip Variable
In your environment, iterate through the skip variable to query all pools:
Most Liquid Pools
Retrieve the top 1000 most liquid pools:
Pool Daily Aggregated Data
Query daily aggregated data for a pool:
Swap Data
General Swap Data
Query data about a specific swap using the transaction hash and index:
Recent Swaps Within a Pool
Fetch recent swaps for a specific pool:
Token Data
General Token Data
Query token information such as decimals, symbol, and volume:
Token Daily Aggregated Data
Fetch aggregate token data over a 24-hour period:
All Tokens
Retrieve all tokens in batches using the skip variable:
Position Data
General Position Data
Query fees and liquidity for a specific position: