Query editor
WITH flow_creates AS (-- v1.0 / v1.1 : ratePerSecond @ word1; no creator/snapshotTimeSELECT block_time AS evt_block_time, tx_hash, contract_address,CASE WHEN contract_address = 0x2d9221a63e12aa796619cb381ec4a71b201281f5 THEN 'v1.0' ELSE 'v1.1' END AS revision,bytearray_to_uint256(bytearray_substring(data, 1, 32)) AS stream_id,bytearray_substring(topic1, 13, 20) AS sender,bytearray_substring(topic2, 13, 20) AS recipient,bytearray_substring(topic3, 13, 20) AS token,CAST(NULL AS VARBINARY) AS creator,bytearray_to_uint256(bytearray_substring(data, 33, 32)) AS rate_per_sec_raw,CAST(NULL AS uint256) AS snapshot_time,bytearray_to_uint256(bytearray_substring(data, 65, 32)) <> 0 AS transferableFROM ethereum.logsWHERE block_number >= 21330577AND contract_address IN (0x2d9221a63e12aa796619cb381ec4a71b201281f5,0x3df2aaede81d2f6b261f79047517713b8e844e04)AND topic0 = 0x2262fa211f8507786a60fefb231f7898b8145fe16350f281c91f121bd2ee118dUNION ALL-- v2.0 / v3.0 : adds creator (word1) + snapshotTime (word3); ratePerSecond @ word2SELECT block_time AS evt_block_time, tx_hash, contract_address,CASE WHEN contract_address = 0x7a86d3e6894f9c5b5f25ffbdaae658cfc7569623 THEN 'v2.0' ELSE 'v3.0' END AS revision,bytearray_to_uint256(bytearray_substring(data, 1, 32)) AS stream_id,bytearray_substring(topic1, 13, 20) AS sender,bytearray_substring(topic2, 13, 20) AS recipient,bytearray_substring(topic3, 13, 20) AS token,bytearray_substring(data, 45, 20) AS creator, -- word1bytearray_to_uint256(bytearray_substring(data, 65, 32)) AS rate_per_sec_raw, -- word2bytearray_to_uint256(bytearray_substring(data, 97, 32)) AS snapshot_time, -- word3bytearray_to_uint256(bytearray_substring(data, 129, 32)) <> 0 AS transferable -- word4FROM ethereum.logsWHERE block_number >= 23507359AND contract_address IN (0x7a86d3e6894f9c5b5f25ffbdaae658cfc7569623,0x844344cd871b28221d725ece9630e8bde4e3a181)AND topic0 = 0xedec8afa4eeca64243a519c152eab5c4f9da1bded6fbb72cba74cd128de68369),flow_deposits AS ( -- identical layout across all four versionsSELECT block_time AS evt_block_time, contract_address,bytearray_to_uint256(topic1) AS stream_id, -- indexed uint256bytearray_substring(topic2, 13, 20) AS funder,bytearray_to_uint256(bytearray_substring(data, 1, 32)) AS amount_raw -- token decimalsFROM ethereum.logsWHERE block_number >= 21330577AND contract_address IN (0x2d9221a63e12aa796619cb381ec4a71b201281f5,0x3df2aaede81d2f6b261f79047517713b8e844e04,0x7a86d3e6894f9c5b5f25ffbdaae658cfc7569623,0x844344cd871b28221d725ece9630e8bde4e3a181)AND topic0 = 0xa06c1466b3c9751408a5ac337a2e8808e5ee0ceed1fd70635d041b21174eb6b4),flow_withdrawals AS ( -- v1.x has protocolFee (word2); v2.0+ does notSELECT block_time AS evt_block_time, contract_address,bytearray_to_uint256(topic1) AS stream_id,bytearray_substring(topic2, 13, 20) AS withdraw_to,bytearray_substring(topic3, 13, 20) AS token,bytearray_substring(data, 13, 20) AS caller, -- word0 addrbytearray_to_uint256(bytearray_substring(data, 33, 32)) AS withdraw_amount_raw, -- word1 (token dp)CASE WHEN topic0 = 0x1a7b0d6c8f96b874563b711cf97793fe3be5dc42dbd1e0720ce40f326918e817THEN bytearray_to_uint256(bytearray_substring(data, 65, 32)) -- word2, v1.x onlyEND AS protocol_fee_rawFROM ethereum.logsWHERE block_number >= 21330577