Query editor
WITH liquidation_logs AS (SELECT'ethereum' AS blockchain,contract_address AS hook_address,lower(to_hex(substr(topic2, 13, 20))) AS silo_address,lower(to_hex(substr(topic3, 13, 20))) AS borrower,block_time,tx_hashFROM ethereum.logsWHERE topic0 = 0x3a84f64446e8eada995aa9da2ddbfcd9b5d5d650503b19f024096d04c05ef2a9UNION ALLSELECT'avalanche' AS blockchain,contract_address AS hook_address,lower(to_hex(substr(topic2, 13, 20))) AS silo_address,lower(to_hex(substr(topic3, 13, 20))) AS borrower,block_time,tx_hashFROM avalanche_c.logsWHERE topic0 = 0x3a84f64446e8eada995aa9da2ddbfcd9b5d5d650503b19f024096d04c05ef2a9UNION ALLSELECT'arbitrum' AS blockchain,contract_address AS hook_address,lower(to_hex(substr(topic2, 13, 20))) AS silo_address,lower(to_hex(substr(topic3, 13, 20))) AS borrower,block_time,tx_hashFROM arbitrum.logsWHERE topic0 = 0x3a84f64446e8eada995aa9da2ddbfcd9b5d5d650503b19f024096d04c05ef2a9UNION ALLSELECT'sonic' AS blockchain,contract_address AS hook_address,lower(to_hex(substr(topic2, 13, 20))) AS silo_address,lower(to_hex(substr(topic3, 13, 20))) AS borrower,block_time,tx_hashFROM sonic.logsWHERE topic0 = 0x3a84f64446e8eada995aa9da2ddbfcd9b5d5d650503b19f024096d04c05ef2a9),ordered_liquidations AS (SELECTblockchain,hook_address,silo_address,borrower,block_time AS liq_time,tx_hash,lag(block_time) OVER (PARTITION BY blockchain, silo_address, borrowerORDER BY block_time, tx_hash) AS prev_liq_time