Table Description
Thedex.trades table captures detailed data on trades executed via decentralized exchanges (DEXs). This table captures all raw trade events that happen across all liquidity pools. It provides a comprehensive view of the entire trade execution process, detailing the specific paths and liquidity sources utilized.
Functional Overview
Thedex.trades table provides an in-depth view of trades on decentralized exchanges like Uniswap or Curve. This table includes entries for each segment of a trade that passes through different liquidity pools, as well as single-step trades. For example, a user may initiate a trade to swap USDC for PEPE. If this trade is executed through multiple liquidity pools, such as USDC-WETH and WETH-PEPE, the dex.trades table will record each segment of the trade as a separate entry. Conversely, a single-step trade, such as directly swapping USDC for ETH, will be recorded as a single entry.
This detailed approach allows for granular analysis of trade execution paths, enabling users to:
- Analyze Liquidity Sources: Understand which liquidity pools are used and how they interact in both single-step and multi-step trades.
- Track Trade Execution Paths: Follow the exact route a trade takes across different DEXs and liquidity pools.
- Assess Slippage and Execution Quality: Evaluate the impact of each step on the overall trade execution, including slippage and price changes.
- Monitor Market Dynamics: Gain insights into the behavior and dynamics of different liquidity pools and DEXs over time.
dex.trades table supports advanced analytics and research into DEX trading behavior and liquidity management.
Complementary tables include dex_aggregator.trades, in which trade-intents that are routed through aggregators are recorded. The volume routed through aggregators is also recorded in the dex.trades table, one row in dex_aggregator trades corresponds to one or more rows in dex.trades.
Coverage
The table covers the following decentralized exchanges and their versions:Table Schema
| Column | Type | Description |
|---|---|---|
blockchain | VARCHAR | Blockchain on which this trade occurred |
project | VARCHAR | Name of the DEX on which the trade occurred |
version | VARCHAR | Version of the DEX protocol/contract |
block_month | DATE | UTC event block month (partition key) |
block_date | DATE | UTC event block date |
block_time | TIMESTAMP | UTC event block time |
block_number | BIGINT | Block number in which the trade occurred |
token_bought_symbol | VARCHAR | Symbol of the token bought |
token_sold_symbol | VARCHAR | Symbol of the token sold |
token_pair | VARCHAR | Symbol pair for the tokens involved, always alphabetical order |
token_bought_amount | DOUBLE | Amount of the token bought in display units |
token_sold_amount | DOUBLE | Amount of the token sold in display units |
token_bought_amount_raw | UINT256 | Raw amount of the token bought before decimal adjustment |
token_sold_amount_raw | UINT256 | Raw amount of the token sold before decimal adjustment |
amount_usd | DOUBLE | USD value of the trade at time of execution |
token_bought_address | VARBINARY | Contract address of the token bought |
token_sold_address | VARBINARY | Contract address of the token sold |
taker | VARBINARY | Address that purchased tokens (can be contract or EOA) |
maker | VARBINARY | Address that sold tokens (can be contract or EOA) |
project_contract_address | VARBINARY | Smart contract address which emitted the event (pool, router, etc.) |
tx_hash | VARBINARY | Transaction hash |
tx_from | VARBINARY | EOA address that sent the trade transaction |
tx_to | VARBINARY | Address called in the first call of this transaction |
evt_index | BIGINT | Index of the event in the transaction |
Table Sample
Examples
The following query demonstrates how to use the dex.trades table to calculate the total volume of trades on a weekly basis.Dex Dashboard
For more examples of how to use the
dex.trades table, check out this dashboard.