Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/with out_eth as (selectt.to as holder,sum(cast(value as double)/1e18) as value_sent_from_ethFROMethereum.traces as twhereblock_time > cast('2022-10-01' as TIMESTAMP)and type = 'call'and "from" = 0xE161a0856B73A1731F031627E09C4Af76A3223Fband (call_type not in ('delegatecall','staticcall','callcode') OR call_type is null)and cast(value as double) > 0group by 1order by 1),in_eth as (selectt."from" as sender,sum(cast(value as double)/1e18) as value_sent_to_ethFROMethereum.traces as twhere to = 0xE161a0856B73A1731F031627E09C4Af76A3223Fband block_time > cast('2022-10-01' as TIMESTAMP)and (call_type not in ('delegatecall','staticcall','callcode') OR call_type is null)and cast(value as double) > 0group by 1order by 1),gas_price as (SELECTsum((gas_price_gwei * gas_used)/1e9) as gas_price_gwei_total,sum((gas_price_usd * gas_used)) as gas_price_total_usdfromgas.feeswhere block_time > cast('2022-10-01' as TIMESTAMP)and blockchain = 'ethereum'and "tx_sender" = 0xE161a0856B73A1731F031627E09C4Af76A3223Fb)selectholder,sender,value_sent_to_eth - COALESCE(value_sent_from_eth,0)- COALESCE(gas_price_gwei_total,0) as balance_xen1from in_eth as i left join out_eth as oon 1=1left join gas_price as gon 1=1group by 1,2,3order by 3 asc