Query editor
WITH tab1 AS (SELECTtx_hashFROM dex.tradesWHERE blockchain = 'ethereum'AND block_time >= TIMESTAMP '2025-07-01 00:00:00 UTC'AND (token_bought_address IN (from_hex('dAC17F958D2ee523a2206206994597C13D831ec7'),from_hex('A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'))OR token_sold_address IN (from_hex('dAC17F958D2ee523a2206206994597C13D831ec7'),from_hex('A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')))--LIMIT 100), tab2 as (selectevt_tx_hash as tx_hash,sum(value / power(10, 6)) as valuefrom erc20_ethereum.evt_transferwhere contract_address IN (from_hex('dAC17F958D2ee523a2206206994597C13D831ec7'),from_hex('A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'))and evt_block_time >= TIMESTAMP '2025-07-01 00:00:00 UTC'group by 1), tx AS ( -- bring in all transactions + flag if in tab1SELECTdate_trunc('day', et.block_time) AS day,(CAST(et.gas_price AS DECIMAL(38,0)) * CAST(et.gas_used AS DECIMAL(38,0))) / 1e18 AS fee_ETH,t2.value as transfer_volume_usdFROM ethereum.transactions etLEFT JOIN tab1 tON et.hash = t.tx_hashLEFT JOIN tab2 t2ON et.hash = t2.tx_hashWHERE et.block_time >= TIMESTAMP '2025-07-01 00:00:00 UTC'and t2.tx_hash IS NOT NULL and t.tx_hash IS NULL), eth_price as (selecttimestamp as day1,avg(price) as pricefrom prices.daywhere contract_address = from_hex('C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')group by 1)selectday,approx_percentile(transfer_volume_usd, 0.5) as median_transfer_amount_usd,avg(transfer_volume_usd) as avg_transfer_amount_usd,sum(transfer_volume_usd) as total_transfer_amount_usd,sum(fee_ETH * price) as fee_USD,avg(fee_ETH * price) as avg_fee_usd,