Query editor
WITH t AS (SELECT block_time AS time,to,input,output,bytearray_substring(input, 1, 4) AS selector,ROW_NUMBER() OVER (ORDER BY block_number,tx_index,trace_address) AS iFROM ethereum.traceswhere tx_successand block_number >= 15674057and ("to" = 0x57619fe9c539f890b19c61812226f9703ce37137 or "from" = 0x57619fe9c539f890b19c61812226f9703ce37137and ("to" = 0x896d8a30c32ead64f2e1195c2c8e0932be7dc20b or "to" = 0x5fA5B62c8AF877CB37031e0a3B2f34A78e3C56A6))),mm AS (SELECT i,time,BYTEARRAY_TO_UINT256(bytearray_substring(output, 33, 32)) AS bammRaw,FALSE AS chickenInOrRedeemFROM tWHERE selector = 0xbfca6c11 /* getLUSDValue() */UNION ALLSELECT i,time,NULL AS bammRaw,TRUE AS chickenInOrRedeemFROM tWHERE selector IN (0x4b10543b,0x7cbc2373) --redeem(uint256,uint256)),m as (select *,LAG(chickenInOrRedeem) over (order by i) as checkpointfrom mm),d as (select i,time,bytearray_to_uint256(bytearray_substring(input, 5, 32))/1e18 as bammDeposit,null as bammRaw,CAST(0 AS DOUBLE) as yTokensfrom twhere to = 0x896d8a30c32ead64f2e1195c2c8e0932be7dc20band selector = 0xb6b55f25 -- deposit(uint256)UNION ALLselect i,time,-(bytearray_to_uint256(bytearray_substring("input", 5, 32))/1e18) as bammDeposit,null as bammRaw,CAST(0 AS DOUBLE) as yTokensfrom twhere selector = 0x00f714ce -- withdraw(uint256,address)UNION ALLselect i,time,CAST(0 as DOUBLE) as bammDeposit,bammRaw/1e18 as bammRaw,CAST(0 AS DOUBLE) as yTokensfrom m