> ## 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_aggregator.trades

> The `dex_aggregator.trades` table captures data on actions taken on aggregators - recording all events across various aggregators and blockchains.

export const TableSample = ({tableName, tableSchema}) => <>
    <div className="hidden dark:block">
      <iframe src={`https://dune.com/embeds/3419983/5785629?table_schema_t6f0df=${tableSchema}&table_name_t6f0df=${tableName}&darkMode=true`} style={{
  width: '100%',
  height: '500px',
  border: 'none',
  marginTop: '10px'
}} />
    </div>
    <div className="dark:hidden">
      <iframe src={`https://dune.com/embeds/3419983/5785629?table_schema_t6f0df=${tableSchema}&table_name_t6f0df=${tableName}`} style={{
  width: '100%',
  height: '500px',
  border: 'none',
  marginTop: '10px'
}} />
    </div>
  </>;

export const DuneEmbed = ({qID, vID, height = '500px'}) => <>
    <div className="hidden dark:block">
      <iframe src={`https://dune.com/embeds/${qID}/${vID}?darkMode=true`} style={{
  width: '100%',
  height,
  border: 'none',
  marginTop: '10px'
}}></iframe>
    </div>
    <div className="dark:hidden">
      <iframe src={`https://dune.com/embeds/${qID}/${vID}`} style={{
  width: '100%',
  height,
  border: 'none',
  marginTop: '10px'
}}></iframe>
    </div>
  </>;

<Frame caption="This table stores data on aggregator trades across protocols...">
  <DuneEmbed qID={3787155} vID={6367567} height={300} />
</Frame>

<Frame caption="... and chains">
  <DuneEmbed qID={3787158} vID={6367574} height={300} />
</Frame>

## Table Description

The `dex_aggregator.trades` table captures high-level trade data executed via decentralized exchange (DEX) aggregators. These aggregators aggregate liquidity from multiple DEXs to provide users with the best possible trade execution. Unlike the `dex.trades` table, which records each intermediary step of a trade, `dex_aggregator.trades` condenses the trade data to reflect the user's intended trade, presenting it as a single entry.

## Functional Overview

Users can expect the `dex_aggregator.trades` table to provide a high-level view of DEX trades facilitated by aggregators. This table simplifies trade records by showing a single entry for trades that may involve multiple DEXs and liquidity pools.\
For instance, a user might initiate a trade to swap USDC for PEPE via a DEX aggregator. The aggregator might route this trade through several liquidity pools such as WETH-USDC and WETH-PEPE, but `dex_aggregator.trades` will record it as a single USDC -> PEPE trade.

Complementary to `dex_aggregator.trades` is the `dex.trades` table, where detailed trade executions are recorded. This table captures the granular steps of each trade, including interactions with different liquidity pools. 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`, providing a comprehensive view of the detailed execution path that aggregated trades take.

## Coverage

The table covers the following decentralized exchanges and their versions:

<div>
  <DuneEmbed qID={3457736} vID={5810651} height={500} />
</div>

## Table Schema

| Column                     | Type            | Description                                               |
| -------------------------- | --------------- | --------------------------------------------------------- |
| `blockchain`               | `VARCHAR`       | Blockchain on which the DEX is deployed                   |
| `project`                  | `VARCHAR`       | Name of the aggregator project                            |
| `version`                  | `VARCHAR`       | Version of the contract built and deployed by the project |
| `block_date`               | `TIMESTAMP`     | UTC event block date                                      |
| `block_month`              | `TIMESTAMP`     | UTC event block month (partition key)                     |
| `block_time`               | `TIMESTAMP`     | UTC event block time                                      |
| `token_bought_symbol`      | `VARCHAR`       | Symbol of the token bought                                |
| `token_sold_symbol`        | `VARCHAR`       | Symbol of the token sold                                  |
| `token_pair`               | `VARCHAR`       | Token symbol pair for each token involved                 |
| `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                            |
| `token_sold_amount_raw`    | `UINT256`       | Raw amount of the token sold                              |
| `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 of trader who purchased tokens                    |
| `maker`                    | `VARBINARY`     | Address of trader who sold tokens                         |
| `project_contract_address` | `VARBINARY`     | Project contract address which executed the trade         |
| `tx_hash`                  | `VARBINARY`     | Transaction hash                                          |
| `tx_from`                  | `VARBINARY`     | Address which initiated the trade                         |
| `tx_to`                    | `VARBINARY`     | Address which received the trade                          |
| `trace_address`            | `ARRAY(BIGINT)` | Trace address within the transaction                      |
| `evt_index`                | `BIGINT`        | Index of the corresponding trade event                    |

## Table Sample

<TableSample tableSchema="dex_aggregator" tableName="trades" />
