Query editor
withspendv2_events as (selectblock_time,block_number,tx_hash,'spend' as event_type,bytearray_substring(topic1, 13, 20) as user_safe,bytearray_substring(topic3, 13, 20) as spend_token,datafromscroll.logswhere block_time >= date '2025-04-01'and contract_address = 0x380B2e96799405be6e3D965f4044099891881acBand topic0 = 0x244f4cc0665ad7ee4709aa59b30d3ea581cecde1b0430a3f23a5dc609d4890fc),head as (select*,cast(bytearray_to_uint256(varbinary_substring(data, 1, 32)) as bigint) as off_tokens,cast(bytearray_to_uint256(varbinary_substring(data, 33, 32)) as bigint) as off_amounts,cast(bytearray_to_uint256(varbinary_substring(data, 65, 32)) as bigint) as off_usd,cast(bytearray_to_uint256(varbinary_substring(data, 97, 32)) as bigint) as total_usd_amt,cast(bytearray_to_uint256(varbinary_substring(data, 129, 32)) as bigint) as modefromspendv2_events),lens as (select*,cast(bytearray_to_uint256(varbinary_substring(data, off_tokens + 1, 32)) as integer) as n_tokens,cast(bytearray_to_uint256(varbinary_substring(data, off_amounts + 1, 32)) as integer) as n_amounts,cast(bytearray_to_uint256(varbinary_substring(data, off_usd + 1, 32)) as integer) as n_usdfromhead),explode_rows as (selectl.block_time,l.block_number,l.event_type,l.user_safe,l.spend_token,l.data,l.tx_hash,l.total_usd_amt,l.mode,i as idx,lower('0x' || to_hex(varbinary_substring(varbinary_substring(l.data, l.off_tokens + 1 + 32 * (i + 1), 32),13,20)