Query editor
WITH interactions AS (SELECT * FROM oneinch_multichain.settlementv3v1_call_postinteractionUNION ALLSELECT 'ethereum', * FROM oneinch_ethereum.settlementv3v2_call_postinteraction), input AS (SELECTs.*,t.taker,t.makingAmount AS making_amount,t.takingAmount AS taking_amount,t.remainingMakingAmount AS remaining_amount,substr(t.extraData,CASE WHEN substr(t.extraData, 1, 1) = 0x00 THEN 48 ELSE 68 END) as wl_dataFROM interactions tJOIN oneinch.swaps s ONs.blockchain = t.chain ANDs.block_number = t.call_block_number ANDs.tx_hash = t.call_tx_hash ANDs.order_hash = t.orderHash ANDs.src_executed_amount = t.makingAmount), hdr AS (SELECT*,from_big_endian_32(substr(wl_data, 1, 4)) AS allowed0,from_big_endian_32(concat( X'000000', substr(wl_data, 5, 1))) AS sizeFROM input), entries AS (SELECTh.*,i AS idx,substr(h.wl_data, 6 + 12 * i, 10) AS taker_suffix,from_big_endian_32(concat( X'0000', substr(h.wl_data, 6 + 12 * i + 10, 2))) AS delta_secondsFROM hdr hCROSS JOIN UNNEST( SEQUENCE(0, h.size - 1) ) AS u(i)), with_allowed_times AS (SELECTe.*,CAST(e.allowed0 + COALESCE(SUM(e.delta_seconds) OVER (PARTITION BY e.order_hashORDER BY e.idxROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), 0) AS bigint) AS allowed_time_unixFROM entries e), first_last_times AS (SELECTorder_hash,