Query editor
WITH pool_123_distributions AS (SELECTblock_time,block_number,hash as tx_hash,"from" as distributor,data,gas_used,gas_price,'distribution' as transaction_typeFROM optimism.transactionsWHEREto = 0x1133eA7Af70876e64665ecD07C0A0476d09465a1 -- Allo contractAND bytearray_substring(data, 1, 4) = 0x3a5fbd92 -- distribute() methodAND bytearray_to_uint256(bytearray_substring(data, 5, 32)) = 123 -- pool_id = 123AND success = trueAND block_time >= TIMESTAMP '2024-01-01' -- Add date filter for performance),pool_123_fundings AS (SELECTblock_time,block_number,hash as tx_hash,"from" as funder,data,gas_used,gas_price,'funding' as transaction_typeFROM optimism.transactionsWHEREto = 0x1133eA7Af70876e64665ecD07C0A0476d09465a1 -- Allo contractAND bytearray_substring(data, 1, 4) = 0x5acd6fac -- fundPool() methodAND bytearray_to_uint256(bytearray_substring(data, 5, 32)) = 123 -- pool_id = 123AND success = trueAND block_time >= TIMESTAMP '2024-01-01' -- Add date filter for performance),pool_123_all_transactions AS (SELECT * FROM pool_123_distributionsUNION ALLSELECTblock_time,block_number,tx_hash,funder as distributor, -- Rename for consistencydata,gas_used,gas_price,transaction_typeFROM pool_123_fundings),pool_123_transfers AS (SELECTd.block_time,d.block_number,d.tx_hash,d.distributor,d.transaction_type,