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

# dex.trades

> The `dex.trades` table captures detailed data on decentralized exchange (DEX) trades, recording all raw trade events across various protocols and blockchains.

[https://dune.com/embeds/4319/8411](https://dune.com/embeds/4319/8411)

This table stores data on dex trades across protocols...

[https://dune.com/embeds/2180075/3571504](https://dune.com/embeds/2180075/3571504)

... and chains

## Table Description

The `dex.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

The `dex.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.

By providing comprehensive trade details, the `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:

[https://dune.com/embeds/3453733/5803813](https://dune.com/embeds/3453733/5803813)

## 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

[https://dune.com/embeds/3419983/5785629?table\_schema\_t6f0df=dex\&table\_name\_t6f0df=trades](https://dune.com/embeds/3419983/5785629?table_schema_t6f0df=dex\&table_name_t6f0df=trades)

## Examples

The following query demonstrates how to use the dex.trades table to calculate the total volume of trades on a weekly basis.

```sql theme={null}
SELECT
  blockchain,
  DATE_TRUNC('week', block_time),
  SUM(CAST(amount_usd AS DOUBLE)) AS usd_volume
FROM
  dex."trades" AS t
WHERE
 block_time > NOW() - INTERVAL '365' day
GROUP BY 1,2
```

[https://dune.com/embeds/2180075/3571504](https://dune.com/embeds/2180075/3571504)

> [card] [Dex Dashboard](https://dune.com/dune/dex-metrics)
>
> For more examples of how to use the `dex.trades` table, check out this dashboard.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.