Query editor
-- Sui AMM swap-transaction gas intensity, January through the last complete UTC day.-- Seven curated AMMs plus Cetus DLMM, Turbos and Ferra CLMM/DLMM exact swap events.-- DeepBook, perpetuals, Bluemove and liquid staking are excluded from swap volume.-- The combined numerator counts each AMM-touching transaction once across all 11 AMMs.-- Eligibility: successful non-system transaction, all observed tracked-AMM swaps positively priced,-- complete gas fields and no conflicting duplicate price rows. Numerator and denominator use the same selected transactions.-- Full PTB gas can include router, other-venue or unrelated work and sponsorship; it is not isolated AMM gas.-- Per-venue rows overlap and must not be summed. Routed execution notional is not unique end-user notional.-- Net gas = computation + storage deposits - storage rebates. DEX trading fees are excluded.-- Chart values are seven-day ratios of sums, not means of daily ratios; missing days stay null.-- Cetus DLMM, Turbos, Ferra USD uses daily median raw-token prices from the verified spot query.WITH curated AS (SELECT * FROM dex_sui.tradesWHERE block_month>=TIMESTAMP '2026-01-01' AND block_date>=DATE '2026-01-01' AND block_date<current_date AND project<>'bluemove'), price_points AS (SELECT block_date day,regexp_replace(lower(token_sold_address),'^(0x)?0*','') coin,cast(token_sold_usd AS double)/cast(token_sold_amount_raw AS double) usd_per_raw FROM curated WHERE token_sold_amount_raw>0 AND token_sold_usd>0UNION ALLSELECT block_date,regexp_replace(lower(token_bought_address),'^(0x)?0*',''),cast(token_bought_usd AS double)/cast(token_bought_amount_raw AS double) FROM curated WHERE token_bought_amount_raw>0 AND token_bought_usd>0), prices AS (SELECT day,coin,approx_percentile(usd_per_raw,0.5) usd_per_raw FROM price_points GROUP BY 1,2), dlmm AS (SELECT e.date block_date,'Cetus DLMM' project,from_unixtime(cast(e.timestamp_ms AS double)/1000) block_time,e.transaction_digest,e.event_index,e.sender,coalesce(try_cast(json_extract_scalar(e.event_json,'$.amount_in') AS double)*pi.usd_per_raw,try_cast(json_extract_scalar(e.event_json,'$.amount_out') AS double)*po.usd_per_raw) amount_usdFROM sui.events eLEFT JOIN prices pi ON pi.day=e.date AND pi.coin=regexp_replace(lower(json_extract_scalar(e.event_json,'$.from.name')),'^(0x)?0*','')LEFT JOIN prices po ON po.day=e.date AND po.coin=regexp_replace(lower(json_extract_scalar(e.event_json,'$.target.name')),'^(0x)?0*','')WHERE e.date>=DATE '2026-01-01' AND e.date<current_date AND e.event_type='0x5664f9d3fd82c84023870cfbda8ea84e14c8dd56ce557ad2116e0668581a682b::pool::SwapEvent'), pool_types AS (SELECT lower(to_hex(object_id)) pool_id,arbitrary(type_) pool_typeFROM sui.objectsWHERE date>=DATE '2026-01-01' AND date<current_dateAND (type_ LIKE '0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::pool::Pool<%' OR type_ LIKE '0xc895342d87127c9c67b76c8ad7f9a22b8bfe1dcdc2c5af82bd85266783115e31::pool::Pool<%' OR type_ LIKE '0x5a5c1d10e4782dbbdec3eb8327ede04bd078b294b97cfdba447b11b846b383ac::lb_pair::LBPair<%')GROUP BY 1), pool_coins AS (SELECT pool_id,regexp_replace(lower(trim(regexp_extract(pool_type,'<([^,]+),',1))),'^(0x)?0*','') coin_a,regexp_replace(lower(trim(regexp_extract(pool_type,', ([^,>]+)',1))),'^(0x)?0*','') coin_bFROM pool_types), extra_events AS (SELECT date block_date,from_unixtime(cast(timestamp_ms AS double)/1000) block_time,transaction_digest,event_index,sender,event_json,CASE split_part(event_type,'::',1) WHEN '0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1' THEN 'Turbos' WHEN '0xc895342d87127c9c67b76c8ad7f9a22b8bfe1dcdc2c5af82bd85266783115e31' THEN 'Ferra CLMM' ELSE 'Ferra DLMM' END project,regexp_replace(lower(coalesce(json_extract_scalar(event_json,'$.pool'),json_extract_scalar(event_json,'$.pair'))),'^0x','') pool_id,coalesce(try_cast(json_extract_scalar(event_json,'$.a_to_b') AS boolean),try_cast(json_extract_scalar(event_json,'$.atob') AS boolean),try_cast(json_extract_scalar(event_json,'$.swap_for_y') AS boolean)) atobFROM sui.events WHERE date>=DATE '2026-01-01' AND date<current_dateAND event_type IN ('0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::pool::SwapEvent','0xc895342d87127c9c67b76c8ad7f9a22b8bfe1dcdc2c5af82bd85266783115e31::pool::SwapEvent','0x5a5c1d10e4782dbbdec3eb8327ede04bd078b294b97cfdba447b11b846b383ac::lb_pair::SwapEvent')), extra_amounts AS (SELECT *,CASE project WHEN 'Turbos' THEN try_cast(json_extract_scalar(event_json,CASE WHEN atob THEN '$.amount_a' ELSE '$.amount_b' END) AS double)WHEN 'Ferra CLMM' THEN try_cast(json_extract_scalar(event_json,'$.amount_in') AS double)ELSE CASE WHEN atob THEN reduce(cast(json_extract(event_json,'$.amounts_in_x') AS array(double)),double '0',(s,x)->s+x,s->s) ELSE reduce(cast(json_extract(event_json,'$.amounts_in_y') AS array(double)),double '0',(s,x)->s+x,s->s) END END amount_in_raw,CASE project WHEN 'Turbos' THEN try_cast(json_extract_scalar(event_json,CASE WHEN atob THEN '$.amount_b' ELSE '$.amount_a' END) AS double)WHEN 'Ferra CLMM' THEN try_cast(json_extract_scalar(event_json,'$.amount_out') AS double)ELSE CASE WHEN atob THEN reduce(cast(json_extract(event_json,'$.amounts_out_y') AS array(double)),double '0',(s,x)->s+x,s->s) ELSE reduce(cast(json_extract(event_json,'$.amounts_out_x') AS array(double)),double '0',(s,x)->s+x,s->s) END END amount_out_rawFROM extra_events), extra_trades AS (SELECT e.block_date,e.project,e.block_time,e.transaction_digest,e.event_index,e.sender,coalesce(nullif(e.amount_out_raw,0)*po.usd_per_raw,nullif(e.amount_in_raw,0)*pi.usd_per_raw) amount_usdFROM extra_amounts e LEFT JOIN pool_coins c ON c.pool_id=e.pool_idLEFT JOIN prices pi ON pi.day=e.block_date AND pi.coin=CASE WHEN e.atob THEN c.coin_a ELSE c.coin_b ENDLEFT JOIN prices po ON po.day=e.block_date AND po.coin=CASE WHEN e.atob THEN c.coin_b ELSE c.coin_a END