Query editor
WITH get_cb_dex_trades AS (--See query for underlying logic to get Coinbase DEX TradesSELECT *, CASE WHEN ROW_NUMBER() OVER (PARTITION BY tx_hash) = 1 THEN 1 ELSE 0 END AS is_first_tx_hashFROM "query_5680127(show_today='{{Show Current Date}}')" --https://dune.com/queries/5680127)SELECT *--,-- project || ' - ' || token_bought_symbol AS dex_token_boughtFROM (SELECTt.block_date, t.blockchain, t.project---- , COALESCE(cb.token_bought_symbol, cast(cb.token_bought_address AS varchar)) AS token_bought_symbol, SUM(is_first_tx_hash) AS num_dex_swaps, COUNT(DISTINCT t.tx_hash) AS num_dex_txs, COUNT(DISTINCT cb.account) AS num_distinct_cb_accounts, SUM(is_first_tx_hash*t.amount_usd) AS sum_dex_volume_usd --include all hops, SUM(CASE WHEN CONTAINS(cb.agg_evt_index, t.evt_index) THEN t.amount_usd ELSE 0 END) AS sum_user_trade_volume_usd --just the volume that the user wantedFROM dex.trades tINNER JOIN get_cb_dex_trades cbON t.blockchain = cb.blockchainAND t.block_date = cb.block_dateAND t.block_number = cb.block_numberAND t.tx_hash = cb.tx_hashWHERE t.blockchain = 'base'AND t.block_date >= date '2025-07-03'AND t.block_month >= date '2025-07-01'GROUP BY 1,2,3--4)ORDER BY block_date DESC, sum_dex_volume_usd DESC