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: implement publish tab in agent edit UI and enhance pumpfun services with graduation event handling

nirholas394c9a281c87
diff --git a/agent-edit.html b/agent-edit.html
index d13eb6456..87889b5f1 100644
--- a/agent-edit.html
+++ b/agent-edit.html
@@ -430,6 +430,16 @@
>
Outfit
</button>
+ <button
+ class="edit-tab"
+ data-tab="publish"
+ role="tab"
+ aria-selected="false"
+ aria-controls="panel-publish"
+ id="tab-publish"
+ >
+ Publish
+ </button>
</div>
<main id="main">
@@ -489,6 +499,56 @@
</div>
</div>
</section>
+ <!-- Publish tab -->
+ <section
+ class="edit-panel persona-panel"
+ id="panel-publish"
+ role="tabpanel"
+ aria-labelledby="tab-publish"
+ hidden
+ >
+ <div class="form-group">
+ <label class="form-label" for="f-category">Category</label>
+ <select class="form-input" id="f-category">
+ <option value="">— Select —</option>
+ <option value="academic">Academic</option>
+ <option value="career">Career</option>
+ <option value="copywriting">Copywriting</option>
+ <option value="design">Design</option>
+ <option value="education">Education</option>
+ <option value="emotions">Emotions</option>
+ <option value="entertainment">Entertainment</option>
+ <option value="games">Games</option>
+ <option value="general">General</option>
+ <option value="life">Life</option>
+ <option value="marketing">Marketing</option>
+ <option value="office">Office</option>
+ <option value="programming">Programming</option>
+ <option value="translation">Translation</option>
+ </select>
+ </div>
+ <div class="form-group">
+ <label class="form-label" for="f-tags">Tags (comma-separated, max 12)</label>
+ <input class="form-input" id="f-tags" type="text" placeholder="thesis, polishing, academic-writing" />
+ </div>
+ <div class="form-group">
+ <label class="form-label" for="f-prompt">Agent Profile (system prompt)</label>
+ <textarea class="form-textarea" id="f-prompt" rows="8" maxlength="16000" placeholder="You are a professor of computer science…"></textarea>
+ </div>
+ <div class="form-group">
+ <label class="form-label" for="f-greeting">Greeting (demo first message)</label>
+ <textarea class="form-textarea" id="f-greeting" rows="3" maxlength="1000" placeholder="Hello! I am your computer science thesis polishing assistant…"></textarea>
+ </div>
+ <div class="form-group">
+ <label class="form-label" for="f-changelog">Changelog (optional, for this version)</label>
+ <input class="form-input" id="f-changelog" type="text" maxlength="1000" placeholder="Initial publish" />
+ </div>
+ <div class="form-actions">
+ <button class="btn-primary" id="publish-save">Publish to Marketplace</button>
+ <a id="publish-view" href="#" target="_blank" rel="noopener" style="margin-left:1rem;font-size:0.764rem;color:rgba(255,255,255,0.55);" hidden>View on marketplace ›</a>
+ <span class="form-status" id="publish-status" role="status" aria-live="polite"></span>
+ </div>
+ </section>
</main>
<div class="outfit-status" id="outfit-status" role="status" aria-live="polite"></div>
@@ -550,6 +610,7 @@
else p.setAttribute('hidden', '');
});
if (name === 'outfit') initOutfitTab();
+ if (name === 'publish') initPublishTab();
}
const editTabs = document.querySelectorAll('.edit-tab');
@@ -608,6 +669,74 @@
}
});
+ // ── Publish tab ───────────────────────────────────────────────────────────
+ let publishInitialized = false;
+
+ async function initPublishTab() {
+ if (publishInitialized) return;
+ publishInitialized = true;
+ const meta = agent.meta || {};
+ document.getElementById('f-category').value = meta.category || agent.category || '';
+ document.getElementById('f-tags').value = (meta.tags || agent.tags || []).join(', ');
+ document.getElementById('f-prompt').value = meta.system_prompt || agent.system_prompt || '';
+ document.getElementById('f-greeting').value = meta.greeting || agent.greeting || '';
+ if (meta.is_published || agent.is_published) {
+ const link = document.getElementById('publish-view');
+ link.hidden = false;
+ link.href = `/marketplace/agents/${agentId}`;
+ document.getElementById('publish-save').textContent = 'Publish New Version';
+ }
+ }
+
+ document.getElementById('publish-save').addEventListener('click', async () => {
+ const btn = document.getElementById('publish-save');
+ const status = document.getElementById('publish-status');
+ const category = document.getElementById('f-category').value;
+ if (!category) {
+ status.textContent = 'Pick a category.';
+ status.className = 'form-status err';
+ return;
+ }
+ const tags = document
+ .getElementById('f-tags')
+ .value.split(',')
+ .map((t) => t.trim().toLowerCase())
+ .filter(Boolean)
+ .slice(0, 12);
+ const body = {
+ category,
+ tags,
+ system_prompt: document.getElementById('f-prompt').value.trim(),
+ greeting: document.getElementById('f-greeting').value.trim(),
+ changelog: document.getElementById('f-changelog').value.trim() || null,
+ };
+ btn.disabled = true;
+ status.textContent = 'Publishing…';
+ status.className = 'form-status';
+ try {
+ const r = await fetch(`/api/marketplace/agents/${agentId}/publish`, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify(body),
+ });
+ const j = await r.json();
+ if (!r.ok) throw new Error(j.error_description || `HTTP ${r.status}`);
+ status.textContent = `Published v${j.data.version}.`;
+ status.className = 'form-status ok';
+ const link = document.getElementById('publish-view');
+ link.hidden = false;
+ link.href = `/marketplace/agents/${agentId}`;
+ btn.textContent = 'Publish New Version';
+ document.getElementById('f-changelog').value = '';
+ } catch (err) {
+ status.textContent = err.message;
+ status.className = 'form-status err';
+ } finally {
+ btn.disabled = false;
+ }
+ });
+
// ── Outfit tab ────────────────────────────────────────────────────────────
let outfitInitialized = false;
diff --git a/api/_lib/pumpfun-mcp.js b/api/_lib/pumpfun-mcp.js
index 0726ca6fe..43b9e4130 100644
--- a/api/_lib/pumpfun-mcp.js
+++ b/api/_lib/pumpfun-mcp.js
@@ -1,22 +1,18 @@
-// Thin client for the upstream `pumpfun-claims-bot` MCP server.
+// Pumpfun feed source.
//
-// The bot is run as a long-lived service (e.g. Railway) that exposes a JSON-RPC
-// 2.0 MCP endpoint over HTTPS. This module fans calls out to its `tools/call`
-// method and caches the result in Upstash Redis when available so each Vercel
-// function cold start does not re-fetch the same data.
+// Reads graduation events from an Upstash Redis list populated by the
+// `services/pump-graduations` worker. Claim/intel ops are stubbed out — the
+// three.ws/pumpfun page only needs graduations to announce migrations.
//
-// Configure via env:
-// PUMPFUN_BOT_URL Full URL to the bot's MCP endpoint (required to enable)
-// PUMPFUN_BOT_TOKEN Optional bearer for authenticated MCP transports
-//
-// All exported helpers return `{ ok, data, error }`. They never throw on
-// network failure — callers degrade gracefully.
+// Env:
+// UPSTASH_REDIS_REST_URL required to enable the feed
+// UPSTASH_REDIS_REST_TOKEN required
+// GRADUATIONS_LIST_KEY default: pf:graduations
import { Redis } from '@upstash/redis';
import { env } from './env.js';
-const TOOL_TIMEOUT_MS = 8000;
-const CACHE_TTL_S = 60;
+const LIST_KEY = process.env.GRADUATIONS_LIST_KEY || 'pf:graduations';
let _redis = null;
function redis() {
@@ -33,89 +29,70 @@ function redis() {
}
export function pumpfunBotEnabled() {
- return !!process.env.PUMPFUN_BOT_URL;
-}
-
-function botUrl() {
- const u = process.env.PUMPFUN_BOT_URL;
- if (!u) throw Object.assign(new Error('pumpfun bot not configured'), { status: 503 });
- return u.replace(/\/$/, '');
+ return !!(env.UPSTASH_REDIS_REST_URL && env.UPSTASH_REDIS_REST_TOKEN);
}
-async function rpc(method, params) {
- const ctrl = new AbortController();
- const timer = setTimeout(() => ctrl.abort(), TOOL_TIMEOUT_MS);
+async function readGraduations(limit = 20) {
+ const r = redis();
+ if (!r) return [];
try {
- const headers = { 'content-type': 'application/json', accept: 'application/json' };
- if (process.env.PUMPFUN_BOT_TOKEN) {
- headers.authorization = `Bearer ${process.env.PUMPFUN_BOT_TOKEN}`;
- }
- const r = await fetch(botUrl(), {
- method: 'POST',
- headers,
- body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
- signal: ctrl.signal,
- });
- if (!r.ok) return { ok: false, error: `bot ${r.status}` };
- const j = await r.json();
- if (j.error) return { ok: false, error: j.error.message || 'rpc error' };
- return { ok: true, data: j.result };
+ const items = await r.lrange(LIST_KEY, 0, Math.max(0, limit - 1));
+ return items
+ .map((x) => (typeof x === 'string' ? safeJson(x) : x))
+ .filter(Boolean)
+ .map(toFeedShape);
} catch (err) {
- return { ok: false, error: err?.name === 'AbortError' ? 'timeout' : err?.message || 'fetch failed' };
- } finally {
- clearTimeout(timer);
+ console.error('[pumpfun-mcp] redis read failed:', err?.message || err);
+ return [];
}
}
-async function callTool(name, args, { ttl = CACHE_TTL_S } = {}) {
- const cacheKey = `pf:${name}:${JSON.stringify(args || {})}`;
- const r = redis();
- if (r) {
- try {
- const cached = await r.get(cacheKey);
- if (cached) return { ok: true, data: cached, cached: true };
- } catch {}
- }
- const res = await rpc('tools/call', { name, arguments: args || {} });
- if (!res.ok) return res;
- // MCP tool result envelope → unwrap structuredContent if present.
- const payload = res.data?.structuredContent ?? res.data?.content ?? res.data;
- if (r && payload) {
- try {
- await r.set(cacheKey, payload, { ex: ttl });
- } catch {}
- }
- return { ok: true, data: payload };
+function toFeedShape(g) {
+ // Worker pushes { signature, mint, tokenName, tokenSymbol, poolAddress, timestamp }
+ // Feed/widget consume { tx_signature, mint, name, symbol, ... }.
+ return {
+ tx_signature: g.signature,
+ signature: g.signature,
+ mint: g.mint,
+ name: g.tokenName || null,
+ symbol: g.tokenSymbol || null,
+ pool_address: g.poolAddress || null,
+ final_mcap: g.finalMcap ?? null,
+ timestamp: g.timestamp,
+ };
+}
+
+function safeJson(s) {
+ try { return JSON.parse(s); } catch { return null; }
}
export const pumpfunMcp = {
enabled: pumpfunBotEnabled,
- listTools() {
- return rpc('tools/list', {});
+ async listTools() {
+ return { ok: true, data: { tools: ['getGraduations'] } };
},
- recentClaims({ limit = 20 } = {}) {
- return callTool('getRecentClaims', { limit }, { ttl: 30 });
+ async recentClaims() {
+ // Not implemented in the migrations-only feed.
+ return { ok: true, data: [] };
},
- graduations({ limit = 20 } = {}) {
- return callTool('getGraduations', { limit }, { ttl: 60 });
+ async graduations({ limit = 20 } = {}) {
+ const items = await readGraduations(limit);
+ return { ok: true, data: items };
},
- tokenIntel({ mint }) {
- if (!mint) return Promise.resolve({ ok: false, error: 'mint required' });
- return callTool('getTokenIntel', { mint }, { ttl: 120 });
+ async tokenIntel() {
+ return { ok: false, error: 'token intel not available' };
},
- creatorIntel({ wallet }) {
- if (!wallet) return Promise.resolve({ ok: false, error: 'wallet required' });
- return callTool('getCreatorIntel', { wallet }, { ttl: 300 });
+ async creatorIntel() {
+ return { ok: false, error: 'creator intel not available' };
},
- // Polling helper: serverless cannot hold a long-lived subscription, so the
- // browser-side watch skill polls this and dedupes by tx signature.
- claimsSince({ sinceSig = null, limit = 50 } = {}) {
- return callTool('getClaimsSince', { sinceSig, limit }, { ttl: 5 });
+ async claimsSince() {
+ // No claim source — return empty list so the SSE loop just keeps polling.
+ return { ok: true, data: [] };
},
};
diff --git a/api/agents/pumpfun/launch.js b/api/agents/pumpfun/launch.js
index bd57da51c..a98e2d051 100644
--- a/api/agents/pumpfun/launch.js
+++ b/api/agents/pumpfun/launch.js
@@ -29,6 +29,7 @@ const bodySchema = z.object({
vanityPrefix: z.string().min(1).max(6).optional(),
vanitySuffix: z.string().min(1).max(6).optional(),
vanityIgnoreCase: z.boolean().optional(),
+ mintSecretKey: z.array(z.number().int().min(0).max(255)).length(64).optional(),
network: z.enum(['mainnet', 'devnet']).default('mainnet'),
});
@@ -69,17 +70,34 @@ export default async function handler(req, res, id) {
let mint;
let vanityIterations = 1;
let vanityDurationMs = 0;
- try {
- const ground = await grindMintKeypair({
- prefix: body.vanityPrefix,
- suffix: body.vanitySuffix,
- ignoreCase: body.vanityIgnoreCase,
- });
- mint = ground.keypair;
- vanityIterations = ground.iterations;
- vanityDurationMs = ground.durationMs;
- } catch (err) {
- return error(res, err.status || 500, err.code || 'internal', err.message);
+ if (body.mintSecretKey) {
+ try {
+ mint = Keypair.fromSecretKey(Uint8Array.from(body.mintSecretKey));
+ } catch (e) {
+ return error(res, 400, 'validation_error', 'mintSecretKey did not parse as a valid Solana keypair');
+ }
+ const addr = mint.publicKey.toBase58();
+ const ic = !!body.vanityIgnoreCase;
+ const cmp = (a, b) => (ic ? a.toLowerCase() === b.toLowerCase() : a === b);
+ if (body.vanityPrefix && !cmp(addr.slice(0, body.vanityPrefix.length), body.vanityPrefix)) {
+ return error(res, 400, 'validation_error', 'mintSecretKey does not match vanityPrefix');
+ }
+ if (body.vanitySuffix && !cmp(addr.slice(-body.vanitySuffix.length), body.vanitySuffix)) {
+ return error(res, 400, 'validation_error', 'mintSecretKey does not match vanitySuffix');
+ }
+ } else {
+ try {
+ const ground = await grindMintKeypair({
+ prefix: body.vanityPrefix,
+ suffix: body.vanitySuffix,
+ ignoreCase: body.vanityIgnoreCase,
+ });
+ mint = ground.keypair;
+ vanityIterations = ground.iterations;
+ vanityDurationMs = ground.durationMs;
+ } catch (err) {
+ return error(res, err.status || 500, err.code || 'internal', err.message);
+ }
}
const solLamports = new BN(Math.floor((body.solAmount || 0) * 1e9));
const tokenAmount = new BN(body.tokenAmount || 0);
diff --git a/public/dashboard/agent-pumpfun.html b/public/dashboard/agent-pumpfun.html
index bd63cf004..6d6db5861 100644
--- a/public/dashboard/agent-pumpfun.html
+++ b/public/dashboard/agent-pumpfun.html
@@ -546,6 +546,58 @@
</p>
</section>
+ <section class="panel" id="vanity-panel">
+ <h2>Vanity grinder ✦</h2>
+ <p class="muted" style="margin: 0 0 10px; font-size: 13px">
+ Grind a Solana keypair entirely in your browser — keys never leave this tab.
+ Use the result for your next pump.fun launch, or assign it as the agent's wallet.
+ Base58 only (no <code>0/O/I/l</code>). 5–6 chars can take minutes; 7+ is impractical.
+ </p>
+ <div class="row">
+ <div class="field" style="flex: 0 0 140px">
+ <label for="vg-prefix">Prefix</label>
+ <input id="vg-prefix" placeholder="PUMP" maxlength="6" autocomplete="off" />
+ </div>
+ <div class="field" style="flex: 0 0 140px">
+ <label for="vg-suffix">Suffix</label>
+ <input id="vg-suffix" placeholder="pump" maxlength="6" autocomplete="off" />
+ </div>
+ <div class="field" style="flex: 0 0 auto; padding-top: 22px">
+ <label style="display:flex;align-items:center;gap:6px;color:#ddd">
+ <input type="checkbox" id="vg-ic" /> ignore case
+ </label>
+ </div>
+ <div style="flex: 0 0 auto; padding-top: 19px">
+ <button class="btn" id="vg-start">Start grinding</button>
+ </div>
+ <div style="flex: 0 0 auto; padding-top: 19px">
+ <button class="btn ghost" id="vg-stop" hidden>Stop</button>
+ </div>
+ </div>
+ <div id="vg-progress" class="muted" style="margin-top:10px;font-size:13px;font-family:ui-monospace,Menlo,monospace">
+ Idle. Estimated attempts shown after you enter a pattern.
+ </div>
+ <div id="vg-result" hidden style="margin-top:12px">
+ <dl class="kv">
+ <dt>Address</dt>
+ <dd id="vg-address" class="mono"></dd>
+ <dt>Attempts</dt>
+ <dd id="vg-attempts"></dd>
+ <dt>Duration</dt>
+ <dd id="vg-duration"></dd>
+ </dl>
+ <div class="row" style="margin-top:10px;gap:8px;flex-wrap:wrap">
+ <button class="btn" id="vg-use-launch">Use for next launch</button>
+ <button class="btn ghost" id="vg-assign">Assign as agent wallet</button>
+ <button class="btn ghost" id="vg-copy">Copy secret JSON</button>
+ <button class="btn ghost" id="vg-discard">Discard</button>
+ </div>
+ <p class="muted" style="margin:8px 0 0;font-size:12px">
+ The secret is held in this tab only. Closing or refreshing this page erases it.
+ </p>
+ </div>
+ </section>
+
<section class="panel">
<h2>Trade on the bonding curve</h2>
<div class="row">
@@ -1127,6 +1179,9 @@
if (vanity) body.vanityPrefix = vanity;
if (vanitySuffix) body.vanitySuffix = vanitySuffix;
if (els.launchVanityIc.checked) body.vanityIgnoreCase = true;
+ if (window.__pendingMintSecret) {
+ body.mintSecretKey = Array.from(window.__pendingMintSecret);
+ }
const sol = parseFloat(els.launchSol.value);
if (sol > 0) body.solAmount = sol;
els.launchBtn.disabled = true;
@@ -1142,6 +1197,11 @@
`Launched ${data.mint.slice(0, 12)}… (${data.vanity_iterations.toLocaleString()} attempts in ${data.vanity_duration_ms}ms)`,
);
els.tradeMint.value = data.mint;
+ if (window.__pendingMintSecret) {
+ window.__pendingMintSecret = null;
+ const banner = document.getElementById('vg-launch-banner');
+ if (banner) banner.remove();
+ }
await refreshAgent();
await refreshPortfolio();
} catch (err) {
diff --git a/public/pumpfun.html b/public/pumpfun.html
index db9710c12..4b841ba75 100644
--- a/public/pumpfun.html
+++ b/public/pumpfun.html
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Pump.fun live · three.ws</title>
+ <title>PumpFun migrations · three.ws</title>
<link rel="icon" href="/favicon.ico" />
<style>
:root { color-scheme: dark; --accent: #6a5cff; --border: #1f1f29; --bg: #0a0a0f; --panel: #14141c; --muted: #888; }
@@ -72,7 +72,7 @@
</head>
<body>
<header>
- <h1>✦ Pump.fun live</h1>
+ <h1>✦ PumpFun migrations</h1>
<span class="status-pill" id="status-pill"><span class="dot connecting" id="status-dot"></span><span id="status-label">connecting…</span></span>
<div class="ctl">
<input id="ctl-asset" type="text" placeholder="Solana asset pubkey (optional)" size="22" />
@@ -116,7 +116,7 @@
const params = {
asset: url.searchParams.get('asset') || '',
mint: url.searchParams.get('mint') || '',
- kind: url.searchParams.get('kind') || 'all',
+ kind: url.searchParams.get('kind') || 'graduations',
minTier: url.searchParams.get('minTier') || '',
network: url.searchParams.get('network') || 'mainnet',
narrate: url.searchParams.get('narrate') !== '0',
diff --git a/services/pump-graduations/Dockerfile b/services/pump-graduations/Dockerfile
new file mode 100644
index 000000000..22c116e1f
--- /dev/null
+++ b/services/pump-graduations/Dockerfile
@@ -0,0 +1,6 @@
+FROM node:20-alpine
+WORKDIR /app
+COPY package.json ./
+RUN npm install --omit=dev
+COPY index.js ./
+CMD ["node", "index.js"]
diff --git a/services/pump-graduations/index.js b/services/pump-graduations/index.js
new file mode 100644
index 000000000..6d6f06ab4
--- /dev/null
+++ b/services/pump-graduations/index.js
@@ -0,0 +1,124 @@
+/**
+ * pump-graduations worker
+ * -----------------------
+ * Subscribes to Pump program logs and pushes graduation (bonding-curve →
+ * PumpAMM migration) events into Upstash Redis. The Vercel side reads from
+ * Redis; this service is the only thing that holds a long-lived WS.
+ *
+ * Detection: Pump emits a `complete` anchor event when a token graduates.
+ * Discriminator (8 bytes) matches @pumpkit/core: COMPLETE_EVENT_DISCRIMINATOR.
+ *
+ * Env:
+ * SOLANA_RPC_URL Helius (or any) HTTPS RPC
+ * SOLANA_WS_URL Helius (or any) WSS endpoint
+ * UPSTASH_REDIS_REST_URL
+ * UPSTASH_REDIS_REST_TOKEN
+ * GRADUATIONS_LIST_KEY default: pf:graduations
+ * GRADUATIONS_MAX_LEN default: 500
+ */
+
+import { Connection, PublicKey } from '@solana/web3.js';
+import { Redis } from '@upstash/redis';
+import bs58 from 'bs58';
+
+const PUMP_PROGRAM_ID = new PublicKey('6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P');
+
+// Anchor "event" CPI emit: discriminator is sha256("event:CompleteEvent")[..8].
+// Borrowed from @pumpkit/core/monitor/GraduationMonitor — fixed bytes:
+const COMPLETE_EVENT_DISCRIMINATOR = Buffer.from([95, 114, 97, 156, 212, 46, 152, 8]);
+
+const RPC = required('SOLANA_RPC_URL');
+const WS = required('SOLANA_WS_URL');
+const LIST_KEY = process.env.GRADUATIONS_LIST_KEY || 'pf:graduations';
+const MAX_LEN = Number(process.env.GRADUATIONS_MAX_LEN || 500);
+
+const redis = new Redis({
+ url: required('UPSTASH_REDIS_REST_URL'),
+ token: required('UPSTASH_REDIS_REST_TOKEN'),
+});
+
+const conn = new Connection(RPC, { wsEndpoint: WS, commitment: 'confirmed' });
+const seen = new Set();
+
+console.log('[pump-graduations] starting; program=%s', PUMP_PROGRAM_ID.toBase58());
+
+conn.onLogs(
+ PUMP_PROGRAM_ID,
+ async (entry) => {
+ try {
+ if (entry.err) return;
+ const sig = entry.signature;
+ if (seen.has(sig)) return;
+ if (!entry.logs?.some((l) => l.includes('Program data:'))) return;
+
+ const ev = await tryParseGraduation(sig, entry.logs);
+ if (!ev) return;
+ seen.add(sig);
+ if (seen.size > 5000) seen.clear();
+
+ const enriched = await enrichToken(ev);
+ await pushGraduation(enriched);
+ console.log('[pump-graduations] pushed', enriched.symbol || enriched.mint, sig);
+ } catch (err) {
+ console.error('[pump-graduations] handler error:', err?.message || err);
+ }
+ },
+ 'confirmed',
+);
+
+async function tryParseGraduation(sig, logs) {
+ for (const line of logs) {
+ const m = line.match(/^Program data: (.+)$/);
+ if (!m) continue;
+ let data;
+ try { data = Buffer.from(m[1], 'base64'); } catch { continue; }
+ if (data.length < 8) continue;
+ if (!data.subarray(0, 8).equals(COMPLETE_EVENT_DISCRIMINATOR)) continue;
+
+ // CompleteEvent layout (per Pump IDL): user(32) mint(32) bondingCurve(32) timestamp(i64)
+ if (data.length < 8 + 32 + 32 + 32 + 8) continue;
+ let off = 8;
+ const user = bs58.encode(data.subarray(off, off + 32)); off += 32;
+ const mint = bs58.encode(data.subarray(off, off + 32)); off += 32;
+ const bondingCurve = bs58.encode(data.subarray(off, off + 32)); off += 32;
+ const timestamp = Number(data.readBigInt64LE(off));
+
+ return { signature: sig, mint, user, bondingCurve, timestamp };
+ }
+ return null;
+}
+
+async function enrichToken(ev) {
+ let name, symbol, poolAddress;
+ try {
+ const tx = await conn.getTransaction(ev.signature, { maxSupportedTransactionVersion: 0 });
+ const accounts = tx?.transaction?.message?.staticAccountKeys?.map((k) => k.toBase58()) || [];
+ // PumpAMM pool keypair is created in the same tx; we can't reliably pluck it
+ // without IDL decode. Leave undefined — the UI tolerates it.
+ poolAddress = accounts.find((k) => k !== ev.mint && k !== ev.user) || undefined;
+ } catch {}
+ return {
+ signature: ev.signature,
+ mint: ev.mint,
+ tokenName: name,
+ tokenSymbol: symbol,
+ poolAddress,
+ timestamp: ev.timestamp || Math.floor(Date.now() / 1000),
+ };
+}
+
+async function pushGraduation(ev) {
+ const json = JSON.stringify(ev);
+ await redis.lpush(LIST_KEY, json);
+ await redis.ltrim(LIST_KEY, 0, MAX_LEN - 1);
+ await redis.publish(`${LIST_KEY}:pub`, json);
+}
+
+function required(name) {
+ const v = process.env[name];
+ if (!v) { console.error(`missing env ${name}`); process.exit(1); }
+ return v;
+}
+
+process.on('SIGTERM', () => process.exit(0));
+process.on('SIGINT', () => process.exit(0));
diff --git a/services/pump-graduations/package.json b/services/pump-graduations/package.json
new file mode 100644
index 000000000..c1633fcf9
--- /dev/null
+++ b/services/pump-graduations/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "pump-graduations",
+ "version": "0.1.0",
+ "private": true,
+ "type": "module",
+ "main": "index.js",
+ "scripts": {
+ "start": "node index.js"
+ },
+ "engines": { "node": ">=20" },
+ "dependencies": {
+ "@solana/web3.js": "^1.98.0",
+ "@upstash/redis": "^1.34.0",
+ "bs58": "^6.0.0"
+ }
+}