Query editor
-- LUA to deposit for LUAUSD-- LUAUSD address: 0x1DD6b5F9281c6B4f043c02A83a46c2772024636c-- LUA address: 0xc3aBC47863524ced8DAf3ef98d74dd881E131C38with deposit as (select date_trunc('day', block_time) as dt, substr(topic2, 13 ) as address, varbinary_to_uint256(data) / 1e18 as amountfrom arbitrum.logswhere topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efand topic2 = 0x000000000000000000000000a09ad598daebd21734da7669ea043aa2817bd6bcand contract_address = 0xc3aBC47863524ced8DAf3ef98d74dd881E131C38 -- LUA address),withdraw as (select date_trunc('day', block_time) as dt, substr(topic2, 13 ) as address, varbinary_to_uint256(data) / 1e18 as amountfrom arbitrum.logswhere topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efand topic1 = 0x000000000000000000000000a09ad598daebd21734da7669ea043aa2817bd6bcand contract_address = 0xc3aBC47863524ced8DAf3ef98d74dd881E131C38),daily_deposit_list as (select dt, sum(amount) as daily_depositfrom depositgroup by 1),daily_withdraw_list as (select dt, -1 * sum(amount) as daily_withdrawfrom withdrawgroup by 1),join_list as (select d.dt as dt1, w.dt as dt2, daily_deposit, daily_withdrawfrom daily_deposit_list dleft join daily_withdraw_list w on d.dt = w.dt),join_list2 as (select dt1, dt2, daily_deposit, COALESCE(daily_withdraw, 0) as daily_withdrawfrom join_list)select dt1, daily_deposit, daily_withdraw, daily_deposit + daily_withdraw as net_deposit,sum(daily_deposit + daily_withdraw) over (order by dt1) as cumulative_depositfrom join_list2group by 1, 2, 3, 4order by 1 desc