Query editor
WITHlisting_bought AS (SELECTlb.listingID, lb.buyer, IF(tx.value = 0, 'Buying', 'Selling') AS listing_type, tx.value / 1e18 AS buy_tx_value, tx.value AS buy_tx_value_raw, tx.hash AS buy_tx_hash, tx."from" AS buy_tx_from, tx.index AS buy_tx_index, tx.block_number AS buy_block_number, tx.block_time AS buy_block_time, date_trunc('minute', tx.block_time) AS buy_block_minute, tx.block_date AS buy_block_dateFROM avalanche_c.transactions txINNER JOIN labninety1_pass_otc_avalanche_c.pass_evt_listingbought lbON lb.evt_block_number = tx.block_numberAND lb.evt_tx_hash = tx.hashWHERE tx.block_number >= 63243103)/*There's an unaccounted edge case that would seldom happen:If the fee amount/formula changed while orders listings were opened. In that case, it's possible the buy fee wouldn'tmatch the listing fee, which is assumed to be the case. We're accepting this in exchange for notable efficiency improvements*/SELECT *FROM listing_boughtORDER BY buy_block_time DESC