Query editor
with cash as (select date_trunc('hour', evt_block_time) as hour,sum(case when "to" = 0x003ca23fd5f0ca87d01f6ec6cd14a8ae60c2b97d then value else 0 end)/1e18 as usd1_in,sum(case when "from" = 0x003ca23fd5f0ca87d01f6ec6cd14a8ae60c2b97d then value else 0 end)/1e18 as usd1_outfrom erc20_ethereum.evt_Transferwhere contract_address = 0x8d0d000ee44948fc98c9b98a4fa4921476f08b0dand evt_block_date >= date '2026-11-29'and ("to" = 0x003ca23fd5f0ca87d01f6ec6cd14a8ae60c2b97d or "from" = 0x003ca23fd5f0ca87d01f6ec6cd14a8ae60c2b97d)group by 1),bal_before as (select sum(case when "to" = 0x003ca23fd5f0ca87d01f6ec6cd14a8ae60c2b97d then cast(value as double) else -cast(value as double) end)/1e18 as b0from erc20_ethereum.evt_Transferwhere contract_address = 0x8d0d000ee44948fc98c9b98a4fa4921476f08b0dand evt_block_date < date '2026-11-29'and ("to" = 0x003ca23fd5f0ca87d01f6ec6cd14a8ae60c2b97d or "from" = 0x003ca23fd5f0ca87d01f6ec6cd14a8ae60c2b97d)),ev as (select block_time, cast(bytearray_substring(topic1,13,20) as varchar) as owner,case topic0 when 0x2bad8bc95088af2c247b30fa2b2e6a0886f88625e0945cd3051008e0e270198f then 'deposit' when 0xbc83c08f0b269b1726990c8348ffdf1ae1696244a14868d766e542a2f18cd7d4 then 'withdraw' else 'transfer' end as kind,cast(bytearray_to_uint256(bytearray_substring(data, case when topic0 = 0x21281f8d59117d0399dc467dbdd321538ceffe3225e80e2bd4de6f1b3355cbc7 then 65 else 33 end, 32)) as double) as market,(case when cast(bytearray_to_uint256(bytearray_substring(data, case when topic0 = 0x21281f8d59117d0399dc467dbdd321538ceffe3225e80e2bd4de6f1b3355cbc7 then 97 else 65 end, 32)) as double) = 1 then 1 else -1 end)* cast(bytearray_to_uint256(bytearray_substring(data, case when topic0 = 0x21281f8d59117d0399dc467dbdd321538ceffe3225e80e2bd4de6f1b3355cbc7 then 129 else 97 end, 32)) as double) / 1e18 as deltafrom ethereum.logswhere contract_address = 0x003ca23fd5f0ca87d01f6ec6cd14a8ae60c2b97d and block_date >= date '2026-11-29'and topic0 in (0x2bad8bc95088af2c247b30fa2b2e6a0886f88625e0945cd3051008e0e270198f, 0xbc83c08f0b269b1726990c8348ffdf1ae1696244a14868d766e542a2f18cd7d4, 0x21281f8d59117d0399dc467dbdd321538ceffe3225e80e2bd4de6f1b3355cbc7)and bytearray_substring(topic1,13,20) in (0x5be9a4959308a0d0c7bc0870e319314d8d957dbb, 0x44a681dd2ae212e6b8ed676b793ea802c7655fad, 0xdc388af5d78f49a4bfe5cd9af4e4a25105c00d4e, 0x310766f4cd537eea2ee789c595b004ae70500c1f, 0xc1338e55a765fd98a17d5fd1aed6cf0068c66522))select 'cash' as k, cast(c.hour as varchar) as t, cast(null as varchar) as owner, cast(null as varchar) as kind, cast(null as double) as market,c.usd1_in, c.usd1_out, b.b0 + sum(c.usd1_in - c.usd1_out) over (order by c.hour) as usd1_cash_afterfrom cash c cross join bal_before bunion allselect 'borrower_event', cast(block_time as varchar), owner, kind, market, delta, null, null from ev where market = 1order by 1, 2