Query editor
with arb_cu as (selectblock_time,hash,substring(data from 17 for 20) as token_address,substring(data from 49 for 20) as to_address,bytearray_to_int256(substring(data from 69 for 32))/1e18 as cu_amountfrom arbitrum.transactionswhere to = 0x22cca5dc96a4ac1ec32c9c7c5ad4d66254a24c35and substring(data from 1 for 4) = 0xd2ce7d65and substring(data from 17 for 20) = 0x89c49a3fa372920ac23ce757a029e6936c0b8e02 --cu tokenand block_time > cast('2024-03-01' as timestamp)),xai_fees as (selectevt_tx_hash as hash,value/1e18 as xai_feefrom erc20_arbitrum.evt_transferwhere evt_tx_hash in (selecthashfrom arb_cu)and contract_address = 0x4Cb9a7AE498CEDcBb5EAe9f25736aE7d428C9D66and to = 0xae21fda3de92de2fdaf606233b2863782ba046f9 --bridge fee transfer, this is later transfered to another addressand evt_block_time > cast('2024-03-01' as timestamp)),cu_in_raw as (selecta.block_time as block_time,a.hash as hash,a.token_address as token_address,a.to_address as to_address,a.cu_amount,x.xai_fee as xai_feefrom arb_cu aleft join xai_fees x on a.hash = x.hashorder by block_time),cu_in as(selectdate_trunc('day', block_time) as day,sum(cu_amount) as cu,sum(xai_fee) as xai_fee,count(*) as bridge_infrom cu_in_rawgroup by 1),cu_out as (selectdate_trunc('day', evt_block_time) as day,sum(value/1e18) as cu_out,count(*) as bridge_outfrom erc20_arbitrum.evt_transferwhere contract_address = 0x89c49a3fa372920ac23ce757a029e6936c0b8e02and "from" = 0xb15a0826d65be4c2fdd961b72636168ee70af030 --bridge addressand evt_block_time > cast('2024-03-01' as timestamp)group by 1),days as (