Common Subgraph Queries
Last modified:
Common Queries
These queries can be run in the v3 subgraph explorer. Replace placeholder values as needed.
Top Pools by TVL
{
pools(first: 10, orderBy: totalValueLockedUSD, orderDirection: desc) {
id
token0 { symbol }
token1 { symbol }
feeTier
totalValueLockedUSD
volumeUSD
token0Price
token1Price
}
}Swap History for a Pool
{
swaps(
first: 20
orderBy: timestamp
orderDirection: desc
where: { pool: "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8" }
) {
timestamp
sender
recipient
amount0
amount1
amountUSD
tick
sqrtPriceX96
}
}LP Positions for a Wallet
{
positions(
where: { owner: "0xYOUR_WALLET_ADDRESS" }
orderBy: liquidity
orderDirection: desc
) {
id
pool {
token0 { symbol }
token1 { symbol }
feeTier
}
tickLower { tickIdx }
tickUpper { tickIdx }
liquidity
depositedToken0
depositedToken1
collectedFeesToken0
collectedFeesToken1
}
}Token Price (Current)
{
token(id: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2") {
symbol
name
derivedETH
totalValueLockedUSD
volumeUSD
tokenDayData(first: 1, orderBy: date, orderDirection: desc) {
priceUSD
date
}
}
}24-Hour Volume (Protocol-Wide)
{
uniswapDayDatas(first: 1, orderBy: date, orderDirection: desc) {
date
volumeUSD
tvlUSD
feesUSD
txCount
}
}Historical Token Prices (Last 30 Days)
{
tokenDayDatas(
first: 30
orderBy: date
orderDirection: desc
where: { token: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" }
) {
date
priceUSD
volumeUSD
totalValueLockedUSD
}
}Pool Hourly Data (Last 24h)
{
poolHourDatas(
first: 24
orderBy: periodStartUnix
orderDirection: desc
where: { pool: "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8" }
) {
periodStartUnix
volumeUSD
tvlUSD
feesUSD
tick
sqrtPrice
}
}Mints and Burns for a Pool
{
mints(
first: 10
orderBy: timestamp
orderDirection: desc
where: { pool: "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8" }
) {
timestamp
owner
amount0
amount1
amountUSD
tickLower
tickUpper
}
burns(
first: 10
orderBy: timestamp
orderDirection: desc
where: { pool: "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8" }
) {
timestamp
owner
amount0
amount1
amountUSD
tickLower
tickUpper
}
}Tips
- Pagination: Use
skipandfirstfor large result sets. Maximumfirstis 1000. - Filtering by time: Use
where: { timestamp_gt: 1700000000 }with a Unix timestamp. - Token IDs are lowercase: Always lowercase token and pool addresses in queries.
- Entity names: The subgraph uses
uniswapDayDatas(notcenturionDayDatas) as the entity name — this reflects the underlying subgraph schema.
Further Reading
- v3 Subgraph Example — detailed walkthrough
- Subgraph Overview — how the subgraph works