Query editor
-- created by @rdmcd with github.com/ohld/ton-analyst-- Per-pack detail. Graduation triggers when cumulative supply first hits the-- pack threshold; once graduated the curve rejects further trades, so held-- stays at peak. Peak is computed via tx_lt (chain-correct order) and-- exposed as `progress` = peak / threshold * 100 (% — comparable across-- packs even when thresholds differ).WITHrange_start AS (SELECT CASE '{{time_range}}'WHEN '7d' THEN now() - INTERVAL '7' DAYWHEN '30d' THEN now() - INTERVAL '30' DAYWHEN '90d' THEN now() - INTERVAL '90' DAYELSE TIMESTAMP '1970-01-01 00:00:00 UTC'END AS since),trades_usd AS (SELECT t.pack_master, t.side, t.qty, t.amount_ton, t.block_time, t.tx_hash, t.tx_lt,t.amount_ton * (p.price_usd * 1e9) AS amount_usdFROM dune.telegram.result_pad_trades tLEFT JOIN ton.prices_daily pON p.token_address = '0:0000000000000000000000000000000000000000000000000000000000000000'AND CAST(p.timestamp AS DATE) = CAST(t.block_time AS DATE)),running_supply AS (SELECTpack_master,tx_lt,SUM(CASE WHEN side = 'buy' THEN qty ELSE -qty END) OVER (PARTITION BY pack_masterORDER BY tx_ltROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cum_supplyFROM trades_usd),supply_summary AS (SELECTpack_master,MAX(cum_supply) AS peak_count,max_by(cum_supply, tx_lt) AS held_countFROM running_supplyGROUP BY pack_master),window_stats AS (SELECTt.pack_master,SUM(CASE WHEN side = 'buy' THEN qty ELSE 0 END) AS n_buys,SUM(CASE WHEN side = 'sell' THEN qty ELSE 0 END) AS n_sells,SUM(t.amount_ton) AS volume_ton,SUM(t.amount_usd) AS volume_usd,MAX(t.block_time) AS last_trade_timeFROM trades_usd t, range_start rWHERE t.block_time >= r.sinceGROUP BY 1)SELECTd.pack_master,d.pack_name,d.cover_url,GET_HREF('https://tonviewer.com/' || ton_address_raw_to_user_friendly(d.deployer, false),