Query editor
with f as (select from_hex(h) as tx_hash, d, pc, vol, cr4, cr6, p from query_8956155 where typ = 'arb' and pc in (1, 2, 16, 32)),txs as (select distinct tx_hash from f),meta as (select t.hash as tx_hash, t."from" as tx_from, t."to" as tx_to, t.block_timefrom ethereum.transactions twhere t.block_date between date '2026-05-30' and date '2026-08-22' and t.hash in (select tx_hash from txs)),xf as (select x.tx_hash, x.contract_address, min(x.block_time) as block_time,sum(case when x."to" in (m.tx_from, m.tx_to) then cast(x.amount_raw as double) else 0 end)- sum(case when x."from" in (m.tx_from, m.tx_to) then cast(x.amount_raw as double) else 0 end) as net_rawfrom tokens.transfers x join meta m on m.tx_hash = x.tx_hashwhere x.blockchain = 'ethereum' and x.block_month between date '2026-05-01' and date '2026-08-01'and x.block_date between date '2026-05-30' and date '2026-08-22'and (x."to" in (m.tx_from, m.tx_to) or x."from" in (m.tx_from, m.tx_to))and not (x."to" in (m.tx_from, m.tx_to) and x."from" in (m.tx_from, m.tx_to))group by 1, 2),px as (select timestamp, contract_address, price, decimals from prices.minutewhere blockchain = 'ethereum' and timestamp >= timestamp '2026-05-30' and timestamp < timestamp '2026-08-23'and (contract_address in (select distinct contract_address from xf) or contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2)),pr as (select xf.tx_hash, sum(xf.net_raw / power(10, coalesce(px.decimals, 18)) * px.price) as net_usd,count(*) as n_tokens, count(px.price) as n_pricedfrom xf left join px on px.contract_address = (case when xf.contract_address = 0x0000000000000000000000000000000000000000 then 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 else xf.contract_address end)and px.timestamp = date_trunc('minute', xf.block_time)group by 1)select to_hex(f.tx_hash) as h, f.d, f.pc, f.vol, f.cr4, f.cr6, f.p, pr.net_usd, pr.n_tokens, pr.n_pricedfrom f left join pr on pr.tx_hash = f.tx_hash