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

# Solana DEX Swaps to your warehouse

> Land decoded Solana DEX trades into ClickHouse, BigQuery, Postgres, Kafka, or S3 via the `swaps` normalizer.

The `swaps` normalizer streams decoded Solana DEX trades into your warehouse as one unified table. See the [Solana normalizers page](/goldrush-pipeline-api/normalizers/solana) for the full per-column schema and supported protocols.

## Why warehouse delivery

Streaming and REST are great for live execution and lookups, but every retention cohort, churn model, token analytics dashboard, and tax export lives in your data warehouse - not in HTTP responses. The Pipeline API streams Solana data continuously into customer-managed destinations with no ETL on your side.

## Pipeline configuration

<Steps>
  <Step title="Create a pipeline">
    In the [GoldRush Platform](https://goldrush.dev/platform/), navigate to **Manage Pipelines** and click **Create Pipeline**. Name it `solana-swaps`.
  </Step>

  <Step title="Pick Solana + Swaps">
    Choose **Solana** as the chain and **Swaps** as the data type.
  </Step>

  <Step title="Configure your destination">
    Connect ClickHouse, BigQuery, Postgres, Kafka, S3/GCS/R2, SQS, or a Webhook. ClickHouse is recommended for high-volume analytical queries over swaps.

    ```yaml theme={null}
    destination:
      type: "clickhouse"
      url: "https://your-cluster.clickhouse.cloud:8443"
      user: "${CH_USER}"
      password: "${CH_PASSWORD}"
      database: "solana_swaps"
      batch_size: 5000
    ```
  </Step>

  <Step title="Optional: SQL transform">
    Filter or reshape rows before they land. Example: keep only swaps over \$100 of volume.

    ```yaml theme={null}
    transforms:
      swaps: >
        SELECT *
        FROM swaps
        WHERE volume_usd >= 100
    ```
  </Step>

  <Step title="Deploy">
    Decoded swaps begin flowing within seconds.
  </Step>
</Steps>

## Schema

The `swaps` table is documented in full on the [Solana Normalizers page](/goldrush-pipeline-api/normalizers/solana). Key columns include `block_slot`, `block_time`, `tx_id`, `signer`, `pool_address`, `base_mint`, `quote_mint`, `base_amount`, `quote_amount`, `price_usd`, `volume_usd`, `protocol_name`, and CPI attribution fields (`outer_program`, `inner_program`, `instruction_type`).

## Sample analytical queries

### Top tokens by 24h volume

```sql theme={null}
SELECT
  base_mint,
  SUM(volume_usd) AS volume_24h
FROM swaps
WHERE block_time >= now() - INTERVAL 1 DAY
GROUP BY base_mint
ORDER BY volume_24h DESC
LIMIT 50;
```

### Per-protocol market share by token

```sql theme={null}
SELECT
  protocol_name,
  SUM(volume_usd) AS volume_24h,
  COUNT(*) AS swap_count
FROM swaps
WHERE base_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
  AND block_time >= now() - INTERVAL 1 DAY
GROUP BY protocol_name
ORDER BY volume_24h DESC;
```

### Whale activity

```sql theme={null}
SELECT
  signer,
  SUM(volume_usd) AS volume_24h,
  COUNT(*) AS swap_count
FROM swaps
WHERE block_time >= now() - INTERVAL 1 DAY
GROUP BY signer
HAVING volume_24h > 1000000
ORDER BY volume_24h DESC;
```

### Jupiter routing through Raydium and Orca

```sql theme={null}
SELECT
  tx_id,
  protocol_name,
  outer_program,
  inner_program,
  base_mint,
  quote_mint,
  volume_usd
FROM swaps
WHERE outer_program = 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4' -- Jupiter v6
  AND block_time >= now() - INTERVAL 1 HOUR
ORDER BY tx_id, instruction_index;
```

## Production tips

* **ClickHouse for high-volume analytics.** Solana swap volume is significant; analytical queries over millions of rows are much faster on ClickHouse than Postgres.
* **Partition by `block_date`.** Most analytical queries are time-bounded.
* **Materialized views for per-token metrics.** Build hourly / daily roll-ups in ClickHouse materialized views to keep dashboards snappy.

## Related

* [Solana Normalizers (full schema)](/goldrush-pipeline-api/normalizers/solana) - column-level reference for `swaps` and other Solana entities.
* [SPL Transfers warehouse recipe](/goldrush-solana/warehouse/spl-transfers) - companion table for transfer-side analytics.
* [DEX firehose (streaming)](/goldrush-solana/streaming/dex-firehose) - real-time push for new pair events.
