> ## Documentation Index
> Fetch the complete documentation index at: https://tokenterminal.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# DEX

> Polygon trading pools, their daily volume, value locked and fees.

A decentralized exchange, or DEX, lets users swap one token for another against a pool: a contract holding a reserve of two tokens that anyone can trade with. Polygon pools appear in three tables.

* [`dimensions.dex_pools`](/docs/catalog/dex/registry): one row per pool.
* [`metrics.dex_pools_daily`](/docs/catalog/dex/metrics): one row per pool per day.
* [`metrics.dex_pool_pairs_daily`](/docs/catalog/dex/metrics): one row per pool and traded token pair per day.

Every column is documented at [DEX](/docs/catalog/dex/index).

## Sample queries

<Warning>
  The daily pool tables are among the largest in the catalog. Bound `timestamp` and filter `chain_id` in every query; without them the query reads the whole table.
</Warning>

<Tabs>
  <Tab title="Top pools, one day">
    **Rank Polygon pools by trading volume on one day.** Reading the day from the daily table and joining the pool list afterwards keeps the join small.

    ```sql theme={null}
    with top_pools as (
        select
            dex_pool_id,
            trading_volume,
            tvl,
            fees
        from `metrics.dex_pools_daily`
        where timestamp >= timestamp('2026-08-20')
          and timestamp < timestamp('2026-08-21')
          and chain_id = 'polygon'
        order by trading_volume desc
        limit 20
    )

    select
        pools.pool_display_name,
        pools.fee_tier,
        top_pools.trading_volume,
        top_pools.tvl,
        top_pools.fees
    from top_pools
    join `dimensions.dex_pools` as pools
        using (dex_pool_id)
    order by top_pools.trading_volume desc
    ```
  </Tab>

  <Tab title="Busiest pairs">
    **Find the busiest traded token pairs on Polygon, and how many pools each one trades in.** `dex_pair_id` joins the two token addresses and the chain in sorted address order, so the same two tokens produce the same identifier whichever way round the trade went.

    ```sql theme={null}
    select
        dex_pair_id,
        count(distinct dex_pool_id) as pools,
        sum(trading_volume) as trading_volume
    from `metrics.dex_pool_pairs_daily`
    where timestamp >= timestamp('2026-08-16')
      and timestamp < timestamp('2026-08-23')
      and chain_id = 'polygon'
    group by dex_pair_id
    order by trading_volume desc
    limit 20
    ```
  </Tab>
</Tabs>

## Notes

Trading volume and fees are flows, so they add up: a week of daily rows sums to the week, and a set of pools sums to the group. Value locked, in the `tvl` column, is a level: the latest row is the answer and summing it across days gives a meaningless number. Every pool gets a `tvl` row every day it exists; volume and fee figures land only on the days a pool saw trading.

`fee_tier` is empty for pools whose design has no configurable fee. A null there records that the pool has no tier to report.
