fetch_uniswap_v3_pool_tvl

Documentation for eth_defi.uniswap_v3.tvl.fetch_uniswap_v3_pool_tvl function.

fetch_uniswap_v3_pool_tvl(pool, quote_token, block_identifier=None)

Return the total value locked of the quote token.

  • This gets the amount of quote token locked in the pool

Note

This includes unclaimed fees.

Example how to read the historical pool TVL for WMATIC-USDC pair on Polygon:

# https://tradingstrategy.ai/trading-view/polygon/uniswap-v3/matic-usdc-fee-5
block_estimated = 45_583_631
pool_address = "0xa374094527e1673a86de625aa59517c5de346d32"
pool = fetch_pool_details(web3, pool_address)

tvl_estimated = fetch_uniswap_v3_pool_tvl(
    pool,
    quote_token=usdc,
    block_identifier=block_estimated,
)

print(f"TVL {tvl_estimated:,} USDC at block {(block_estimated,)}")
Parameters
Returns

Amount of quote token locked in the pool.

The US dollar TVL is this value * 2, because for the locked value both sides of the pool count, although this is irrelevant for trading

Return type

decimal.Decimal