Query editor
/* ============================================================Aftermath Perps — Market Maker Metrics (v3)Changes from v2:1. ORDERS are counted from events, not transactions. A PTB cancarry any number of place/cancel calls, and that batchingfactor drifts, so tx counts are not order counts. Exposeddirectly as orders_per_tx so the batching is visible.2. Cancel:place ratio comes from PostedOrder/CanceledOrderevents instead of the created/deleted object-count proxy.3. Rebate metric replaced with NET storage (rebate - storage_cost).The old "storage_rebate > 0" test is true for nearly every Suitx (gas-coin mutation always refunds), which is why it pinnednear 99%.4. Series starts at first observed Aftermath activity, so a freshpackage deploy no longer back-fills the chart with false zeros.5. redeploy_healthcheck column: goes to 0 if the package filterstops matching, so a silent redeploy is visible instead oflooking like the MM went quiet.6. Position package added to the filter.NETWORK SHARE is unchanged from v2 — it was already correct.It is a transaction-count share of ALL Sui activity (system txsincluded), not an order share and not a DeFi-only share.BEFORE TRUSTING ORDER COUNTS: run the probe at the bottom of thisfile to confirm the live event type names. Only PostedOrder,CanceledOrder and AllocatedCollateral were observed directly.============================================================ */WITH/* --- Aftermath perps transactions: gas-level facts --- */af_tx AS (SELECTtransaction_digest,DATE_TRUNC('minute', FROM_UNIXTIME(timestamp_ms/1000)) AS bucket_time,CAST(total_gas_cost AS DOUBLE) AS gas_mist,CAST(storage_cost AS DOUBLE) AS storage_cost_mist,CAST(storage_rebate AS DOUBLE) AS storage_rebate_mist,execution_successFROM sui.transactionsWHERE date >= CURRENT_DATE - INTERVAL '7' DAYAND total_gas_cost IS NOT NULLAND ((packages LIKE '%3ec740df8428aa9c93aaef7f8cc1542ac3194fd014826b51bfe245346d64efc7%' OR packages LIKE '%e54757433d663835bda85cfc89c6c44bc8d952e941affa5ae57bba0baa226c1b%') -- perpsOR (packages LIKE '%bab1b714c5533a46ee27a9c124d6f9281ca54831fc288d4d0c133dae3a57254a%' OR packages LIKE '%2b741712605799d9627a8a04d429cc03c14047d0eeab30af6788d3c24f8e889d%' OR packages LIKE '%a7a4d5abbf6f352d9f9525159215a829e2c39487f1afea3ac9b981972329d05f%') -- vaultsOR packages LIKE '%9196fffe0341b2f0ca7424926b22d9e9e35b4807a1f625fc20eeea1382d08dec%' -- position)),/* --- Real order counts, one row per transaction --- */af_orders AS (SELECTtransaction_digest,COUNT(*) FILTER (WHERE event_type LIKE '%PostedOrder%') AS orders_placed,COUNT(*) FILTER (WHERE event_type LIKE '%CanceledOrder%') AS orders_canceledFROM sui.eventsWHERE date >= CURRENT_DATE - INTERVAL '7' DAYAND package IN (from_hex('3ec740df8428aa9c93aaef7f8cc1542ac3194fd014826b51bfe245346d64efc7'),