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

[**DEX Trades** 
\
Individual trades across DEX protocols like Uniswap, SushiSwap, Curve and more]

[**Aggregator Trades** 
\
Trades routed through aggregators like 1inch, 0x Protocol, ParaSwap]

[**Sandwich Attacks** 
\
Detected sandwich attack trades and their details]

[**Sandwiched Trades** 
\
Transactions that were victims of sandwich attacks]

### Solana DEX Data

[**Solana DEX Trades** 
\
Detailed trade data across Solana DEX protocols like Orca, Raydium, and more]

[**Jupiter Aggregator** 
\
Trades executed through the Jupiter aggregator on Solana]

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

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

```
-- ✅ 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. 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):**

```
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):**

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