Query editor
--0xa0cA98Ac421CA3B7874f39021A1372aF18010682withtransfer_in as (SELECTsum(cast(value as double)/1e18) as eth_inFROM ethereum.traces--you could also use transfers_ethereum.eth or transfers_optimism.eth and only filter on tx_to insteadWHERE to = {{address}}AND type = 'call'AND successAND (call_type NOT IN ('delegatecall', 'staticcall', 'callcode') OR call_type is null)AND cast(value as double) > 0), transfer_out as (SELECTsum(cast(value as double)/1e18) as eth_outFROM ethereum.traces--you could also use transfers_ethereum.eth or transfers_optimism.eth and only filter on tx_from insteadWHERE "from" = {{address}}AND type = 'call'AND successAND (call_type NOT IN ('delegatecall', 'staticcall', 'callcode') OR call_type is null)AND cast(value as double) > 0), gas_spent as (SELECTSUM((gas_price_gwei*gas_used)/1e9) as gas_spentFROM gas.feesWHERE blockchain = 'ethereum'AND tx_sender = {{address}})SELECT*, eth_in - COALESCE(eth_out,0) - COALESCE(gas_spent,0) as balanceFROM transfer_in tinLEFT JOIN transfer_out tout ON 1=1LEFT JOIN gas_spent gs ON 1=1