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

> Curated DEX trading data across multiple blockchain networks

Decentralized exchanges (DEXs) have become a cornerstone of DeFi, enabling permissionless trading of tokens directly on-chain. Dune provides comprehensive coverage of DEX activity through curated tables that capture trades, aggregator usage, and MEV events like sandwich attacks across both EVM and Solana networks. These datasets enable analysis of trading volumes, liquidity dynamics, price impact, and market manipulation across major DEX protocols and networks.

<Info>
  **Maintained by:** Dune · **Refresh:** \~30 min · **Chains:** 50 EVM chains, Solana
</Info>

<Card title="Get This Data" icon="database" href="https://dune.com/enterprise?dataset=dex.trades">
  Access DEX trading data via API, Datashare, or the Dune App.
</Card>

## Cross-Chain DEX Coverage

Our DEX data covers multiple blockchain ecosystems:

* **EVM Networks**: Ethereum, Arbitrum, Polygon, Base, Optimism, and 50 EVM chains total
* **Solana**: Comprehensive coverage of Solana DEX protocols and Jupiter aggregator

## Available Datasets

### EVM DEX Data

<CardGroup cols={2}>
  <Card title="DEX Trades" icon="arrow-right-arrow-left" href="/data-catalog/curated/dex-trades/evm/dex-trades">
    Individual trades across DEX protocols like Uniswap, SushiSwap, Curve and more
  </Card>

  <Card title="Aggregator Trades" icon="shuffle" href="/data-catalog/curated/dex-trades/evm/dex-aggregator-trades">
    Trades routed through aggregators like 1inch, 0x Protocol, ParaSwap
  </Card>

  <Card title="Sandwich Attacks" icon="bread-slice" href="/data-catalog/curated/dex-trades/evm/dex-sandwiches">
    Detected sandwich attack trades and their details
  </Card>

  <Card title="Sandwiched Trades" icon="user-injured" href="/data-catalog/curated/dex-trades/evm/dex-sandwiched">
    Transactions that were victims of sandwich attacks
  </Card>
</CardGroup>

### Solana DEX Data

<CardGroup cols={2}>
  <Card title="Solana DEX Trades" icon="handshake" href="/data-catalog/curated/dex-trades/solana/solana-dex-trades">
    Detailed trade data across Solana DEX protocols like Orca, Raydium, and more
  </Card>

  <Card title="Jupiter Aggregator" icon="layer-group" href="/data-catalog/curated/dex-trades/solana/jupiter-aggregator-trades">
    Trades executed through the Jupiter aggregator on Solana
  </Card>
</CardGroup>

## Key Features

* **Multi-Chain Coverage**: Analyze DEX activity across EVM and Solana ecosystems
* **Standardized Schema**: Consistent data structure for cross-chain analysis
* **MEV Detection**: Identify sandwich attacks and other MEV activities (EVM)
* **Aggregator Data**: Track trades through major aggregators on both networks
* **Real-time Updates**: Data is updated continuously as new blocks are processed

## Sample Cross-Chain Analysis

Compare DEX trading volume across different blockchain networks:

```sql theme={null}
-- EVM DEX volume
SELECT 
    'EVM' as ecosystem,
    blockchain,
    DATE_TRUNC('day', block_time) as date,
    SUM(amount_usd) as volume_usd
FROM dex.trades
WHERE block_time >= NOW() - INTERVAL '30' day
GROUP BY 1, 2, 3

UNION ALL

-- Solana DEX volume  
SELECT 
    'Solana' as ecosystem,
    'solana' as blockchain,
    DATE_TRUNC('day', block_time) as date,
    SUM(amount_usd) as volume_usd
FROM dex_solana.trades
WHERE block_time >= NOW() - INTERVAL '30' day
GROUP BY 1, 2, 3

ORDER BY date DESC, volume_usd DESC
```

## When to Use These Tables

* Analyze DEX trading volumes and market share across protocols and chains
* Track token price impact and liquidity depth on specific pairs
* Monitor MEV activity (sandwich attacks) and their cost to traders
* Build DEX aggregator performance benchmarks
* Compare DEX activity across L1s and L2s for ecosystem analysis

## Query Performance

**Partition keys for `dex.trades`:** `blockchain`, `project`, `block_month`

Always include `blockchain` and a time filter (`block_month` or `block_time` range) for best performance.

```sql theme={null}
-- ✅ Good: partition key filters
SELECT * FROM dex.trades
WHERE blockchain = 'ethereum'
  AND block_month >= DATE '2025-01-01'
  AND project = 'uniswap'

-- ❌ Slow: no partition filters
SELECT * FROM dex.trades
WHERE token_bought_symbol = 'USDC'
```

## Methodology

DEX tables are maintained by Dune ([source code](https://github.com/duneanalytics/spellbook)). They aggregate data from protocol-specific base models (e.g., `uniswap_v3_ethereum.trades`, `curve_ethereum.trades`) that decode swap events from each DEX's smart contracts. Token amounts are decimal-adjusted and joined with Dune's price feeds for USD values. The `dex.trades` union view combines all EVM chain models; `dex_solana.trades` covers Solana DEXs separately.

## Example Queries

**Daily DEX volume by protocol on Ethereum (last 30 days):**

```sql theme={null}
SELECT
  date_trunc('day', block_time) AS day,
  project,
  SUM(amount_usd) AS volume_usd,
  COUNT(*) AS num_trades
FROM dex.trades
WHERE blockchain = 'ethereum'
  AND block_month >= DATE '2025-01-01'
  AND block_time >= NOW() - INTERVAL '30' DAY
GROUP BY 1, 2
ORDER BY 1 DESC, 3 DESC
```

**Top traded pairs on Uniswap v3 (last 7 days):**

```sql theme={null}
SELECT
  token_bought_symbol,
  token_sold_symbol,
  SUM(amount_usd) AS volume_usd,
  COUNT(*) AS num_trades
FROM dex.trades
WHERE blockchain = 'ethereum'
  AND project = 'uniswap'
  AND project_version = '3'
  AND block_time >= NOW() - INTERVAL '7' DAY
GROUP BY 1, 2
ORDER BY 3 DESC
LIMIT 20
```

## Related Tables

* `prices.day` / `prices.hour` / `prices.minute` — Token pricing feeds used for USD values
* `tokens.erc20` — Token metadata (symbols, decimals, contract addresses)
* `nft.trades` — NFT marketplace trades (separate from fungible token DEX trades)
* `dex.sandwiches` — MEV sandwich attack data

<CardGroup cols={2}>
  <Card title="Enterprise Data Solutions" icon="building" href="https://dune.com/enterprise">
    Need custom DEX datasets or dedicated support? Talk to our enterprise team.
  </Card>

  <Card title="Build Custom Models" icon="code" href="/api-reference/connectors/overview">
    Build private DEX analytics pipelines with the dbt Connector.
  </Card>
</CardGroup>
