Query editor
WITH raw_bid_events AS (-- pull BidPlaced() events from the MegaETH saleSELECTl.block_time AS block_time,l.tx_hash AS tx_hash,l.tx_index AS evt_index,tx."from" AS bidder, -- wallet that called replaceBidWithApproval()l.topic1 AS entity_id_topic, -- indexed bytes16 (padded)bytearray_to_uint256(bytearray_substring(l.data, 1, 32)) AS price_ticks, -- uint64 price (ticks of 0.0001 USDT/token)bytearray_to_uint256(bytearray_substring(l.data,33, 32)) AS amount_raw, -- uint64 USDT amount (6 decimals)bytearray_to_uint256(bytearray_substring(l.data,65, 32)) AS lockup_int -- bool -> 0/1FROM ethereum.logs lJOIN ethereum.transactions txON tx.hash = l.tx_hashWHERE l.contract_address = 0xaB02bf85a7a851b6A379eA3D5bD3B9b4f5Dd8461-- BidPlaced(bytes16 indexed entityID, (uint64 price, uint64 amount, bool lockup) bid)AND l.topic0 = 0x804b42e7e171589ed3879c1882898c8dd15f3d4168afc3292253f5d9ebabc7be-- only recent auction activity (tune if you want full history)AND l.block_time >= TIMESTAMP '2025-10-27 12:00:00 UTC'-- SPEED-UP OPTION: ignore tiny bids under 10k USDT-- AND bytearray_to_uint256(bytearray_substring(l.data,33,32)) >= 10000e6),bids_enriched AS (SELECTblock_time,tx_hash,evt_index,bidder,-- entity_id is the FIRST 16 bytes of topic1 (bytes16 in a 32-byte topic word)bytearray_substring(entity_id_topic, 1, 16) AS entity_id,price_ticks,amount_raw,CAST(amount_raw AS DOUBLE) / 1e6 AS amount_usdt,price_ticks * 0.0001 AS price_usd_per_token,(CAST(amount_raw AS DOUBLE) / 1e6) / (price_ticks * 0.0001) AS tokens_requested,CASE WHEN lockup_int > 0 THEN TRUE ELSE FALSE END AS lockup,-- latest bid per entity (highest block_time / last log in tx)ROW_NUMBER() OVER (PARTITION BY bytearray_substring(entity_id_topic, 1, 16)ORDER BY block_time DESC, evt_index DESC) AS rn_latest,-- previous amount for delta calc in chronological orderLAG(amount_raw) OVER (PARTITION BY bytearray_substring(entity_id_topic, 1, 16)ORDER BY block_time, evt_index) AS prev_amount_rawFROM raw_bid_events),-- snapshot of each entity's CURRENT live bidlatest_bids AS (SELECT *FROM bids_enriched