Query editor
WITH scroll_croc_traces AS (SELECT534352 as chain_id, t.tx_hash as tx_hash,bytearray_substring(t.input, 1, 4) AS method_id,t.tx_index as t_tx_index, t.block_number as block_number, t.block_time,try(map(ARRAY[0x3d719cd9, 0xa15112f9, 0x13fd34f4, 0x08719070, 0x90b33ce5, 0x7c6dfe3d, 0x7b370fc2, 0x2370632b, 0x2ee11587],ARRAY['swap', 'userCmd', 'protocolCmd', 'userCmdRelayer', 'userCmdRouter', 'micro_burnConcLp', 'micro_swap', 'micro_mintConcLp', 'micro_mintAmbLp'])[bytearray_substring(t.input, 1, 4)]) as method,CASE bytearray_substring(t.input, 1, 4)WHEN 0xa15112f9 THEN bytearray_to_integer(bytearray_substring(t.input, 4 + 29, 4))WHEN 0x13fd34f4 THEN bytearray_to_integer(bytearray_substring(t.input, 4 + 29, 4))END as callpath_idx,CASE bytearray_substring(t.input, 1, 4)WHEN 0xa15112f9 THEN bytearray_to_integer(bytearray_substring(t.input, 4 + 96 + 29, 4))WHEN 0x13fd34f4 THEN bytearray_to_integer(bytearray_substring(t.input, 4 + 128 + 29, 4))END as cmd_idx,t.input, t.outputFROM scroll.traces as tWHEREt.block_number >= 267408 AND t.block_time < cast('{{timestamp}}' as timestamp) AND (t.to = 0xaaaaaaaacb71bf2c8cae522ea5fa455571a74106 OR t.to = 0x646929453e753565467f330110850885ead93fa9 OR t.to = 0x418c68ce5b73783abe178db12dfee9375d965dbb) AND t.success/* pools and pool_hashes calculate hashes for all the pools so that MicroPaths calls (which only have pool hash)can have their pool info recovered. */), pools AS (SELECTCASE WHEN method = 'swap' THEN bytearray_substring(input, 4 + 12 + 1, 20) WHEN (method = 'userCmd' and callpath_idx = 1) THEN bytearray_substring(input, 4 + 96 + 12 + 1, 20) END as base,CASE WHEN method = 'swap' THEN bytearray_substring(input, 4 + 12 + 33, 20) WHEN (method = 'userCmd' and callpath_idx = 1) THEN bytearray_substring(input, 4 + 96 + 12 + 33, 20) END as quote,CASE WHEN method = 'swap' THEN bytearray_substring(input, 4 + 28 + 65, 4) WHEN (method = 'userCmd' and callpath_idx = 1) THEN bytearray_substring(input, 4 + 96 + 28 + 65, 4) END as pool_idxFROM scroll_croc_tracesWHERE method = 'swap' OR (method = 'userCmd' and callpath_idx = 1)GROUP BYCASE WHEN method = 'swap' THEN bytearray_substring(input, 4 + 12 + 1, 20) WHEN (method = 'userCmd' and callpath_idx = 1) THEN bytearray_substring(input, 4 + 96 + 12 + 1, 20) END,CASE WHEN method = 'swap' THEN bytearray_substring(input, 4 + 12 + 33, 20) WHEN (method = 'userCmd' and callpath_idx = 1) THEN bytearray_substring(input, 4 + 96 + 12 + 33, 20) END,CASE WHEN method = 'swap' THEN bytearray_substring(input, 4 + 28 + 65, 4) WHEN (method = 'userCmd' and callpath_idx = 1) THEN bytearray_substring(input, 4 + 96 + 28 + 65, 4) END), pool_hashes as (SELECT keccak(bytearray_concat(bytearray_concat(bytearray_concat(0x000000000000000000000000, base), bytearray_concat(0x000000000000000000000000, quote)), bytearray_concat(0x00000000000000000000000000000000000000000000000000000000, pool_idx))) as pool_hash,map_from_entries(ARRAY[('base', base),('quote', quote),('pool_idx', pool_idx)]) as poolFROM pools), protocol_traces AS (SELECT *,CASEWHEN callpath_idx = 3 AND cmd_idx = 109 THEN 'disableTemplate'WHEN callpath_idx = 3 AND cmd_idx = 110 THEN 'setTemplate'WHEN callpath_idx = 3 AND cmd_idx = 111 THEN 'poolRevise'WHEN callpath_idx = 3 AND cmd_idx = 112 THEN 'setPoolInitLiq'WHEN callpath_idx = 3 AND cmd_idx = 113 THEN 'setOffGrid'WHEN callpath_idx = 3 AND cmd_idx = 114 THEN 'setProtocolTake'WHEN callpath_idx = 3 AND cmd_idx = 115 THEN 'resyncPoolProtocolTake'WHEN callpath_idx = 3 AND cmd_idx = 116 THEN 'setRelayerProtocolTake'END as cmdFROM scroll_croc_tracesWHERE method = 'protocolCmd'), protocol_commands AS (SELECT chain_id, block_time, block_number, cmd,CASEWHEN cmd = 'setTemplate'