Query editor
WITH base_dex_volume AS (SELECTdate_trunc('month', block_date) AS month,'base' AS blockchain,'DEX Trading' AS volume_type,SUM(amount_usd) AS volume_usdFROM dex.tradesWHERE (token_bought_address = 0x46c85152bfe9f96829aa94755d9f915f9b10ef5fOR token_sold_address = 0x46c85152bfe9f96829aa94755d9f915f9b10ef5f)AND blockchain = 'base'AND block_time >= TIMESTAMP '2024-08-01'GROUP BY 1, 2, 3),bsc_dex_volume AS (SELECTdate_trunc('month', block_date) AS month,'bsc' AS blockchain,'DEX Trading' AS volume_type,SUM(amount_usd) AS volume_usdFROM dex.tradesWHERE (token_bought_address = 0xa8AEA66B361a8d53e8865c62D142167Af28Af058OR token_sold_address = 0xa8AEA66B361a8d53e8865c62D142167Af28Af058)AND blockchain = 'bnb'AND block_time >= TIMESTAMP '2024-08-01'GROUP BY 1, 2, 3),base_p2p_volume AS (SELECTdate_trunc('month', t.evt_block_time) AS month,'base' AS blockchain,'P2P Transfer' AS volume_type,SUM(p.price * t.value / POWER(10, 6)) AS volume_usdFROM erc20_base.evt_transfer tINNER JOIN dune.dune_africa.result_ngn_price_usd pON p.currency = 'NGN' AND date_trunc('day', t.evt_block_time) = p.dayLEFT JOIN base.creation_traces c1 ON c1.address = t."from"LEFT JOIN base.creation_traces c2 ON c2.address = t."to"WHERE t.contract_address = 0x46c85152bfe9f96829aa94755d9f915f9b10ef5fAND t.evt_block_time >= TIMESTAMP '2024-08-01'AND t."to" != 0x0000000000000000000000000000000000000000AND t."from" != 0x0000000000000000000000000000000000000000AND c1.address IS NULL AND c2.address IS NULLGROUP BY 1, 2, 3),bsc_p2p_volume AS (SELECTdate_trunc('month', t.evt_block_time) AS month,'bsc' AS blockchain,'P2P Transfer' AS volume_type,SUM(p.price * t.value / POWER(10, 6)) AS volume_usdFROM erc20_bnb.evt_transfer tINNER JOIN dune.dune_africa.result_ngn_price_usd pON p.currency = 'NGN' AND date_trunc('day', t.evt_block_time) = p.dayLEFT JOIN bnb.creation_traces c1 ON c1.address = t."from"LEFT JOIN bnb.creation_traces c2 ON c2.address = t."to"WHERE t.contract_address = 0xa8AEA66B361a8d53e8865c62D142167Af28Af058AND t.evt_block_time >= TIMESTAMP '2024-08-01'AND t."to" != 0x0000000000000000000000000000000000000000AND t."from" != 0x0000000000000000000000000000000000000000AND c1.address IS NULL AND c2.address IS NULL