Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(atomic): decode pump.fun on-chain events and replay a transaction step by step

nirholasf5c5f66b2635
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 606fdadd0..1b8bc90c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-10-14
- **A read-only drift report for every standalone GitHub mirror**: npm run mirrors:drift compares each of the ~105 standalone mirrors in data/standalone-mirrors.json against its monorepo source at the last synced commit (GitHub API, with a README-timestamp fallback when rate-limited), flags any package whose GitHub copy has diverged, and writes the result to tasks/mirror-drift-<date>.json. It never pushes or mutates a mirror; it is the audit step that found the two fixes above. (`/docs/contributing`) `[infra, docs]`
+- **Atomic now replays a pump.fun transaction step by step**: Atomic (/atomic) decodes every Pump, PumpSwap, and PumpFees event in a transaction's logs, oldest first, and renders it as a Replay panel: a bonding-curve-position bar, a human-readable description of each step (create, buy/sell, graduation, creator-fee collection and distribution, GitHub social-fee claims, and post-graduation PumpSwap swaps), and the SOL/token amounts that moved. An event the installed SDK does not recognize still renders, labeled unrecognized, instead of silently disappearing. For a create transaction, the panel also pages through the earliest trades on that mint since launch, walking Solana's signature history backward in bounded pages since RPC has no forward cursor. `[feature]`
- **Deep links to a specific avatar now actually load that avatar**: @three-ws/walk's ?walk=play&avatar=<id> deep link and the drop-in resume path read the saved avatar preference straight out of storage and never looked at the query string, so sharing a link to a specific avatar silently loaded the stored (or default) one instead. A new deepLinkAvatarId resolver gives the query param precedence and persists it, the same way picking an avatar in the UI does. `[fix, sdk]`
- **GitHub fee-claim channel now attributes withdrawals to a coin, or says plainly it cannot**: A GitHub identity withdrawing pump.fun fees through the claim_social_fee_pda instruction only proves payment to that identity, not which coin paid it: one GitHub fee account can be a shareholder on more than one coin, and its address can be pasted into a copycat coin's metadata. The claims feed and its Telegram channel now classify every such withdrawal with on-chain evidence: a same-transaction distribution to the exact account, or a 90%-dominant distribution history since the previous claim, then a repository-owner or creator-wallet match, down to an honest unresolved or unverified label when nothing proves a coin. A new-GitHub-account-plus-copycat-coin pattern holds the claim for review instead of posting it with a celebratory card. `[feature, security]`
- **GitHub fee-claim feed now reads from a real-time listener, not just an on-demand RPC scan**: The claims feed's GitHub-attribution path used to walk Solana RPC history fresh on every request, the same cost every time, with nothing persisted in between. services/pump-claims is a standalone process that subscribes to PumpFees program logs directly, decodes and attributes each claim as it happens, and writes it to a new pump_fee_claims table with a watchdog that resubscribes on a stalled connection and gap-fills whatever a drop missed. The claims route now reads that table first and only falls back to the RPC scan when the table has nothing for the requested window, so PUMPFUN_BOT_URL is no longer required for GitHub claims specifically (ordinary wallet claims still use it). `[feature, infra]`
diff --git a/api/_lib/pump-events.js b/api/_lib/pump-events.js
index da732864d..5df6b2d95 100644
--- a/api/_lib/pump-events.js
+++ b/api/_lib/pump-events.js
@@ -14,7 +14,8 @@
// normalising helpers below convert the ones this codebase consumes to plain
// strings so attribution math can use BigInt directly.
-import { parsePumpEventsFromLogs } from '@nirholas/pump-sdk';
+import { parsePumpEventsFromLogs, PumpIdl, PumpAmmIdl, PumpFeesIdl } from '@nirholas/pump-sdk';
+import { PUMP_PROGRAM_ID, PUMP_AMM_PROGRAM_ID, PUMP_FEE_PROGRAM_ID } from './solana/programs.js';
/** Every decodable event in a transaction's logs, oldest first. Never throws. */
export function parseEventsFromLogs(logs) {
@@ -89,3 +90,97 @@ export function parseSocialFeeClaim(logs) {
export function isSocialClaimLog(logs) {
return (logs || []).some((line) => line.includes('Program log: Instruction: ClaimSocialFeePda'));
}
+
+// --- Full-transaction replay (/atomic's "Replay" panel) ---------------------
+//
+// parsePumpEventsFromLogs only returns events it recognises; a line whose
+// discriminator it cannot match is silently skipped. A replay that walks a
+// transaction step by step must never drop a frame just because a program
+// upgrade added an event this install's @nirholas/pump-sdk predates, so
+// decodeTransactionEvents re-walks the same invoke-stack shape the SDK reads
+// and, for every "Program data:" line under a known Pump/PumpSwap/PumpFees
+// program invocation whose 8-byte discriminator the SDK's own IDLs don't
+// list, emits it as `{ type: 'unrecognized' }` carrying the raw bytes instead
+// of disappearing.
+
+function discriminatorHex(bytes) {
+ return Buffer.from(bytes).toString('hex');
+}
+
+const KNOWN_EVENT_DISCRIMINATORS = new Set(
+ [PumpIdl, PumpAmmIdl, PumpFeesIdl].flatMap((idl) => (idl.events || []).map((e) => discriminatorHex(e.discriminator))),
+);
+
+const EVENT_PROGRAM_IDS = new Set([PUMP_PROGRAM_ID, PUMP_AMM_PROGRAM_ID, PUMP_FEE_PROGRAM_ID]);
+
+const INVOKE_RE = /^Program ([1-9A-HJ-NP-Za-km-z]{32,44}) invoke \[\d+\]$/;
+const RETURN_RE = /^Program [1-9A-HJ-NP-Za-km-z]{32,44} (success|failed)/;
+
+/** Anchor decodes pubkeys as PublicKey and numerics as BN; flatten both to JSON-safe values. */
+function normalizeEventValue(value) {
+ if (value == null) return value;
+ if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string') return value;
+ if (typeof value.toBase58 === 'function') return value.toBase58();
+ if (typeof value.toNumber === 'function' && typeof value.toString === 'function') return value.toString();
+ if (Array.isArray(value)) return value.map(normalizeEventValue);
+ if (typeof value === 'object') {
+ const out = {};
+ for (const [key, v] of Object.entries(value)) out[key] = normalizeEventValue(v);
+ return out;
+ }
+ return value;
+}
+
+/**
+ * Every decodable Pump/PumpSwap/PumpFees event in a transaction's logs, oldest
+ * first, normalised to JSON-safe values. An event whose discriminator is not
+ * in the installed SDK's IDLs (a program upgrade this install predates)
+ * renders as `{ type: 'unrecognized', programId, discriminator, dataBase64 }`
+ * rather than being dropped. Never throws.
+ * @param {string[]} logs
+ * @returns {Array<{type:string, programId:string, data?:object, discriminator?:string, dataBase64?:string}>}
+ */
+export function decodeTransactionEvents(logs) {
+ if (!Array.isArray(logs) || logs.length === 0) return [];
+ const out = [];
+ const stack = [];
+ for (const line of logs) {
+ const invoke = line.match(INVOKE_RE);
+ if (invoke) {
+ stack.push(invoke[1]);
+ continue;
+ }
+ if (RETURN_RE.test(line)) {
+ stack.pop();
+ continue;
+ }
+ if (!line.startsWith('Program data: ')) continue;
+ const programId = stack[stack.length - 1];
+ if (!EVENT_PROGRAM_IDS.has(programId)) continue;
+
+ let data;
+ try {
+ data = Buffer.from(line.slice('Program data: '.length), 'base64');
+ } catch {
+ continue;
+ }
+ if (data.length < 8) continue;
+ const discriminator = discriminatorHex(data.subarray(0, 8));
+
+ if (!KNOWN_EVENT_DISCRIMINATORS.has(discriminator)) {
+ out.push({ type: 'unrecognized', programId, discriminator, dataBase64: data.toString('base64') });
+ continue;
+ }
+ const [decoded] = parsePumpEventsFromLogs([
+ `Program ${programId} invoke [1]`,
+ line,
+ `Program ${programId} success`,
+ ]);
+ out.push(
+ decoded
+ ? { type: decoded.type, programId, data: normalizeEventValue(decoded.data) }
+ : { type: 'unrecognized', programId, discriminator, dataBase64: data.toString('base64') },
+ );
+ }
+ return out;
+}
diff --git a/api/solana/atomic.js b/api/solana/atomic.js
index f4becf7b2..a2d7fea8b 100644
--- a/api/solana/atomic.js
+++ b/api/solana/atomic.js
@@ -1,8 +1,16 @@
// Solana Transaction V1 observatory and pre-sign inspector.
//
-// GET /api/solana/atomic -> live feature-gate status
-// GET /api/solana/atomic?signature=<sig> -> fetch and inspect a confirmed tx
-// POST /api/solana/atomic { transaction } -> inspect base64 wire bytes offline
+// GET /api/solana/atomic -> live feature-gate status
+// GET /api/solana/atomic?signature=<sig> -> fetch and inspect a confirmed tx
+// POST /api/solana/atomic { transaction } -> inspect base64 wire bytes offline
+// POST /api/solana/atomic { signature, ... } -> same as the GET signature path
+//
+// A pump.fun transaction's inspection also carries `events`: every decoded
+// Pump/PumpSwap/PumpFees event in that transaction, oldest first (see
+// decodeTransactionEvents). A `create` transaction additionally carries
+// `replay`: the earliest trades on that mint since launch, paged backward
+// with `before` because getSignaturesForAddress has no forward cursor (see
+// firstTradesAfterCreate).
import bs58 from 'bs58';
import { PublicKey } from '@solana/web3.js';
@@ -14,6 +22,87 @@ import {
decodeFeatureActivationSlot,
inspectWireTransaction,
} from '../_lib/solana/transaction-v1.js';
+import { decodeTransactionEvents } from '../_lib/pump-events.js';
+import { bondingProgressPct } from '../_lib/pump-bonding.js';
+
+// Bounded cost for the replay feature: each page is one getSignaturesForAddress
+// call (cheap), each trade found is one more getTransaction call (not cheap),
+// so both the backward walk and the trade count stay capped regardless of what
+// a caller asks for.
+const REPLAY_PAGE_LIMIT = 1_000;
+const REPLAY_PAGE_BUDGET = 5;
+const REPLAY_TRADE_LIMIT_DEFAULT = 12;
+const REPLAY_TRADE_LIMIT_MAX = 25;
+
+function tradeStep(event, signature, blockTime) {
+ const d = event.data;
+ return {
+ signature,
+ blockTime: blockTime ?? null,
+ side: d.isBuy ? 'buy' : 'sell',
+ user: d.user,
+ solAmountRaw: d.solAmount,
+ tokenAmountRaw: d.tokenAmount,
+ virtualSolReserves: d.virtualSolReserves,
+ virtualTokenReserves: d.virtualTokenReserves,
+ realSolReserves: d.realSolReserves,
+ realTokenReserves: d.realTokenReserves,
+ curveProgressPct: bondingProgressPct(d.realTokenReserves),
+ };
+}
+
+/**
+ * The earliest trades on `mint` since `createSignature`, walking
+ * getSignaturesForAddress backward from `before` (or from now) because Solana
+ * has no forward-from-a-point cursor. Bounded by REPLAY_PAGE_BUDGET pages; a
+ * caller that gets `hasMore: true` back pages deeper with `nextBefore`.
+ * @param {import('@solana/web3.js').Connection} connection
+ * @param {string} mint
+ * @param {string} createSignature
+ * @param {{limit?: number, before?: string}} [opts]
+ */
+async function firstTradesAfterCreate(connection, mint, createSignature, opts = {}) {
+ const limit = Math.min(Math.max(1, Number(opts.limit) || REPLAY_TRADE_LIMIT_DEFAULT), REPLAY_TRADE_LIMIT_MAX);
+ const mintKey = new PublicKey(mint);
+ let cursor = opts.before || undefined;
+ const collected = [];
+ let reachedCreate = false;
+
+ for (let page = 0; page < REPLAY_PAGE_BUDGET; page++) {
+ const sigs = await connection.getSignaturesForAddress(mintKey, { limit: REPLAY_PAGE_LIMIT, before: cursor });
+ if (!sigs.length) break;
+ const createIdx = sigs.findIndex((s) => s.signature === createSignature);
+ if (createIdx !== -1) {
+ collected.push(...sigs.slice(0, createIdx));
+ reachedCreate = true;
+ break;
+ }
+ collected.push(...sigs);
+ cursor = sigs[sigs.length - 1].signature;
+ }
+
+ // getSignaturesForAddress answers newest first; the earliest trades sit at
+ // the tail of what we collected walking backward.
+ const chronological = collected.filter((s) => !s.err).reverse();
+ const earliest = chronological.slice(0, limit);
+
+ const trades = [];
+ for (const s of earliest) {
+ const rpc = await connection._rpcRequest('getTransaction', [
+ s.signature,
+ { encoding: 'json', commitment: 'confirmed', maxSupportedTransactionVersion: 1 },
+ ]);
+ const logs = rpc?.result?.meta?.logMessages;
+ if (!logs) continue;
+ for (const event of decodeTransactionEvents(logs)) {
+ if (event.type === 'trade' && event.data.mint === mint) {
+ trades.push(tradeStep(event, s.signature, rpc.result.blockTime ?? s.blockTime ?? null));
+ }
+ }
+ }
+
+ return { trades, reachedCreate, nextBefore: reachedCreate ? null : cursor || null };
+}
function isSignature(value) {
if (!/^[1-9A-HJ-NP-Za-km-z]{64,96}$/.test(value)) return false;
@@ -42,7 +131,7 @@ async function liveStatus(connection) {
};
}
-async function inspectSignature(connection, signature) {
+async function inspectSignature(connection, signature, opts = {}) {
const rpc = await connection._rpcRequest('getTransaction', [
signature,
{ encoding: 'base64', commitment: 'confirmed', maxSupportedTransactionVersion: 1 },
@@ -56,10 +145,33 @@ async function inspectSignature(connection, signature) {
}
const inspection = inspectWireTransaction(encoded);
const consumed = rpc.result.meta?.computeUnitsConsumed ?? null;
+ const events = decodeTransactionEvents(rpc.result.meta?.logMessages || []).map((e) => {
+ if (e.type === 'create' || e.type === 'trade') return { ...e, curveProgressPct: bondingProgressPct(e.data.realTokenReserves) };
+ if (e.type === 'complete') return { ...e, curveProgressPct: 100 };
+ return e;
+ });
+
+ let replay = null;
+ const createEvent = events.find((e) => e.type === 'create');
+ if (createEvent) {
+ const mint = createEvent.data.mint;
+ try {
+ const { trades, reachedCreate, nextBefore } = await firstTradesAfterCreate(connection, mint, signature, {
+ limit: opts.tradeLimit,
+ before: opts.before,
+ });
+ replay = { mint, creator: createEvent.data.creator, trades, hasMore: !reachedCreate, nextBefore, error: null };
+ } catch (err) {
+ replay = { mint, creator: createEvent.data.creator, trades: [], hasMore: true, nextBefore: null, error: err.message };
+ }
+ }
+
return {
...inspection,
signature,
cluster: 'mainnet-beta',
+ events,
+ replay,
confirmation: {
slot: rpc.result.slot,
blockTime: rpc.result.blockTime ?? null,
@@ -88,10 +200,25 @@ export default wrap(async function atomicHandler(req, res) {
return error(res, 429, 'rate_limited', 'too many requests - retry shortly');
}
+ const connection = solanaConnection({ network: 'mainnet' });
+
if (req.method === 'POST') {
let body;
try {
body = await readJson(req, 16_384);
+ } catch (err) {
+ return error(res, err.status || 400, 'invalid_json', err.message);
+ }
+
+ const signature = typeof body.signature === 'string' ? body.signature.trim() : '';
+ if (signature) {
+ if (!isSignature(signature)) {
+ return error(res, 400, 'invalid_signature', 'signature must be a base58 Solana transaction signature');
+ }
+ return respondWithSignature(res, connection, signature, { before: body.before, tradeLimit: body.tradeLimit });
+ }
+
+ try {
const inspection = inspectWireTransaction(body.transaction);
res.setHeader('cache-control', 'no-store');
return json(res, 200, { inspection });
@@ -102,7 +229,6 @@ export default wrap(async function atomicHandler(req, res) {
const url = new URL(req.url, 'http://atomic.local');
const signature = (url.searchParams.get('signature') || '').trim();
- const connection = solanaConnection({ network: 'mainnet' });
if (!signature) {
try {
@@ -119,13 +245,20 @@ export default wrap(async function atomicHandler(req, res) {
return error(res, 400, 'invalid_signature', 'signature must be a base58 Solana transaction signature');
}
+ return respondWithSignature(res, connection, signature, {
+ before: url.searchParams.get('before') || undefined,
+ tradeLimit: url.searchParams.get('tradeLimit') || undefined,
+ });
+});
+
+async function respondWithSignature(res, connection, signature, opts) {
try {
- const inspection = await inspectSignature(connection, signature);
+ const inspection = await inspectSignature(connection, signature, opts);
if (!inspection) return error(res, 404, 'not_found', 'transaction was not found on Solana mainnet');
- res.setHeader('cache-control', 'public, s-maxage=3600, stale-while-revalidate=86400');
+ res.setHeader('cache-control', opts.before ? 'no-store' : 'public, s-maxage=3600, stale-while-revalidate=86400');
return json(res, 200, { inspection });
} catch (err) {
console.error('[solana/atomic] transaction lookup failed:', err?.message);
return error(res, err.upstream ? 502 : 400, err.upstream ? 'upstream_error' : 'invalid_transaction', err.message);
}
-});
+}
diff --git a/data/changelog.json b/data/changelog.json
index b8c797074..0b812b8b9 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,14 @@
{
"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security, desktop (desktop entries become the desktop app's release notes). `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-10-14",
+ "title": "Atomic now replays a pump.fun transaction step by step",
+ "summary": "Atomic (/atomic) decodes every Pump, PumpSwap, and PumpFees event in a transaction's logs, oldest first, and renders it as a Replay panel: a bonding-curve-position bar, a human-readable description of each step (create, buy/sell, graduation, creator-fee collection and distribution, GitHub social-fee claims, and post-graduation PumpSwap swaps), and the SOL/token amounts that moved. An event the installed SDK does not recognize still renders, labeled unrecognized, instead of silently disappearing. For a create transaction, the panel also pages through the earliest trades on that mint since launch, walking Solana's signature history backward in bounded pages since RPC has no forward cursor.",
+ "tags": [
+ "feature"
+ ]
+ },
{
"date": "2026-10-14",
"title": "GitHub fee-claim feed now reads from a real-time listener, not just an on-demand RPC scan",
diff --git a/docs/atomic.md b/docs/atomic.md
index a8eaefbf3..2da3c8011 100644
--- a/docs/atomic.md
+++ b/docs/atomic.md
@@ -47,6 +47,35 @@ curl https://three.ws/api/solana/atomic \
The response is JSON-safe. Priority fees and other wide integers are returned as numbers when they fit safely, otherwise as decimal strings.
+## Replay: pump.fun lifecycle events
+
+When a confirmed transaction invoked Pump, PumpSwap, or PumpFees, Atomic decodes every typed event in its logs, oldest first, and the page renders them as a step-by-step **Replay**: a curve-position bar, a human-readable description of each step, and the SOL/token amounts that moved.
+
+The decoder covers a coin's full lifecycle:
+
+- `create`: a new bonding curve launches.
+- `trade`: a buy or sell against the bonding curve, with the post-trade curve-fill percentage.
+- `complete`: the curve graduates; liquidity migrates to PumpSwap.
+- `ammBuy` / `ammSell`: a swap against the graduated PumpSwap pool.
+- `collectCreatorFee` / `distributeCreatorFees`: creator-fee collection and its split across shareholders.
+- `socialFeePdaClaimed`: a GitHub social-fee PDA claim.
+
+An event whose 8-byte discriminator is not in the installed `@nirholas/pump-sdk`'s IDLs (a program upgrade this install predates) still renders, as `unrecognized`, with its raw program ID and bytes. The replay never silently drops a step.
+
+For a `create` transaction, the response also carries `replay`: the earliest trades on that mint since launch. Solana's `getSignaturesForAddress` has no forward cursor, only a `before` cursor walking backward from "now," so the server walks backward in capped pages (5 pages of 1,000 signatures) looking for the create signature, then returns the trades between it and the oldest page reached. A caller that gets `hasMore: true` back pages deeper with the returned `nextBefore`; the page's "Load earlier trades" button does this automatically.
+
+Try it against a real $THREE trade:
+
+```bash
+curl https://three.ws/api/solana/atomic \
+ -H 'content-type: application/json' \
+ -d '{"signature":"3mmfm7wj9CtC5QutckLKvYQZDhQcaVBrbYD8sZFwKHW7efN9E3ETz9yMeMNfYw8coodpNfYzpM6wfzr5RUf1CYo"}'
+```
+
+$THREE graduated its bonding curve some time ago, so this particular signature decodes as PumpSwap AMM events (`ammInitUserVolumeAccumulator`, `ammBuy`, `ammCloseUserVolumeAccumulator`) rather than bonding-curve `trade` events; both shapes render in the same Replay panel. AMM buy/sell events carry a `pool` address but no `mint` field in the installed IDL, so the panel's "View launch" link only appears when the transaction includes a bonding-curve event (`create`, `trade`, or `complete`), which does carry one.
+
+A transaction with no pump.fun events (most Solana transactions) shows a plain "no pump.fun events in this transaction" state instead of an empty panel.
+
## API
### Mainnet activation status
@@ -63,7 +92,7 @@ This reads the `txv1` feature account and the current confirmed slot through the
curl 'https://three.ws/api/solana/atomic?signature=SOLANA_SIGNATURE'
```
-The RPC request always passes `maxSupportedTransactionVersion: 1`. Confirmed results are cached because their wire bytes and metadata are immutable.
+The RPC request always passes `maxSupportedTransactionVersion: 1`. Confirmed results are cached because their wire bytes and metadata are immutable. The response also carries `events` (every decoded pump.fun event in the transaction, see Replay above) and, for a create transaction, `replay`. `before` and `tradeLimit` query params page a create transaction's `replay.trades` deeper; a response that passed `before` is never cached.
### Raw transaction
diff --git a/pages/atomic.html b/pages/atomic.html
index fa243c7d8..e71bc6b8c 100644
--- a/pages/atomic.html
+++ b/pages/atomic.html
@@ -108,6 +108,27 @@
<div class="at-actions"><a id="at-explorer" target="_blank" rel="noopener noreferrer" hidden data-i18n="atomic.explorer_link">Open in Solscan</a><button type="button" id="at-share" data-i18n="atomic.share_btn">Copy inspection link</button></div>
</section>
</div>
+
+ <section class="at-replay" id="at-replay" aria-labelledby="at-replay-title">
+ <div class="at-section-head">
+ <div><p class="at-label" data-i18n="atomic.replay_label">Pump.fun lifecycle</p><h3 id="at-replay-title" data-i18n="atomic.replay_title">Replay</h3></div>
+ <a id="at-replay-mint-link" class="at-replay-mint-link" target="_blank" rel="noopener noreferrer" hidden data-i18n="atomic.replay_view_launch">View launch &rarr;</a>
+ </div>
+ <p class="at-replay-empty" id="at-replay-empty" hidden data-i18n="atomic.replay_empty">No pump.fun events in this transaction. Atomic decodes create, trade, graduation, fee-collection, fee-distribution, and GitHub social-fee-claim events from Pump, PumpSwap, and PumpFees. This transaction did not invoke any of them.</p>
+ <div class="at-replay-curve" id="at-replay-curve" hidden>
+ <div class="at-ruler"><div id="at-replay-curve-fill"></div></div>
+ <p class="at-ruler-note" id="at-replay-curve-note"></p>
+ </div>
+ <ol class="at-replay-steps" id="at-replay-steps"></ol>
+ <div class="at-replay-skeleton" id="at-replay-skeleton" hidden aria-hidden="true"><div></div><div></div><div></div></div>
+ <div class="at-replay-error" id="at-replay-error" hidden>
+ <p id="at-replay-error-message"></p>
+ <button type="button" id="at-replay-retry" data-i18n="atomic.replay_retry">Retry replay</button>
+ </div>
+ <div class="at-replay-loadmore" id="at-replay-loadmore-wrap" hidden>
+ <button type="button" id="at-replay-loadmore" data-i18n="atomic.replay_loadmore">Load earlier trades</button>
+ </div>
+ </section>
</section>
<section class="at-empty" id="at-empty">
diff --git a/public/changelog-recent.json b/public/changelog-recent.json
index e53c154da..3e0e2dd57 100644
--- a/public/changelog-recent.json
+++ b/public/changelog-recent.json
@@ -1,11 +1,11 @@
{
- "generated_at": "2026-10-14T04:20:35.625Z",
+ "generated_at": "2026-10-14T04:58:24.891Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
"url": "https://three.ws"
},
- "total": 4085,
+ "total": 4086,
"complete": false,
"full_feed": "/changelog.json",
"entries": [
@@ -20,6 +20,16 @@
"docs"
]
},
+ {
+ "date": "2026-10-14",
+ "type": "update",
+ "title": "Atomic now replays a pump.fun transaction step by step",
+ "summary": "Atomic (/atomic) decodes every Pump, PumpSwap, and PumpFees event in a transaction's logs, oldest first, and renders it as a Replay panel: a bonding-curve-position bar, a human-readable description of each step (create, buy/sell, graduation, creator-fee collection and distribution, GitHub social-fee claims, and post-graduation PumpSwap swaps), and the SOL/token amounts that moved. An event the installed SDK does not recognize still renders, labeled unrecognized, instead of silently disappearing. For a create transaction, the panel also pages through the earliest trades on that mint since launch, walking Solana's signature history backward in bounded pages since RPC has no forward cursor.",
+ "link": null,
+ "tags": [
+ "feature"
+ ]
+ },
{
"date": "2026-10-14",
"type": "update",
@@ -1547,17 +1557,6 @@
"tags": [
"improvement"
]
- },
- {
- "date": "2026-10-10",
- "type": "update",
- "title": "Coin logos, agent art and IPFS images load again",
- "summary": "Several public IPFS gateways started refusing image and metadata requests from websites this month, which left coin logos, the 3D coin face, agent cards and on-chain agent art blank or broken across the site. Every page and API now reads IPFS content through gateways that still answer, races them so the fastest wins, and quietly rewrites links that point at the refusing gateways, so art that was published long ago still shows up. Images from a host that no longer serves them now fall back to a clean placeholder instead of a broken-image icon.",
- "link": "/launches",
- "tags": [
- "fix",
- "improvement"
- ]
}
]
}
diff --git a/public/changelog.json b/public/changelog.json
index ec7203039..5e342b318 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-10-14T04:20:35.603Z",
+ "generated_at": "2026-10-14T04:58:24.870Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -17,6 +17,16 @@
"docs"
]
},
+ {
+ "date": "2026-10-14",
+ "type": "update",
+ "title": "Atomic now replays a pump.fun transaction step by step",
+ "summary": "Atomic (/atomic) decodes every Pump, PumpSwap, and PumpFees event in a transaction's logs, oldest first, and renders it as a Replay panel: a bonding-curve-position bar, a human-readable description of each step (create, buy/sell, graduation, creator-fee collection and distribution, GitHub social-fee claims, and post-graduation PumpSwap swaps), and the SOL/token amounts that moved. An event the installed SDK does not recognize still renders, labeled unrecognized, instead of silently disappearing. For a create transaction, the panel also pages through the earliest trades on that mint since launch, walking Solana's signature history backward in bounded pages since RPC has no forward cursor.",
+ "link": null,
+ "tags": [
+ "feature"
+ ]
+ },
{
"date": "2026-10-14",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 8a57a3c6a..df1ae22a6 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -14,6 +14,14 @@
<category>infra</category>
<description>npm run mirrors:drift compares each of the ~105 standalone mirrors in data/standalone-mirrors.json against its monorepo source at the last synced commit (GitHub API, with a README-timestamp fallback when rate-limited), flags any package whose GitHub copy has diverged, and writes the result to tasks/mirror-drift-&lt;date&gt;.json. It never pushes or mutates a mirror; it is the audit step that found the two fixes above.</description>
</item>
+ <item>
+ <title>Atomic now replays a pump.fun transaction step by step</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-10-14:Atomic now replays a pump.fun transaction step by step</guid>
+ <pubDate>Wed, 14 Oct 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>Atomic (/atomic) decodes every Pump, PumpSwap, and PumpFees event in a transaction's logs, oldest first, and renders it as a Replay panel: a bonding-curve-position bar, a human-readable description of each step (create, buy/sell, graduation, creator-fee collection and distribution, GitHub social-fee claims, and post-graduation PumpSwap swaps), and the SOL/token amounts that moved. An event the installed SDK does not recognize still renders, labeled unrecognized, instead of silently disappearing. For a create transaction, the panel also pages through the earliest trades on that mint since launch, walking Solana's signature history backward in bounded pages since RPC has no forward cursor.</description>
+ </item>
<item>
<title>Deep links to a specific avatar now actually load that avatar</title>
<link>https://three.ws/changelog</link>
diff --git a/public/features.json b/public/features.json
index d401333c2..5b4bd3c27 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-10-14T04:20:35.590Z",
+ "generated_at": "2026-10-14T04:58:24.857Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/atomic.css b/src/atomic.css
index e1ec2c293..de46ef1a3 100644
--- a/src/atomic.css
+++ b/src/atomic.css
@@ -50,9 +50,37 @@ body { margin: 0; background: var(--at-bg); color: var(--at-text); }
.at-notes { display: grid; gap: .8rem; margin: 1.2rem 0; padding: 0; list-style: none; }.at-notes li { position: relative; padding-left: 1.2rem; color: var(--at-muted); line-height: 1.5; }.at-notes li::before { content: ''; position: absolute; top: .55rem; left: 0; width: .42rem; height: .42rem; border-radius: 50%; background: var(--at-green); }
.at-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1.4rem; }.at-actions a, .at-actions button { display: inline-grid; place-items: center; min-height: 42px; padding: .55rem .75rem; color: var(--at-green); background: transparent; font-size: .78rem; }.at-actions a:hover, .at-actions button:hover { color: var(--at-mint); border-color: var(--at-mint); background: rgba(101,245,170,.1); }
.at-empty { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; padding-top: 1rem; }.at-empty article { min-height: 190px; padding: 1.4rem; border-top: 1px solid var(--at-line); background: linear-gradient(180deg, rgba(101,245,170,.035), transparent); }.at-empty span { color: var(--at-green); font: .7rem monospace; }.at-empty h2 { margin: 2.5rem 0 .5rem; font-size: 1.15rem; }.at-empty p { margin: 0; color: var(--at-muted); line-height: 1.55; font-size: .86rem; }.at-empty code { color: var(--at-mint); }
+.at-replay { padding: clamp(1.2rem, 3vw, 1.8rem); border: 1px solid var(--at-line); border-radius: 22px; background: var(--at-panel); backdrop-filter: blur(16px); display: grid; gap: 1rem; }
+.at-replay-mint-link { color: var(--at-green); font: 700 .78rem monospace; text-decoration: none; }
+.at-replay-mint-link:hover { color: var(--at-mint); text-decoration: underline; }
+.at-replay-mint-link:focus-visible { outline: 2px solid var(--at-green); outline-offset: 2px; }
+.at-replay-empty { margin: 0; padding: 1.4rem; border: 1px dashed var(--at-line); border-radius: 14px; color: var(--at-muted); line-height: 1.6; font-size: .88rem; }
+.at-replay-curve .at-ruler { margin: .4rem 0 .6rem; }
+.at-replay-steps { display: grid; gap: .7rem; margin: 0; padding: 0; list-style: none; }
+.at-replay-step { padding: 1rem 1.1rem; border: 1px solid var(--at-line); border-radius: 14px; background: rgba(0,0,0,.18); }
+.at-replay-step-head { display: flex; align-items: center; gap: .6rem; }
+.at-replay-step-index { color: var(--at-muted); font: 700 .72rem monospace; }
+.at-replay-step-head strong { flex: 1; font-size: .95rem; }
+.at-replay-step-pct { color: var(--at-green); font: 700 .72rem monospace; }
+.at-replay-step-detail { margin: .5rem 0 0; color: var(--at-muted); font-size: .84rem; }
+.at-replay-step-delta { margin: .3rem 0 0; color: var(--at-mint); font: 500 .82rem monospace; }
+.at-replay-step-link { display: inline-block; margin-top: .5rem; color: var(--at-green); font-size: .76rem; text-decoration: none; }
+.at-replay-step-link:hover { color: var(--at-mint); text-decoration: underline; }
+.at-replay-step-link:focus-visible { outline: 2px solid var(--at-green); outline-offset: 2px; }
+.at-replay-step.is-unrecognized { border-color: rgba(255,198,109,.4); }
+.at-replay-step.is-amm-minor { opacity: .7; }
+.at-replay-error { padding: 1rem 1.1rem; border: 1px solid rgba(255,198,109,.4); border-radius: 14px; color: var(--at-text); }
+.at-replay-loadmore button, .at-replay-error button { min-height: 42px; margin-top: .6rem; padding: .6rem .9rem; border: 1px solid var(--at-green); border-radius: 11px; color: var(--at-green); background: transparent; font-weight: 700; cursor: pointer; }
+.at-replay-loadmore button:hover, .at-replay-error button:hover { color: var(--at-mint); border-color: var(--at-mint); background: rgba(101,245,170,.08); }
+.at-replay-loadmore button:active, .at-replay-error button:active { transform: translateY(1px); }
+.at-replay-loadmore button:focus-visible, .at-replay-error button:focus-visible { outline: 2px solid var(--at-green); outline-offset: 2px; }
+.at-replay-loadmore button:disabled { opacity: .5; cursor: wait; }
+.at-replay-skeleton { display: grid; gap: .6rem; }
+.at-replay-skeleton div { height: 54px; border-radius: 14px; background: linear-gradient(90deg, rgba(101,245,170,.05), rgba(101,245,170,.14), rgba(101,245,170,.05)); background-size: 200% 100%; animation: at-shimmer 1.4s ease-in-out infinite; }
@keyframes at-spin { to { transform: rotate(1turn); } }
-@media (max-width: 760px) { .at-shell { padding-top: 6rem; }.at-hero-stats, .at-empty, .at-report-grid { grid-template-columns: 1fr; }.at-hero-stats div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--at-line); }.at-panel-head { align-items: flex-start; flex-direction: column; }.at-tabs { width: 100%; }.at-tabs button { flex: 1; }.at-input-row { grid-template-columns: 1fr; }.at-metrics { grid-template-columns: repeat(2, 1fr); }.at-verdict { align-items: flex-start; flex-direction: column; }.at-ruler i span { left: .2rem; transform: none; }.at-live { flex-wrap: wrap; } }
-@media (prefers-reduced-motion: reduce) { .at-spinner { animation: none; }.at-ruler > div { transition: none; } }
+@keyframes at-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
+@media (max-width: 760px) { .at-shell { padding-top: 6rem; }.at-hero-stats, .at-empty, .at-report-grid { grid-template-columns: 1fr; }.at-hero-stats div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--at-line); }.at-panel-head { align-items: flex-start; flex-direction: column; }.at-tabs { width: 100%; }.at-tabs button { flex: 1; }.at-input-row { grid-template-columns: 1fr; }.at-metrics { grid-template-columns: repeat(2, 1fr); }.at-verdict { align-items: flex-start; flex-direction: column; }.at-ruler i span { left: .2rem; transform: none; }.at-live { flex-wrap: wrap; }.at-section-head { align-items: flex-start; flex-direction: column; } }
+@media (prefers-reduced-motion: reduce) { .at-spinner { animation: none; }.at-ruler > div { transition: none; }.at-replay-skeleton div { animation: none; } }
[data-theme="light"] body { --at-bg: #f2f7f4; --at-panel: rgba(255,255,255,.86); --at-line: rgba(14,61,39,.15); --at-green: #087d45; --at-mint: #135d3b; --at-amber: #9b5a00; --at-text: #071a11; --at-muted: #546d60; }
[data-theme="light"] .at-shell { background: radial-gradient(circle at 76% 5%, rgba(55,190,120,.13), transparent 31rem), var(--at-bg); }
[data-theme="light"] .at-metrics div { background: #f7fbf8; }
diff --git a/src/atomic.js b/src/atomic.js
index a5fadcb6f..51ecebafe 100644
--- a/src/atomic.js
+++ b/src/atomic.js
@@ -1,10 +1,191 @@
const $ = (id) => document.getElementById(id);
-const state = { mode: 'signature', lastInspection: null };
+const state = { mode: 'signature', lastInspection: null, replayNextBefore: null };
function formatNumber(value) {
return value == null ? 'Not set' : Number(value).toLocaleString('en-US');
}
+function shortKey(key) {
+ return key ? `${key.slice(0, 4)}..${key.slice(-4)}` : 'unknown';
+}
+
+function solFromRaw(raw) {
+ if (raw == null) return null;
+ return Number(BigInt(raw)) / 1e9;
+}
+
+function tokensFromRaw(raw) {
+ if (raw == null) return null;
+ return Number(BigInt(raw)) / 1e6;
+}
+
+function fmtSol(raw) {
+ const n = solFromRaw(raw);
+ return n == null ? 'not set' : `${n.toLocaleString('en-US', { maximumFractionDigits: 4 })} SOL`;
+}
+
+function fmtTokens(raw) {
+ const n = tokensFromRaw(raw);
+ return n == null ? 'not set' : `${n.toLocaleString('en-US', { maximumFractionDigits: 2 })} tokens`;
+}
+
+/** A typed pump event (or a flattened replay trade) reduced to what the Replay panel renders. */
+function describeStep(event) {
+ const d = event.data || {};
+ switch (event.type) {
+ case 'create':
+ return {
+ kind: 'create',
+ title: 'Launch created',
+ pct: event.curveProgressPct ?? 0,
+ detail: `${d.name} (${d.symbol}) - creator ${shortKey(d.creator)}`,
+ delta: `${fmtTokens(d.tokenTotalSupply)} total supply`,
+ };
+ case 'trade':
+ return {
+ kind: 'trade',
+ title: d.isBuy ? 'Buy' : 'Sell',
+ pct: event.curveProgressPct,
+ detail: `${shortKey(d.user)} ${d.isBuy ? 'bought' : 'sold'} on the bonding curve`,
+ delta: `${fmtSol(d.solAmount)} ${d.isBuy ? 'in' : 'out'} · ${fmtTokens(d.tokenAmount)} ${d.isBuy ? 'out' : 'in'}`,
+ };
+ case 'complete':
+ return {
+ kind: 'complete',
+ title: 'Graduated',
+ pct: 100,
+ detail: `Bonding curve completed for ${shortKey(d.mint)}`,
+ delta: 'Liquidity migrated to PumpSwap',
+ };
+ case 'collectCreatorFee':
+ return { kind: 'fee', title: 'Creator fee collected', pct: null, detail: `Creator ${shortKey(d.creator)}`, delta: fmtSol(d.creatorFee) };
+ case 'distributeCreatorFees':
+ return {
+ kind: 'fee',
+ title: 'Creator fees distributed',
+ pct: null,
+ detail: `${(d.shareholders || []).length} shareholder(s)`,
+ delta: fmtSol(d.distributed),
+ };
+ case 'socialFeePdaClaimed':
+ return { kind: 'fee', title: 'GitHub social fee claimed', pct: null, detail: `GitHub user ${d.userId}`, delta: fmtSol(d.amountClaimed) };
+ case 'ammBuy':
+ case 'ammSell':
+ return {
+ kind: 'amm',
+ title: event.type === 'ammBuy' ? 'Buy (PumpSwap)' : 'Sell (PumpSwap)',
+ pct: 100,
+ detail: `${shortKey(d.user)} traded on the graduated pool`,
+ delta: `${fmtSol(d.quoteAmountIn ?? d.quoteAmountOut)} SOL side · ${fmtTokens(d.baseAmountOut ?? d.baseAmountIn)} token side`,
+ };
+ case 'ammInitUserVolumeAccumulator':
+ case 'ammCloseUserVolumeAccumulator':
+ return { kind: 'amm-minor', title: 'Volume accumulator', pct: null, detail: shortKey(d.user), delta: null };
+ case 'unrecognized':
+ return {
+ kind: 'unrecognized',
+ title: 'Unrecognized event',
+ pct: null,
+ detail: `Program ${shortKey(event.programId)} · discriminator ${event.discriminator}`,
+ delta: null,
+ };
+ default:
+ return { kind: 'other', title: event.type, pct: event.curveProgressPct ?? null, detail: 'Decoded event', delta: null };
+ }
+}
+
+/** A trade from inspection.replay.trades: flat shape, not a {type,data} event. */
+function describeReplayTrade(t) {
+ return {
+ kind: 'trade',
+ title: t.side === 'buy' ? 'Buy' : 'Sell',
+ pct: t.curveProgressPct,
+ detail: `${shortKey(t.user)} ${t.side === 'buy' ? 'bought' : 'sold'} on the bonding curve`,
+ delta: `${fmtSol(t.solAmountRaw)} ${t.side === 'buy' ? 'in' : 'out'} · ${fmtTokens(t.tokenAmountRaw)} ${t.side === 'buy' ? 'out' : 'in'}`,
+ sig: t.signature,
+ };
+}
+
+function stepToElement(d, i) {
+ const li = document.createElement('li');
+ li.className = `at-replay-step is-${d.kind}`;
+ const head = document.createElement('div');
+ head.className = 'at-replay-step-head';
+ const idx = document.createElement('span');
+ idx.className = 'at-replay-step-index';
+ idx.textContent = String(i + 1).padStart(2, '0');
+ const title = document.createElement('strong');
+ title.textContent = d.title;
+ head.append(idx, title);
+ if (d.pct != null) {
+ const pct = document.createElement('span');
+ pct.className = 'at-replay-step-pct';
+ pct.textContent = `${d.pct}%`;
+ head.append(pct);
+ }
+ li.append(head);
+ if (d.detail) {
+ const p = document.createElement('p');
+ p.className = 'at-replay-step-detail';
+ p.textContent = d.detail;
+ li.append(p);
+ }
+ if (d.delta) {
+ const p = document.createElement('p');
+ p.className = 'at-replay-step-delta';
+ p.textContent = d.delta;
+ li.append(p);
+ }
+ if (d.sig) {
+ const a = document.createElement('a');
+ a.href = `https://solscan.io/tx/${d.sig}`;
+ a.target = '_blank';
+ a.rel = 'noopener noreferrer';
+ a.className = 'at-replay-step-link';
+ a.textContent = 'View trade';
+ li.append(a);
+ }
+ return li;
+}
+
+function renderReplay(inspection) {
+ const events = inspection.events || [];
+ const replay = inspection.replay;
+ const empty = $('at-replay-empty');
+ const curveWrap = $('at-replay-curve');
+ const steps = $('at-replay-steps');
+ const errorBox = $('at-replay-error');
+ const loadmoreWrap = $('at-replay-loadmore-wrap');
+ const mintLink = $('at-replay-mint-link');
+
+ const hasReplayTrades = Boolean(replay && replay.trades && replay.trades.length);
+ empty.hidden = events.length > 0 || hasReplayTrades;
+
+ const descriptors = events.map(describeStep);
+ if (replay) descriptors.push(...replay.trades.map(describeReplayTrade));
+ steps.replaceChildren(...descriptors.map(stepToElement));
+
+ const pcts = descriptors.map((d) => d.pct).filter((p) => p != null);
+ if (pcts.length) {
+ const last = pcts[pcts.length - 1];
+ curveWrap.hidden = false;
+ $('at-replay-curve-fill').style.width = `${Math.min(100, last)}%`;
+ $('at-replay-curve-note').textContent = last >= 100 ? 'Graduated to PumpSwap.' : `${last}% of the bonding curve filled.`;
+ } else {
+ curveWrap.hidden = true;
+ }
+
+ const mintish = replay ? replay.mint : events.find((e) => e.data && e.data.mint)?.data?.mint;
+ mintLink.hidden = !mintish;
+ if (mintish) mintLink.href = `/launches/${mintish}`;
+
+ errorBox.hidden = !(replay && replay.error);
+ if (replay && replay.error) $('at-replay-error-message').textContent = replay.error;
+
+ loadmoreWrap.hidden = !(replay && replay.hasMore);
+ state.replayNextBefore = replay ? replay.nextBefore : null;
+}
+
function show(name) {
for (const key of ['loading', 'error', 'report', 'empty']) $(`at-${key}`).hidden = key !== name;
}
@@ -99,6 +280,7 @@ function render(inspection) {
explorer.hidden = !inspection.explorerUrl;
if (inspection.explorerUrl) explorer.href = inspection.explorerUrl;
$('at-share').hidden = !inspection.signature;
+ renderReplay(inspection);
show('report');
}
@@ -145,6 +327,53 @@ $('at-share').addEventListener('click', async () => {
setTimeout(() => { button.textContent = 'Copy inspection link'; }, 1_400);
});
+$('at-replay-loadmore').addEventListener('click', async () => {
+ const signature = state.lastInspection?.signature;
+ if (!signature || !state.replayNextBefore) return;
+ const button = $('at-replay-loadmore');
+ button.disabled = true;
+ $('at-replay-skeleton').hidden = false;
+ try {
+ const { inspection } = await fetch('/api/solana/atomic', {
+ method: 'POST',
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
+ body: JSON.stringify({ signature, before: state.replayNextBefore }),
+ }).then(responseJson);
+ const replay = state.lastInspection.replay;
+ replay.trades = [...(replay.trades || []), ...(inspection.replay?.trades || [])];
+ replay.hasMore = inspection.replay?.hasMore ?? false;
+ replay.nextBefore = inspection.replay?.nextBefore ?? null;
+ replay.error = inspection.replay?.error ?? null;
+ renderReplay(state.lastInspection);
+ } catch (err) {
+ $('at-replay-error-message').textContent = err.message;
+ $('at-replay-error').hidden = false;
+ } finally {
+ button.disabled = false;
+ $('at-replay-skeleton').hidden = true;
+ }
+});
+
+$('at-replay-retry').addEventListener('click', async () => {
+ const signature = state.lastInspection?.signature;
+ if (!signature) return;
+ $('at-replay-error').hidden = true;
+ $('at-replay-skeleton').hidden = false;
+ try {
+ const { inspection } = await fetch(`/api/solana/atomic?signature=${encodeURIComponent(signature)}`, {
+ headers: { accept: 'application/json' },
+ cache: 'no-store',
+ }).then(responseJson);
+ state.lastInspection.replay = inspection.replay;
+ renderReplay(state.lastInspection);
+ } catch (err) {
+ $('at-replay-error-message').textContent = err.message;
+ $('at-replay-error').hidden = false;
+ } finally {
+ $('at-replay-skeleton').hidden = true;
+ }
+});
+
loadStatus();
const initialSignature = new URLSearchParams(location.search).get('signature');
if (initialSignature) {
diff --git a/tests/_helpers/pump-log-fixtures.js b/tests/_helpers/pump-log-fixtures.js
index 3ea546e9c..ef5492da3 100644
--- a/tests/_helpers/pump-log-fixtures.js
+++ b/tests/_helpers/pump-log-fixtures.js
@@ -17,6 +17,10 @@ class BorshWriter {
this.chunks.push(Buffer.from([v]));
return this;
}
+ bool(v) {
+ this.chunks.push(Buffer.from([v ? 1 : 0]));
+ return this;
+ }
u16(v) {
const b = Buffer.alloc(2);
b.writeUInt16LE(v);
@@ -66,6 +70,13 @@ function discriminatorBuffer(disc) {
const DISTRIBUTE_CREATOR_FEES_DISC = 'a537817004b3ca28';
const SOCIAL_FEE_PDA_CLAIMED_DISC = '3212c141edd2eaec';
+// Discriminators below read straight off the installed @nirholas/pump-sdk's
+// PumpIdl.events (Buffer.from(event.discriminator).toString('hex')), same as
+// the two above.
+const CREATE_EVENT_DISC = '1b72a94ddeeb6376';
+const TRADE_EVENT_DISC = 'bddb7fd34ee661ee';
+const COMPLETE_EVENT_DISC = '5f72619cd42e9808';
+const COLLECT_CREATOR_FEE_EVENT_DISC = '7a027f010ebf0caf';
/**
* @param {{mint:string, bondingCurve:string, sharingConfig:string, admin:string,
@@ -105,6 +116,85 @@ export function encodeSocialFeePdaClaimed(fields) {
return Buffer.concat([discriminatorBuffer(SOCIAL_FEE_PDA_CLAIMED_DISC), w.bytes()]);
}
+/**
+ * @param {{name:string, symbol:string, uri:string, mint:string, bondingCurve:string,
+ * user:string, creator:string, timestamp?:number, virtualTokenReserves:bigint|number,
+ * virtualSolReserves:bigint|number, realTokenReserves:bigint|number,
+ * tokenTotalSupply:bigint|number, tokenProgram:string, isMayhemMode?:boolean,
+ * isCashbackEnabled?:boolean}} fields
+ */
+export function encodeCreateEvent(fields) {
+ const w = new BorshWriter();
+ w.string(fields.name)
+ .string(fields.symbol)
+ .string(fields.uri)
+ .pubkey(fields.mint)
+ .pubkey(fields.bondingCurve)
+ .pubkey(fields.user)
+ .pubkey(fields.creator)
+ .i64(fields.timestamp ?? 1_760_000_000)
+ .u64(fields.virtualTokenReserves)
+ .u64(fields.virtualSolReserves)
+ .u64(fields.realTokenReserves)
+ .u64(fields.tokenTotalSupply)
+ .pubkey(fields.tokenProgram)
+ .bool(fields.isMayhemMode ?? false)
+ .bool(fields.isCashbackEnabled ?? false);
+ return Buffer.concat([discriminatorBuffer(CREATE_EVENT_DISC), w.bytes()]);
+}
+
+/**
+ * @param {{mint:string, solAmount:bigint|number, tokenAmount:bigint|number, isBuy:boolean,
+ * user:string, timestamp?:number, virtualSolReserves:bigint|number,
+ * virtualTokenReserves:bigint|number, realSolReserves:bigint|number,
+ * realTokenReserves:bigint|number, feeRecipient:string, feeBasisPoints?:bigint|number,
+ * fee?:bigint|number, creator:string, creatorFeeBasisPoints?:bigint|number,
+ * creatorFee?:bigint|number, ixName?:string}} fields
+ */
+export function encodeTradeEvent(fields) {
+ const w = new BorshWriter();
+ w.pubkey(fields.mint)
+ .u64(fields.solAmount)
+ .u64(fields.tokenAmount)
+ .bool(fields.isBuy)
+ .pubkey(fields.user)
+ .i64(fields.timestamp ?? 1_760_000_050)
+ .u64(fields.virtualSolReserves)
+ .u64(fields.virtualTokenReserves)
+ .u64(fields.realSolReserves)
+ .u64(fields.realTokenReserves)
+ .pubkey(fields.feeRecipient)
+ .u64(fields.feeBasisPoints ?? 100)
+ .u64(fields.fee ?? 0)
+ .pubkey(fields.creator)
+ .u64(fields.creatorFeeBasisPoints ?? 50)
+ .u64(fields.creatorFee ?? 0)
+ .bool(fields.trackVolume ?? false)
+ .u64(fields.totalUnclaimedTokens ?? 0)
+ .u64(fields.totalClaimedTokens ?? 0)
+ .u64(fields.currentSolVolume ?? 0)
+ .i64(fields.lastUpdateTimestamp ?? 0)
+ .string(fields.ixName ?? (fields.isBuy ? 'buy' : 'sell'))
+ .bool(fields.mayhemMode ?? false)
+ .u64(fields.cashbackFeeBasisPoints ?? 0)
+ .u64(fields.cashback ?? 0);
+ return Buffer.concat([discriminatorBuffer(TRADE_EVENT_DISC), w.bytes()]);
+}
+
+/** @param {{user:string, mint:string, bondingCurve:string, timestamp?:number}} fields */
+export function encodeCompleteEvent(fields) {
+ const w = new BorshWriter();
+ w.pubkey(fields.user).pubkey(fields.mint).pubkey(fields.bondingCurve).i64(fields.timestamp ?? 1_760_000_200);
+ return Buffer.concat([discriminatorBuffer(COMPLETE_EVENT_DISC), w.bytes()]);
+}
+
+/** @param {{creator:string, creatorFee:bigint|number, timestamp?:number}} fields */
+export function encodeCollectCreatorFeeEvent(fields) {
+ const w = new BorshWriter();
+ w.i64(fields.timestamp ?? 1_760_000_300).pubkey(fields.creator).u64(fields.creatorFee);
+ return Buffer.concat([discriminatorBuffer(COLLECT_CREATOR_FEE_EVENT_DISC), w.bytes()]);
+}
+
function programDataLogLine(bytes) {
return `Program data: ${bytes.toString('base64')}`;
}
@@ -158,6 +248,42 @@ export function distributionLogs(distribution) {
]);
}
+/** Logs for a create transaction (a coin launch) alone. */
+export function createEventLogs(createFields) {
+ return buildTransactionLogs([
+ { programId: PUMP_PROGRAM_ID, instruction: 'Create', dataPayloads: [encodeCreateEvent(createFields)] },
+ ]);
+}
+
+/** Logs for a buy/sell transaction on an existing bonding curve. */
+export function tradeEventLogs(tradeFields) {
+ return buildTransactionLogs([
+ {
+ programId: PUMP_PROGRAM_ID,
+ instruction: tradeFields.isBuy ? 'Buy' : 'Sell',
+ dataPayloads: [encodeTradeEvent(tradeFields)],
+ },
+ ]);
+}
+
+/** Logs for the trade transaction that graduates a bonding curve, trade event then complete event. */
+export function completeEventLogs(tradeFields, completeFields) {
+ return buildTransactionLogs([
+ {
+ programId: PUMP_PROGRAM_ID,
+ instruction: tradeFields.isBuy ? 'Buy' : 'Sell',
+ dataPayloads: [encodeTradeEvent(tradeFields), encodeCompleteEvent(completeFields)],
+ },
+ ]);
+}
+
+/** Logs for a creator collecting their accrued fee off a bonding curve. */
+export function collectCreatorFeeEventLogs(collectFields) {
+ return buildTransactionLogs([
+ { programId: PUMP_PROGRAM_ID, instruction: 'CollectCreatorFee', dataPayloads: [encodeCollectCreatorFeeEvent(collectFields)] },
+ ]);
+}
+
/** A deterministic, valid 32-byte base58 pubkey from a short ASCII tag. Never a real key. */
function synthPubkey(tag) {
const buf = Buffer.alloc(32);
@@ -180,4 +306,11 @@ export const SYNTH = {
ADMIN: synthPubkey('synth-admin'),
RECIPIENT: synthPubkey('synth-recipient'),
CLAIM_AUTHORITY: synthPubkey('synth-claim-authority'),
+ USER_A: synthPubkey('synth-user-a'),
+ USER_B: synthPubkey('synth-user-b'),
+ CREATOR_A: synthPubkey('synth-creator-a'),
+ FEE_RECIPIENT: synthPubkey('synth-fee-recipient'),
+ // SPL Token program, the real mainnet id: every pump.fun mint is a real SPL
+ // token, so this is a known-constant account, not a third-party key.
+ TOKEN_PROGRAM: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
};
diff --git a/tests/pump-events.test.js b/tests/pump-events.test.js
new file mode 100644
index 000000000..41c412f6d
--- /dev/null
+++ b/tests/pump-events.test.js
@@ -0,0 +1,218 @@
+import { describe, it, expect } from 'vitest';
+import { decodeTransactionEvents, parseTransactionDistributions, parseSocialFeeClaim } from '../api/_lib/pump-events.js';
+import {
+ createEventLogs,
+ tradeEventLogs,
+ completeEventLogs,
+ collectCreatorFeeEventLogs,
+ socialClaimWithDistributionsLogs,
+ buildTransactionLogs,
+ encodeTradeEvent,
+ SYNTH,
+} from './_helpers/pump-log-fixtures.js';
+import { PUMP_PROGRAM_ID, PUMP_FEE_PROGRAM_ID } from '../api/_lib/solana/programs.js';
+
+describe('decodeTransactionEvents: create', () => {
+ it('decodes a launch into a typed create event', () => {
+ const logs = createEventLogs({
+ name: '$THREE',
+ symbol: 'THREE',
+ uri: 'https://three.ws/metadata/three.json',
+ mint: SYNTH.MINT_A,
+ bondingCurve: SYNTH.BONDING_CURVE_A,
+ user: SYNTH.USER_A,
+ creator: SYNTH.CREATOR_A,
+ virtualTokenReserves: 1_073_000_000_000_000n,
+ virtualSolReserves: 30_000_000_000n,
+ realTokenReserves: 793_100_000_000_000n,
+ tokenTotalSupply: 1_000_000_000_000_000n,
+ tokenProgram: SYNTH.TOKEN_PROGRAM,
+ });
+
+ const events = decodeTransactionEvents(logs);
+ expect(events).toHaveLength(1);
+ expect(events[0].type).toBe('create');
+ expect(events[0].programId).toBe(PUMP_PROGRAM_ID);
+ expect(events[0].data.mint).toBe(SYNTH.MINT_A);
+ expect(events[0].data.name).toBe('$THREE');
+ expect(events[0].data.symbol).toBe('THREE');
+ expect(events[0].data.creator).toBe(SYNTH.CREATOR_A);
+ expect(events[0].data.realTokenReserves).toBe('793100000000000');
+ expect(events[0].data.isMayhemMode).toBe(false);
+ });
+});
+
+describe('decodeTransactionEvents: trade', () => {
+ it('decodes a buy with side, SOL/token deltas, and post-trade virtual reserves', () => {
+ const logs = tradeEventLogs({
+ mint: SYNTH.MINT_A,
+ solAmount: 5_000_000_000n,
+ tokenAmount: 120_000_000_000n,
+ isBuy: true,
+ user: SYNTH.USER_A,
+ virtualSolReserves: 35_000_000_000n,
+ virtualTokenReserves: 953_000_000_000_000n,
+ realSolReserves: 5_000_000_000n,
+ realTokenReserves: 673_100_000_000_000n,
+ feeRecipient: SYNTH.FEE_RECIPIENT,
+ creator: SYNTH.CREATOR_A,
+ });
+
+ const [event] = decodeTransactionEvents(logs);
+ expect(event.type).toBe('trade');
+ expect(event.data.isBuy).toBe(true);
+ expect(event.data.solAmount).toBe('5000000000');
+ expect(event.data.tokenAmount).toBe('120000000000');
+ expect(event.data.virtualSolReserves).toBe('35000000000');
+ expect(event.data.virtualTokenReserves).toBe('953000000000000');
+ expect(event.data.user).toBe(SYNTH.USER_A);
+ });
+
+ it('decodes a sell the same way, side flipped', () => {
+ const logs = tradeEventLogs({
+ mint: SYNTH.MINT_A,
+ solAmount: 1_000_000_000n,
+ tokenAmount: 20_000_000_000n,
+ isBuy: false,
+ user: SYNTH.USER_B,
+ virtualSolReserves: 34_000_000_000n,
+ virtualTokenReserves: 973_000_000_000_000n,
+ realSolReserves: 4_000_000_000n,
+ realTokenReserves: 693_100_000_000_000n,
+ feeRecipient: SYNTH.FEE_RECIPIENT,
+ creator: SYNTH.CREATOR_A,
+ });
+
+ const [event] = decodeTransactionEvents(logs);
+ expect(event.type).toBe('trade');
+ expect(event.data.isBuy).toBe(false);
+ expect(event.data.ixName).toBe('sell');
+ });
+});
+
+describe('decodeTransactionEvents: complete', () => {
+ it('decodes a graduating trade as [trade, complete] in order', () => {
+ const logs = completeEventLogs(
+ {
+ mint: SYNTH.MINT_A,
+ solAmount: 85_000_000_000n,
+ tokenAmount: 793_100_000_000_000n,
+ isBuy: true,
+ user: SYNTH.USER_A,
+ virtualSolReserves: 115_000_000_000n,
+ virtualTokenReserves: 280_000_000_000_000n,
+ realSolReserves: 85_000_000_000n,
+ realTokenReserves: 0n,
+ feeRecipient: SYNTH.FEE_RECIPIENT,
+ creator: SYNTH.CREATOR_A,
+ },
+ { user: SYNTH.USER_A, mint: SYNTH.MINT_A, bondingCurve: SYNTH.BONDING_CURVE_A },
+ );
+
+ const events = decodeTransactionEvents(logs);
+ expect(events.map((e) => e.type)).toEqual(['trade', 'complete']);
+ expect(events[0].data.realTokenReserves).toBe('0');
+ expect(events[1].data.mint).toBe(SYNTH.MINT_A);
+ expect(events[1].data.bondingCurve).toBe(SYNTH.BONDING_CURVE_A);
+ });
+});
+
+describe('decodeTransactionEvents: collect and distribute', () => {
+ it('decodes a creator fee collection', () => {
+ const logs = collectCreatorFeeEventLogs({ creator: SYNTH.CREATOR_A, creatorFee: 2_500_000_000n });
+ const [event] = decodeTransactionEvents(logs);
+ expect(event.type).toBe('collectCreatorFee');
+ expect(event.programId).toBe(PUMP_PROGRAM_ID);
+ expect(event.data.creator).toBe(SYNTH.CREATOR_A);
+ expect(event.data.creatorFee).toBe('2500000000');
+ });
+
+ it('decodes a same-tx distribution alongside a GitHub social-fee claim', () => {
+ const logs = socialClaimWithDistributionsLogs(
+ {
+ userId: '12345',
+ platform: 2,
+ socialFeePda: SYNTH.PDA_A,
+ recipient: SYNTH.RECIPIENT,
+ socialClaimAuthority: SYNTH.CLAIM_AUTHORITY,
+ amountClaimed: 7_000_000n,
+ lifetimeClaimed: 7_000_000n,
+ },
+ [
+ {
+ mint: SYNTH.MINT_A,
+ bondingCurve: SYNTH.BONDING_CURVE_A,
+ sharingConfig: SYNTH.SHARING_CONFIG_A,
+ admin: SYNTH.ADMIN,
+ shareholders: [{ address: SYNTH.PDA_A, shareBps: 10_000 }],
+ distributed: 7_000_000n,
+ },
+ ],
+ );
+
+ const events = decodeTransactionEvents(logs);
+ expect(events.map((e) => e.type)).toEqual(['distributeCreatorFees', 'socialFeePdaClaimed']);
+ expect(events[0].programId).toBe(PUMP_PROGRAM_ID);
+ expect(events[1].programId).toBe(PUMP_FEE_PROGRAM_ID);
+
+ // The existing typed helpers still read the same decoded shape.
+ expect(parseTransactionDistributions(logs)).toHaveLength(1);
+ expect(parseSocialFeeClaim(logs)?.githubUserId).toBe('12345');
+ });
+});
+
+describe('decodeTransactionEvents: unrecognized events never get dropped', () => {
+ it('keeps a frame whose discriminator is not in the installed SDK IDLs', () => {
+ const futureEventPayload = Buffer.concat([Buffer.from('ffffffffffffffff', 'hex'), Buffer.from('new-field-bytes')]);
+ const logs = buildTransactionLogs([
+ { programId: PUMP_PROGRAM_ID, instruction: null, dataPayloads: [futureEventPayload] },
+ ]);
+
+ const events = decodeTransactionEvents(logs);
+ expect(events).toHaveLength(1);
+ expect(events[0]).toMatchObject({
+ type: 'unrecognized',
+ programId: PUMP_PROGRAM_ID,
+ discriminator: 'ffffffffffffffff',
+ });
+ expect(events[0].dataBase64).toBe(futureEventPayload.toString('base64'));
+ });
+
+ it('ignores program data emitted outside a known Pump program invocation', () => {
+ const logs = [
+ 'Program 11111111111111111111111111111111 invoke [1]',
+ `Program data: ${encodeTradeEvent({
+ mint: SYNTH.MINT_A,
+ solAmount: 1n,
+ tokenAmount: 1n,
+ isBuy: true,
+ user: SYNTH.USER_A,
+ virtualSolReserves: 1n,
+ virtualTokenReserves: 1n,
+ realSolReserves: 1n,
+ realTokenReserves: 1n,
+ feeRecipient: SYNTH.FEE_RECIPIENT,
+ creator: SYNTH.CREATOR_A,
+ }).toString('base64')}`,
+ 'Program 11111111111111111111111111111111 success',
+ ];
+ expect(decodeTransactionEvents(logs)).toEqual([]);
+ });
+});
+
+describe('decodeTransactionEvents: never throws', () => {
+ it('returns an empty array for non-array input', () => {
+ expect(decodeTransactionEvents(null)).toEqual([]);
+ expect(decodeTransactionEvents(undefined)).toEqual([]);
+ expect(decodeTransactionEvents([])).toEqual([]);
+ });
+
+ it('skips an unparseable base64 "Program data:" line instead of throwing', () => {
+ const logs = [
+ `Program ${PUMP_PROGRAM_ID} invoke [1]`,
+ 'Program data: not-valid-base64!!!',
+ `Program ${PUMP_PROGRAM_ID} success`,
+ ];
+ expect(() => decodeTransactionEvents(logs)).not.toThrow();
+ });
+});