liquidity_pool_data fetching

Returns 10 DEX trades by token on Ethereum, where currency smart contract is 0xb399…cADC, side type is buy and side type is sell, sorted by sell volume, highest first: protocol name, protocol family, smart contract, side currency name, side currency symbol, side smart contract, sum of trade side amount in USD and 17 more fields.

By Sanai · saved 2 July 2025 · Bitquery API v2

What it returns

Filters

The query

query TokenAnalysis($network: evm_network!, $token: String!, $time_24h_ago: DateTime!, $time_7d_ago: DateTime!) {
    EVM(dataset: combined, network: $network) {
        
        # 1. TOTAL LIQUIDITY ACROSS ALL POOLS
        Total_Liquidity: DEXTradeByTokens(
            where: {Trade: {Currency: {SmartContract: {is: $token}}}}
            orderBy: {descendingByField: "liquidity"}
        ) {
            Trade {
                Dex {
                    ProtocolName
                    ProtocolFamily
                    SmartContract
                }
                Side {
                    Currency {
                        Name
                        Symbol
                        SmartContract
                    }
                }
            }
            liquidity: sum(of: Trade_Side_AmountInUSD)
            pairs: uniq(of: Trade_Side_Currency_SmartContract)
        }
        
        # 2. ALL DEX PAIRS & AVAILABILITY
        DEX_Pairs: DEXTradeByTokens(
            where: {Trade: {Currency: {SmartContract: {is: $token}}}}
            orderBy: {descendingByField: "volume"}
        ) {
            Trade {
                Currency {
                    Name
                    Symbol
                    SmartContract
                }
                Dex {
                    ProtocolName
                    ProtocolFamily
                    ProtocolVersion
                    SmartContract
                }
                Side {
                    Currency {
                        Name
                        Symbol
                        SmartContract
                    }
                }
            }
            volume: sum(of: Trade_AmountInUSD)
            trades: count
            uniqueBuyers: uniq(of: Trade_Buyer)
            uniqueSellers: uniq(of: Trade_Seller)
        }
        
        # 3. 24H TRADING VOLUME & METRICS
        Volume_24h: DEXTradeByTokens(
            where: {
                Trade: {Currency: {SmartContract: {is: $token}}}
                Block: {Time: {after: $time_24h_ago}}
            }
        ) {
            volume24h: sum(of: Trade_AmountInUSD)
            trades24h: count
            avgTradeSize24h: average(of: Trade_AmountInUSD)
            uniqueBuyers24h: uniq(of: Trade_Buyer)
            uniqueSellers24h: uniq(of: Trade_Seller)
        }
        
        # 4. 7D TRADING VOLUME & METRICS
        Volume_7d: DEXTradeByTokens(
            where: {
                Trade: {Currency: {SmartContract: {is: $token}}}
                Block: {Time: {after: $time_7d_ago}}
            }
        ) {
            volume7d: sum(of: Trade_AmountInUSD)
            trades7d: count
            avgTradeSize7d: average(of: Trade_AmountInUSD)
            uniqueBuyers7d: uniq(of: Trade_Buyer)
            uniqueSellers7d: uniq(of: Trade_Seller)
        }
        
        # 5. CURRENT PRICE & RECENT TRADES
        Current_Price: DEXTradeByTokens(
            limit: {count: 1}
            orderBy: {descending: Block_Time}
            where: {Trade: {Currency: {SmartContract: {is: $token}}}}
        ) {
            Block {
                Time
            }
            Trade {
                Currency {
                    Name
                    Symbol
                    SmartContract
                    Decimals
                }
                Amount
                AmountInUSD
                Price
                PriceInUSD
                Side {
                    Currency {
                        Name
                        Symbol
                    }
                }
                Dex {
                    ProtocolName
                }
            }
        }
        
        
        # # 7. TOP BUYERS
        # Top_Buyers: DEXTradeByTokens(
        #     where: {Trade: {Currency: {SmartContract: {is: $token}}}}
        #     orderBy: {descendingByField: "buyVolume"}
        #     limit: {count: 10}
        # ) {
        #     Trade {
        #         Buyer
        #     }
        #     buyVolume: sum(of: Trade_AmountInUSD)
        #     buyTrades: count
        #     avgBuySize: average(of: Trade_AmountInUSD)
        # }
        
        # # 8. TOP SELLERS  
        # Top_Sellers: DEXTradeByTokens(
        #     where: {Trade: {Currency: {SmartContract: {is: $token}}}}
        #     orderBy: {descendingByField: "sellVolume"}  
        #     limit: {count: 10}
        # ) {
        #     Trade {
        #         Seller
        #     }
        #     sellVolume: sum(of: Trade_Side_AmountInUSD)
        #     sellTrades: count
        #     avgSellSize: average(of: Trade_Side_AmountInUSD)
        # }
    
    # 7. TOP BUYERS (FIXED)
Top_Buyers: DEXTradeByTokens(
    where: {
        Trade: {
            Currency: {SmartContract: {is: $token}}
            Side: {Type: {is: buy}}  
        }
        Block: {Time: {after: $time_24h_ago}}  
    }
    orderBy: {descendingByField: "buyVolume"}
    limit: {count: 10}
) {
    Trade {
        Buyer
    }
    buyVolume: sum(of: Trade_AmountInUSD)  
    count
    avgBuySize: average(of: Trade_AmountInUSD)
}

# 8. TOP SELLERS (FIXED)
Top_Sellers: DEXTradeByTokens(
    where: {
        Trade: {
            Currency: {SmartContract: {is: $token}}
            Side: {Type: {is: sell}}  
        }
        Block: {Time: {after: $time_24h_ago}}  
    }
    orderBy: {descendingByField: "sellVolume"}
    limit: {count: 10}
) {
    Trade {
        Seller
    }
    sellVolume: sum(of: Trade_AmountInUSD)  
    count
    avgSellSize: average(of: Trade_AmountInUSD)
}
    }
}

Variables

{
    "network": "eth",
    "token": "0xb3999F658C0391d94A37f7FF328F3feC942BcADC",
    "time_24h_ago": "2025-06-30T11:18:35Z",
    "time_7d_ago": "2025-06-24T11:18:35Z"
}

Similar queries