Query editor
-- Weighted average gas per order (true cost) — AF Perps v2 vs DeepBook v3-- AF Perps v2 package: 0x3ec740df... (published 2026-08-18, version 1)-- v1 (0x21d001e8...) is retired and emits no events in the trailing window.-- Date bounds are inlined (no params CTE) so Trino can prune the `date` partitions;-- with v2's event volume the cross-joined variant blows the 2-min small-engine limit.WITH order_events AS (SELECTe.transaction_digest,CASEWHEN e.package IN (0x3ec740df8428aa9c93aaef7f8cc1542ac3194fd014826b51bfe245346d64efc7, 0xe54757433d663835bda85cfc89c6c44bc8d952e941affa5ae57bba0baa226c1b)THEN 'Aftermath Perps (v2)'WHEN e.package = 0x2c8d603bc51326b8c13cef9dd07031a408a48dddb541963357661df5d3204809THEN 'DeepBook v3'END AS protocol,COUNT(*) AS orders_per_txFROM sui.events eWHERE e.date >= CURRENT_DATE - INTERVAL '30' DAYAND e.event_type LIKE '%Order%'AND e.package IN (0x3ec740df8428aa9c93aaef7f8cc1542ac3194fd014826b51bfe245346d64efc7,0xe54757433d663835bda85cfc89c6c44bc8d952e941affa5ae57bba0baa226c1b,0x2c8d603bc51326b8c13cef9dd07031a408a48dddb541963357661df5d3204809)GROUP BY 1, 2),tx_costs AS (SELECTo.protocol,o.orders_per_tx,(t.total_gas_cost / 1e9) AS gas_suiFROM order_events oJOIN sui.transactions tON t.transaction_digest = o.transaction_digestWHERE t.date >= CURRENT_DATE - INTERVAL '30' DAYAND t.total_gas_cost IS NOT NULLAND o.protocol IS NOT NULL)SELECTprotocol,COUNT(*) AS txs,SUM(orders_per_tx) AS total_orders,ROUND(SUM(gas_sui), 6) AS total_gas_sui,ROUND( (SUM(gas_sui) / NULLIF(SUM(orders_per_tx), 0)) * 1000, 6) AS weighted_avg_gas_per_order_mSUIFROM tx_costsGROUP BY 1ORDER BY weighted_avg_gas_per_order_mSUI ASC;