Query editor
WITH tab1 AS ( -- trades you care aboutSELECT tx_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), 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)) AS fee_wei,CASE WHEN t.tx_hash IS NOT NULLTHEN CAST(et.gas_price AS DECIMAL(38,0)) * CAST(et.gas_used AS DECIMAL(38,0))ELSE 0 END AS fee_wei_tab1FROM ethereum.transactions etLEFT JOIN tab1 tON et.hash = t.tx_hashWHERE et.block_time >= TIMESTAMP '2025-07-01 00:00:00 UTC')select*,(gas_fee_stable_swaps / gas_fee_eth_total) * 100 as percentfrom (SELECTday,SUM(fee_wei) / 1e18 AS gas_fee_eth_total, -- all Ethereum txsSUM(fee_wei_tab1) / 1e18 AS gas_fee_stable_swaps -- just the txs in tab1FROM txGROUP BY 1)