Query editor
WITH tab1 AS (SELECTtx_hashFROM dex.tradesWHERE blockchain = 'base'AND block_time >= TIMESTAMP '2025-07-01 00:00:00 UTC'AND (token_bought_address IN (from_hex('833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'))OR token_sold_address IN (from_hex('833589fCD6eDb6E08f4c7C32D4f71b54bdA02913')))--LIMIT 100), tab2 as (selectevt_tx_hash as tx_hash,sum(value / power(10, 6)) as valuefrom erc20_base.evt_transferwhere contract_address IN (from_hex('833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'))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 base.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,approx_percentile(fee_ETH * price, 0.5) as median_fee_usd,approx_percentile(((fee_ETH * price)/ transfer_volume_usd) * 100, 0.5) as medain_gas_fee_percent,(sum(fee_ETH * price) / sum(transfer_volume_usd)) * 100 as avg_gas_fee_percent,