Query editor
with tr_in as (SELECTsum(cast(value as double)/1e18) as eth_inFROM {{Chain}}.tracesWHERE to = {{Wallet Address}}AND (call_type NOT IN ('delegatecall', 'staticcall', 'callcode') OR call_type is null)AND successAND cast(value as double) > 0),tr_out as (SELECTsum(cast(value as double)/1e18) as eth_outFROM {{Chain}}.tracesWHERE "from" = {{Wallet Address}}AND type = 'call'AND (call_type NOT IN ('delegatecall', 'staticcall', 'callcode') OR call_type is null)AND successAND cast(value as double) > 0),gas_spent as (SELECTSUM(cast(gas_price as double)/1e18 * gas_used) as gas_spentfrom {{Chain}}.transactionswhere "from" = {{Wallet Address}})SELECTeth_in - COALESCE(eth_out,0) - COALESCE(gas_spent,0) as balanceFROM tr_inLEFT JOIN tr_out out ON 1=1LEFT JOIN gas_spent gs ON 1=1