Query editor
WITH phantom_evm AS (SELECT'Phantom' AS wallet,t.blockchain,COALESCE(t.token_pair, 'UNKNOWN') AS token_pair,t.amount_usd,CAST(t.tx_hash AS varchar) AS tx_hashFROM dune.phantom.dataset_phantom_evm_swappers_pre2024 pJOIN dex.trades tON t.blockchain = p.chainAND t.tx_hash = p.transaction_hashWHERE t.block_month < DATE '2024-01-01'AND t.block_month >= DATE '2020-01-01'AND t.amount_usd IS NOT NULL),phantom_sol AS (SELECT'Phantom' AS wallet,'solana' AS blockchain,COALESCE(t.token_pair, 'UNKNOWN') AS token_pair,t.amount_usd,t.tx_id AS tx_hashFROM dune.phantom.dataset_phantom_sol_swappers_pre2024 pJOIN dex_solana.trades tON t.tx_id = p.txn_idWHERE t.block_month < DATE '2024-01-01'AND t.block_month >= DATE '2020-01-01'AND t.amount_usd IS NOT NULL),pair_volume AS (SELECTwallet,blockchain,token_pair,COUNT(*) AS trade_rows,COUNT(DISTINCT tx_hash) AS tx_count,SUM(amount_usd) AS volume_usdFROM (SELECT * FROM phantom_evmUNION ALLSELECT * FROM phantom_sol)GROUP BY 1, 2, 3),ranked AS (SELECTwallet,blockchain,token_pair,trade_rows,tx_count,volume_usd,SUM(volume_usd) OVER (PARTITION BY blockchain) AS chain_volume_usdFROM pair_volume)SELECTwallet,blockchain,token_pair,trade_rows,