Query editor
WITH deposits AS (SELECTlogs.tx_from AS address,SUM(traces.value) / 1e18 AS total_deposit -- Aggregate and convert deposit value to ETHFROMethereum.logs AS logsLEFT JOINethereum.traces AS tracesONlogs.tx_hash = traces.tx_hashWHERElogs.contract_address = 0xac3e018457b222d93114458476f3e3416abbe38f -- Contract address for depositsAND logs.topic0 = 0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7 -- Deposit topicAND traces.value > 0 -- Ensure only positive deposit values are includedGROUP BYlogs.tx_from),withdrawals AS (SELECTlogs.tx_to AS address,SUM(traces.value) / 1e18 AS total_withdrawal -- Aggregate and convert withdrawal value to ETHFROMethereum.logs AS logsLEFT JOINethereum.traces AS tracesONlogs.tx_hash = traces.tx_hashWHERElogs.contract_address = 0xac3e018457b222d93114458476f3e3416abbe38f -- Contract address for withdrawalsAND logs.topic0 = 0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db -- Withdrawal topicAND traces.value > 0 -- Ensure only positive withdrawal values are includedGROUP BYlogs.tx_to)SELECTCOALESCE(deposits.address, withdrawals.address) AS address,COALESCE(deposits.total_deposit, 0) - COALESCE(withdrawals.total_withdrawal, 0) AS net_value -- Calculate net depositsFROMdepositsFULL OUTER JOINwithdrawalsONdeposits.address = withdrawals.addressORDER BYnet_value DESC