Skip to main content

Liquidity Pool Token

Overview

The liquidity_pool_token table associates tokens with liquidity pools, supporting multi-token pools (e.g., Balancer, Curve). This table enables tracking which tokens are part of each liquidity pool.

Schema

FieldTypeModeDescription
idSTRINGREQUIREDClient-generated deterministic ID using truncated MD5 hash of (liquidity_pool_id, token_contract_id). Same association always gets same ID
liquidity_pool_idSTRINGREQUIREDForeign key to liquidity_pool table
token_contract_idSTRINGREQUIREDForeign key to token_contract table
ingested_atTIMESTAMPREQUIREDTimestamp when this record was inserted into BigQuery

Primary Key

  • id: A deterministic ID generated using truncated MD5 hash of liquidity_pool_id and token_contract_id

Foreign Keys

  • liquidity_pool_id: References the liquidity_pool table
  • token_contract_id: References the token_contract table

Usage Examples

-- Get all tokens in a specific liquidity pool
SELECT tc.symbol, tc.name, tc.decimals
FROM `bitpulse.dex.liquidity_pool_token` lpt
JOIN `bitpulse.dex.token_contract` tc ON lpt.token_contract_id = tc.id
WHERE lpt.liquidity_pool_id = 123;

-- Find all pools containing both WETH and USDC
SELECT lp.name, lp.address, di.name AS dex_name
FROM `bitpulse.dex.liquidity_pool` lp
JOIN `bitpulse.dex.dex_instance` di ON lp.dex_instance_id = di.id
WHERE lp.id IN (
SELECT lpt1.liquidity_pool_id
FROM `bitpulse.dex.liquidity_pool_token` lpt1
JOIN `bitpulse.dex.token_contract` tc1 ON lpt1.token_contract_id = tc1.id
JOIN `bitpulse.dex.liquidity_pool_token` lpt2 ON lpt1.liquidity_pool_id = lpt2.liquidity_pool_id
JOIN `bitpulse.dex.token_contract` tc2 ON lpt2.token_contract_id = tc2.id
WHERE tc1.symbol = 'WETH' AND tc2.symbol = 'USDC'
)
ORDER BY di.name, lp.name;

Notes

  • This table is particularly important for multi-token pools like those found in Balancer or Curve.
  • For standard two-token pools (like those in Uniswap), there will be two entries per pool.
  • The combination of liquidity_pool_id and token_contract_id is unique within this table.
  • This table does not store token balances - see the pool_tvl table for that information.