Query editor
withfluid_pools as (select*fromquery_3856239where project = 'fluid'),log_operate_events as (selectdate_trunc('day', block_time) as day,blockchain,block_time,block_number,tx_hash,tx_index,pool_address,-- case-- when token_address = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee and blockchain = 'ethereum' then 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2-- when token_address = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee and blockchain = 'arbitrum' then 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1-- else token_address-- end as token_address,token_address,supply_amount,borrow_amount,sum(supply_amount+borrow_amount) over (partition by pool_address, token_address, blockchain order by block_number, tx_index) as net_amountfrom (selectb.*,b.supply_amount_raw/pow(10, er.decimals) as supply_amount,b.borrow_amount_raw/pow(10, er.decimals) as borrow_amountfrom (select'ethereum' as blockchain,block_time,block_number,tx_hash,index as tx_index,contract_address,bytearray_substring(topic1, 13, 20) as pool_address,casewhen bytearray_substring(topic2, 13, 20) = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee then 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2else bytearray_substring(topic2, 13, 20)end as token_address,-- bytearray_substring(topic2, 13, 20) as token_address,bytearray_to_int256(bytearray_substring(data,1,32)) as supply_amount_raw,bytearray_to_int256(bytearray_substring(data,33,32)) as borrow_amount_rawfromethereum.logswhere block_date >= date '2024-10-01'and contract_address = 0x52Aa899454998Be5b000Ad077a46Bbe360F4e497and topic0 = 0x4d93b232a24e82b284ced7461bf4deacffe66759d5c24513e6f29e571ad78d15union allselect'arbitrum' as blockchain,block_time,