Query editor
WITH raw_trades AS (SELECTl.block_time,l.block_number,l.tx_hash,l.index AS log_index,bytearray_to_uint256(bytearray_substring(l.topic1, 25, 8)) AS buyer_account_id,bytearray_to_uint256(bytearray_substring(l.topic2, 25, 8)) AS seller_account_id,CAST(bytearray_to_uint256(bytearray_substring(l.data, 9, 8)) AS double) / 1e8 AS quantity_btc,CAST(bytearray_to_uint256(bytearray_substring(l.data, 17, 8)) AS double) / 1e4 AS seller_fee_usdm,CAST(bytearray_to_uint256(bytearray_substring(l.data, 25, 8)) AS double) / 1e4 AS buyer_fee_usdm,CAST(CAST(bytearray_to_uint256(bytearray_substring(l.data, 36, 1)) AS bigint) AS integer) % 2 AS buyer_is_maker,CAST(bytearray_to_uint256(bytearray_substring(l.data, 37, 8)) AS double) AS price_packed_d,CAST(CAST(bytearray_to_uint256(bytearray_substring(l.data, 44, 1)) AS bigint) AS integer) % 32 AS price_scale,CAST(bytearray_to_uint256(bytearray_substring(l.data, 61, 4)) AS bigint) AS trade_seqFROM megaeth.logs lWHERE l.block_date >= DATE '2026-02-01'AND l.contract_address = 0x757b27D961A25FEF0C2B71819c91de8A7c669079AND l.topic0 = 0x18552bd75bd768d6b943973270f4b4cb69370ade12f8e60e7cd6d5019b13467d), decoded AS (SELECTblock_time,block_number,tx_hash,log_index,CAST(trade_seq AS bigint) AS trade_seq,CAST(buyer_account_id AS bigint) AS buyer_account_id,CAST(seller_account_id AS bigint) AS seller_account_id,buyer_is_maker = 1 AS buyer_is_maker,IF(buyer_is_maker = 1, CAST(buyer_account_id AS bigint), CAST(seller_account_id AS bigint)) AS maker_account_id,IF(buyer_is_maker = 1, CAST(seller_account_id AS bigint), CAST(buyer_account_id AS bigint)) AS taker_account_id,IF(buyer_is_maker = 1, seller_fee_usdm, buyer_fee_usdm) AS taker_fee_usdm,IF(buyer_is_maker = 1, buyer_fee_usdm, seller_fee_usdm) AS maker_fee_usdm,buyer_fee_usdm,seller_fee_usdm,quantity_btc,(price_packed_d / 32.0) / pow(10.0, price_scale) AS priceFROM raw_trades), watched AS (SELECTCASE taker_account_idWHEN 542 THEN 'hit.one / 542'WHEN 94 THEN '94'WHEN 652 THEN '652'ELSE CAST(taker_account_id AS varchar)END AS account_label,*FROM decodedWHERE taker_account_id IN (94, 542, 652)), ranked AS (SELECT *, row_number() OVER (PARTITION BY taker_account_id ORDER BY block_time DESC, block_number DESC, log_index DESC) AS rn_latestFROM watched)SELECT'summary' AS row_type,account_label,taker_account_id,COUNT(*) AS taker_trades,COUNT_IF(taker_fee_usdm > 0) AS taker_trades_with_fee,COUNT_IF(taker_fee_usdm = 0) AS taker_trades_zero_fee,