Query editor
/* Supports dynamic fees, so a row will be created whenever a pool is eitherinitialized or its fee is revised. */WITH scroll_croc_protocol_traces AS (SELECT534352 as chain_id, -- t.tx_hash as tx_hash,t.block_time, t.block_number, 'protocolCmd' as method,bytearray_to_integer(bytearray_substring(t.input, 4 + 29, 4)) as callpath_idx,bytearray_to_integer(bytearray_substring(t.input, 4 + 128 + 29, 4)) as cmd_idx,t.inputFROM scroll.traces as tWHERE t.block_number > 267408 AND t.to = 0xaaaaaaaacb71bf2c8cae522ea5fa455571a74106 AND bytearray_substring(t.input, 1, 4) = 0x13fd34f4 AND t.success), protocol_traces AS (SELECT *,CASEWHEN ((chain_id = 1 AND callpath_idx = 3 AND cmd_idx = 109) OR (chain_id = 534352 AND callpath_idx = 3 AND cmd_idx = 109) OR (chain_id = 81457 AND callpath_idx = 3 AND cmd_idx = 109)) THEN 'disableTemplate'WHEN ((chain_id = 1 AND callpath_idx = 3 AND cmd_idx = 110) OR (chain_id = 534352 AND callpath_idx = 3 AND cmd_idx = 110) OR (chain_id = 81457 AND callpath_idx = 3 AND cmd_idx = 110)) THEN 'setTemplate'WHEN ((chain_id = 1 AND callpath_idx = 3 AND cmd_idx = 111) OR (chain_id = 534352 AND callpath_idx = 3 AND cmd_idx = 111) OR (chain_id = 81457 AND callpath_idx = 3 AND cmd_idx = 111)) THEN 'poolRevise'WHEN ((chain_id = 1 AND callpath_idx = 3 AND cmd_idx = 112) OR (chain_id = 534352 AND callpath_idx = 3 AND cmd_idx = 112) OR (chain_id = 81457 AND callpath_idx = 3 AND cmd_idx = 112)) THEN 'setPoolInitLiq'WHEN ((chain_id = 1 AND callpath_idx = 3 AND cmd_idx = 113) OR (chain_id = 534352 AND callpath_idx = 3 AND cmd_idx = 113) OR (chain_id = 81457 AND callpath_idx = 3 AND cmd_idx = 113)) THEN 'setOffGrid'WHEN ((chain_id = 1 AND callpath_idx = 3 AND cmd_idx = 114) OR (chain_id = 534352 AND callpath_idx = 3 AND cmd_idx = 114) OR (chain_id = 81457 AND callpath_idx = 3 AND cmd_idx = 114)) THEN 'setProtocolTake'WHEN ((chain_id = 1 AND callpath_idx = 3 AND cmd_idx = 115) OR (chain_id = 534352 AND callpath_idx = 3 AND cmd_idx = 115) OR (chain_id = 81457 AND callpath_idx = 3 AND cmd_idx = 115)) THEN 'resyncPoolProtocolTake'WHEN ((chain_id = 1 AND callpath_idx = 3 AND cmd_idx = 116) OR (chain_id = 534352 AND callpath_idx = 3 AND cmd_idx = 116) OR (chain_id = 81457 AND callpath_idx = 3 AND cmd_idx = 116)) THEN 'setRelayerProtocolTake'END as cmdFROM scroll_croc_protocol_tracesWHERE method = 'protocolCmd'), protocol_commands AS (SELECT chain_id, block_time, block_number, cmd,CASEWHEN cmd = 'setTemplate'THEN map_from_entries(ARRAY[('base', 0x),('quote', 0x),('pool_idx', bytearray_substring(input, 4 + 160 + 28 + 1, 4))])WHEN cmd = 'poolRevise'THEN map_from_entries(ARRAY[('base', bytearray_substring(input, 4 + 128 + 12 + 1, 20)),('quote', bytearray_substring(input, 4 + 160 + 12 + 1, 20)),('pool_idx', bytearray_substring(input, 4 + 192 + 28 + 1, 4))])END as pool,CASEWHEN cmd = 'setTemplate' THEN CAST(bytearray_to_integer(bytearray_substring(input, 4 + 192 + 30 + 1, 2)) as DOUBLE) / 10000.0 / 100.0WHEN cmd = 'poolRevise' THEN CAST(bytearray_to_integer(bytearray_substring(input, 4 + 224 + 30 + 1, 2)) as DOUBLE) / 10000.0 / 100.0END as fee_rateFROM protocol_traces), pool_revisions as (SELECT cmd, chain_id, block_time, block_number, pool, fee_rateFROM protocol_commandsWHERE cmd = 'poolRevise'), pool_templates as (SELECT cmd, chain_id, block_time, block_number, pool, fee_rateFROM protocol_commandsWHERE cmd = 'setTemplate'), scroll_croc_traces AS (SELECT534352 as chain_id, t.tx_hash as tx_hash,