Query editor
-- =====================================================-- Optimized Booster Sales & Mint Comparison-- Uses block_date partitioning and minimal joins-- Adjust date range as needed (last 90 days)-- =====================================================WITHdate_filter AS (SELECT CURRENT_DATE - INTERVAL '7' DAY AS min_date),-- 1. Direct sales events (with date filter)direct_events AS (SELECTevt_tx_hash,value AS token_amount,evt_block_time,evt_block_dateFROM its_megaeth.its_booster_pack_evt_transfersingleWHERE "from" != 0x0000000000000000000000000000000000000000AND "to" != 0x0000000000000000000000000000000000000000AND evt_block_date >= (SELECT min_date FROM date_filter)),-- 2. Seaport events (with date filter)seaport_events AS (SELECTevt_tx_hash,evt_block_time,evt_block_date,offer[1] AS offer_item,consideration[1] AS consideration_itemFROM opensea_megaeth.seaport_evt_orderfulfilledWHERE evt_block_date >= (SELECT min_date FROM date_filter)AND offer[1] IS NOT NULLAND consideration[1] IS NOT NULL),-- 3. Parse Seaport JSON (only for our booster contract)parsed_seaport AS (SELECTevt_tx_hash,evt_block_time,CAST(COALESCE(json_extract_scalar(CAST(json_parse(offer_item) AS json), '$.amount'),json_extract_scalar(CAST(json_parse(offer_item) AS json), '$.value')) AS UINT256) AS token_amount,CAST(json_extract_scalar(CAST(json_parse(consideration_item) AS json), '$.amount') AS DOUBLE) / 1e18 AS eth_priceFROM seaport_eventsWHERE from_hex(json_extract_scalar(CAST(json_parse(offer_item) AS json), '$.token')) = 0x0d2de3b0fbb28e7a3944264adf0c8a63094c8204AND from_hex(json_extract_scalar(CAST(json_parse(consideration_item) AS json), '$.token')) = 0x0000000000000000000000000000000000000000),-- 4. Collect all transaction hashes that need ETH valuesall_tx_hashes AS (SELECT evt_tx_hash FROM direct_eventsUNIONSELECT evt_tx_hash FROM parsed_seaport),