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.

fix(pump): show a live curve for our own launches instead of a cached 404

nirholas5abd87eaccf5
diff --git a/api/_lib/pump-curve-view.js b/api/_lib/pump-curve-view.js
index ea2ca197f..938482b04 100644
--- a/api/_lib/pump-curve-view.js
+++ b/api/_lib/pump-curve-view.js
@@ -14,6 +14,7 @@
import { rpcFallbackFromEnv, getBondingCurveState, getTokenPrice, getGraduationProgress } from './solana/index.js';
import { createCache } from './mem-cache.js';
+import { hasThreeWsMark } from '../../src/solana/vanity/brand.js';
// Mints that can never carry a pump.fun bonding curve. These are coin-agnostic
// payment-rail / native tokens, listed only so we can *exclude* them from curve
@@ -29,11 +30,22 @@ export const NON_CURVE_MINTS = new Set([
// these tokens fully-diluted value therefore equals market cap.
export const PUMP_TOTAL_SUPPLY = 1_000_000_000;
-// Every pump.fun mint keypair is ground to end in the literal suffix "pump". A
-// mint that does not end in "pump" (or that is a known settlement token) has no
-// bonding curve and never will — so we can reject it without touching RPC.
+// Cheap, RPC-free pre-filter for "could this address carry a pump.fun bonding
+// curve?". Two shapes qualify, both decided from the address alone:
+//
+// 1. pump.fun's own launcher grinds every mint to end in the literal suffix
+// "pump".
+// 2. three.ws grinds its own launches to carry the "3ws" mark as a PREFIX
+// (src/solana/vanity/brand.js) and never the "pump" suffix. Every agent
+// token this platform mints therefore lands here, and the suffix test
+// alone used to reject all of them with a 300s-cached `not_a_pump_mint`
+// 404 — the curve read for our own coins could never succeed.
+//
+// A known settlement/native token is excluded outright: it has no curve and
+// never will.
export function isPumpMint(mint) {
- return typeof mint === 'string' && mint.endsWith('pump') && !NON_CURVE_MINTS.has(mint);
+ if (typeof mint !== 'string' || NON_CURVE_MINTS.has(mint)) return false;
+ return mint.endsWith('pump') || hasThreeWsMark(mint);
}
export function isPlausibleMint(s) {
diff --git a/src/pump/coin-status-card.js b/src/pump/coin-status-card.js
index 67d943d1c..c5d86ec4a 100644
--- a/src/pump/coin-status-card.js
+++ b/src/pump/coin-status-card.js
@@ -9,9 +9,19 @@
* its own. This unifies all of that: map the response shape once here, and
* every consumer benefits when a field name or format changes.
*
- * Data source: GET /api/pump/coin?mint=<mint> (pump.fun coin object, proxied).
- * The raw shape is normalized exactly once in `mapCoin()`, so renaming an
- * upstream field (e.g. `usd_market_cap` → `mcap`) is a one-line change that
+ * Data sources, in the order the widget tries them:
+ * 1. GET /api/pump/coin?mint=<mint> — pump.fun's indexed coin object. Rich
+ * (logo, 24h volume, USD market cap) but mainnet-only, and it only knows a
+ * coin once pump.fun's indexer has picked it up.
+ * 2. GET /api/pump/curve?mint=<mint>&network=<n> — the on-chain bonding curve
+ * read straight off the cluster. This is the only source that exists on
+ * devnet, and it answers for a mint the indexer has not seen yet, so it is
+ * both the devnet lane and the mainnet cold-start fallback. Devnet figures
+ * are denominated in SOL: devnet SOL has no dollar value, so pricing a
+ * rehearsal coin in USD would be a fiction.
+ *
+ * Each raw shape is normalized exactly once (`mapCoin()` / `mapCurve()`) into
+ * one coin object, so renaming an upstream field is a one-line change that
* propagates to all three variants without touching any caller.
*
* Variants:
@@ -24,7 +34,10 @@
* its own refresh timer; callers just hand it a container and call destroy().
*/
+import { computeView, getSolUsd } from '../widgets/bonding-curve.js';
+
const COIN_ENDPOINT = '/api/pump/coin';
+const CURVE_ENDPOINT = '/api/pump/curve';
const ORACLE_ENDPOINT = '/api/oracle/coin';
const DEFAULT_REFRESH_MS = 30_000;
// pump.fun bonding curves complete (graduate) around a ~$69k USD market cap;
@@ -55,6 +68,23 @@ export function formatPrice(n) {
return `$${Math.round(n).toLocaleString('en-US')}`;
}
+/** Compact SOL market cap: `◎1.20K`, `◎4.31`, `◎0.0042`. */
+export function formatSolMcap(n) {
+ if (!Number.isFinite(n) || n < 0) return '—';
+ if (n >= 1e6) return `◎${(n / 1e6).toFixed(2)}M`;
+ if (n >= 1e3) return `◎${(n / 1e3).toFixed(2)}K`;
+ if (n >= 1) return `◎${n.toFixed(2)}`;
+ if (n > 0) return `◎${n.toFixed(4)}`;
+ return '◎0';
+}
+
+/** Per-token SOL price — always tiny, so significant digits over fixed places. */
+export function formatSolPrice(n) {
+ if (!Number.isFinite(n) || n <= 0) return '—';
+ if (n >= 0.01) return `◎${n.toFixed(5)}`;
+ return `◎${n.toFixed(12).replace(/0+$/, '')}`;
+}
+
/** Percentage (0–100 in, clamped): `0%`, `34%`, `7.5%`. */
export function formatPct(n) {
if (!Number.isFinite(n)) return '—';
@@ -88,6 +118,20 @@ function spokenUsd(n) {
return `${n.toFixed(2)} dollars`;
}
+// Same, for a SOL-denominated coin — a screen reader must never hear "dollars"
+// for a devnet rehearsal figure.
+function spokenSol(n) {
+ if (!Number.isFinite(n)) return 'unavailable';
+ if (n >= 1e6) return `${(n / 1e6).toFixed(2)} million SOL`;
+ if (n >= 1e3) return `${(n / 1e3).toFixed(1)} thousand SOL`;
+ if (n >= 1) return `${n.toFixed(2)} SOL`;
+ return `${n.toFixed(4)} SOL`;
+}
+
+function spokenValue(coin, n) {
+ return coin.denom === 'sol' ? spokenSol(n) : spokenUsd(n);
+}
+
// ── field mapping (the single source of truth for the API shape) ─────────────
/**
@@ -95,7 +139,7 @@ function spokenUsd(n) {
* reads from. This is the ONLY place that knows the upstream field names — a
* rename here propagates to chip, row, and card at once.
*/
-function mapCoin(raw, mint) {
+export function mapCoin(raw, mint) {
const mcap = Number(raw?.usd_market_cap);
const supplyAtomic = Number(raw?.total_supply);
// pump.fun tokens carry 6 decimals; human supply = atomic / 1e6.
@@ -120,9 +164,68 @@ function mapCoin(raw, mint) {
graduated,
volume24h: Number.isFinite(volume24h) ? volume24h : null,
createdAt: Number(raw?.created_timestamp) || null,
+ denom: 'usd',
+ network: 'mainnet',
+ source: 'indexer',
};
}
+/**
+ * Normalize a `/api/pump/curve` response — the on-chain bonding-curve read —
+ * into the same coin shape `mapCoin()` produces, so every variant renders a
+ * cluster-sourced coin without knowing where the numbers came from.
+ *
+ * `computeView` (src/widgets/bonding-curve.js) already turns the raw curve
+ * payload into market cap, per-token price and graduation progress, including
+ * the graduated-coin cases where the curve account is closed or zeroed. This
+ * reuses it rather than re-deriving the curve math a second time.
+ *
+ * @param {object|null} raw the /api/pump/curve body
+ * @param {string} mint
+ * @param {object} [o]
+ * @param {number|null} [o.solUsd] SOL price in USD. Passed on mainnet, and
+ * deliberately omitted on devnet: devnet SOL is not worth dollars, so a
+ * rehearsal coin is priced in SOL and labelled as such.
+ * @param {string} [o.network]
+ * @param {object} [o.meta] registry facts (symbol, name, launch time) the
+ * chain does not carry — the curve knows economics, not identity.
+ * @returns {object|null} null when the mint has no curve to render.
+ */
+export function mapCurve(raw, mint, { solUsd = null, network = 'mainnet', meta = null } = {}) {
+ const view = computeView(raw, solUsd);
+ if (!view || view.status === 'empty') return null;
+
+ const usable = view.hasUsd && Number.isFinite(view.marketCapUsd);
+ return {
+ mint: raw?.mint || mint,
+ symbol: meta?.symbol || '',
+ name: meta?.name || '',
+ image: meta?.image || '',
+ mcap: usable ? view.marketCapUsd : view.marketCapSol,
+ price: usable ? view.priceUsd : view.priceSol,
+ graduationPct: Number.isFinite(view.progressPct) ? view.progressPct : null,
+ graduated: view.status === 'graduated',
+ // The curve carries no trade history, so there is no 24h volume to show.
+ volume24h: null,
+ createdAt: meta?.createdAt ?? null,
+ denom: usable ? 'usd' : 'sol',
+ network: view.network || network,
+ source: 'curve',
+ };
+}
+
+/** Format a market cap in whichever unit this coin's numbers are denominated. */
+function mcapText(coin) {
+ if (coin.mcap == null) return '—';
+ return coin.denom === 'sol' ? formatSolMcap(coin.mcap) : formatMcap(coin.mcap);
+}
+
+/** Format a per-token price in whichever unit this coin's numbers are denominated. */
+function priceText(coin) {
+ if (coin.price == null) return '—';
+ return coin.denom === 'sol' ? formatSolPrice(coin.price) : formatPrice(coin.price);
+}
+
// ── tiny DOM helper ──────────────────────────────────────────────────────────
function el(tag, props = {}, children = []) {
@@ -209,11 +312,13 @@ function renderConvictionBadge(conviction) {
function renderChip(coin, opts) {
const nodes = [el('span', { class: 'csc-sym', text: coin.symbol ? `$${coin.symbol}` : shortMint(coin.mint) })];
+ const devnetTag = networkTag(coin);
+ if (devnetTag) nodes.push(devnetTag);
if (coin.price != null) {
- nodes.push(el('span', { class: 'csc-price', text: formatPrice(coin.price), 'aria-label': `Price: ${formatPrice(coin.price)} per token` }));
+ nodes.push(el('span', { class: 'csc-price', text: priceText(coin), 'aria-label': `Price: ${priceText(coin)} per token` }));
}
if (coin.mcap != null) {
- nodes.push(el('span', { class: 'csc-mcap', text: formatMcap(coin.mcap), 'aria-label': `Market cap: ${spokenUsd(coin.mcap)}` }));
+ nodes.push(el('span', { class: 'csc-mcap', text: mcapText(coin), 'aria-label': `Market cap: ${spokenValue(coin, coin.mcap)}` }));
}
if (coin.graduationPct != null) {
nodes.push(
@@ -223,7 +328,7 @@ function renderChip(coin, opts) {
}),
);
}
- if (opts.showBuy) nodes.push(buyLink(coin.mint));
+ if (opts.showBuy) nodes.push(buyLink(coin.mint, coin.network));
return el('div', { class: 'csc csc-chip' }, nodes);
}
@@ -231,17 +336,18 @@ function renderRow(coin, opts) {
const nodes = [
el('span', { class: 'csc-sym', text: coin.symbol ? `$${coin.symbol}` : coin.name || '—' }),
el('span', { class: 'csc-mono csc-mint', text: shortMint(coin.mint) }),
+ networkTag(coin),
el('span', {
class: 'csc-mcap',
- text: coin.mcap != null ? formatMcap(coin.mcap) : '—',
- 'aria-label': `Market cap: ${spokenUsd(coin.mcap)}`,
+ text: mcapText(coin),
+ 'aria-label': `Market cap: ${spokenValue(coin, coin.mcap)}`,
}),
- ];
+ ].filter(Boolean);
if (coin.volume24h != null) {
nodes.push(el('span', { class: 'csc-vol', text: `Vol ${formatMcap(coin.volume24h)}` }));
}
if (coin.createdAt) nodes.push(el('span', { class: 'csc-time', text: timeSince(coin.createdAt) }));
- if (opts.showBuy) nodes.push(buyLink(coin.mint));
+ if (opts.showBuy) nodes.push(buyLink(coin.mint, coin.network));
return el('div', { class: 'csc csc-row' }, nodes);
}
@@ -251,7 +357,8 @@ function renderCard(coin, opts) {
el('div', { class: 'csc-card-id' }, [
el('span', { class: 'csc-card-name', text: coin.name || coin.symbol || 'Coin' }),
el('span', { class: 'csc-sym', text: coin.symbol ? `$${coin.symbol}` : shortMint(coin.mint) }),
- ]),
+ networkTag(coin),
+ ].filter(Boolean)),
coin.graduationPct != null ? graduationRing(coin.graduationPct) : null,
]);
@@ -260,16 +367,16 @@ function renderCard(coin, opts) {
el('span', { class: 'csc-stat-label', text: 'Price' }),
el('span', {
class: 'csc-stat-value',
- text: coin.price != null ? formatPrice(coin.price) : '—',
- 'aria-label': coin.price != null ? `Price: ${formatPrice(coin.price)} per token` : null,
+ text: priceText(coin),
+ 'aria-label': coin.price != null ? `Price: ${priceText(coin)} per token` : null,
}),
]),
el('div', { class: 'csc-stat' }, [
el('span', { class: 'csc-stat-label', text: 'Market cap' }),
el('span', {
class: 'csc-stat-value',
- text: coin.mcap != null ? formatMcap(coin.mcap) : '—',
- 'aria-label': `Market cap: ${spokenUsd(coin.mcap)}`,
+ text: mcapText(coin),
+ 'aria-label': `Market cap: ${spokenValue(coin, coin.mcap)}`,
}),
]),
]);
@@ -292,7 +399,7 @@ function renderCard(coin, opts) {
const foot = el('div', { class: 'csc-card-foot' }, [
coin.createdAt ? el('span', { class: 'csc-time', text: `Launched ${timeSince(coin.createdAt)}` }) : null,
- opts.showBuy ? buyLink(coin.mint) : null,
+ opts.showBuy ? buyLink(coin.mint, coin.network) : null,
]);
return el('div', { class: 'csc csc-card' }, [head, stats, coin.graduationPct != null ? bar : null, badge, foot]);
@@ -318,7 +425,33 @@ function coinAvatar(coin, placeholder) {
return box;
}
-function buyLink(mint) {
+/**
+ * A "DEVNET" marker, so a rehearsal coin's real-but-worthless numbers can never
+ * read as a live market. Renders nothing on mainnet.
+ */
+function networkTag(coin) {
+ if (coin.network !== 'devnet') return null;
+ return el('span', {
+ class: 'csc-net',
+ text: 'DEVNET',
+ title: 'Launched on Solana devnet — real on-chain state, no real value',
+ });
+}
+
+/**
+ * The outbound market link. A devnet coin has no pump.fun market page, so it
+ * points at the explorer for that cluster instead of a URL that 404s.
+ */
+function buyLink(mint, network = 'mainnet') {
+ if (network === 'devnet') {
+ return el('a', {
+ class: 'csc-buy',
+ href: `https://explorer.solana.com/address/${mint}?cluster=devnet`,
+ target: '_blank',
+ rel: 'noopener noreferrer',
+ text: 'Explorer →',
+ });
+ }
return el('a', {
class: 'csc-buy',
href: `https://pump.fun/${mint}`,
@@ -362,6 +495,8 @@ const STYLES = `
.csc-price { color: var(--ink-dim, rgba(255,255,255,0.7)); }
.csc-mcap { font-weight: 600; }
.csc-grad { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: rgba(120,140,255,0.14); color: rgba(190,200,255,0.95); }
+.csc-net { font-size: 10px; font-weight: 700; letter-spacing: .07em; padding: 1px 6px; border-radius: 999px;
+ background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.35); color: #fbbf24; }
.csc-grad-done { background: rgba(120,200,140,0.16); color: rgba(170,235,190,0.95); }
.csc-buy { position: relative; z-index: 2; color: var(--accent, #7c83ff); text-decoration: none; font-weight: 600; transition: opacity .15s; }
.csc-buy:hover { opacity: .8; }
@@ -445,6 +580,14 @@ function injectStyles() {
* Hosts that already batch-fetch conviction (e.g. the
* watchlist) pass false to skip the redundant per-coin
* /api/oracle/coin round trip.
+ * @param {string} [opts.network] — 'mainnet' (default) | 'devnet'. A
+ * devnet coin is read straight off the cluster's bonding
+ * curve and rendered in SOL; there is no indexer, no
+ * Oracle score, and no pump.fun market page out there.
+ * @param {object} [opts.meta] — registry facts the chain does not
+ * carry (symbol, name, image, createdAt). Used to label
+ * the cluster-sourced lane, where economics come from the
+ * curve and identity comes from our own launch record.
* @returns {{ destroy: () => void }} — cleanup handle
*/
export function mountCoinStatus(container, mint, opts = {}) {
@@ -452,7 +595,11 @@ export function mountCoinStatus(container, mint, opts = {}) {
const refreshMs = opts.refreshMs == null ? DEFAULT_REFRESH_MS : Number(opts.refreshMs);
const showBuy = !!opts.showBuy;
const placeholder = opts.placeholder || null;
- const wantOracle = opts.oracle !== false;
+ const network = opts.network === 'devnet' ? 'devnet' : 'mainnet';
+ const meta = opts.meta || null;
+ // Devnet has no pump.fun indexer and no Oracle coverage — the cluster is the
+ // only source, so never spend a round trip discovering that again.
+ const wantOracle = opts.oracle !== false && network !== 'devnet';
// Optional observer fired with the normalized coin after every successful
// load (initial + each refresh). Lets a host surface aggregate the same live
// market data it's already paying to fetch — e.g. the launches feed's
@@ -479,6 +626,24 @@ export function mountCoinStatus(container, mint, opts = {}) {
container.replaceChildren(node);
};
+ /**
+ * Cluster-sourced read: the bonding curve itself. Sole source on devnet, and
+ * the fallback on mainnet for a coin pump.fun's indexer has not caught up to
+ * yet — which is every three.ws launch for its first minutes of life.
+ */
+ async function loadFromCurve(sig) {
+ // A devnet coin is priced in SOL on purpose (see mapCurve): asking for a
+ // USD rate would only let a worthless rehearsal figure render as dollars.
+ const [r, solUsd] = await Promise.all([
+ fetch(`${CURVE_ENDPOINT}?mint=${encodeURIComponent(mint)}&network=${network}`, { signal: sig }),
+ network === 'devnet' ? Promise.resolve(null) : getSolUsd().catch(() => null),
+ ]);
+ if (!r.ok) throw new Error(`curve api ${r.status}`);
+ const coin = mapCurve(await r.json(), mint, { solUsd, network, meta });
+ if (!coin) throw new Error('mint has no bonding curve');
+ return coin;
+ }
+
async function load({ silent = false } = {}) {
if (destroyed) return;
if (abort) abort.abort();
@@ -502,10 +667,19 @@ export function mountCoinStatus(container, mint, opts = {}) {
.catch(() => null)
: null;
- const r = await fetch(`${COIN_ENDPOINT}?mint=${encodeURIComponent(mint)}`, { signal: sig });
- if (!r.ok) throw new Error(`coin api ${r.status}`);
- const raw = await r.json();
- lastCoin = mapCoin(raw, mint);
+ if (network === 'devnet') {
+ lastCoin = await loadFromCurve(sig);
+ } else {
+ const r = await fetch(`${COIN_ENDPOINT}?mint=${encodeURIComponent(mint)}`, { signal: sig });
+ if (r.ok) {
+ lastCoin = mapCoin(await r.json(), mint);
+ } else {
+ // The indexer does not know this coin (yet). The chain always does:
+ // fall through to the curve rather than showing "unavailable" for a
+ // coin that is live and trading.
+ lastCoin = await loadFromCurve(sig);
+ }
+ }
if (oraclePromise) {
const od = await oraclePromise;
diff --git a/src/pump/coin-status-card.test.js b/src/pump/coin-status-card.test.js
index b0ba0933a..545fe6e22 100644
--- a/src/pump/coin-status-card.test.js
+++ b/src/pump/coin-status-card.test.js
@@ -3,7 +3,15 @@
// down here keeps all three surfaces rendering identically.
import { describe, it, expect } from 'vitest';
-import { formatMcap, formatPrice, formatPct } from './coin-status-card.js';
+import {
+ formatMcap,
+ formatPrice,
+ formatPct,
+ formatSolMcap,
+ formatSolPrice,
+ mapCoin,
+ mapCurve,
+} from './coin-status-card.js';
describe('formatMcap', () => {
it('renders billions, millions, and thousands compactly', () => {
@@ -59,3 +67,115 @@ describe('formatPrice', () => {
expect(formatPrice(NaN)).toBe('—');
});
});
+
+describe('SOL denomination', () => {
+ it('renders compact SOL market caps', () => {
+ expect(formatSolMcap(1_200)).toBe('◎1.20K');
+ expect(formatSolMcap(4.312)).toBe('◎4.31');
+ expect(formatSolMcap(0.0042)).toBe('◎0.0042');
+ expect(formatSolMcap(0)).toBe('◎0');
+ });
+
+ it('renders tiny per-token SOL prices without exponent notation', () => {
+ expect(formatSolPrice(0.000000028)).toBe('◎0.000000028');
+ expect(formatSolPrice(0)).toBe('—');
+ expect(formatSolPrice(NaN)).toBe('—');
+ });
+});
+
+// The on-chain lane: a bonding-curve payload from /api/pump/curve, which is the
+// only market source that exists on devnet and the fallback on mainnet while
+// pump.fun's indexer catches up to a fresh launch.
+const CURVE_MINT = '3wsSynthetic11111111111111111111111111111';
+
+function curveBody(overrides = {}) {
+ return {
+ mint: CURVE_MINT,
+ network: 'devnet',
+ curve: {
+ realSolReserves: '1200000000', // 1.2 SOL raised
+ complete: false,
+ },
+ price: {
+ marketCap: '32000000000', // 32 SOL
+ buyPricePerToken: '32', // 0.000000032 SOL
+ },
+ graduation: { progressBps: 1500, solAccumulated: '1200000000' },
+ ...overrides,
+ };
+}
+
+describe('mapCurve', () => {
+ it('prices a devnet coin in SOL and tags the network', () => {
+ const coin = mapCurve(curveBody(), CURVE_MINT, {
+ network: 'devnet',
+ meta: { symbol: 'RSL', name: 'Rehearsal', createdAt: 1_700_000_000_000 },
+ });
+ expect(coin.denom).toBe('sol');
+ expect(coin.network).toBe('devnet');
+ expect(coin.source).toBe('curve');
+ expect(coin.mcap).toBeCloseTo(32, 6);
+ expect(coin.price).toBeCloseTo(0.000000032, 12);
+ expect(coin.graduationPct).toBeCloseTo(15, 6);
+ expect(coin.graduated).toBe(false);
+ // Identity comes from our own launch record; the curve carries economics.
+ expect(coin.symbol).toBe('RSL');
+ expect(coin.createdAt).toBe(1_700_000_000_000);
+ // A bonding curve has no trade history to total up.
+ expect(coin.volume24h).toBeNull();
+ });
+
+ it('converts to USD on mainnet when a SOL price is supplied', () => {
+ const coin = mapCurve(curveBody({ network: 'mainnet' }), CURVE_MINT, {
+ network: 'mainnet',
+ solUsd: 200,
+ });
+ expect(coin.denom).toBe('usd');
+ expect(coin.mcap).toBeCloseTo(6400, 6); // 32 SOL × $200
+ });
+
+ it('falls back to SOL when the USD rate is unavailable', () => {
+ const coin = mapCurve(curveBody({ network: 'mainnet' }), CURVE_MINT, {
+ network: 'mainnet',
+ solUsd: null,
+ });
+ expect(coin.denom).toBe('sol');
+ expect(coin.mcap).toBeCloseTo(32, 6);
+ });
+
+ it('reports a graduated coin at 100% with its DEX price', () => {
+ const coin = mapCurve(
+ {
+ mint: CURVE_MINT,
+ network: 'mainnet',
+ curve: null,
+ graduated: true,
+ graduation: { isGraduated: true, progressBps: 10_000 },
+ graduatedPrice: { priceUsd: 0.00004, marketCapUsd: 40_000, source: 'jupiter' },
+ },
+ CURVE_MINT,
+ { network: 'mainnet', solUsd: 200 },
+ );
+ expect(coin.graduated).toBe(true);
+ expect(coin.graduationPct).toBe(100);
+ expect(coin.denom).toBe('usd');
+ expect(coin.mcap).toBe(40_000);
+ });
+
+ it('returns null when the mint has no curve to render', () => {
+ expect(mapCurve({ mint: CURVE_MINT, curve: null }, CURVE_MINT)).toBeNull();
+ expect(mapCurve(null, CURVE_MINT)).toBeNull();
+ });
+});
+
+describe('mapCoin', () => {
+ it('tags indexer-sourced coins as mainnet USD', () => {
+ const coin = mapCoin(
+ { mint: CURVE_MINT, symbol: 'SYN', usd_market_cap: 34_500, total_supply: 1e15 },
+ CURVE_MINT,
+ );
+ expect(coin.denom).toBe('usd');
+ expect(coin.network).toBe('mainnet');
+ expect(coin.source).toBe('indexer');
+ });
+});
diff --git a/src/widgets/bonding-curve.js b/src/widgets/bonding-curve.js
index 636cf309f..fe2607e2d 100644
--- a/src/widgets/bonding-curve.js
+++ b/src/widgets/bonding-curve.js
@@ -15,6 +15,7 @@
* lamportsToSol / fmtSol / fmtUsd / fmtPrice — pure formatters (tested)
* curveValue / curvePoints / areaPathFor — pure curve geometry (tested)
* computeView(data, solUsd) — pure view-model (tested)
+ * getSolUsd() — shared, cached SOL/USD read
* renderCardShell(view, cfg) — pure HTML string (tested)
* mountBondingCurve(rootEl, opts) — full mount + polling + anim
*
@@ -22,6 +23,8 @@
* handled by the dispatcher in kol-trades.js.
*/
+import { hasThreeWsMark } from '../solana/vanity/brand.js';
+
const LAMPORTS_PER_SOL = 1_000_000_000;
const SOL_MINT = 'So11111111111111111111111111111111111111112';
@@ -40,13 +43,16 @@ const NON_CURVE_MINTS = new Set([
'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', // USDT
]);
-// Every pump.fun mint is ground to end in the literal suffix "pump". A mint that
-// doesn't end in "pump" (or that is a known settlement token) has no bonding
-// curve — so the widget can skip the network request entirely and show its empty
-// state, never contributing to the /api/pump/curve 404 storm on a misconfigured
-// (e.g. USDC) mount.
+// Address-only pre-filter, mirroring the server's gate in
+// api/_lib/pump-curve-view.js. A pump.fun-ground mint ends in the literal
+// suffix "pump"; a three.ws-launched mint carries the "3ws" mark as a prefix
+// instead (src/solana/vanity/brand.js) and is just as curve-bearing. Anything
+// else — a settlement token, a misconfigured (e.g. USDC) mount — has no curve,
+// so the widget skips the request entirely and shows its empty state rather
+// than contributing to a /api/pump/curve 404 storm.
export function isPumpMint(mint) {
- return typeof mint === 'string' && mint.endsWith('pump') && !NON_CURVE_MINTS.has(mint);
+ if (typeof mint !== 'string' || NON_CURVE_MINTS.has(mint)) return false;
+ return mint.endsWith('pump') || hasThreeWsMark(mint);
}
// SVG geometry. viewBox is fixed; the element scales to its container.
@@ -445,7 +451,7 @@ function injectStyles(doc) {
let _solUsd = { value: null, at: 0, inflight: null };
const SOL_USD_TTL = 60_000;
-async function getSolUsd() {
+export async function getSolUsd() {
const now = Date.now();
if (_solUsd.value != null && now - _solUsd.at < SOL_USD_TTL) return _solUsd.value;
if (_solUsd.inflight) return _solUsd.inflight;