Monitoring Real-Time Liquidity of Liquidity Pools
How to monitor TVL/Liquidity of an LP of interest in real-time, using the token balances table.
First, identify the liquidity pool that you're interested in. In this example, we'll look at 0x3416cf6c708da44db2624d63ea0aaef7113527c6
, a Uniswap V3 0.01% fee USDC-USDT pool.
Find the query here.
SELECT
address,
contract_address,
ROUND(VALUE / POW(10, decimals),6) AS token_amount,
symbol
FROM
ethereum_mainnet.fungible_token_balances AS f
WHERE
address = '0x3416cf6c708da44db2624d63ea0aaef7113527c6' -- Uniswap V3 0.01 USDC-USDT pool
AND contract_address IN (
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', -- USDC
'0xdac17f958d2ee523a2206206994597c13d831ec7' -- USDT
);
In the above query, we filter on the address
of interest, then we filter by the specific tokens we would like to monitor through the contract_address
field. This in turn gives us a final result of the TVL/Overall Liquidity of that address
. This can be extended to any LP, contract, or user's address(es).
You could also run this query to get similar results via the pre-built API offerings
query MyQuery {
token_balances(first: 10, where: {address: {eq:"0x3416cf6c708da44db2624d63ea0aaef7113527c6"}, contract_address: {in:["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0xdac17f958d2ee523a2206206994597c13d831ec7"]}}) {
value
address
contract_address
token_metadata {
decimals
symbol
name
}
}
}
To use our pre-built GraphQL API endpoints, go here.
Updated 7 months ago