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.

Add Smart Money Radar — pump.fun wallet reputation graph + UI

nirholasda20642b8a17
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd99fa811..4bf0d7f39 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,9 +6,12 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-06-15
+- **Coin Intelligence** (`/coin-intel`) — Every pump.fun launch watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals predict winners.
+- **Coin Radar** (`/radar`) — Live pump.fun launch intelligence: every new coin scored in its first ~90 seconds — bundle vs organic, wallet concentration, dev behaviour, and risk flags from the Coin Intelligence Engine.
- **Launch a Coin** (`/launch`) — Mint a coin for your 3D AI agent in one flow — pick an agent, set the name, symbol, and image, then launch on pump.fun straight from your wallet with an optional three.ws-branded vanity mint.
- **Sniper Arena — autonomous AI agents trading live** (`/play/arena`) — Watch three.ws AI agents trade pump.fun autonomously in real time. Live P&L leaderboard, each trade signed by the agent's own wallet and verifiable on-chain.
- **The $THREE Economy** (`/three`) — How three.ws charges in $THREE, the only coin: pay-per-use pricing for AI compute, hold-to-access holder tiers with lower fees, rare *.threews.sol names, and a holder-rewards loop. No burns — every spend funds the treasury or reflects back to holders.
+- **Trader Leaderboard** (`/leaderboard`) — Pump.fun traders ranked by a provable, on-chain track record — realized P&L, win rate, drawdown — with every number traceable to its transaction.
- **After you launch a coin, jump straight to viewing or managing it** — The success screen you see right after launching a coin no longer dead-ends. Alongside the shareable card and copy/share buttons, there's now a clear set of next steps: View in 3D opens your coin as a live, interactive 3D scene; Manage on Dashboard takes you straight to that agent's control panel — with its row highlighted and ready — so you can speak, animate, and manage it; and View on pump.fun opens the coin on pump.fun. Closing the modal no longer forces a full page reload, so the rest of the page updates smoothly in place. (`/pump-dashboard`) `[improvement]`
- **Agent reputation now reflects a real pump.fun track record** — An agent's pump.fun behavior now feeds its reputation and shows on its passport. When the wallet behind an agent graduates a token, claims creator fees, makes a whale-sized buy, or launches a coin, that moment is recorded as a typed signal — graduating a token counts for more than a routine claim, and a flagged or brand-new-account claim counts against. These signals roll up into the agent's Solana reputation score and appear on the public agent passport, readable by anyone without a wallet. The live pump.fun dashboard gains a new "SIGNAL" lane that surfaces these agent-attributed events as they happen, alongside the raw mint, whale, and claim feed. The processor behind this used to sit idle unless an optional external service was configured; it now runs continuously off the platform's own live pump.fun stream with no external dependency, records only genuinely new events so nothing is double-counted, and attributes each one to the agent behind the wallet. (`/pump-dashboard`) `[improvement, fix]`
- **Agents and items are now clearly separate — a teapot won't get a brain** — Every 3D model you create is now clearly one of two things: an Agent (a character that thinks, talks, remembers, and can go on-chain) or an Item (a 3D object or prop for scenes and trading). On the review screen the choice is spelled out with a short description of each, and we pick a smart default — models from the selfie, studio, and character tools start as agents, while anything you type into existence with prompt-to-3D starts as an item, so a teapot is never pre-loaded with a brain. Pick Item and the agent-only capabilities (voice, persona, on-chain identity) step aside for a gentle note — with a one-click "made a character? make it an agent" escape hatch if the guess was wrong. The Forge tagger now groups its labels the same way, calling out that only avatars and creatures can become agents. (`/create`) `[improvement]`
@@ -53,6 +56,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Three distinct dancers, now waiting at their poles** — The Pole Club stage no longer sits empty between tips. Three dancers now stand at their own poles, lit and facing the crowd, the moment you arrive — each a different 3D avatar pulled from the gallery (still tinted to her pole's neon color) instead of copies of one model, and every dancer is auto-scaled to the same height so the lineup reads as a set. Tip a pole and that dancer steps onto it and runs her routine, then returns to her stance at the pole. No tip, no dance — same rule, just a stage that looks alive from the first second. Behind the scenes the animation engine now retargets onto more rig types, so far more uploaded avatars can actually dance. (`/club`) `[improvement]`
- **three.ws can now register itself on-chain on Solana** — Alongside its ERC-8004 identity, three.ws can now mint its own agent on Solana — as a Metaplex Core asset in the official "three.ws Agents" collection, exactly the way agents you deploy through the platform are registered. A one-command tool builds the platform's 3D Agent Card, verifies the avatar's SHA-256 against the exact GLB bytes served (so the model can't be silently swapped), pins the metadata, mints the asset into the collection, and writes the result back into the public discovery documents at three.ws/.well-known so any wallet, explorer, or agent can resolve and verify three.ws. The discovery card and its schema now carry Solana identities (CAIP-10) alongside EVM ones, and the platform agent's on-chain badge links straight to its Solana passport. (`/.well-known/agent-registration.json`) `[feature, infra]`
- **three.ws now registers itself as an on-chain agent (ERC-8004)** — The platform that helps you put your agents on-chain now does the same for itself. three.ws publishes a 3D Agent Card — a verifiable manifest of its name, its default 3D avatar, and its A2A/MCP/x402 service endpoints — at three.ws/.well-known/3d-agent-card.json, and ships a one-command tool that mints the platform agent in the canonical ERC-8004 IdentityRegistry on Base (with a Base Sepolia rehearsal first). The card cryptographically commits to the avatar: the SHA-256 in the card matches the exact GLB bytes served, so any indexer or wallet can independently verify the model hasn't been swapped. Other agents and directories can now discover and trust three.ws the same way three.ws lets them be discovered. `[feature, infra]`
+- **Trader Leaderboard — pump.fun traders ranked by a track record you can verify** — A new leaderboard ranks every trading agent by a single Trader Score that blends realized P&L, win rate, profit factor, consistency and drawdown — then holds back judgment until a trader has enough closed trades to trust. Losing trades are counted, never hidden, and fast in-and-out churn is penalized rather than rewarded. Filter by time window (24h / 7d / 30d / all-time), rank by score, P&L, win rate or ROI, and show verified traders only. Open any trader for a full profile: a score gauge, a realized-equity curve, every key metric, their open positions, and a Proof tab where each closed trade links straight to its on-chain buy and sell transaction on Solscan — the numbers come from those, nothing else. The headline score is also committed on-chain daily as a signed attestation, so it can't be quietly edited after the fact. Share any track record as a one-tap PnL card. (`/leaderboard`) `[feature]`
- **USDC-paired agent coins now record and display correct trade amounts** — Coins launched against USDC are now tracked in the right currency end to end. Every buy and sell records which quote asset it actually used and how much of it moved — USDC amounts in USDC, SOL amounts in SOL — instead of quietly storing a USDC trade as if it were SOL and reporting a price and market cap that were off by orders of magnitude. Portfolios now subtotal holdings separately by quote asset, so your SOL positions and USDC positions each get their own value, cost basis, and unrealized P&L with no more mixing of mismatched units. Existing SOL trades are unchanged, and historical rows were backfilled as SOL-paired so nothing shifts. `[fix, feature]`
- **Verify the $THREE economy on-chain — no "trust us"** — The /three economy page now shows the real, live Solana wallets behind the numbers. The treasury and the holder-rewards pool are linked straight to Solscan with their current $THREE balances, so anyone can confirm the figures themselves. We never burn supply — instead, the rewards pool is distributed pro-rata back to holders, and there's now a public 'reflected to holders' total with a run-by-run history (each future distribution links to its on-chain transaction). Value is returned to holders, not destroyed, and every claim on this page is something you can check against the chain. (`/three`) `[feature, improvement]`
- **Walk into the Pole Club as your own 3D avatar** — The club now has a way in that you control. Land on /club and you spawn outside in an alley as your own 3D avatar — move with WASD, arrows, or a touch joystick, drag to look around, and walk up to the neon door at the end of the alley. Step into range and a prompt appears: press E, tap, or click the door to pay the $0.01 cover. Pay it and your avatar walks through the club house interior while the night's anthem kicks in, then the room with the poles opens up around you. It's all real 3D, streamed from compressed scenes (~20 MB exports cut to ~1.6 MB each) and prefetched while you walk so nothing stalls. Already paid tonight? You skip the line and walk straight in. (`/club`) `[feature]`
diff --git a/api/_lib/migrations/20260615080000_smart_money.sql b/api/_lib/migrations/20260615080000_smart_money.sql
new file mode 100644
index 000000000..21c88dc0a
--- /dev/null
+++ b/api/_lib/migrations/20260615080000_smart_money.sql
@@ -0,0 +1,85 @@
+-- Migration: Smart Money Radar — a first-party pump.fun wallet reputation graph.
+-- Apply: psql "$DATABASE_URL" -f api/_lib/migrations/20260615080000_smart_money.sql
+-- (or `npm run db:migrate`). Idempotent.
+--
+-- The edge: judge a coin by WHO is buying it. We already observe every coin's
+-- per-wallet footprint (pump_coin_wallets) and we know which coins actually won
+-- (pumpfun_graduations = the coin reached Raydium). Cross those over time and
+-- each wallet earns a track record: how often it's an early buyer of eventual
+-- graduates, vs how often it sprays into duds or dumps on the people following
+-- it. That reputation, applied live to a fresh launch, is the highest-signal
+-- "should I buy this" the platform can produce — and only we can compute it in
+-- real time because we have full-coverage trade data.
+--
+-- Read-only on the engine's tables; everything below is this system's own.
+-- Mainnet-only (that is where pump.fun lives). Lamports in numeric(40,0).
+
+begin;
+
+-- One row per wallet: its accumulated, idempotently-folded track record.
+create table if not exists wallet_reputation (
+ wallet text not null,
+ network text not null default 'mainnet' check (network in ('mainnet','devnet')),
+
+ coins_traded int not null default 0, -- coins (judged) this wallet bought
+ early_entries int not null default 0, -- of those, bought within the early window
+ wins int not null default 0, -- bought a coin that later graduated
+ early_wins int not null default 0, -- early AND graduated
+ duds int not null default 0, -- bought a coin judged dead (never graduated)
+ dumps int not null default 0, -- sold ≥ half its buy inside the window
+ creator_count int not null default 0, -- coins this wallet created
+ creator_wins int not null default 0, -- of those, graduated
+ buy_volume_lamports numeric(40,0) not null default 0,
+
+ win_rate numeric not null default 0, -- wins / (wins+duds) %
+ early_win_rate numeric not null default 0, -- early_wins / early_entries %
+ dump_rate numeric not null default 0, -- dumps / (wins+duds) %
+ smart_money_score numeric not null default 0, -- 0..100 composite
+ label text not null default 'unproven',
+ -- smart_money | sniper | dumper | rugger | fresh | neutral | unproven
+
+ first_seen_at timestamptz not null default now(),
+ last_active_at timestamptz,
+ updated_at timestamptz not null default now(),
+ primary key (wallet, network)
+);
+
+create index if not exists wallet_reputation_score
+ on wallet_reputation (network, smart_money_score desc);
+create index if not exists wallet_reputation_label
+ on wallet_reputation (network, label, smart_money_score desc);
+
+-- One row per recent/live coin: how much proven money is in it right now.
+create table if not exists coin_smart_money (
+ mint text not null,
+ network text not null default 'mainnet' check (network in ('mainnet','devnet')),
+ symbol text,
+ name text,
+ image_uri text,
+ category text,
+
+ smart_money_score numeric not null default 0, -- 0..100, pedigree-weighted
+ smart_wallet_count int not null default 0, -- # proven (≥70) wallets buying
+ proven_buy_lamports numeric(40,0) not null default 0,
+ total_buy_lamports numeric(40,0) not null default 0,
+ notable jsonb not null default '[]'::jsonb, -- [{wallet,label,score,buy_sol}]
+
+ coin_first_seen_at timestamptz,
+ graduated boolean not null default false,
+ scored_at timestamptz not null default now(),
+ primary key (mint, network)
+);
+
+create index if not exists coin_smart_money_feed
+ on coin_smart_money (network, graduated, smart_money_score desc, scored_at desc);
+
+-- Idempotency cursor: a coin's wallets are folded into reputation exactly once.
+create table if not exists smart_money_scored (
+ mint text not null,
+ network text not null default 'mainnet',
+ outcome text not null check (outcome in ('graduated','dud')),
+ scored_at timestamptz not null default now(),
+ primary key (mint, network)
+);
+
+commit;
diff --git a/api/_lib/pump-intel/enrich.js b/api/_lib/pump-intel/enrich.js
new file mode 100644
index 000000000..5022361ba
--- /dev/null
+++ b/api/_lib/pump-intel/enrich.js
@@ -0,0 +1,337 @@
+// Coin Intelligence — wallet funder-graph enrichment (the bubble-map engine).
+//
+// The intel watcher records every wallet that traded a new coin, but it has no
+// chain access on the hot path, so pump_coin_wallets.funder is left null and the
+// bubble-map / "is this a bundle?" signal (bubblemap_connectivity, the `bundled`
+// wallet label, the funder clusters the /coin-intel API renders) stays dark.
+//
+// This module fills it. For a coin's top buyers it resolves each wallet's FUNDER
+// — the address that sent it its first SOL — directly from chain history, then:
+// • writes pump_coin_wallets.funder (a column nothing else writes — no clobber)
+// • recomputes bubblemap_connectivity (largest shared-funder cluster share) and
+// fresh_wallet_ratio, and merges a structured `bundle` block into the coin's
+// signals, persisting to pump_coin_intel.
+//
+// Wallets funded from a common source shortly before buying are the classic
+// sybil/bundle signature (Bubblemaps' "funding chains"). Wallets with almost no
+// prior history are fresh — a bundler/sniper tell. Both become real signals here.
+//
+// Real chain calls (Helius if configured, else the platform Solana RPC), bounded
+// and graceful: it never throws to the caller and degrades to "resolved fewer"
+// under rate limits rather than failing the request (Rule 9).
+
+import { env } from '../env.js';
+import { sql } from '../db.js';
+
+const LAMPORTS_PER_SOL = 1_000_000_000;
+// A wallet with at most this many lifetime transactions is "fresh" — a brand-new
+// wallet funded once and pointed at a launch is the bundler/sniper fingerprint.
+const FRESH_TX_MAX = 12;
+// Pagination cap when hunting a wallet's earliest tx. Fresh wallets resolve in
+// one page; this bounds the work for old wallets we'll mark not-fresh anyway.
+const MAX_SIG_PAGES = 3;
+const SIG_PAGE = 1000;
+const RPC_TIMEOUT_MS = 8_000;
+// System program + common no-signal sources we never treat as a "funder".
+const NON_FUNDERS = new Set([
+ '11111111111111111111111111111111', // System Program
+ 'So11111111111111111111111111111111111111112', // Wrapped SOL
+]);
+
+/** Best RPC endpoint for the cluster: Helius when keyed (high rate limits), else the platform RPC. */
+export function rpcEndpoint(network = 'mainnet') {
+ if (network === 'devnet') return env.SOLANA_RPC_URL_DEVNET;
+ const key = env.HELIUS_API_KEY;
+ if (key) return `https://mainnet.helius-rpc.com/?api-key=${key}`;
+ return env.SOLANA_RPC_URL;
+}
+
+async function rpc(endpoint, method, params) {
+ const r = await fetch(endpoint, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
+ signal: AbortSignal.timeout(RPC_TIMEOUT_MS),
+ });
+ if (!r.ok) {
+ const e = new Error(`rpc ${method} ${r.status}`);
+ e.status = r.status;
+ throw e;
+ }
+ const body = await r.json();
+ if (body.error) throw new Error(`rpc ${method}: ${body.error.message || body.error.code}`);
+ return body.result;
+}
+
+/**
+ * Parse the funder of `address` from its earliest transaction. Pure — given a
+ * jsonParsed getTransaction result, find who sent SOL into the wallet.
+ *
+ * Two layers: (1) an explicit system `transfer`/`transferChecked` whose
+ * destination is the wallet → its source is the funder (the precise case);
+ * (2) fallback — the wallet's balance rose in this tx and the fee payer (first
+ * signer) is someone else → the fee payer funded it (covers CEX/program routes).
+ * Returns the funder address or null. Exported for unit testing.
+ */
+export function parseFunderFromTransaction(tx, address) {
+ if (!tx?.transaction?.message) return null;
+ const msg = tx.transaction.message;
+
+ const scanIxList = (list) => {
+ for (const ix of list || []) {
+ const p = ix?.parsed;
+ if (!p || (ix.program !== 'system' && ix.programId !== '11111111111111111111111111111111')) continue;
+ const t = p.type;
+ if (t !== 'transfer' && t !== 'transferChecked' && t !== 'createAccount' && t !== 'createAccountWithSeed') continue;
+ const info = p.info || {};
+ const dest = info.destination || info.newAccount;
+ const src = info.source || info.lamports?.source || info.from;
+ if (dest === address && src && src !== address && !NON_FUNDERS.has(src)) {
+ return { funder: src, lamports: Number(info.lamports) || null };
+ }
+ }
+ return null;
+ };
+
+ // (1) outer instructions, then inner instructions (CEX withdrawals nest).
+ const outer = scanIxList(msg.instructions);
+ if (outer) return outer;
+ for (const inner of tx.meta?.innerInstructions || []) {
+ const hit = scanIxList(inner.instructions);
+ if (hit) return hit;
+ }
+
+ // (2) balance-delta fallback: did this wallet receive SOL, and who paid?
+ const keys = msg.accountKeys || [];
+ const idx = keys.findIndex((k) => (typeof k === 'string' ? k : k.pubkey) === address);
+ const pre = tx.meta?.preBalances;
+ const post = tx.meta?.postBalances;
+ if (idx >= 0 && Array.isArray(pre) && Array.isArray(post) && post[idx] > pre[idx]) {
+ const feePayer = typeof keys[0] === 'string' ? keys[0] : keys[0]?.pubkey;
+ if (feePayer && feePayer !== address && !NON_FUNDERS.has(feePayer)) {
+ return { funder: feePayer, lamports: post[idx] - pre[idx] };
+ }
+ }
+ return null;
+}
+
+/**
+ * Resolve one wallet's funder + freshness from chain history.
+ * @returns {Promise<{ funder: string|null, fundedLamports: number|null, priorTxCount: number, fresh: boolean }|null>}
+ */
+export async function resolveFunder(address, { endpoint }) {
+ if (!address) return null;
+ // Page back to the wallet's earliest signature (and count its history).
+ let page = await rpc(endpoint, 'getSignaturesForAddress', [address, { limit: SIG_PAGE }]);
+ if (!Array.isArray(page) || !page.length) return null;
+ let earliest = page[page.length - 1];
+ let total = page.length;
+ let pages = 1;
+ while (page.length === SIG_PAGE && pages < MAX_SIG_PAGES) {
+ page = await rpc(endpoint, 'getSignaturesForAddress', [address, { limit: SIG_PAGE, before: earliest.signature }]);
+ if (!Array.isArray(page) || !page.length) break;
+ earliest = page[page.length - 1];
+ total += page.length;
+ pages++;
+ }
+ const fresh = page.length < SIG_PAGE && total <= FRESH_TX_MAX;
+
+ const tx = await rpc(endpoint, 'getTransaction', [
+ earliest.signature,
+ { encoding: 'jsonParsed', maxSupportedTransactionVersion: 0, commitment: 'confirmed' },
+ ]);
+ const parsed = parseFunderFromTransaction(tx, address);
+ return {
+ funder: parsed?.funder || null,
+ fundedLamports: parsed?.lamports ?? null,
+ priorTxCount: total,
+ fresh,
+ };
+}
+
+// Bounded-concurrency map — keeps RPC pressure (and 429s) in check.
+async function mapPool(items, concurrency, fn) {
+ const out = new Array(items.length);
+ let next = 0;
+ const worker = async () => {
+ while (next < items.length) {
+ const i = next++;
+ try { out[i] = await fn(items[i], i); }
+ catch (err) { out[i] = { error: err?.message || 'failed' }; }
+ }
+ };
+ await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, worker));
+ return out;
+}
+
+/**
+ * bubblemap_connectivity = share of known-funder wallets that sit in the single
+ * largest shared-funder cluster. Mirrors signals.js bubblemapConnectivity so the
+ * worker's and the enricher's numbers mean exactly the same thing. 0..1, or null
+ * when fewer than 3 wallets have a known funder (not enough to claim a cluster).
+ */
+export function connectivityFromFunders(funderByWallet) {
+ const counts = new Map();
+ let known = 0;
+ for (const f of Object.values(funderByWallet)) {
+ if (!f) continue;
+ known++;
+ counts.set(f, (counts.get(f) || 0) + 1);
+ }
+ if (known < 3) return { connectivity: null, known, largest_cluster: 0, clusters: 0 };
+ const sizes = [...counts.values()];
+ const largest = Math.max(...sizes);
+ const clusters = sizes.filter((n) => n >= 2).length;
+ return { connectivity: Math.round((largest / known) * 1e4) / 1e4, known, largest_cluster: largest, clusters };
+}
+
+/**
+ * Resolve funders for a coin's top buyers and write them to pump_coin_wallets.
+ * Only touches wallets without a funder already (idempotent, no clobber).
+ * @returns {Promise<{ funders: Record<string,string>, resolved: number, attempted: number, fresh: number, source: string }>}
+ */
+export async function enrichCoinFunders({ mint, wallets, network = 'mainnet', max = 16, concurrency = 3 }) {
+ const endpoint = rpcEndpoint(network);
+ const source = env.HELIUS_API_KEY ? 'helius' : 'rpc';
+ // Rank by buy size; the biggest early buyers are what bundle detection cares about.
+ const targets = (wallets || [])
+ .filter((w) => w.wallet && !w.funder)
+ .sort((a, b) => (Number(b.buy_lamports) || 0) - (Number(a.buy_lamports) || 0))
+ .slice(0, max);
+
+ const funders = {};
+ let fresh = 0;
+ if (!targets.length) return { funders, resolved: 0, attempted: 0, fresh: 0, source };
+
+ const results = await mapPool(targets, concurrency, (w) => resolveFunder(w.wallet, { endpoint }));
+
+ const updates = [];
+ results.forEach((res, i) => {
+ if (!res || res.error) return;
+ if (res.fresh) fresh++;
+ if (res.funder) {
+ funders[targets[i].wallet] = res.funder;
+ updates.push({ wallet: targets[i].wallet, funder: res.funder });
+ }
+ });
+
+ // Persist funders (only where still null — never overwrite the worker or a prior pass).
+ for (const u of updates) {
+ try {
+ await sql`
+ update pump_coin_wallets set funder = ${u.funder}
+ where mint = ${mint} and wallet = ${u.wallet} and funder is null
+ `;
+ } catch (err) {
+ console.warn('[coin-intel-enrich] funder write failed:', err?.message);
+ }
+ }
+
+ return { funders, resolved: updates.length, attempted: targets.length, fresh, source };
+}
+
+/**
+ * Recompute the funder-dependent signals for a coin from whatever funders are now
+ * known, and persist them: bubblemap_connectivity, fresh_wallet_ratio, a bundle
+ * block merged into signals, and the bundle_launch risk flag when warranted.
+ * @returns {Promise<{ bubblemap_connectivity:number|null, bundle:object }>}
+ */
+export async function recomputeAndPersist({ mint, network = 'mainnet', freshCount = null, attempted = null }) {
+ const rows = await sql`
+ select wallet, buy_lamports, sell_lamports, is_creator, funder
+ from pump_coin_wallets where mint = ${mint}
+ `;
+ const funderByWallet = {};
+ let buyVolume = 0;
+ const buyByWallet = new Map();
+ for (const w of rows) {
+ const b = Number(w.buy_lamports) || 0;
+ buyVolume += b;
+ buyByWallet.set(w.wallet, b);
+ if (w.funder) funderByWallet[w.wallet] = w.funder;
+ }
+ const conn = connectivityFromFunders(funderByWallet);
+
+ // Share of buy volume that flowed through multi-wallet shared-funder clusters.
+ const clusterMembers = new Map(); // funder -> [wallets]
+ for (const [wallet, funder] of Object.entries(funderByWallet)) {
+ if (!clusterMembers.has(funder)) clusterMembers.set(funder, []);
+ clusterMembers.get(funder).push(wallet);
+ }
+ let bundledVol = 0;
+ let bundleWallets = 0;
+ for (const members of clusterMembers.values()) {
+ if (members.length < 2) continue;
+ bundleWallets += members.length;
+ for (const w of members) bundledVol += buyByWallet.get(w) || 0;
+ }
+ const bundleBuyPct = buyVolume > 0 ? Math.round((bundledVol / buyVolume) * 1000) / 10 : 0;
+
+ const bundle = {
+ bundle_detected: bundleWallets >= 2,
+ bundle_wallet_count: bundleWallets,
+ bundle_buy_pct: bundleBuyPct,
+ cluster_count: conn.clusters,
+ funders_known: conn.known,
+ funder_source: env.HELIUS_API_KEY ? 'helius' : 'rpc',
+ ...(attempted != null ? { wallets_probed: attempted } : {}),
+ };
+ // fresh_wallet_ratio over the probed set, when we measured it.
+ const freshRatio = (freshCount != null && attempted)
+ ? Math.round((freshCount / attempted) * 1e4) / 1e4
+ : null;
+
+ try {
+ await sql`
+ update pump_coin_intel set
+ bubblemap_connectivity = ${conn.connectivity}::numeric,
+ fresh_wallet_ratio = coalesce(${freshRatio}::numeric, fresh_wallet_ratio),
+ signals = coalesce(signals, '{}'::jsonb) || ${JSON.stringify({ bundle, bubblemap_connectivity: conn.connectivity, ...(freshRatio != null ? { fresh_wallet_ratio: freshRatio } : {}) })}::jsonb,
+ risk_flags = (
+ select array(
+ select distinct unnest(
+ coalesce(risk_flags, '{}') || case when ${bundle.bundle_detected && bundleBuyPct >= 25} then array['bundle_launch'] else '{}'::text[] end
+ )
+ )
+ ),
+ updated_at = now()
+ where mint = ${mint} and network = ${network}
+ `;
+ } catch (err) {
+ console.warn('[coin-intel-enrich] signal persist failed:', err?.message);
+ }
+
+ return { bubblemap_connectivity: conn.connectivity, fresh_wallet_ratio: freshRatio, bundle };
+}
+
+/**
+ * Full enrichment for one coin: resolve funders for its top buyers, then
+ * recompute + persist the funder-dependent signals. The orchestrator the API
+ * endpoint and any backfill job calls. Never throws — returns a result envelope.
+ */
+export async function enrichCoin({ mint, network = 'mainnet', max = 16, concurrency = 3 }) {
+ try {
+ const rows = await sql`
+ select wallet, buy_lamports, sell_lamports, is_creator, funder
+ from pump_coin_wallets where mint = ${mint}
+ order by buy_lamports desc limit 200
+ `;
+ if (!rows.length) return { ok: false, reason: 'no_wallets', mint };
+ const already = rows.every((w) => w.funder) ? rows.length : 0;
+
+ const { funders, resolved, attempted, fresh, source } =
+ await enrichCoinFunders({ mint, wallets: rows, network, max, concurrency });
+
+ const signals = await recomputeAndPersist({ mint, network, freshCount: fresh, attempted });
+
+ return {
+ ok: true, mint, network, source,
+ resolved, attempted, fresh,
+ already_known: already,
+ ...signals,
+ };
+ } catch (err) {
+ console.warn('[coin-intel-enrich] enrichCoin failed:', err?.message);
+ return { ok: false, reason: 'enrich_failed', error: err?.message, mint };
+ }
+}
diff --git a/api/cron/smart-money-rollup.js b/api/cron/smart-money-rollup.js
new file mode 100644
index 000000000..1dfe23fa7
--- /dev/null
+++ b/api/cron/smart-money-rollup.js
@@ -0,0 +1,351 @@
+// GET /api/cron/smart-money-rollup — build the pump.fun wallet reputation graph.
+//
+// The Smart Money Radar's engine. Three phases, all first-party — no external
+// price oracle:
+//
+// A. JUDGE & FOLD. Take coins old enough to judge that we haven't scored yet.
+// Outcome is unambiguous: in pumpfun_graduations → 'graduated' (a win),
+// else 'dud'. Fold every buyer's footprint on that coin into its running
+// reputation record. Each coin is folded exactly once (smart_money_scored).
+// B. RECOMPUTE. Re-derive score + label for every wallet we just touched.
+// C. SCORE LIVE. For coins launched in the last few hours, rank them by the
+// pedigree of the money buying them right now (coin_smart_money) — that is
+// what the radar feed and a follow-the-smart-money sniper read.
+//
+// Reads the engine's tables (pump_coin_intel / pump_coin_wallets) and the
+// graduation feed read-only; writes only this system's own tables. Mainnet-only
+// (pump_coin_wallets / pumpfun_graduations are mainnet). Idempotent + bounded so
+// a 5-minute cron can never run away.
+
+import { error, json, method, wrap } from '../_lib/http.js';
+import { env } from '../_lib/env.js';
+import { constantTimeEquals } from '../_lib/crypto.js';
+import { sql } from '../_lib/db.js';
+import { attributeCoin, computeReputation } from '../../src/pump/wallet-reputation.js';
+import { computeCoinSmartMoney } from '../../src/pump/smart-money-score.js';
+
+const NETWORK = 'mainnet';
+const JUDGE_AFTER_HOURS = 6; // a coin must be this old before "never graduated" = dud
+const MAX_AGE_DAYS = 14; // don't reach back further than this
+const COINS_PER_RUN = 80; // judge+fold at most this many coins per run
+const TOP_WALLETS = 60; // per coin, cap wallets folded/scored
+const LIVE_WINDOW_HOURS = 3; // score coins launched within this window
+const LIVE_COINS = 150;
+
+function requireCron(req, res) {
+ const secret = process.env.CRON_SECRET || env.CRON_SECRET;
+ if (!secret) {
+ error(res, 503, 'not_configured', 'CRON_SECRET unset');
+ return false;
+ }
+ const auth = req.headers['authorization'] || '';
+ const presented = auth.startsWith('Bearer ') ? auth.slice(7) : '';
+ if (!constantTimeEquals(presented, secret)) {
+ error(res, 401, 'unauthorized', 'invalid cron secret');
+ return false;
+ }
+ return true;
+}
+
+export default wrap(async (req, res) => {
+ if (!method(req, res, ['GET', 'POST'])) return;
+ if (!requireCron(req, res)) return;
+
+ const started = Date.now();
+ const folded = await judgeAndFold();
+ const recomputed = await recomputeTouched(folded.touchedWallets);
+ const live = await scoreLiveCoins();
+
+ return json(res, 200, {
+ ok: true,
+ network: NETWORK,
+ coins_judged: folded.coinsJudged,
+ graduates: folded.graduates,
+ wallets_touched: folded.touchedWallets.length,
+ wallets_recomputed: recomputed,
+ live_coins_scored: live.scored,
+ smart_money_coins: live.withSmartMoney,
+ remaining_unjudged: folded.remaining,
+ took_ms: Date.now() - started,
+ });
+});
+
+// ── Phase A: judge newly-rated coins and fold buyers into reputation ─────────
+async function judgeAndFold() {
+ const candidates = await sql`
+ SELECT i.mint, extract(epoch from i.first_seen_at)::bigint AS first_ts
+ FROM pump_coin_intel i
+ WHERE i.network = ${NETWORK}
+ AND i.first_seen_at < now() - make_interval(hours => ${JUDGE_AFTER_HOURS})
+ AND i.first_seen_at > now() - make_interval(days => ${MAX_AGE_DAYS})
+ AND NOT EXISTS (
+ SELECT 1 FROM smart_money_scored s
+ WHERE s.mint = i.mint AND s.network = ${NETWORK}
+ )
+ ORDER BY i.first_seen_at ASC
+ LIMIT ${COINS_PER_RUN}
+ `;
+ if (!candidates.length) {
+ return { coinsJudged: 0, graduates: 0, touchedWallets: [], remaining: 0 };
+ }
+
+ const mints = candidates.map((c) => c.mint);
+ const gradRows = await sql`SELECT mint FROM pumpfun_graduations WHERE mint = ANY(${mints})`;
+ const graduated = new Set(gradRows.map((r) => r.mint));
+
+ // wallet → accumulated delta across every coin in this run.
+ const deltas = new Map();
+ const bump = (wallet, d) => {
+ const cur = deltas.get(wallet) || zeroDelta();
+ for (const k of DELTA_KEYS) cur[k] += d[k];
+ deltas.set(wallet, cur);
+ };
+
+ for (const coin of candidates) {
+ const outcome = graduated.has(coin.mint) ? 'graduated' : 'dud';
+ const wallets = await sql`
+ SELECT wallet, buy_lamports, sell_lamports, is_creator,
+ extract(epoch from first_seen_at)::bigint AS first_ts
+ FROM pump_coin_wallets
+ WHERE mint = ${coin.mint}
+ ORDER BY buy_lamports DESC
+ LIMIT ${TOP_WALLETS}
+ `;
+ for (const w of wallets) {
+ const d = attributeCoin({
+ outcome,
+ wallet: {
+ buy_lamports: Number(w.buy_lamports),
+ sell_lamports: Number(w.sell_lamports),
+ first_seen_ts: Number(w.first_ts),
+ is_creator: w.is_creator,
+ },
+ coinFirstSeenTs: Number(coin.first_ts),
+ });
+ bump(w.wallet, d);
+ }
+ }
+
+ if (deltas.size) {
+ const wallets = [...deltas.keys()];
+ const cols = Object.fromEntries(DELTA_KEYS.map((k) => [k, wallets.map((w) => deltas.get(w)[k])]));
+ await sql`
+ INSERT INTO wallet_reputation
+ (wallet, network, coins_traded, early_entries, wins, early_wins, duds, dumps,
+ creator_count, creator_wins, buy_volume_lamports, last_active_at, updated_at)
+ SELECT u.wallet, ${NETWORK}, u.coins_traded, u.early_entries, u.wins, u.early_wins, u.duds, u.dumps,
+ u.creator_count, u.creator_wins, u.buy_volume_lamports, now(), now()
+ FROM unnest(
+ ${wallets}::text[],
+ ${cols.coins_traded}::int[],
+ ${cols.early_entries}::int[],
+ ${cols.wins}::int[],
+ ${cols.early_wins}::int[],
+ ${cols.duds}::int[],
+ ${cols.dumps}::int[],
+ ${cols.creator_count}::int[],
+ ${cols.creator_wins}::int[],
+ ${cols.buy_volume_lamports.map(String)}::numeric[]
+ ) AS u(wallet, coins_traded, early_entries, wins, early_wins, duds, dumps,
+ creator_count, creator_wins, buy_volume_lamports)
+ ON CONFLICT (wallet, network) DO UPDATE SET
+ coins_traded = wallet_reputation.coins_traded + EXCLUDED.coins_traded,
+ early_entries = wallet_reputation.early_entries + EXCLUDED.early_entries,
+ wins = wallet_reputation.wins + EXCLUDED.wins,
+ early_wins = wallet_reputation.early_wins + EXCLUDED.early_wins,
+ duds = wallet_reputation.duds + EXCLUDED.duds,
+ dumps = wallet_reputation.dumps + EXCLUDED.dumps,
+ creator_count = wallet_reputation.creator_count + EXCLUDED.creator_count,
+ creator_wins = wallet_reputation.creator_wins + EXCLUDED.creator_wins,
+ buy_volume_lamports = wallet_reputation.buy_volume_lamports + EXCLUDED.buy_volume_lamports,
+ last_active_at = now(),
+ updated_at = now()
+ `;
+ }
+
+ // Mark every judged coin scored so it's never folded twice.
+ const outcomes = candidates.map((c) => (graduated.has(c.mint) ? 'graduated' : 'dud'));
+ await sql`
+ INSERT INTO smart_money_scored (mint, network, outcome)
+ SELECT u.mint, ${NETWORK}, u.outcome
+ FROM unnest(${mints}::text[], ${outcomes}::text[]) AS u(mint, outcome)
+ ON CONFLICT (mint, network) DO NOTHING
+ `;
+
+ const [{ remaining }] = await sql`
+ SELECT count(*)::int AS remaining
+ FROM pump_coin_intel i
+ WHERE i.network = ${NETWORK}
+ AND i.first_seen_at < now() - make_interval(hours => ${JUDGE_AFTER_HOURS})
+ AND i.first_seen_at > now() - make_interval(days => ${MAX_AGE_DAYS})
+ AND NOT EXISTS (SELECT 1 FROM smart_money_scored s WHERE s.mint = i.mint AND s.network = ${NETWORK})
+ `;
+
+ return {
+ coinsJudged: candidates.length,
+ graduates: graduated.size,
+ touchedWallets: [...deltas.keys()],
+ remaining: Number(remaining) || 0,
+ };
+}
+
+// ── Phase B: recompute score + label for the wallets we just touched ─────────
+async function recomputeTouched(touched) {
+ if (!touched.length) return 0;
+ const rows = await sql`
+ SELECT wallet, wins, duds, early_entries, early_wins, dumps, coins_traded,
+ creator_count, creator_wins
+ FROM wallet_reputation
+ WHERE network = ${NETWORK} AND wallet = ANY(${touched})
+ `;
+ if (!rows.length) return 0;
+
+ const wallets = [];
+ const winRate = [];
+ const earlyWinRate = [];
+ const dumpRate = [];
+ const score = [];
+ const label = [];
+ for (const r of rows) {
+ const rep = computeReputation(r);
+ wallets.push(r.wallet);
+ winRate.push(rep.win_rate);
+ earlyWinRate.push(rep.early_win_rate);
+ dumpRate.push(rep.dump_rate);
+ score.push(rep.smart_money_score);
+ label.push(rep.label);
+ }
+ await sql`
+ UPDATE wallet_reputation w SET
+ win_rate = u.win_rate,
+ early_win_rate = u.early_win_rate,
+ dump_rate = u.dump_rate,
+ smart_money_score = u.score,
+ label = u.label,
+ updated_at = now()
+ FROM unnest(
+ ${wallets}::text[],
+ ${winRate}::numeric[],
+ ${earlyWinRate}::numeric[],
+ ${dumpRate}::numeric[],
+ ${score}::numeric[],
+ ${label}::text[]
+ ) AS u(wallet, win_rate, early_win_rate, dump_rate, score, label)
+ WHERE w.wallet = u.wallet AND w.network = ${NETWORK}
+ `;
+ return rows.length;
+}
+
+// ── Phase C: score the coins trading right now by their buyers' pedigree ─────
+async function scoreLiveCoins() {
+ const coins = await sql`
+ SELECT mint, symbol, name, image_uri, category, first_seen_at
+ FROM pump_coin_intel
+ WHERE network = ${NETWORK} AND first_seen_at > now() - make_interval(hours => ${LIVE_WINDOW_HOURS})
+ ORDER BY first_seen_at DESC
+ LIMIT ${LIVE_COINS}
+ `;
+ if (!coins.length) return { scored: 0, withSmartMoney: 0 };
+
+ const mints = coins.map((c) => c.mint);
+ // Top buyers per coin in one round trip (window-limited).
+ const walletRows = await sql`
+ SELECT mint, wallet, buy_lamports, is_creator FROM (
+ SELECT mint, wallet, buy_lamports, is_creator,
+ row_number() OVER (PARTITION BY mint ORDER BY buy_lamports DESC) AS rn
+ FROM pump_coin_wallets
+ WHERE mint = ANY(${mints}) AND buy_lamports > 0
+ ) t WHERE rn <= ${TOP_WALLETS}
+ `;
+ const gradRows = await sql`SELECT mint FROM pumpfun_graduations WHERE mint = ANY(${mints})`;
+ const graduated = new Set(gradRows.map((r) => r.mint));
+
+ const byCoin = new Map();
+ const allWallets = new Set();
+ for (const r of walletRows) {
+ if (!byCoin.has(r.mint)) byCoin.set(r.mint, []);
+ byCoin.get(r.mint).push({ wallet: r.wallet, buy_lamports: Number(r.buy_lamports), is_creator: r.is_creator });
+ allWallets.add(r.wallet);
+ }
+
+ const repMap = new Map();
+ if (allWallets.size) {
+ const repRows = await sql`
+ SELECT wallet, smart_money_score, label
+ FROM wallet_reputation
+ WHERE network = ${NETWORK} AND wallet = ANY(${[...allWallets]})
+ `;
+ for (const r of repRows) repMap.set(r.wallet, { smart_money_score: Number(r.smart_money_score), label: r.label });
+ }
+
+ const out = {
+ mint: [], symbol: [], name: [], image: [], category: [],
+ score: [], smartCount: [], provenBuy: [], totalBuy: [], notable: [], firstSeen: [], grad: [],
+ };
+ let withSmartMoney = 0;
+ for (const coin of coins) {
+ const wallets = byCoin.get(coin.mint) || [];
+ const r = computeCoinSmartMoney(wallets, repMap);
+ if (r.smart_wallet_count > 0) withSmartMoney++;
+ out.mint.push(coin.mint);
+ out.symbol.push(coin.symbol || null);
+ out.name.push(coin.name || null);
+ out.image.push(coin.image_uri || null);
+ out.category.push(coin.category || null);
+ out.score.push(r.smart_money_score);
+ out.smartCount.push(r.smart_wallet_count);
+ out.provenBuy.push(String(r.proven_buy_lamports));
+ out.totalBuy.push(String(r.total_buy_lamports));
+ out.notable.push(JSON.stringify(r.notable));
+ out.firstSeen.push(coin.first_seen_at ? new Date(coin.first_seen_at).toISOString() : null);
+ out.grad.push(graduated.has(coin.mint));
+ }
+
+ await sql`
+ INSERT INTO coin_smart_money
+ (mint, network, symbol, name, image_uri, category, smart_money_score, smart_wallet_count,
+ proven_buy_lamports, total_buy_lamports, notable, coin_first_seen_at, graduated, scored_at)
+ SELECT u.mint, ${NETWORK}, u.symbol, u.name, u.image, u.category, u.score, u.smart_count,
+ u.proven_buy, u.total_buy, u.notable::jsonb, u.first_seen, u.grad, now()
+ FROM unnest(
+ ${out.mint}::text[],
+ ${out.symbol}::text[],
+ ${out.name}::text[],
+ ${out.image}::text[],
+ ${out.category}::text[],
+ ${out.score}::numeric[],
+ ${out.smartCount}::int[],
+ ${out.provenBuy}::numeric[],
+ ${out.totalBuy}::numeric[],
+ ${out.notable}::text[],
+ ${out.firstSeen}::timestamptz[],
+ ${out.grad}::boolean[]
+ ) AS u(mint, symbol, name, image, category, score, smart_count,
+ proven_buy, total_buy, notable, first_seen, grad)
+ ON CONFLICT (mint, network) DO UPDATE SET
+ symbol = EXCLUDED.symbol,
+ name = EXCLUDED.name,
+ image_uri = EXCLUDED.image_uri,
+ category = EXCLUDED.category,
+ smart_money_score = EXCLUDED.smart_money_score,
+ smart_wallet_count = EXCLUDED.smart_wallet_count,
+ proven_buy_lamports = EXCLUDED.proven_buy_lamports,
+ total_buy_lamports = EXCLUDED.total_buy_lamports,
+ notable = EXCLUDED.notable,
+ graduated = EXCLUDED.graduated,
+ scored_at = now()
+ `;
+
+ return { scored: coins.length, withSmartMoney };
+}
+
+// ── delta bookkeeping ────────────────────────────────────────────────────────
+const DELTA_KEYS = [
+ 'coins_traded', 'early_entries', 'wins', 'early_wins', 'duds', 'dumps',
+ 'creator_count', 'creator_wins', 'buy_volume_lamports',
+];
+function zeroDelta() {
+ const d = {};
+ for (const k of DELTA_KEYS) d[k] = 0;
+ return d;
+}
diff --git a/api/pump/intel-enrich.js b/api/pump/intel-enrich.js
new file mode 100644
index 000000000..12965feb4
--- /dev/null
+++ b/api/pump/intel-enrich.js
@@ -0,0 +1,93 @@
+// POST/GET /api/pump/intel-enrich
+// -------------------------------
+// Lights up the bubble-map. The intel engine records every wallet that traded a
+// new coin but never resolves WHO FUNDED those wallets, so pump_coin_wallets.funder
+// is null and the funder-cluster / bundle / bubblemap_connectivity signals the
+// /coin-intel API and radar render stay empty. This endpoint resolves funders
+// from chain history (api/_lib/pump-intel/enrich.js) and persists them, turning a
+// designed-but-dark signal into a real one — the "is this coordinated or organic?"
+// answer the whole engine was built to give.
+//
+// ?mint=<mint>&network=mainnet enrich ONE coin's top buyers (the "deep scan")
+// ?recent=<n>&network=mainnet backfill the n freshest not-yet-enriched coins (cap 8)
+//
+// Writes only pump_coin_wallets.funder (a column nothing else writes) and the
+// funder-derived signal fields on pump_coin_intel — no clobber of the watcher's
+// writes. Makes bounded chain calls, so it's rate-limited harder than the reads.
+// Idempotent: re-running skips wallets whose funder is already known.
+
+import { cors, json, method, wrap, error, rateLimited } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { sql } from '../_lib/db.js';
+import { enrichCoin } from '../_lib/pump-intel/enrich.js';
+
+const NETWORKS = new Set(['mainnet', 'devnet']);
+const ADDR_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
+const MAX_BACKFILL = 8;
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,POST,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET', 'POST'])) return;
+
+ // Bounded chain work per call → the meta limiter (60 / 10 min / IP) fits.
+ const rl = await limits.pumpMetaIp(clientIp(req));
+ if (!rl.success) return rateLimited(res, rl);
+
+ const p = new URL(req.url, `http://${req.headers.host || 'x'}`).searchParams;
+ const network = NETWORKS.has(p.get('network')) ? p.get('network') : 'mainnet';
+ const mint = (p.get('mint') || '').trim();
+ const recent = p.get('recent');
+
+ // ── single-coin deep scan ────────────────────────────────────────────────
+ if (mint) {
+ if (!ADDR_RE.test(mint)) {
+ return error(res, 400, 'invalid_mint', 'mint must be a base58 pump.fun address');
+ }
+ const result = await enrichCoin({ mint, network });
+ if (!result.ok && result.reason === 'no_wallets') {
+ return error(res, 404, 'not_found', 'No observed wallets for this coin yet — it may be outside the radar window.');
+ }
+ return json(res, 200, result, { 'cache-control': 'no-store' });
+ }
+
+ // ── bounded backfill of the freshest un-enriched coins ───────────────────
+ if (recent != null) {
+ const n = Math.max(1, Math.min(MAX_BACKFILL, parseInt(recent, 10) || 3));
+ let mints = [];
+ try {
+ // Coins observed recently whose wallet ledger has NO funder resolved yet.
+ const rows = await sql`
+ select i.mint
+ from pump_coin_intel i
+ where i.network = ${network}
+ and i.first_seen_at >= now() - interval '6 hours'
+ and not exists (
+ select 1 from pump_coin_wallets w
+ where w.mint = i.mint and w.funder is not null
+ )
+ and exists (
+ select 1 from pump_coin_wallets w where w.mint = i.mint
+ )
+ order by i.first_seen_at desc
+ limit ${n}
+ `;
+ mints = rows.map((r) => r.mint);
+ } catch (err) {
+ return error(res, 503, 'intel_unavailable', 'intel store is temporarily unavailable');
+ }
+ if (!mints.length) {
+ return json(res, 200, { network, backfilled: 0, results: [], note: 'nothing to enrich' },
+ { 'cache-control': 'no-store' });
+ }
+ // Sequential — bounds total chain pressure across coins per invocation.
+ const results = [];
+ for (const m of mints) results.push(await enrichCoin({ mint: m, network }));
+ return json(res, 200, {
+ network,
+ backfilled: results.filter((r) => r.ok).length,
+ results,
+ }, { 'cache-control': 'no-store' });
+ }
+
+ return error(res, 400, 'bad_request', 'pass ?mint=<mint> for a deep scan, or ?recent=<n> to backfill.');
+});
diff --git a/api/pump/smart-money.js b/api/pump/smart-money.js
new file mode 100644
index 000000000..ccdfef698
--- /dev/null
+++ b/api/pump/smart-money.js
@@ -0,0 +1,235 @@
+/**
+ * Smart Money Radar — public read API.
+ *
+ * GET /api/pump/smart-money → live feed: coins ranked by
+ * &min_score=20&limit=50&graduated=0 the pedigree of money in them
+ * GET /api/pump/smart-money?leaderboard=1 → top wallets by track record
+ * &label=smart_money&min_coins=8&limit=50
+ * GET /api/pump/smart-money?wallet=<addr> → one wallet's reputation card
+ * GET /api/pump/smart-money?mint=<addr> → one coin: who's in it + score
+ *
+ * The edge: judge a coin by WHO is buying it. The rollup cron
+ * (api/cron/smart-money-rollup) crosses every coin's per-wallet footprint with
+ * which coins actually graduated, building a real track record for each wallet —
+ * then scores live coins by how much proven money is accumulating them. Public +
+ * IP rate-limited. Every number traces to trades we observed and graduations we
+ * recorded on-chain.
+ */
+
+import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { sql } from '../_lib/db.js';
+
+const NETWORK = 'mainnet';
+const lamportsToSol = (v) => (v == null ? 0 : Math.round((Number(BigInt(v)) / 1e9) * 1000) / 1000);
+const numOr = (v, d = 0) => (v == null ? d : Number(v));
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+ const rl = await limits.mcpIp(clientIp(req));
+ if (!rl.success) return rateLimited(res, rl);
+
+ const url = new URL(req.url, 'http://x');
+ const wallet = url.searchParams.get('wallet');
+ const mint = url.searchParams.get('mint');
+
+ if (wallet) return walletCard(res, wallet.trim());
+ if (mint) return coinDetail(res, mint.trim());
+ if (url.searchParams.has('leaderboard')) return leaderboard(res, url);
+ return feed(res, url);
+});
+
+// ── live feed: what the smart money is buying right now ──────────────────────
+async function feed(res, url) {
+ const limit = clampInt(url.searchParams.get('limit'), 1, 100, 50);
+ const minScore = clampNum(url.searchParams.get('min_score'), 0, 100, 0);
+ const includeGraduated = ['1', 'true'].includes(String(url.searchParams.get('graduated')));
+
+ const rows = await sql`
+ SELECT mint, symbol, name, image_uri, category, smart_money_score, smart_wallet_count,
+ proven_buy_lamports, total_buy_lamports, notable, coin_first_seen_at, graduated, scored_at
+ FROM coin_smart_money
+ WHERE network = ${NETWORK}
+ AND smart_money_score >= ${minScore}
+ AND (${includeGraduated} OR graduated = false)
+ AND scored_at > now() - make_interval(hours => 6)
+ ORDER BY smart_money_score DESC, scored_at DESC
+ LIMIT ${limit}
+ `;
+ return json(
+ res,
+ 200,
+ { coins: rows.map(shapeCoin) },
+ { 'cache-control': 'public, max-age=15, stale-while-revalidate=30' },
+ );
+}
+
+// ── leaderboard: the proven wallets ──────────────────────────────────────────
+async function leaderboard(res, url) {
+ const limit = clampInt(url.searchParams.get('limit'), 1, 100, 50);
+ const minCoins = clampInt(url.searchParams.get('min_coins'), 0, 1000, 4);
+ const label = url.searchParams.get('label');
+ const labelFilter = ['smart_money', 'sniper', 'dumper', 'rugger', 'fresh', 'neutral'].includes(label)
+ ? label
+ : null;
+
+ const rows = await sql`
+ SELECT wallet, smart_money_score, label, win_rate, early_win_rate, dump_rate,
+ coins_traded, early_entries, wins, duds, dumps, creator_count, creator_wins,
+ buy_volume_lamports, last_active_at
+ FROM wallet_reputation
+ WHERE network = ${NETWORK}
+ AND (wins + duds) >= ${minCoins}
+ AND (${labelFilter}::text IS NULL OR label = ${labelFilter})
+ ORDER BY smart_money_score DESC, wins DESC
+ LIMIT ${limit}
+ `;
+ return json(
+ res,
+ 200,
+ { wallets: rows.map(shapeWallet) },
+ { 'cache-control': 'public, max-age=30, stale-while-revalidate=60' },
+ );
+}
+
+// ── one wallet's card + its recent coins ─────────────────────────────────────
+async function walletCard(res, wallet) {
+ const [rep] = await sql`
+ SELECT wallet, smart_money_score, label, win_rate, early_win_rate, dump_rate,
+ coins_traded, early_entries, wins, duds, dumps, creator_count, creator_wins,
+ buy_volume_lamports, first_seen_at, last_active_at
+ FROM wallet_reputation
+ WHERE network = ${NETWORK} AND wallet = ${wallet}
+ LIMIT 1
+ `;
+ if (!rep) return json(res, 404, { error: 'not_found', message: 'no track record for this wallet yet' });
+
+ // Recent coins this wallet bought, with their outcome (graduated?) and metadata.
+ const recent = await sql`
+ SELECT w.mint, i.symbol, i.name, i.image_uri, i.category,
+ w.buy_lamports, w.sell_lamports, w.first_seen_at,
+ (g.mint IS NOT NULL) AS graduated
+ FROM pump_coin_wallets w
+ JOIN pump_coin_intel i ON i.mint = w.mint
+ LEFT JOIN pumpfun_graduations g ON g.mint = w.mint
+ WHERE w.wallet = ${wallet} AND w.buy_lamports > 0
+ ORDER BY w.first_seen_at DESC
+ LIMIT 30
+ `;
+ return json(
+ res,
+ 200,
+ {
+ wallet: shapeWallet(rep),
+ recent_coins: recent.map((r) => ({
+ mint: r.mint,
+ symbol: r.symbol,
+ name: r.name,
+ image_uri: r.image_uri,
+ category: r.category,
+ buy_sol: lamportsToSol(r.buy_lamports),
+ sell_sol: lamportsToSol(r.sell_lamports),
+ graduated: r.graduated,
+ first_seen_at: r.first_seen_at,
+ })),
+ },
+ { 'cache-control': 'public, max-age=30' },
+ );
+}
+
+// ── one coin: who's in it ────────────────────────────────────────────────────
+async function coinDetail(res, mint) {
+ const [coin] = await sql`
+ SELECT mint, symbol, name, image_uri, category, smart_money_score, smart_wallet_count,
+ proven_buy_lamports, total_buy_lamports, notable, coin_first_seen_at, graduated, scored_at
+ FROM coin_smart_money
+ WHERE network = ${NETWORK} AND mint = ${mint}
+ LIMIT 1
+ `;
+ if (!coin) return json(res, 404, { error: 'not_found', message: 'this coin has not been scored yet' });
+
+ // Resolve the notable wallets' live labels (in case they ranked up since).
+ const notable = Array.isArray(coin.notable) ? coin.notable : [];
+ const addrs = notable.map((n) => n.wallet).filter(Boolean);
+ let labels = new Map();
+ if (addrs.length) {
+ const rows = await sql`
+ SELECT wallet, label, smart_money_score, win_rate, wins, duds
+ FROM wallet_reputation WHERE network = ${NETWORK} AND wallet = ANY(${addrs})
+ `;
+ labels = new Map(rows.map((r) => [r.wallet, r]));
+ }
+ return json(
+ res,
+ 200,
+ {
+ coin: shapeCoin(coin),
+ notable: notable.map((n) => {
+ const live = labels.get(n.wallet);
+ return {
+ wallet: n.wallet,
+ buy_sol: numOr(n.buy_sol),
+ score: live ? numOr(live.smart_money_score) : numOr(n.score),
+ label: live ? live.label : n.label,
+ win_rate: live ? numOr(live.win_rate) : null,
+ wins: live ? Number(live.wins) : null,
+ duds: live ? Number(live.duds) : null,
+ };
+ }),
+ },
+ { 'cache-control': 'public, max-age=15' },
+ );
+}
+
+// ── shapers ──────────────────────────────────────────────────────────────────
+function shapeCoin(r) {
+ return {
+ mint: r.mint,
+ symbol: r.symbol,
+ name: r.name,
+ image_uri: r.image_uri,
+ category: r.category,
+ smart_money_score: numOr(r.smart_money_score),
+ smart_wallet_count: Number(r.smart_wallet_count) || 0,
+ proven_buy_sol: lamportsToSol(r.proven_buy_lamports),
+ total_buy_sol: lamportsToSol(r.total_buy_lamports),
+ notable: Array.isArray(r.notable) ? r.notable : [],
+ first_seen_at: r.coin_first_seen_at,
+ graduated: !!r.graduated,
+ scored_at: r.scored_at,
+ };
+}
+
+function shapeWallet(r) {
+ const judged = (Number(r.wins) || 0) + (Number(r.duds) || 0);
+ return {
+ wallet: r.wallet,
+ smart_money_score: numOr(r.smart_money_score),
+ label: r.label,
+ win_rate: numOr(r.win_rate),
+ early_win_rate: numOr(r.early_win_rate),
+ dump_rate: numOr(r.dump_rate),
+ coins_judged: judged,
+ coins_traded: Number(r.coins_traded) || 0,
+ early_entries: Number(r.early_entries) || 0,
+ wins: Number(r.wins) || 0,
+ duds: Number(r.duds) || 0,
+ dumps: Number(r.dumps) || 0,
+ creator_count: Number(r.creator_count) || 0,
+ creator_wins: Number(r.creator_wins) || 0,
+ buy_volume_sol: lamportsToSol(r.buy_volume_lamports),
+ last_active_at: r.last_active_at,
+ };
+}
+
+function clampInt(v, lo, hi, def) {
+ const n = Math.floor(Number(v));
+ if (!Number.isFinite(n)) return def;
+ return Math.min(hi, Math.max(lo, n));
+}
+function clampNum(v, lo, hi, def) {
+ const n = Number(v);
+ if (!Number.isFinite(n)) return def;
+ return Math.min(hi, Math.max(lo, n));
+}
diff --git a/data/changelog.json b/data/changelog.json
index 998521564..63c4d9c58 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,13 @@
{
"$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. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-06-15",
+ "title": "Trader Leaderboard — pump.fun traders ranked by a track record you can verify",
+ "summary": "A new leaderboard ranks every trading agent by a single Trader Score that blends realized P&L, win rate, profit factor, consistency and drawdown — then holds back judgment until a trader has enough closed trades to trust. Losing trades are counted, never hidden, and fast in-and-out churn is penalized rather than rewarded. Filter by time window (24h / 7d / 30d / all-time), rank by score, P&L, win rate or ROI, and show verified traders only. Open any trader for a full profile: a score gauge, a realized-equity curve, every key metric, their open positions, and a Proof tab where each closed trade links straight to its on-chain buy and sell transaction on Solscan — the numbers come from those, nothing else. The headline score is also committed on-chain daily as a signed attestation, so it can't be quietly edited after the fact. Share any track record as a one-tap PnL card.",
+ "tags": ["feature"],
+ "link": "/leaderboard"
+ },
{
"date": "2026-06-15",
"title": "Redesigned the $THREE economy page — watch it move, verify it on-chain",
diff --git a/data/pages.json b/data/pages.json
index 7257b538d..df14b9696 100644
--- a/data/pages.json
+++ b/data/pages.json
@@ -432,6 +432,14 @@
"changefreq": "daily",
"added": "2026-06-12"
},
+ {
+ "path": "/leaderboard",
+ "title": "Trader Leaderboard",
+ "description": "Pump.fun traders ranked by a provable, on-chain track record — realized P&L, win rate, drawdown — with every number traceable to its transaction.",
+ "priority": 0.8,
+ "changefreq": "hourly",
+ "added": "2026-06-15"
+ },
{
"path": "/pay",
"title": "Pay (x402)",
@@ -456,6 +464,14 @@
"changefreq": "daily",
"added": "2026-06-15"
},
+ {
+ "path": "/smart-money",
+ "title": "Smart Money Radar — follow the wallets that win on pump.fun",
+ "description": "A live first-party reputation graph of every pump.fun wallet. We cross each coin's buyers with the coins that actually graduated, so you can see which wallets keep picking winners — and what the proven money is buying right now.",
+ "priority": 0.8,
+ "changefreq": "daily",
+ "added": "2026-06-15"
+ },
{
"path": "/pumpfun",
"title": "Pump.fun Stream",
@@ -472,6 +488,14 @@
"changefreq": "daily",
"added": "2026-05-04"
},
+ {
+ "path": "/radar",
+ "title": "Coin Radar",
+ "description": "Live pump.fun launch intelligence: every new coin scored in its first ~90 seconds — bundle vs organic, wallet concentration, dev behaviour, and risk flags from the Coin Intelligence Engine.",
+ "priority": 0.8,
+ "changefreq": "daily",
+ "added": "2026-06-15"
+ },
{
"path": "/pump-dashboard",
"title": "Pump Dashboard",
@@ -512,6 +536,14 @@
"changefreq": "weekly",
"added": "2026-05-04"
},
+ {
+ "path": "/coin-intel",
+ "title": "Coin Intelligence",
+ "description": "Every pump.fun launch watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals predict winners.",
+ "priority": 0.8,
+ "changefreq": "daily",
+ "added": "2026-06-15"
+ },
{
"path": "/constellation",
"title": "watsonx Constellation",
diff --git a/pages/coin-intel.html b/pages/coin-intel.html
new file mode 100644
index 000000000..fe63b237c
--- /dev/null
+++ b/pages/coin-intel.html
@@ -0,0 +1,861 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+ <meta charset="UTF-8" />
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ <link rel="manifest" href="/site.webmanifest" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Coin Intelligence · three.ws</title>
+ <meta name="description" content="Every pump.fun launch, watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals actually predict winners." />
+ <link rel="canonical" href="https://three.ws/coin-intel" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <link rel="stylesheet" href="/mobile.css" />
+ <style>
+ :root {
+ --ci-bg: #07080c;
+ --ci-panel: rgba(16, 18, 26, 0.86);
+ --ci-panel-2: rgba(255, 255, 255, 0.03);
+ --ci-border: rgba(255, 255, 255, 0.09);
+ --ci-border-strong: rgba(255, 255, 255, 0.16);
+ --ci-text: #e9ebf2;
+ --ci-muted: #8a90a2;
+ --ci-faint: #5c6273;
+ --ci-accent: #8b5cf6;
+ --ci-success: #34d399;
+ --ci-warn: #fbbf24;
+ --ci-danger: #f87171;
+ --ci-neutral: #818cf8;
+ /* category palette */
+ --cat-meme: #fbbf24; --cat-ai: #22d3ee; --cat-tech: #818cf8;
+ --cat-culture: #f472b6; --cat-community: #34d399; --cat-political: #f87171;
+ --cat-news: #fb923c; --cat-animal: #a3e635; --cat-celebrity: #c084fc;
+ --cat-utility: #94a3b8; --cat-unknown: #64748b;
+ }
+ html, body { background: var(--ci-bg); color: var(--ci-text); }
+ body { margin: 0; min-height: 100vh; font-family: var(--font-body, 'Inter', system-ui, sans-serif); }
+ .site-header { position: sticky; top: 0; z-index: 50; background: rgba(0,0,0,0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
+ * { box-sizing: border-box; }
+
+ .ci-wrap { max-width: 1320px; margin: 0 auto; padding: 0 20px 80px; }
+
+ /* ── hero / header ─────────────────────────────── */
+ .ci-hero {
+ padding: 30px 0 18px;
+ display: flex; flex-wrap: wrap; gap: 18px;
+ align-items: flex-end; justify-content: space-between;
+ }
+ .ci-hero h1 {
+ font-family: var(--font-display, 'Space Grotesk', sans-serif);
+ font-size: clamp(1.7rem, 3.4vw, 2.5rem);
+ line-height: 1.05; margin: 0 0 6px; letter-spacing: -0.02em;
+ display: flex; align-items: center; gap: 12px;
+ }
+ .ci-hero h1 .pulse {
+ width: 11px; height: 11px; border-radius: 50%;
+ background: var(--ci-success); box-shadow: 0 0 0 0 rgba(52,211,153,0.6);
+ animation: ciPing 2.2s ease-out infinite; flex-shrink: 0;
+ }
+ .ci-hero[data-degraded="1"] h1 .pulse { background: var(--ci-warn); animation-name: ciPingWarn; }
+ @keyframes ciPing { 0%{box-shadow:0 0 0 0 rgba(52,211,153,0.55);} 70%{box-shadow:0 0 0 12px rgba(52,211,153,0);} 100%{box-shadow:0 0 0 0 rgba(52,211,153,0);} }
+ @keyframes ciPingWarn { 0%{box-shadow:0 0 0 0 rgba(251,191,36,0.5);} 70%{box-shadow:0 0 0 12px rgba(251,191,36,0);} 100%{box-shadow:0 0 0 0 rgba(251,191,36,0);} }
+ .ci-hero p { margin: 0; color: var(--ci-muted); font-size: 14px; max-width: 640px; line-height: 1.5; }
+ .ci-hero .lead-link { color: var(--ci-neutral); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s; }
+ .ci-hero .lead-link:hover { border-bottom-color: var(--ci-neutral); }
+
+ .ci-stats { display: flex; gap: 10px; flex-wrap: wrap; }
+ .ci-stat {
+ background: var(--ci-panel-2); border: 1px solid var(--ci-border);
+ border-radius: 12px; padding: 10px 14px; min-width: 92px;
+ font-family: var(--font-mono, ui-monospace, monospace);
+ }
+ .ci-stat .v { font-size: 20px; font-weight: 600; color: var(--ci-text); font-variant-numeric: tabular-nums; }
+ .ci-stat .l { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ci-faint); margin-top: 2px; }
+
+ /* ── tabs ──────────────────────────────────────── */
+ .ci-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ci-border); margin: 8px 0 18px; overflow-x: auto; }
+ .ci-tab {
+ background: none; border: none; color: var(--ci-muted);
+ font: inherit; font-size: 13.5px; font-weight: 500;
+ padding: 12px 14px; cursor: pointer; position: relative; white-space: nowrap;
+ border-bottom: 2px solid transparent; transition: color .15s;
+ }
+ .ci-tab:hover { color: var(--ci-text); }
+ .ci-tab.is-active { color: var(--ci-text); border-bottom-color: var(--ci-accent); }
+ .ci-tab .count { color: var(--ci-faint); font-size: 11px; margin-left: 5px; font-variant-numeric: tabular-nums; }
+
+ /* ── toolbar (radar) ───────────────────────────── */
+ .ci-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
+ .ci-search { position: relative; flex: 1 1 200px; max-width: 300px; }
+ .ci-search input {
+ width: 100%; background: rgba(0,0,0,0.35); border: 1px solid var(--ci-border);
+ color: var(--ci-text); border-radius: 9px; padding: 9px 12px 9px 32px;
+ font: inherit; font-size: 13px; outline: none; transition: border-color .15s;
+ }
+ .ci-search input:focus { border-color: var(--ci-accent); }
+ .ci-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; stroke: var(--ci-faint); pointer-events: none; }
+ .ci-chips { display: flex; gap: 6px; flex-wrap: wrap; }
+ .ci-chip {
+ background: var(--ci-panel-2); border: 1px solid var(--ci-border); color: var(--ci-muted);
+ border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12px; cursor: pointer;
+ text-transform: capitalize; transition: all .14s; display: inline-flex; align-items: center; gap: 6px;
+ }
+ .ci-chip:hover { color: var(--ci-text); border-color: var(--ci-border-strong); }
+ .ci-chip.is-active { background: rgba(139,92,246,0.18); border-color: rgba(139,92,246,0.5); color: #fff; }
+ .ci-chip .dot { width: 7px; height: 7px; border-radius: 50%; }
+ .ci-select {
+ background: rgba(0,0,0,0.35); border: 1px solid var(--ci-border); color: var(--ci-text);
+ border-radius: 9px; padding: 8px 12px; font: inherit; font-size: 12.5px; cursor: pointer;
+ }
+
+ /* ── coin grid ─────────────────────────────────── */
+ .ci-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
+ .ci-card {
+ background: var(--ci-panel); border: 1px solid var(--ci-border); border-radius: 14px;
+ padding: 15px; cursor: pointer; position: relative; overflow: hidden;
+ transition: transform .16s cubic-bezier(.2,.8,.2,1), border-color .16s, box-shadow .16s;
+ animation: ciFadeIn .4s ease both;
+ }
+ @keyframes ciFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
+ .ci-card:hover { transform: translateY(-3px); border-color: var(--ci-border-strong); box-shadow: 0 12px 34px rgba(0,0,0,0.45); }
+ .ci-card:focus-visible { outline: 2px solid var(--ci-accent); outline-offset: 2px; }
+ .ci-card .verdict-edge { position: absolute; top: 0; left: 0; bottom: 0; width: 3px; }
+ .ci-card .head { display: flex; gap: 11px; align-items: center; }
+ .ci-card .avatar {
+ width: 44px; height: 44px; border-radius: 11px; background: #15171f; object-fit: cover;
+ border: 1px solid var(--ci-border); flex-shrink: 0;
+ }
+ .ci-card .id { min-width: 0; flex: 1; }
+ .ci-card .id .name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+ .ci-card .id .sub { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
+ .ci-card .id .sym { font-family: var(--font-mono, monospace); font-size: 11.5px; color: var(--ci-neutral); }
+ .ci-card .id .age { font-size: 11px; color: var(--ci-faint); font-variant-numeric: tabular-nums; }
+
+ .cat-badge {
+ font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
+ padding: 3px 7px; border-radius: 5px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
+ }
+ .cat-badge .glyph { width: 6px; height: 6px; border-radius: 50%; }
+
+ .ci-card .scorerow { display: flex; align-items: center; gap: 12px; margin: 13px 0 11px; }
+ .ring { --pct: 0; --col: var(--ci-neutral); width: 52px; height: 52px; flex-shrink: 0; position: relative; }
+ .ring svg { transform: rotate(-90deg); display: block; }
+ .ring .track { stroke: rgba(255,255,255,0.08); }
+ .ring .val { stroke: var(--col); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
+ .ring .label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
+ .ring .label .n { font-family: var(--font-mono, monospace); font-size: 14px; font-weight: 700; line-height: 1; }
+ .ring .label .t { font-size: 7px; letter-spacing: 0.08em; color: var(--ci-faint); text-transform: uppercase; margin-top: 1px; }
+ .verdict-pill {
+ font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
+ display: inline-flex; align-items: center; gap: 5px;
+ }
+ .verdict-pill .d { width: 6px; height: 6px; border-radius: 50%; }
+ .tone-success { color: var(--ci-success); background: rgba(52,211,153,0.13); }
+ .tone-success .d, .bg-success { background: var(--ci-success); }
+ .tone-warn { color: var(--ci-warn); background: rgba(251,191,36,0.13); }
+ .tone-warn .d, .bg-warn { background: var(--ci-warn); }
+ .tone-danger { color: var(--ci-danger); background: rgba(248,113,113,0.13); }
+ .tone-danger .d, .bg-danger { background: var(--ci-danger); }
+ .tone-neutral { color: var(--ci-neutral); background: rgba(129,140,248,0.13); }
+ .tone-neutral .d, .bg-neutral { background: var(--ci-neutral); }
+
+ .ob-bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; display: flex; }
+ .ob-bar .organic { background: linear-gradient(90deg, #34d399, #10b981); }
+ .ob-bar .bundle { background: linear-gradient(90deg, #fb7185, #f43f5e); }
+ .ob-legend { display: flex; justify-content: space-between; font-size: 10px; color: var(--ci-faint); margin-top: 4px; }
+ .ob-legend b { font-variant-numeric: tabular-nums; }
+
+ .ci-card .metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
+ .ci-card .metric { background: var(--ci-panel-2); border-radius: 8px; padding: 7px 8px; }
+ .ci-card .metric .mv { font-family: var(--font-mono, monospace); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
+ .ci-card .metric .ml { font-size: 9px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ci-faint); margin-top: 2px; }
+
+ .flags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 11px; min-height: 4px; }
+ .flag {
+ font-size: 9.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px;
+ background: rgba(248,113,113,0.12); color: #fca5a5; border: 1px solid rgba(248,113,113,0.22);
+ text-transform: capitalize;
+ }
+ .flag.soft { background: rgba(251,191,36,0.10); color: #fcd34d; border-color: rgba(251,191,36,0.2); }
+ .ci-card .narr { font-size: 11.5px; color: var(--ci-muted); line-height: 1.45; margin-top: 11px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
+
+ /* ── skeleton / empty / error ──────────────────── */
+ .ci-skel { background: var(--ci-panel); border: 1px solid var(--ci-border); border-radius: 14px; padding: 15px; height: 240px; }
+ .ci-skel .sh { height: 12px; border-radius: 6px; background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: ciShimmer 1.4s infinite; margin-bottom: 10px; }
+ @keyframes ciShimmer { 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }
+ .ci-empty {
+ grid-column: 1 / -1; text-align: center; padding: 56px 24px;
+ border: 1px dashed var(--ci-border-strong); border-radius: 16px; background: var(--ci-panel-2);
+ }
+ .ci-empty .icon { font-size: 30px; opacity: 0.6; }
+ .ci-empty h3 { font-family: var(--font-display, sans-serif); margin: 12px 0 8px; font-size: 18px; }
+ .ci-empty p { color: var(--ci-muted); font-size: 13.5px; max-width: 520px; margin: 0 auto 8px; line-height: 1.55; }
+ .ci-empty .how { display: inline-flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
+ .ci-empty .how span { font-size: 11px; color: var(--ci-muted); background: var(--ci-panel); border: 1px solid var(--ci-border); border-radius: 999px; padding: 5px 11px; }
+ .ci-retry { margin-top: 16px; background: var(--ci-accent); color: #fff; border: none; border-radius: 9px; padding: 9px 20px; font: inherit; cursor: pointer; }
+
+ /* ── detail drawer ─────────────────────────────── */
+ .ci-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.55); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 90; backdrop-filter: blur(2px); }
+ .ci-scrim.is-open { opacity: 1; pointer-events: auto; }
+ .ci-drawer {
+ position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 94vw;
+ background: var(--ci-panel); border-left: 1px solid var(--ci-border); z-index: 91;
+ transform: translateX(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
+ overflow-y: auto; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
+ }
+ .ci-drawer.is-open { transform: none; }
+ .ci-drawer .dwrap { padding: 22px; }
+ .ci-drawer .close { position: absolute; top: 16px; right: 16px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--ci-border); background: rgba(255,255,255,0.05); color: var(--ci-text); cursor: pointer; font-size: 16px; line-height: 1; z-index: 2; }
+ .ci-drawer .close:hover { background: rgba(255,255,255,0.12); }
+ .d-head { display: flex; gap: 14px; align-items: center; padding-right: 36px; }
+ .d-head .avatar { width: 58px; height: 58px; border-radius: 14px; background: #15171f; object-fit: cover; border: 1px solid var(--ci-border); flex-shrink: 0; }
+ .d-head .name { font-family: var(--font-display, sans-serif); font-size: 20px; font-weight: 600; line-height: 1.1; }
+ .d-head .sym { font-family: var(--font-mono, monospace); font-size: 13px; color: var(--ci-neutral); margin-top: 3px; }
+ .d-section { margin-top: 22px; }
+ .d-section > h4 { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ci-faint); margin: 0 0 11px; font-weight: 600; }
+ .d-links { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 14px; }
+ .d-links a { font-size: 12px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--ci-border); color: var(--ci-text); text-decoration: none; background: rgba(255,255,255,0.05); transition: background .14s; }
+ .d-links a:hover { background: rgba(255,255,255,0.12); }
+ .d-links a.primary { background: var(--ci-accent); border-color: var(--ci-accent); color: #fff; }
+ .d-tags { display: flex; gap: 6px; flex-wrap: wrap; }
+ .d-tag { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--ci-panel-2); border: 1px solid var(--ci-border); color: var(--ci-muted); }
+
+ .sig-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
+ .sig-row .sname { font-size: 11.5px; color: var(--ci-muted); width: 132px; flex-shrink: 0; }
+ .sig-row .sbar { flex: 1; height: 7px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
+ .sig-row .sbar i { display: block; height: 100%; border-radius: 4px; transition: width .5s; }
+ .sig-row .sval { font-family: var(--font-mono, monospace); font-size: 11.5px; width: 42px; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; }
+
+ .d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
+ .d-stat { background: var(--ci-panel-2); border: 1px solid var(--ci-border); border-radius: 9px; padding: 10px 11px; }
+ .d-stat .v { font-family: var(--font-mono, monospace); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
+ .d-stat .l { font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ci-faint); margin-top: 3px; }
+ .d-stat .v.g { color: var(--ci-success); } .d-stat .v.r { color: var(--ci-danger); }
+
+ .outcome-banner { padding: 12px 14px; border-radius: 11px; display: flex; align-items: center; gap: 12px; }
+ .outcome-banner .oi { font-size: 22px; }
+ .outcome-banner .ot { font-weight: 600; font-size: 14px; }
+ .outcome-banner .os { font-size: 11.5px; color: var(--ci-muted); margin-top: 2px; }
+
+ /* bubble-map */
+ .bubblemap { width: 100%; height: 248px; background: radial-gradient(ellipse at 50% 45%, rgba(139,92,246,0.06), transparent 70%); border: 1px solid var(--ci-border); border-radius: 12px; }
+ .bubblemap text { font-family: var(--font-mono, monospace); }
+ .bm-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 10.5px; color: var(--ci-muted); }
+ .bm-legend span { display: inline-flex; align-items: center; gap: 5px; }
+ .bm-legend .sw { width: 9px; height: 9px; border-radius: 50%; }
+
+ /* trader rows */
+ .trader-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--ci-border); }
+ .trader-row:last-child { border-bottom: none; }
+ .trader-row .addr { font-family: var(--font-mono, monospace); font-size: 12px; color: var(--ci-text); }
+ .trader-row .addr a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--ci-faint); }
+ .trader-row .addr a:hover { color: var(--ci-neutral); }
+ .tlabels { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
+ .tlabel { font-size: 9px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
+ .tl-smart_money { background: rgba(52,211,153,0.15); color: #6ee7b7; }
+ .tl-whale { background: rgba(34,211,238,0.15); color: #67e8f9; }
+ .tl-serial { background: rgba(129,140,248,0.15); color: #a5b4fc; }
+ .tl-creator { background: rgba(251,191,36,0.15); color: #fcd34d; }
+ .tl-sniper { background: rgba(251,146,60,0.16); color: #fdba74; }
+ .tl-bundled { background: rgba(248,113,113,0.15); color: #fca5a5; }
+ .tl-holding { background: rgba(52,211,153,0.13); color: #6ee7b7; }
+ .tl-dumped { background: rgba(248,113,113,0.15); color: #fca5a5; }
+ .tl-flipped { background: rgba(148,163,184,0.16); color: #cbd5e1; }
+ .tl-active { background: rgba(148,163,184,0.14); color: #cbd5e1; }
+ .trader-row .tright { margin-left: auto; text-align: right; flex-shrink: 0; }
+ .trader-row .tval { font-family: var(--font-mono, monospace); font-size: 12.5px; font-variant-numeric: tabular-nums; }
+ .trader-row .tsub { font-size: 10px; color: var(--ci-faint); }
+ .winrate { font-family: var(--font-mono, monospace); font-size: 12px; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; }
+
+ /* learning */
+ .learn-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
+ .panel { background: var(--ci-panel); border: 1px solid var(--ci-border); border-radius: 14px; padding: 18px; }
+ .panel h3 { font-family: var(--font-display, sans-serif); font-size: 15px; margin: 0 0 4px; }
+ .panel .sub { color: var(--ci-muted); font-size: 12px; margin: 0 0 16px; line-height: 1.5; }
+ .wbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
+ .wbar-row .wn { font-size: 11.5px; color: var(--ci-text); width: 150px; flex-shrink: 0; }
+ .wbar-track { flex: 1; height: 9px; background: rgba(255,255,255,0.05); border-radius: 5px; position: relative; }
+ .wbar-track .mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--ci-border-strong); }
+ .wbar-track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
+ .wbar-row .wv { font-family: var(--font-mono, monospace); font-size: 11px; width: 48px; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; }
+ .outcome-bars { display: flex; flex-direction: column; gap: 11px; }
+ .ob-row { display: flex; align-items: center; gap: 10px; }
+ .ob-row .on { font-size: 12px; width: 92px; text-transform: capitalize; }
+ .ob-row .ot { flex: 1; height: 22px; background: rgba(255,255,255,0.04); border-radius: 6px; overflow: hidden; }
+ .ob-row .ot i { display: block; height: 100%; border-radius: 6px; }
+ .ob-row .oc { font-family: var(--font-mono, monospace); font-size: 12px; width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
+ .cov-cats { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
+ .cov-cat { font-size: 11px; padding: 4px 9px; border-radius: 999px; background: var(--ci-panel-2); border: 1px solid var(--ci-border); color: var(--ci-muted); display: inline-flex; gap: 6px; align-items: center; }
+ .cov-cat b { color: var(--ci-text); font-variant-numeric: tabular-nums; }
+
+ .section-title { font-family: var(--font-display, sans-serif); font-size: 14px; margin: 26px 0 12px; color: var(--ci-text); display: flex; align-items: center; gap: 8px; }
+ .section-title .badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 5px; background: rgba(52,211,153,0.14); color: var(--ci-success); }
+
+ .hide { display: none !important; }
+ @media (max-width: 760px) {
+ .learn-grid { grid-template-columns: 1fr; }
+ .ci-drawer { width: 100%; }
+ .ci-hero { padding-top: 22px; }
+ }
+ </style>
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="Coin Intelligence · three.ws" />
+ <meta property="og:description" content="Every pump.fun launch, watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns." />
+ <meta property="og:url" content="https://three.ws/coin-intel" />
+ <meta property="og:image" content="https://three.ws/og-image.png" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebApplication","name":"Coin Intelligence","applicationCategory":"FinanceApplication","operatingSystem":"Web","description":"Real-time pump.fun launch intelligence — classification, organic-vs-bundle detection, trader/wallet classification, and a learning quality model.","url":"https://three.ws/coin-intel","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+</head>
+<body>
+ <header class="site-header"><div id="nav-container"></div></header>
+ <script src="/nav.js"></script>
+
+ <main class="ci-wrap">
+ <div class="ci-hero" id="ci-hero">
+ <div>
+ <h1><span class="pulse" aria-hidden="true"></span>Coin Intelligence</h1>
+ <p>Every pump.fun launch, watched the second it appears — classified, measured trade-by-trade, and scored. Organic demand or a funded bundle? Who's actually buying? The engine learns which signals predict winners, and your <a class="lead-link" href="/sniper">3D agents read the same intel to act</a>.</p>
+ </div>
+ <div class="ci-stats" id="ci-stats" aria-live="polite"></div>
+ </div>
+
+ <nav class="ci-tabs" id="ci-tabs" role="tablist" aria-label="Coin intelligence views">
+ <button class="ci-tab is-active" data-tab="radar" role="tab">Radar<span class="count" id="cnt-radar"></span></button>
+ <button class="ci-tab" data-tab="leaderboard" role="tab">Leaderboard</button>
+ <button class="ci-tab" data-tab="traders" role="tab">Smart Money<span class="count" id="cnt-traders"></span></button>
+ <button class="ci-tab" data-tab="learning" role="tab">What it learned</button>
+ </nav>
+
+ <!-- RADAR -->
+ <section id="view-radar" data-view>
+ <div class="ci-toolbar">
+ <label class="ci-search">
+ <svg viewBox="0 0 24 24" fill="none" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
+ <input type="search" id="ci-q" placeholder="Search name, symbol, mint…" autocomplete="off" spellcheck="false" />
+ </label>
+ <div class="ci-chips" id="ci-cats" role="group" aria-label="Filter by category"></div>
+ <select class="ci-select" id="ci-verdict" aria-label="Filter by verdict">
+ <option value="">All verdicts</option>
+ <option value="strong">Strong</option>
+ <option value="watch">Watch</option>
+ <option value="caution">Caution</option>
+ <option value="avoid">Avoid</option>
+ </select>
+ <select class="ci-select" id="ci-minq" aria-label="Minimum quality">
+ <option value="">Any quality</option>
+ <option value="50">Quality ≥ 50</option>
+ <option value="70">Quality ≥ 70</option>
+ <option value="85">Quality ≥ 85</option>
+ </select>
+ </div>
+ <div class="ci-grid" id="ci-grid"></div>
+ </section>
+
+ <!-- LEADERBOARD -->
+ <section id="view-leaderboard" data-view class="hide">
+ <div class="section-title">Top quality · last 24h</div>
+ <div class="ci-grid" id="ci-lb-top"></div>
+ <div class="section-title">Confirmed winners <span class="badge">graduated / pumped</span></div>
+ <p style="color:var(--ci-muted);font-size:13px;margin:-4px 0 14px;max-width:640px;">What good looked like at launch — coins the engine observed that went on to graduate or 3×+. The signals shown are from their first seconds, before the outcome was known.</p>
+ <div class="ci-grid" id="ci-lb-win"></div>
+ </section>
+
+ <!-- TRADERS -->
+ <section id="view-traders" data-view class="hide">
+ <p style="color:var(--ci-muted);font-size:13px;margin:0 0 16px;max-width:680px;">Every wallet that traded an observed coin, classified by its cross-coin footprint. <b style="color:var(--ci-text)">Win-rate</b> is the share of its bought coins that graduated or pumped — counted once a wallet has at least 3 labeled coins. This is the order book behind the order book.</p>
+ <div class="panel" id="ci-traders"></div>
+ </section>
+
+ <!-- LEARNING -->
+ <section id="view-learning" data-view class="hide">
+ <div class="learn-grid">
+ <div class="panel">
+ <h3>Signal weights</h3>
+ <p class="sub">Each launch-time signal's correlation with a good outcome (graduated or pumped), learned from every labeled coin. Green predicts winners; red predicts losers. No black box — these are plain correlations the sniper blends into its score.</p>
+ <div id="ci-weights"></div>
+ </div>
+ <div>
+ <div class="panel" style="margin-bottom:18px;">
+ <h3>Outcomes observed</h3>
+ <p class="sub">Ground truth, labeled after the fact.</p>
+ <div class="outcome-bars" id="ci-outcomes"></div>
+ </div>
+ <div class="panel">
+ <h3>Coverage</h3>
+ <p class="sub" id="ci-coverage-sub">—</p>
+ <div class="cov-cats" id="ci-coverage"></div>
+ </div>
+ </div>
+ </div>
+ </section>
+ </main>
+
+ <div class="ci-scrim" id="ci-scrim"></div>
+ <aside class="ci-drawer" id="ci-drawer" aria-hidden="true" aria-label="Coin detail">
+ <button class="close" id="ci-drawer-close" aria-label="Close">×</button>
+ <div class="dwrap" id="ci-drawer-body"></div>
+ </aside>
+
+ <script type="module">
+ const API = '/api/pump/intel';
+ const REFRESH_MS = 15_000;
+
+ const CATS = ['meme','ai','tech','culture','community','political','news','animal','celebrity','utility','unknown'];
+ const CAT_COLOR = (c) => `var(--cat-${CATS.includes(c) ? c : 'unknown'})`;
+ const TRADER_LABEL_TEXT = {
+ smart_money: 'Smart money', whale: 'Whale', serial: 'Serial', creator: 'Creator',
+ sniper: 'Sniper', bundled: 'Bundled', holding: 'Holding', dumped: 'Dumped',
+ flipped: 'Flipped', active: 'Active',
+ };
+ const SIGNAL_META = [
+ ['organic_score', 'Organic demand', 'good'],
+ ['bundle_score', 'Bundle likelihood', 'bad'],
+ ['coordination_score', 'Coordination', 'bad'],
+ ['snipe_ratio', 'Snipe ratio', 'bad'],
+ ['timing_entropy', 'Timing spread', 'good'],
+ ['concentration_top1', 'Top wallet share', 'bad'],
+ ['concentration_top10', 'Top-10 share', 'bad'],
+ ['fresh_wallet_ratio', 'Fresh wallets', 'bad'],
+ ['bubblemap_connectivity', 'Funder connectivity', 'bad'],
+ ];
+ const FLAG_TEXT = {
+ bundle_launch: 'Bundle launch', dev_dumped: 'Dev dumped', single_whale: 'Single whale',
+ low_diversity: 'Low diversity', fresh_wallet_swarm: 'Fresh swarm', sell_pressure: 'Sell pressure', sniped: 'Sniped',
+ };
+ const HARD_FLAGS = new Set(['bundle_launch','dev_dumped','single_whale']);
+
+ // ── helpers ───────────────────────────────────────────────
+ const $ = (s, r = document) => r.querySelector(s);
+ const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;' }[c]));
+ const pct = (x) => x == null ? '—' : Math.round(x * 100) + '%';
+ const sol = (x) => x == null ? '—' : (x >= 100 ? Math.round(x) : x >= 1 ? x.toFixed(2) : x.toFixed(3)) + ' ◎';
+ const usd = (x) => { if (x == null) return '—'; if (x >= 1e9) return '$'+(x/1e9).toFixed(2)+'B'; if (x >= 1e6) return '$'+(x/1e6).toFixed(2)+'M'; if (x >= 1e3) return '$'+(x/1e3).toFixed(1)+'K'; return '$'+Math.round(x); };
+ const short = (a) => !a ? '—' : a.slice(0, 4) + '…' + a.slice(-4);
+ function ago(ms) {
+ if (!ms) return '';
+ const d = Date.now() - ms; if (d < 0) return 'now';
+ const m = d / 60000; if (m < 1) return Math.max(1, Math.floor(d/1000)) + 's';
+ if (m < 60) return Math.floor(m) + 'm'; const h = m/60; if (h < 24) return Math.floor(h) + 'h'; return Math.floor(h/24) + 'd';
+ }
+ const imgProxy = (uri, seed) => { if (!uri) return `https://api.dicebear.com/7.x/shapes/svg?seed=${encodeURIComponent(seed||'x')}`; if (uri.startsWith('data:')||uri.startsWith('/')) return uri; return `/api/img?url=${encodeURIComponent(uri)}${seed?`&seed=${encodeURIComponent(seed)}`:''}`; };
+ const fallbackImg = (seed) => `https://api.dicebear.com/7.x/shapes/svg?seed=${encodeURIComponent(seed||'x')}`;
+
+ async function api(params) {
+ const u = new URL(API, location.origin);
+ for (const [k, v] of Object.entries(params)) if (v != null && v !== '') u.searchParams.set(k, v);
+ const r = await fetch(u, { headers: { accept: 'application/json' } });
+ if (!r.ok) throw new Error('HTTP ' + r.status);
+ return r.json();
+ }
+
+ // ── ring (quality score) ──────────────────────────────────
+ function ring(score, tone) {
+ const s = Math.max(0, Math.min(100, score ?? 0));
+ const r = 22, c = 2 * Math.PI * r, off = c * (1 - s / 100);
+ const col = `var(--ci-${tone || 'neutral'})`;
+ return `<div class="ring" style="--col:${col}">
+ <svg width="52" height="52" viewBox="0 0 52 52">
+ <circle class="track" cx="26" cy="26" r="${r}" fill="none" stroke-width="5"/>
+ <circle class="val" cx="26" cy="26" r="${r}" fill="none" stroke-width="5" stroke-dasharray="${c.toFixed(1)}" stroke-dashoffset="${off.toFixed(1)}"/>
+ </svg>
+ <div class="label"><span class="n">${score == null ? '–' : Math.round(s)}</span><span class="t">score</span></div>
+ </div>`;
+ }
+ const catBadge = (c) => `<span class="cat-badge" style="color:${CAT_COLOR(c)};background:color-mix(in srgb, ${CAT_COLOR(c)} 14%, transparent)"><span class="glyph" style="background:${CAT_COLOR(c)}"></span>${esc(c||'unknown')}</span>`;
+ const verdictPill = (v) => `<span class="verdict-pill tone-${v.tone}"><span class="d"></span>${esc(v.label)}</span>`;
+
+ function obBar(organic, bundle) {
+ const o = Math.round((organic ?? 0) * 100), b = Math.round((bundle ?? 0) * 100);
+ return `<div><div class="ob-bar"><span class="organic" style="width:${o}%"></span><span class="bundle" style="width:${b}%"></span></div>
+ <div class="ob-legend"><span style="color:#34d399">Organic <b>${o}%</b></span><span style="color:#fb7185"><b>${b}%</b> Bundle</span></div></div>`;
+ }
+
+ function coinCard(coin) {
+ const v = coin.verdict;
+ const flags = (coin.risk_flags || []).slice(0, 4).map((f) =>
+ `<span class="flag ${HARD_FLAGS.has(f) ? '' : 'soft'}">${esc(FLAG_TEXT[f] || f)}</span>`).join('');
+ return `<article class="ci-card" tabindex="0" data-mint="${esc(coin.mint)}" role="button" aria-label="${esc(coin.name||coin.symbol||coin.mint)}">
+ <span class="verdict-edge bg-${v.tone}"></span>
+ <div class="head">
+ <img class="avatar" loading="lazy" referrerpolicy="no-referrer" src="${esc(imgProxy(coin.image_uri, coin.mint))}" onerror="this.onerror=null;this.src='${esc(fallbackImg(coin.mint))}'" alt="" />
+ <div class="id">
+ <div class="name">${esc(coin.name || 'Unknown')}</div>
+ <div class="sub"><span class="sym">$${esc((coin.symbol||'').toUpperCase())}</span><span class="age">${ago(coin.first_seen_at_ms)}</span></div>
+ </div>
+ ${catBadge(coin.category)}
+ </div>
+ <div class="scorerow">
+ ${ring(coin.quality_score, v.tone)}
+ <div style="flex:1;min-width:0">
+ <div style="margin-bottom:9px">${verdictPill(v)}${coin.is_news_meme ? ' <span class="flag soft" style="text-transform:none">news meme</span>' : ''}</div>
+ ${obBar(coin.organic_score, coin.bundle_score)}
+ </div>
+ </div>
+ <div class="metrics">
+ <div class="metric"><div class="mv">${coin.unique_buyers ?? 0}</div><div class="ml">Buyers</div></div>
+ <div class="metric"><div class="mv">${coin.dev_buy_sol != null ? sol(coin.dev_buy_sol) : '—'}</div><div class="ml">Dev buy</div></div>
+ <div class="metric"><div class="mv">${pct(coin.concentration_top1)}</div><div class="ml">Top wallet</div></div>
+ </div>
+ <div class="flags">${flags}</div>
+ ${coin.narrative ? `<div class="narr">${esc(coin.narrative)}</div>` : ''}
+ </article>`;
+ }
+
+ // ── radar ─────────────────────────────────────────────────
+ const state = { tab: 'radar', category: '', verdict: '', minq: '', q: '', coins: [], loading: false };
+ const grid = $('#ci-grid');
+
+ function renderCatChips() {
+ const wrap = $('#ci-cats');
+ wrap.innerHTML = `<button class="ci-chip ${state.category===''?'is-active':''}" data-cat="">All</button>` +
+ CATS.filter(c => c !== 'unknown').map(c =>
+ `<button class="ci-chip ${state.category===c?'is-active':''}" data-cat="${c}"><span class="dot" style="background:${CAT_COLOR(c)}"></span>${c}</button>`).join('');
+ wrap.querySelectorAll('.ci-chip').forEach(b => b.addEventListener('click', () => { state.category = b.dataset.cat; renderCatChips(); loadRadar(); }));
+ }
+
+ function skeletons(n = 6) { return Array.from({length:n}, () => `<div class="ci-skel"><div class="sh" style="width:60%"></div><div class="sh" style="width:90%"></div><div class="sh" style="width:40%"></div><div class="sh" style="width:75%"></div></div>`).join(''); }
+
+ function emptyState(degraded) {
+ if (degraded) {
+ return `<div class="ci-empty"><div class="icon">🛰️</div><h3>The engine is warming up</h3>
+ <p>The Coin Intelligence engine watches the live pump.fun firehose, observing each new launch's first ~90 seconds before it has a verdict. As soon as coins are observed they appear here — newest first.</p>
+ <div class="how"><span>Classifies every launch</span><span>Records every wallet</span><span>Organic vs bundle</span><span>Learns from outcomes</span></div>
+ <button class="ci-retry" id="ci-empty-retry">Refresh</button></div>`;
+ }
+ return `<div class="ci-empty"><div class="icon">🔍</div><h3>No coins match these filters</h3>
+ <p>Loosen the category, verdict, or quality filters to see more of the live radar.</p>
+ <button class="ci-retry" id="ci-empty-retry">Reset filters</button></div>`;
+ }
+
+ async function loadRadar() {
+ if (!state.coins.length) grid.innerHTML = skeletons();
+ state.loading = true;
+ try {
+ const data = await api({ view: 'feed', limit: 60, category: state.category, verdict: state.verdict, minQuality: state.minq, q: state.q });
+ state.degraded = !!data.degraded;
+ state.coins = data.coins || [];
+ $('#cnt-radar').textContent = state.degraded ? '' : state.coins.length;
+ if (state.degraded || !state.coins.length) {
+ grid.innerHTML = emptyState(state.degraded);
+ const rb = $('#ci-empty-retry');
+ if (rb) rb.addEventListener('click', () => { if (!state.degraded) { state.category=state.verdict=state.minq=state.q=''; $('#ci-q').value=''; $('#ci-verdict').value=''; $('#ci-minq').value=''; renderCatChips(); } loadRadar(); });
+ } else {
+ grid.innerHTML = state.coins.map(coinCard).join('');
+ wireCards(grid);
+ }
+ } catch (e) {
+ grid.innerHTML = `<div class="ci-empty"><div class="icon">⚠️</div><h3>Couldn't reach the intelligence feed</h3><p>${esc(e.message)}</p><button class="ci-retry" id="ci-empty-retry">Retry</button></div>`;
+ $('#ci-empty-retry')?.addEventListener('click', loadRadar);
+ } finally { state.loading = false; }
+ }
+
+ function wireCards(root) {
+ root.querySelectorAll('.ci-card').forEach(c => {
+ const open = () => openDrawer(c.dataset.mint);
+ c.addEventListener('click', open);
+ c.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(); } });
+ });
+ }
+
+ // ── leaderboard ───────────────────────────────────────────
+ let lbLoaded = false;
+ async function loadLeaderboard() {
+ if (lbLoaded) return;
+ $('#ci-lb-top').innerHTML = skeletons(3); $('#ci-lb-win').innerHTML = skeletons(3);
+ try {
+ const data = await api({ view: 'leaderboard', limit: 18 });
+ const top = data.top || [], win = data.winners || [];
+ $('#ci-lb-top').innerHTML = top.length ? top.map(coinCard).join('') : emptyState(!!data.degraded);
+ $('#ci-lb-win').innerHTML = win.length ? win.map(coinCard).join('')
+ : `<div class="ci-empty"><div class="icon">🌱</div><h3>No labeled winners yet</h3><p>Once observed coins graduate or 3×, they're labeled and surfaced here with their launch-time signals.</p></div>`;
+ wireCards($('#ci-lb-top')); wireCards($('#ci-lb-win'));
+ lbLoaded = true;
+ } catch (e) {
+ $('#ci-lb-top').innerHTML = `<div class="ci-empty"><div class="icon">⚠️</div><h3>Couldn't load leaderboard</h3><p>${esc(e.message)}</p></div>`;
+ }
+ }
+
+ // ── traders / smart money ─────────────────────────────────
+ let tradersLoaded = false;
+ function traderRow(t) {
+ const labels = (t.labels || []).map(l => `<span class="tlabel tl-${l}">${esc(TRADER_LABEL_TEXT[l] || l)}</span>`).join('');
+ let wr = '';
+ if (t.win_rate != null && t.labeled >= 1) {
+ const p = Math.round(t.win_rate * 100);
+ const tone = p >= 50 ? 'tone-success' : p >= 25 ? 'tone-warn' : 'tone-danger';
+ wr = `<span class="winrate ${tone}">${p}% <span style="opacity:.7">${t.wins}/${t.labeled}</span></span>`;
+ } else wr = `<span class="tsub">unproven</span>`;
+ return `<div class="trader-row">
+ <div style="min-width:0;flex:1">
+ <div class="addr"><a href="https://solscan.io/account/${esc(t.wallet)}" target="_blank" rel="noopener noreferrer">${esc(short(t.wallet))}</a></div>
+ <div class="tlabels">${labels}</div>
+ </div>
+ <div style="text-align:center;flex-shrink:0;width:108px">${wr}<div class="tsub">${t.coins} coins · ${t.buys} buys</div></div>
+ <div class="tright"><div class="tval">${sol(t.buy_sol)}</div><div class="tsub">net ${sol(t.net_sol)}</div></div>
+ </div>`;
+ }
+ async function loadTraders() {
+ if (tradersLoaded) return;
+ $('#ci-traders').innerHTML = `<div class="sub" style="color:var(--ci-muted)">Loading traders…</div>`;
+ try {
+ const data = await api({ view: 'traders', limit: 50 });
+ const ts = data.traders || [];
+ $('#cnt-traders').textContent = ts.length || '';
+ $('#ci-traders').innerHTML = ts.length ? ts.map(traderRow).join('')
+ : `<div class="ci-empty" style="border:none;background:none"><div class="icon">👻</div><h3>No traders recorded yet</h3><p>As the engine observes coins, every wallet that buys or sells is recorded and classified across coins. Smart-money win-rates appear once wallets accumulate labeled coins.</p></div>`;
+ tradersLoaded = true;
+ } catch (e) {
+ $('#ci-traders').innerHTML = `<div class="ci-empty" style="border:none;background:none"><div class="icon">⚠️</div><h3>Couldn't load traders</h3><p>${esc(e.message)}</p></div>`;
+ }
+ }
+
+ // ── learning ──────────────────────────────────────────────
+ let learnLoaded = false;
+ const OUTCOME_COLOR = { graduated: '#34d399', pumped: '#22d3ee', flat: '#818cf8', rugged: '#f87171', unknown: '#64748b' };
+ async function loadLearning() {
+ if (learnLoaded) return;
+ $('#ci-weights').innerHTML = `<div class="sub">Loading…</div>`;
+ try {
+ const data = await api({ view: 'learning' });
+ // weights
+ const ws = data.weights || [];
+ if (ws.length) {
+ const max = Math.max(0.15, ...ws.map(w => Math.abs(w.weight)));
+ $('#ci-weights').innerHTML = ws.map(w => {
+ const frac = Math.min(1, Math.abs(w.weight) / max), half = 50 * frac;
+ const pos = w.weight >= 0;
+ const i = pos
+ ? `left:50%;width:${half}%;background:linear-gradient(90deg,#10b981,#34d399)`
+ : `right:50%;width:${half}%;background:linear-gradient(90deg,#f43f5e,#fb7185)`;
+ return `<div class="wbar-row"><span class="wn">${esc(prettySignal(w.signal))}</span><div class="wbar-track"><span class="mid"></span><i style="${i}"></i></div><span class="wv" style="color:${pos?'#34d399':'#fb7185'}">${w.weight>=0?'+':''}${w.weight.toFixed(2)}</span></div>`;
+ }).join('') + `<p class="sub" style="margin-top:14px">Trained on <b style="color:var(--ci-text)">${data.sample_size || 0}</b> labeled coins${data.trained_at ? ' · '+ago(new Date(data.trained_at).getTime())+' ago' : ''}.</p>`;
+ } else {
+ $('#ci-weights').innerHTML = `<div class="ci-empty" style="border:none;background:none;padding:30px 0"><div class="icon">🧠</div><h3>Not enough data to train yet</h3><p>The model needs ~50 labeled coins (graduated/pumped/flat/rugged) before it computes signal weights. Until then the sniper uses the transparent baseline quality score.</p></div>`;
+ }
+ // outcomes
+ const outs = data.outcomes || [];
+ const totalOut = outs.reduce((s, o) => s + o.count, 0) || 1;
+ const order = ['graduated','pumped','flat','rugged','unknown'];
+ $('#ci-outcomes').innerHTML = order.map(name => {
+ const o = outs.find(x => x.outcome === name) || { count: 0, avg_multiple: null };
+ const w = Math.round((o.count / totalOut) * 100);
+ return `<div class="ob-row"><span class="on">${name}</span><div class="ot"><i style="width:${Math.max(o.count?6:0,w)}%;background:${OUTCOME_COLOR[name]}"></i></div><span class="oc">${o.count}${o.avg_multiple?` · ${o.avg_multiple}×`:''}</span></div>`;
+ }).join('');
+ // coverage
+ const cov = data.coverage || { observed:0, classified:0, labeled:0, by_category:[] };
+ $('#ci-coverage-sub').innerHTML = `<b style="color:var(--ci-text)">${cov.observed}</b> coins observed · <b style="color:var(--ci-text)">${cov.classified}</b> classified · <b style="color:var(--ci-text)">${cov.labeled}</b> outcome-labeled`;
+ $('#ci-coverage').innerHTML = (cov.by_category||[]).map(c => `<span class="cov-cat"><span class="dot" style="width:7px;height:7px;border-radius:50%;background:${CAT_COLOR(c.category)}"></span>${esc(c.category)} <b>${c.count}</b></span>`).join('') || '<span class="sub">No categories yet.</span>';
+ learnLoaded = true;
+ } catch (e) {
+ $('#ci-weights').innerHTML = `<div class="ci-empty" style="border:none;background:none"><div class="icon">⚠️</div><h3>Couldn't load learning data</h3><p>${esc(e.message)}</p></div>`;
+ }
+ }
+ const prettySignal = (k) => ({ organic_score:'Organic demand', bundle_score:'Bundle likelihood', snipe_ratio:'Snipe ratio', coordination_score:'Coordination', timing_entropy:'Timing spread', concentration_top1:'Top wallet share', concentration_top5:'Top-5 share', concentration_top10:'Top-10 share', fresh_wallet_ratio:'Fresh wallets', bubblemap_connectivity:'Funder connectivity' }[k] || k);
+
+ // ── detail drawer + bubble-map ────────────────────────────
+ const scrim = $('#ci-scrim'), drawer = $('#ci-drawer'), drawerBody = $('#ci-drawer-body');
+ function closeDrawer() { drawer.classList.remove('is-open'); scrim.classList.remove('is-open'); drawer.setAttribute('aria-hidden','true'); }
+ $('#ci-drawer-close').addEventListener('click', closeDrawer);
+ scrim.addEventListener('click', closeDrawer);
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeDrawer(); });
+
+ async function openDrawer(mint) {
+ drawer.classList.add('is-open'); scrim.classList.add('is-open'); drawer.setAttribute('aria-hidden','false');
+ drawer.scrollTop = 0;
+ drawerBody.innerHTML = `<div class="sh" style="height:60px;border-radius:14px;background:linear-gradient(90deg,rgba(255,255,255,.04),rgba(255,255,255,.09),rgba(255,255,255,.04));background-size:200% 100%;animation:ciShimmer 1.4s infinite"></div>`;
+ try {
+ const data = await api({ mint });
+ if (!data.found) { drawerBody.innerHTML = `<div class="ci-empty" style="border:none"><div class="icon">🔎</div><h3>Not observed yet</h3><p>This coin isn't in the intelligence index.</p></div>`; return; }
+ drawerBody.innerHTML = renderDetail(data);
+ const svg = $('#bm-svg'); if (svg) drawBubbleMap(svg, data.wallets || [], data.clusters || []);
+ } catch (e) {
+ drawerBody.innerHTML = `<div class="ci-empty" style="border:none"><div class="icon">⚠️</div><h3>Couldn't load detail</h3><p>${esc(e.message)}</p></div>`;
+ }
+ }
+
+ function renderDetail(d) {
+ const c = d.coin, v = c.verdict;
+ const tags = (c.tags || []).map(t => `<span class="d-tag">${esc(t)}</span>`).join('');
+ const sigRows = SIGNAL_META.map(([key, name, dir]) => {
+ const val = c[key];
+ if (val == null) return '';
+ const w = Math.round(val * 100);
+ const col = dir === 'good' ? (val >= 0.5 ? '#34d399' : '#fbbf24') : (val >= 0.5 ? '#f87171' : '#34d399');
+ return `<div class="sig-row"><span class="sname">${esc(name)}</span><div class="sbar"><i style="width:${w}%;background:${col}"></i></div><span class="sval">${pct(val)}</span></div>`;
+ }).join('');
+ const flags = (c.risk_flags||[]).map(f => `<span class="flag ${HARD_FLAGS.has(f)?'':'soft'}">${esc(FLAG_TEXT[f]||f)}</span>`).join('') || '<span class="sub" style="color:var(--ci-faint);font-size:12px">No risk flags raised.</span>';
+
+ let outcomeHtml = '';
+ if (d.outcome && d.outcome.outcome !== 'unknown') {
+ const o = d.outcome;
+ const map = { graduated:['🎓','Graduated','tone-success'], pumped:['🚀','Pumped',`tone-success`], flat:['➖','Flat','tone-neutral'], rugged:['💀','Rugged','tone-danger'] };
+ const m = map[o.outcome] || ['❔','Unknown','tone-neutral'];
+ outcomeHtml = `<div class="d-section"><h4>Outcome</h4><div class="outcome-banner ${m[2]}"><span class="oi">${m[0]}</span><div><div class="ot">${m[1]}</div><div class="os">${o.ath_multiple!=null?`ATH ${o.ath_multiple}× from first sight · `:''}${o.ath_market_cap_usd!=null?`ATH ${usd(o.ath_market_cap_usd)}`:''}${o.last_market_cap_usd!=null?` · now ${usd(o.last_market_cap_usd)}`:''}</div></div></div></div>`;
+ }
+
+ const wallets = d.wallets || [];
+ const walletRows = wallets.slice(0, 20).map(w => {
+ const labels = (w.labels||[]).map(l => `<span class="tlabel tl-${l}">${esc(TRADER_LABEL_TEXT[l]||l)}</span>`).join('');
+ return `<div class="trader-row">
+ <div style="min-width:0;flex:1">
+ <div class="addr"><a href="https://solscan.io/account/${esc(w.wallet)}" target="_blank" rel="noopener noreferrer">${esc(short(w.wallet))}</a></div>
+ <div class="tlabels">${labels||'<span class="tlabel tl-active">trader</span>'}</div>
+ </div>
+ <div class="tright"><div class="tval">${sol(w.net_sol)}</div><div class="tsub">${pct(w.share)} of buys</div></div>
+ </div>`;
+ }).join('');
+
+ const clusters = d.clusters || [];
+ const bmLegend = clusters.length
+ ? `<div class="bm-legend">${clusters.slice(0,6).map((cl,i)=>`<span><span class="sw" style="background:${clusterColor(cl.cluster)}"></span>${cl.wallets} wallets · ${sol(cl.net_sol)}</span>`).join('')}<span><span class="sw" style="background:#fbbf24"></span>creator</span></div>`
+ : `<div class="bm-legend"><span><span class="sw" style="background:#fbbf24"></span>creator</span><span><span class="sw" style="background:#5b6478"></span>independent buyers (no shared funder)</span></div>`;
+
+ return `
+ <div class="d-head">
+ <img class="avatar" referrerpolicy="no-referrer" src="${esc(imgProxy(c.image_uri, c.mint))}" onerror="this.onerror=null;this.src='${esc(fallbackImg(c.mint))}'" alt="" />
+ <div><div class="name">${esc(c.name||'Unknown')}</div><div class="sym">$${esc((c.symbol||'').toUpperCase())} · ${esc(short(c.mint))}</div>
+ <div style="margin-top:8px;display:flex;gap:8px;align-items:center;flex-wrap:wrap">${catBadge(c.category)}${verdictPill(v)}${c.is_news_meme?'<span class="flag soft" style="text-transform:none">news meme</span>':''}</div></div>
+ </div>
+ <div class="d-section">
+ <div style="display:flex;align-items:center;gap:14px">
+ ${ring(c.quality_score, v.tone)}
+ <div style="flex:1">${obBar(c.organic_score, c.bundle_score)}</div>
+ </div>
+ </div>
+ ${c.narrative ? `<div class="d-section"><h4>Thesis</h4><p style="font-size:13.5px;line-height:1.55;color:var(--ci-text);margin:0">${esc(c.narrative)}</p>${tags?`<div class="d-tags" style="margin-top:10px">${tags}</div>`:''}<p class="sub" style="margin:8px 0 0;color:var(--ci-faint);font-size:11px">Classified by ${esc(c.classify_source||'heuristic')}${c.classify_confidence!=null?` · ${Math.round(c.classify_confidence*100)}% confidence`:''}</p></div>` : ''}
+ ${outcomeHtml}
+ <div class="d-section"><h4>Launch signals</h4>${sigRows||'<span class="sub">No signal data.</span>'}</div>
+ <div class="d-section"><h4>Trade footprint</h4><div class="d-grid">
+ <div class="d-stat"><div class="v">${c.unique_buyers??0}</div><div class="l">Unique buyers</div></div>
+ <div class="d-stat"><div class="v">${c.unique_sellers??0}</div><div class="l">Unique sellers</div></div>
+ <div class="d-stat"><div class="v g">${sol(c.buy_volume_sol)}</div><div class="l">Buy volume</div></div>
+ <div class="d-stat"><div class="v r">${sol(c.sell_volume_sol)}</div><div class="l">Sell volume</div></div>
+ <div class="d-stat"><div class="v">${c.dev_buy_sol!=null?sol(c.dev_buy_sol):'—'}</div><div class="l">Dev buy ${c.dev_sold?'· <span style="color:var(--ci-danger)">dumped</span>':''}</div></div>
+ <div class="d-stat"><div class="v">${sol(c.largest_buy_sol)}</div><div class="l">Largest buy</div></div>
+ </div></div>
+ <div class="d-section"><h4>Risk flags</h4><div class="flags">${flags}</div></div>
+ <div class="d-section"><h4>Wallet network · funder clusters</h4>
+ <svg id="bm-svg" class="bubblemap" viewBox="0 0 420 248" preserveAspectRatio="xMidYMid meet"></svg>
+ ${bmLegend}
+ </div>
+ <div class="d-section"><h4>Order book · classified ${wallets.length?`(${wallets.length} wallets)`:''}</h4>
+ ${walletRows || '<span class="sub" style="color:var(--ci-faint);font-size:12px">No wallet-level data captured for this coin yet.</span>'}
+ </div>
+ <div class="d-section"><div class="d-links">
+ <a class="primary" href="/coin3d?mint=${encodeURIComponent(c.mint)}">Open in 3D →</a>
+ <a href="https://pump.fun/coin/${encodeURIComponent(c.mint)}" target="_blank" rel="noopener noreferrer">pump.fun ↗</a>
+ <a href="https://solscan.io/token/${encodeURIComponent(c.mint)}" target="_blank" rel="noopener noreferrer">Solscan ↗</a>
+ </div></div>`;
+ }
+
+ const CLUSTER_PALETTE = ['#f87171','#fb923c','#22d3ee','#a78bfa','#f472b6','#a3e635','#38bdf8','#fb7185'];
+ const clusterColor = (i) => CLUSTER_PALETTE[i % CLUSTER_PALETTE.length];
+
+ // Bubblemaps-lite: bubbles = top wallets sized by net SOL, grouped + colored
+ // by shared SOL funder. Wallets in the same cluster are linked + drawn near
+ // each other; independent buyers are scattered. The creator is gold-ringed.
+ function drawBubbleMap(svg, wallets, clusters) {
+ const W = 420, H = 248, ns = 'http://www.w3.org/2000/svg';
+ svg.innerHTML = '';
+ const top = wallets.filter(w => (w.net_sol||0) > 0).slice(0, 34);
+ if (!top.length) {
+ const t = document.createElementNS(ns, 'text');
+ t.setAttribute('x', W/2); t.setAttribute('y', H/2); t.setAttribute('text-anchor','middle');
+ t.setAttribute('fill', '#5c6273'); t.setAttribute('font-size','12');
+ t.textContent = 'No wallet network captured';
+ svg.appendChild(t); return;
+ }
+ const maxNet = Math.max(...top.map(w => w.net_sol));
+ const rOf = (n) => 7 + Math.sqrt(n / maxNet) * 21;
+
+ // group: each cluster id → center; null-cluster wallets scatter on outer ring.
+ const clusterIds = [...new Set(top.map(w => w.cluster).filter(c => c != null))];
+ const centers = new Map();
+ clusterIds.forEach((id, i) => {
+ const a = (i / Math.max(1, clusterIds.length)) * Math.PI * 2 - Math.PI / 2;
+ centers.set(id, { x: W/2 + Math.cos(a) * 78, y: H/2 + Math.sin(a) * 64 });
+ });
+ let scatterI = 0;
+ const scatterN = top.filter(w => w.cluster == null).length;
+ const placed = top.map(w => {
+ if (w.cluster != null && centers.has(w.cluster)) {
+ const c = centers.get(w.cluster);
+ const sib = top.filter(x => x.cluster === w.cluster);
+ const idx = sib.indexOf(w), a = (idx / Math.max(1, sib.length)) * Math.PI * 2;
+ return { w, x: c.x + Math.cos(a) * 22, y: c.y + Math.sin(a) * 22, cx: c.x, cy: c.y };
+ }
+ const a = (scatterI / Math.max(1, scatterN)) * Math.PI * 2;
+ scatterI++;
+ return { w, x: W/2 + Math.cos(a) * 96, y: H/2 + Math.sin(a) * 82, cx: null, cy: null };
+ });
+
+ // links within clusters
+ for (const p of placed) {
+ if (p.cx == null) continue;
+ const line = document.createElementNS(ns, 'line');
+ line.setAttribute('x1', p.x); line.setAttribute('y1', p.y);
+ line.setAttribute('x2', p.cx); line.setAttribute('y2', p.cy);
+ line.setAttribute('stroke', clusterColor(p.w.cluster)); line.setAttribute('stroke-width','1'); line.setAttribute('stroke-opacity','0.35');
+ svg.appendChild(line);
+ }
+ // bubbles
+ for (const p of placed) {
+ const r = rOf(p.w.net_sol);
+ const g = document.createElementNS(ns, 'g');
+ const circle = document.createElementNS(ns, 'circle');
+ circle.setAttribute('cx', p.x); circle.setAttribute('cy', p.y); circle.setAttribute('r', r);
+ const col = p.w.is_creator ? '#fbbf24' : (p.w.cluster != null ? clusterColor(p.w.cluster) : '#5b6478');
+ circle.setAttribute('fill', col); circle.setAttribute('fill-opacity', p.w.cluster != null || p.w.is_creator ? '0.5' : '0.32');
+ circle.setAttribute('stroke', col); circle.setAttribute('stroke-width', p.w.is_creator ? '2.2' : '1.2'); circle.setAttribute('stroke-opacity','0.95');
+ const title = document.createElementNS(ns, 'title');
+ title.textContent = `${short(p.w.wallet)}${p.w.is_creator?' (creator)':''} — net ${sol(p.w.net_sol)}${(p.w.labels||[]).length?' · '+p.w.labels.join(', '):''}`;
+ circle.appendChild(title);
+ g.appendChild(circle);
+ svg.appendChild(g);
+ }
+ }
+
+ // ── tabs ───────────────────────────────────────────────────
+ function switchTab(tab) {
+ state.tab = tab;
+ document.querySelectorAll('.ci-tab').forEach(t => t.classList.toggle('is-active', t.dataset.tab === tab));
+ document.querySelectorAll('[data-view]').forEach(s => s.classList.add('hide'));
+ $('#view-' + tab).classList.remove('hide');
+ if (tab === 'leaderboard') loadLeaderboard();
+ else if (tab === 'traders') loadTraders();
+ else if (tab === 'learning') loadLearning();
+ }
+ document.querySelectorAll('.ci-tab').forEach(t => t.addEventListener('click', () => switchTab(t.dataset.tab)));
+
+ // ── header stats ───────────────────────────────────────────
+ async function loadStats() {
+ try {
+ const data = await api({ view: 'learning' });
+ const cov = data.coverage || { observed:0, classified:0, labeled:0 };
+ const grad = (data.outcomes||[]).find(o => o.outcome === 'graduated')?.count || 0;
+ $('#ci-stats').innerHTML = [
+ ['Observed', cov.observed], ['Classified', cov.classified], ['Labeled', cov.labeled], ['Graduated', grad],
+ ].map(([l,v]) => `<div class="ci-stat"><div class="v">${v}</div><div class="l">${l}</div></div>`).join('');
+ $('#ci-hero').dataset.degraded = data.degraded ? '1' : '0';
+ } catch { $('#ci-hero').dataset.degraded = '1'; }
+ }
+
+ // ── filters wiring ─────────────────────────────────────────
+ let qDebounce;
+ $('#ci-q').addEventListener('input', (e) => { clearTimeout(qDebounce); qDebounce = setTimeout(() => { state.q = e.target.value.trim(); loadRadar(); }, 220); });
+ $('#ci-verdict').addEventListener('change', (e) => { state.verdict = e.target.value; loadRadar(); });
+ $('#ci-minq').addEventListener('change', (e) => { state.minq = e.target.value; loadRadar(); });
+
+ // ── boot + auto-refresh ────────────────────────────────────
+ renderCatChips();
+ loadStats();
+ loadRadar();
+ let timer = setInterval(() => { if (state.tab === 'radar' && !document.hidden) loadRadar(); }, REFRESH_MS);
+ document.addEventListener('visibilitychange', () => { if (!document.hidden && state.tab === 'radar') loadRadar(); });
+ </script>
+ <script src="/brand.js" defer></script>
+</body>
+</html>
diff --git a/pages/radar.html b/pages/radar.html
new file mode 100644
index 000000000..2afc2c642
--- /dev/null
+++ b/pages/radar.html
@@ -0,0 +1,92 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Coin Radar — live pump.fun launch intelligence · three.ws</title>
+ <meta
+ name="description"
+ content="A live radar of every pump.fun coin in its first ~90 seconds of trading — classified and risk-scored by the Coin Intelligence Engine. See bundle vs organic, concentration, and risk flags before you act."
+ />
+ <meta name="robots" content="index, follow" />
+ <link rel="canonical" href="https://three.ws/radar" />
+
+ <meta property="og:type" content="website" />
+ <meta property="og:site_name" content="three.ws" />
+ <meta property="og:title" content="Coin Radar — live pump.fun launch intelligence" />
+ <meta
+ property="og:description"
+ content="Every new pump.fun coin, scored in its first ~90 seconds: bundle vs organic, concentration, risk flags — live."
+ />
+ <meta property="og:url" content="https://three.ws/radar" />
+ <meta property="og:image" content="https://three.ws/og-image.png" />
+ <meta property="og:image:width" content="1200" />
+ <meta property="og:image:height" content="630" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="Coin Radar — live pump.fun launch intelligence" />
+ <meta
+ name="twitter:description"
+ content="Every new pump.fun coin, scored in its first ~90 seconds: bundle vs organic, concentration, risk flags — live."
+ />
+ <meta name="twitter:image" content="https://three.ws/og-image.png" />
+
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ <link rel="manifest" href="/site.webmanifest" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <link rel="stylesheet" href="/mobile.css" />
+ <link rel="stylesheet" href="/src/radar.css" />
+
+ <script type="application/ld+json">
+ {
+ "@context": "https://schema.org",
+ "@type": "WebPage",
+ "name": "Coin Radar",
+ "description": "Live radar of every pump.fun coin in its first ~90 seconds of trading, classified and risk-scored by the Coin Intelligence Engine.",
+ "url": "https://three.ws/radar",
+ "isPartOf": { "@type": "WebSite", "name": "three.ws", "url": "https://three.ws" }
+ }
+ </script>
+ </head>
+ <body class="radar-page">
+ <header><div id="nav-container"></div></header>
+ <script src="/nav.js"></script>
+
+ <main class="radar-main" id="main-content">
+ <nav class="radar-breadcrumb" aria-label="Breadcrumb">
+ <a href="/">three.ws</a>
+ <span aria-hidden="true">/</span>
+ <a href="/launches">Launches</a>
+ <span aria-hidden="true">/</span>
+ <span>Coin Radar</span>
+ </nav>
+
+ <section class="radar-hero">
+ <span class="radar-pill"><span class="radar-pill-dot"></span> Coin Intelligence Engine</span>
+ <h1>Coin Radar</h1>
+ <p>
+ Every new pump.fun coin, watched for its first ~90 seconds of trading and scored on the
+ spot — bundle vs organic, wallet concentration, dev behaviour, and live risk flags. Read the
+ room before you act.
+ </p>
+ </section>
+
+ <div id="radar-root"></div>
+ </main>
+
+ <div id="footer-container"></div>
+ <script src="/footer.js"></script>
+
+ <script type="module">
+ import { mountRadar } from '/src/radar.js';
+ mountRadar(document.getElementById('radar-root'));
+ </script>
+ <script src="/brand.js" defer></script>
+ </body>
+</html>
diff --git a/pages/smart-money.html b/pages/smart-money.html
new file mode 100644
index 000000000..08ed71b8f
--- /dev/null
+++ b/pages/smart-money.html
@@ -0,0 +1,373 @@
+<!doctype html>
+<html lang="en" data-theme="dark">
+<head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
+ <title>Smart Money Radar — follow the wallets that actually win on pump.fun · three.ws</title>
+ <meta name="description" content="A live, first-party reputation graph of every pump.fun wallet. We cross each coin's buyers with which coins actually graduated, so you can see exactly which wallets keep picking winners — and what they're buying right now." />
+ <meta property="og:title" content="Smart Money Radar · three.ws" />
+ <meta property="og:description" content="Stop guessing. See which wallets actually win on pump.fun, and what the proven money is accumulating right now — scored from full-coverage trade data." />
+ <meta property="og:type" content="website" />
+ <meta property="og:site_name" content="three.ws" />
+ <meta property="og:url" content="https://three.ws/smart-money" />
+ <meta property="og:image" content="https://three.ws/og-image.png" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="Smart Money Radar — follow the wallets that actually win on pump.fun" />
+ <meta name="twitter:description" content="A live reputation graph of every pump.fun wallet. See who keeps picking winners, and what they're buying right now." />
+ <meta name="twitter:image" content="https://three.ws/og-image.png" />
+ <link rel="canonical" href="https://three.ws/smart-money" />
+ <link rel="icon" href="/favicon.ico" />
+ <link rel="stylesheet" href="/nav.css" />
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Smart Money Radar","description":"A live first-party reputation graph of pump.fun wallets — see which wallets keep picking winners and what the proven money is buying now.","url":"https://three.ws/smart-money","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+ <style>
+ :root {
+ --bg: #06070d; --panel: rgba(14,16,24,0.72); --panel-solid: #0d0f17; --line: rgba(255,255,255,0.09);
+ --ink: #e9edf6; --muted: #8b93a7; --faint: rgba(255,255,255,0.45);
+ --cyan: #6ee7ff; --violet: #9a7bff; --gold: #fbbf24; --up: #34d399; --down: #f87171;
+ --r: 16px; --r-sm: 11px;
+ --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace;
+ --shadow: 0 18px 50px -22px rgba(0,0,0,0.85), 0 1px 0 rgba(255,255,255,0.05) inset;
+ --blur: saturate(160%) blur(16px);
+ }
+ * { box-sizing: border-box; }
+ html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
+ font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
+ body { background:
+ radial-gradient(60% 50% at 80% -5%, color-mix(in srgb, var(--violet) 16%, transparent), transparent 70%),
+ radial-gradient(50% 40% at 5% 0%, color-mix(in srgb, var(--cyan) 12%, transparent), transparent 65%), var(--bg); }
+ a { color: inherit; text-decoration: none; }
+ button { font: inherit; color: inherit; cursor: pointer; }
+ .wrap { max-width: 1160px; margin: 0 auto; padding: 0 18px 80px; }
+
+ /* hero */
+ .hero { padding: 40px 0 26px; }
+ .eyebrow { display: inline-flex; align-items: center; gap: 8px; font: 600 12px/1 var(--mono); letter-spacing: .04em;
+ text-transform: uppercase; color: var(--cyan); padding: 7px 12px; border: 1px solid color-mix(in srgb, var(--cyan) 30%, var(--line));
+ border-radius: 999px; background: color-mix(in srgb, var(--cyan) 9%, transparent); }
+ .eyebrow i { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 0 rgba(52,211,153,.6); animation: pulse 1.9s infinite; }
+ @keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(52,211,153,.5)} 70%{box-shadow:0 0 0 7px rgba(52,211,153,0)} 100%{box-shadow:0 0 0 0 rgba(52,211,153,0)} }
+ .hero h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.05; letter-spacing: -0.025em; margin: 18px 0 12px; font-weight: 800; }
+ .hero h1 span { background: linear-gradient(100deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
+ .hero p { max-width: 680px; font-size: 16px; color: var(--muted); margin: 0; }
+ .statline { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 22px; }
+ .statline div span { display: block; font: 600 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 5px; }
+ .statline div b { font: 800 22px/1 var(--mono); }
+
+ /* tabs */
+ .tabs { display: flex; gap: 8px; margin: 28px 0 18px; border-bottom: 1px solid var(--line); }
+ .tab { padding: 11px 4px; margin-bottom: -1px; border: none; background: none; color: var(--muted); font-weight: 600; font-size: 14px;
+ border-bottom: 2px solid transparent; transition: color .2s, border-color .2s; }
+ .tab:hover { color: var(--ink); }
+ .tab.on { color: var(--ink); border-bottom-color: var(--cyan); }
+ .tab .ct { font: 600 11px/1 var(--mono); color: var(--faint); margin-left: 6px; }
+
+ .view { display: none; }
+ .view.on { display: block; animation: fade .3s; }
+ @keyframes fade { from { opacity: 0; transform: translateY(4px); } }
+
+ /* coin grid */
+ .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
+ .coin { text-align: left; width: 100%; background: var(--panel); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
+ border: 1px solid var(--line); border-radius: var(--r); padding: 15px; box-shadow: var(--shadow);
+ display: flex; flex-direction: column; gap: 13px; transition: transform .14s, border-color .18s; }
+ .coin:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--cyan) 42%, var(--line)); }
+ .coin-top { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; }
+ .coin-img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; background: radial-gradient(120% 100% at 50% 0%, #1b2233, #0d1018); border: 1px solid var(--line); display: grid; place-items: center; font: 700 17px/1 var(--mono); color: var(--faint); }
+ .coin-id { min-width: 0; }
+ .coin-sym { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+ .coin-name { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+ .score-badge { text-align: center; }
+ .score-badge b { font: 800 24px/1 var(--mono); display: block; }
+ .score-badge span { font: 600 9px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
+ .s-hi { color: var(--up); } .s-mid { color: var(--gold); } .s-lo { color: var(--muted); }
+ .coin-meta { display: flex; gap: 8px; flex-wrap: wrap; }
+ .chip { font: 600 11px/1 var(--mono); padding: 5px 9px; border-radius: 8px; background: rgba(255,255,255,0.05); border: 1px solid var(--line); color: var(--muted); }
+ .chip b { color: var(--ink); }
+ .chip.cat { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 30%, var(--line)); }
+ .notable-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
+ .nlabel { font: 600 10px/1 var(--mono); padding: 4px 7px; border-radius: 6px; white-space: nowrap; }
+ .lb-smart_money { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); }
+ .lb-sniper { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
+ .lb-dumper, .lb-rugger { background: color-mix(in srgb, var(--down) 18%, transparent); color: var(--down); }
+ .lb-neutral, .lb-fresh, .lb-unproven { background: rgba(255,255,255,0.06); color: var(--faint); }
+
+ /* wallet leaderboard */
+ .lwrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
+ .lhead, .lrow { display: grid; grid-template-columns: 38px 1fr 92px 78px 92px; gap: 10px; align-items: center; padding: 12px 16px; }
+ .lhead { font: 600 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); border-bottom: 1px solid var(--line); }
+ .lrow { border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; transition: background .16s; }
+ .lrow:last-child { border-bottom: none; }
+ .lrow:hover { background: rgba(255,255,255,0.04); }
+ .lrank { font: 700 14px/1 var(--mono); color: var(--faint); }
+ .lrank.top { color: var(--gold); }
+ .lw { min-width: 0; display: flex; align-items: center; gap: 9px; }
+ .lw-addr { font: 600 13px/1 var(--mono); overflow: hidden; text-overflow: ellipsis; }
+ .lscore { font: 800 16px/1 var(--mono); text-align: right; }
+ .lstat { font: 600 13px/1 var(--mono); text-align: right; color: var(--muted); }
+ .lstat b { color: var(--ink); }
+ .colhide { text-align: right; }
+
+ /* drawer */
+ .drawer { position: fixed; inset: 0; z-index: 30; display: none; }
+ .drawer.open { display: block; }
+ .dr-back { position: absolute; inset: 0; background: rgba(4,5,9,0.66); backdrop-filter: blur(5px); animation: fade .25s; }
+ .dr-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(480px, 100vw); background: var(--panel-solid);
+ border-left: 1px solid var(--line); box-shadow: var(--shadow); overflow: auto; animation: slidein .3s cubic-bezier(.22,1,.36,1); }
+ @keyframes slidein { from { transform: translateX(30px); opacity: .4; } }
+ .dr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel-solid); z-index: 1; }
+ .dr-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
+ .dr-x { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); display: grid; place-items: center; }
+ .dr-x:hover { border-color: var(--cyan); }
+ .dr-body { padding: 18px 20px; }
+ .dr-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
+ .dr-stat { background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
+ .dr-stat span { display: block; font: 600 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .07em; color: var(--faint); margin-bottom: 6px; }
+ .dr-stat b { font: 800 19px/1 var(--mono); }
+ .dr-sec { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .09em; color: var(--faint); margin: 18px 0 10px; }
+ .nwallet { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
+ .nwallet:last-child { border: none; }
+ .solscan { font: 600 12px/1 var(--mono); color: var(--cyan); }
+
+ /* states */
+ .state { padding: 56px 22px; text-align: center; color: var(--muted); }
+ .state b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 8px; }
+ .state .btn { margin-top: 16px; }
+ .btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line);
+ background: var(--panel); font-weight: 600; font-size: 13px; transition: transform .12s, border-color .2s; }
+ .btn:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--cyan) 50%, var(--line)); }
+ .btn.primary { background: linear-gradient(135deg, color-mix(in srgb, var(--cyan) 24%, var(--panel)), color-mix(in srgb, var(--violet) 24%, var(--panel))); border-color: color-mix(in srgb, var(--cyan) 42%, var(--line)); color: #fff; }
+ .skel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); height: 150px;
+ position: relative; overflow: hidden; }
+ .skel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); animation: shimmer 1.4s infinite; }
+ @keyframes shimmer { to { transform: translateX(100%); } }
+
+ .foot { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--faint); }
+ .foot b { color: var(--muted); }
+
+ @media (max-width: 620px) {
+ .lhead, .lrow { grid-template-columns: 30px 1fr 70px 70px; }
+ .colhide { display: none; }
+ .dr-panel { width: 100vw; }
+ }
+ @media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; } }
+ </style>
+</head>
+<body>
+ <div id="nav-container"></div>
+ <script defer src="/nav.js"></script>
+
+ <main class="wrap">
+ <header class="hero">
+ <span class="eyebrow"><i></i> Live · pump.fun reputation graph</span>
+ <h1>Don't read the coin.<br><span>Read the money buying it.</span></h1>
+ <p>Every pump.fun launch, every wallet, every trade — crossed against which coins actually graduated to Raydium. The result is a real track record for each wallet, and a live read on which fresh coins the <em>proven</em> money is quietly accumulating. The only edge that compounds: follow the wallets that keep being right.</p>
+ <div class="statline" id="statline">
+ <div><span>Proven wallets</span><b id="stProven">—</b></div>
+ <div><span>Wallets ranked</span><b id="stRanked">—</b></div>
+ <div><span>Coins on radar</span><b id="stCoins">—</b></div>
+ <div><span>Updated</span><b id="stUpdated">—</b></div>
+ </div>
+ </header>
+
+ <nav class="tabs">
+ <button class="tab on" data-view="feed">Smart money is buying <span class="ct" id="ctFeed"></span></button>
+ <button class="tab" data-view="wallets">Top wallets <span class="ct" id="ctWallets"></span></button>
+ </nav>
+
+ <section class="view on" id="view-feed">
+ <div class="grid" id="feedGrid"></div>
+ </section>
+
+ <section class="view" id="view-wallets">
+ <div class="lwrap">
+ <div class="lhead">
+ <div>#</div><div>Wallet</div><div class="colhide">Win rate</div><div class="colhide">Record</div><div style="text-align:right">Score</div>
+ </div>
+ <div id="walletList"></div>
+ </div>
+ </section>
+
+ <p class="foot">Scored from first-party trade observation and on-chain graduations. A wallet's reputation is its track record, not a guarantee — coins are volatile and this is not financial advice. Reputations rebuild as new outcomes land.</p>
+ </main>
+
+ <div class="drawer" id="drawer">
+ <div class="dr-back" id="drBack"></div>
+ <div class="dr-panel" role="dialog" aria-modal="true">
+ <div class="dr-head">
+ <h3 id="drTitle">Details</h3>
+ <button class="dr-x" id="drClose" aria-label="Close">
+ <svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"><path d="M5 5l10 10M15 5L5 15"/></svg>
+ </button>
+ </div>
+ <div class="dr-body" id="drBody"></div>
+ </div>
+ </div>
+
+ <script type="module">
+ const API = '/api/pump/smart-money';
+ const $ = (id) => document.getElementById(id);
+ const fmtSol = (n) => (n == null ? '0' : (n >= 100 ? Math.round(n) : n.toFixed(n >= 10 ? 1 : 2)));
+ const short = (w) => (w ? w.slice(0, 4) + '…' + w.slice(-4) : '—');
+ const scoreClass = (s) => (s >= 70 ? 's-hi' : s >= 40 ? 's-mid' : 's-lo');
+ const labelText = { smart_money: 'smart money', sniper: 'sniper', dumper: 'dumper', rugger: 'rugger', fresh: 'fresh', neutral: 'neutral', unproven: 'new' };
+ const esc = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
+
+ let timer = null;
+
+ async function getJSON(url) {
+ const r = await fetch(url, { headers: { accept: 'application/json' } });
+ if (!r.ok) throw new Error(`${r.status}`);
+ return r.json();
+ }
+
+ function coinCard(c) {
+ const sc = Math.round(c.smart_money_score);
+ const img = c.image_uri
+ ? `<img class="coin-img" src="${esc(c.image_uri)}" alt="" loading="lazy" onerror="this.replaceWith(Object.assign(document.createElement('div'),{className:'coin-img',textContent:'${esc((c.symbol || '?').slice(0, 2))}'}))">`
+ : `<div class="coin-img">${esc((c.symbol || '?').slice(0, 2))}</div>`;
+ const notable = (c.notable || []).slice(0, 4).map((n) =>
+ `<span class="nlabel lb-${n.label || 'neutral'}">${short(n.wallet)}</span>`).join('');
+ return `<button class="coin" data-mint="${esc(c.mint)}">
+ <div class="coin-top">
+ ${img}
+ <div class="coin-id"><div class="coin-sym">${esc(c.symbol || '—')}</div><div class="coin-name">${esc(c.name || c.mint.slice(0, 10))}</div></div>
+ <div class="score-badge"><b class="${scoreClass(sc)}">${sc}</b><span>pedigree</span></div>
+ </div>
+ <div class="coin-meta">
+ <span class="chip"><b>${c.smart_wallet_count}</b> proven in</span>
+ <span class="chip"><b>${fmtSol(c.proven_buy_sol)}</b>◎ smart buy</span>
+ ${c.category ? `<span class="chip cat">${esc(c.category)}</span>` : ''}
+ ${c.graduated ? '<span class="chip" style="color:var(--up)">graduated</span>' : ''}
+ </div>
+ ${notable ? `<div class="notable-row">${notable}</div>` : ''}
+ </button>`;
+ }
+
+ function renderFeed(coins) {
+ const grid = $('feedGrid');
+ $('ctFeed').textContent = coins.length ? `(${coins.length})` : '';
+ if (!coins.length) {
+ grid.innerHTML = `<div class="state" style="grid-column:1/-1"><b>No proven money on a fresh coin yet.</b>
+ The radar only lights up when wallets with a real track record start buying a new launch. As coins are judged (≈6h after launch) and reputations build, this fills in. Check back shortly.</div>`;
+ return;
+ }
+ grid.innerHTML = coins.map(coinCard).join('');
+ grid.querySelectorAll('.coin').forEach((el) => el.addEventListener('click', () => openCoin(el.dataset.mint)));
+ }
+
+ function walletRow(w, i) {
+ return `<button class="lrow" data-wallet="${esc(w.wallet)}">
+ <div class="lrank ${i < 3 ? 'top' : ''}">${i + 1}</div>
+ <div class="lw"><span class="nlabel lb-${w.label}">${labelText[w.label] || w.label}</span><span class="lw-addr">${short(w.wallet)}</span></div>
+ <div class="lstat colhide">${Math.round(w.win_rate)}%</div>
+ <div class="lstat colhide"><b>${w.wins}</b>/${w.coins_judged}</div>
+ <div class="lscore ${scoreClass(w.smart_money_score)}">${Math.round(w.smart_money_score)}</div>
+ </button>`;
+ }
+
+ function renderWallets(wallets) {
+ const list = $('walletList');
+ $('ctWallets').textContent = wallets.length ? `(${wallets.length})` : '';
+ if (!wallets.length) {
+ list.innerHTML = `<div class="state"><b>No wallets ranked yet.</b>The graph is still accumulating verdicts. Wallets appear here once they have a few judged coins on record.</div>`;
+ return;
+ }
+ list.innerHTML = wallets.map(walletRow).join('');
+ list.querySelectorAll('.lrow').forEach((el) => el.addEventListener('click', () => openWallet(el.dataset.wallet)));
+ }
+
+ async function openCoin(mint) {
+ openDrawer('Loading…', '<div class="skel" style="height:120px"></div>');
+ try {
+ const { coin, notable } = await getJSON(`${API}?mint=${encodeURIComponent(mint)}`);
+ $('drTitle').textContent = coin.symbol || 'Coin';
+ const rows = (notable || []).map((n) => `<div class="nwallet">
+ <div class="lw"><span class="nlabel lb-${n.label}">${labelText[n.label] || n.label}</span><span class="lw-addr">${short(n.wallet)}</span></div>
+ <div class="lstat">${fmtSol(n.buy_sol)}◎</div>
+ <a class="solscan" href="https://solscan.io/account/${esc(n.wallet)}" target="_blank" rel="noopener">${Math.round(n.score)}</a>
+ </div>`).join('') || '<p style="color:var(--muted)">No reputable wallets identified in this coin yet.</p>';
+ $('drBody').innerHTML = `
+ <div class="dr-stats">
+ <div class="dr-stat"><span>Pedigree score</span><b class="${scoreClass(coin.smart_money_score)}">${Math.round(coin.smart_money_score)}</b></div>
+ <div class="dr-stat"><span>Proven wallets in</span><b>${coin.smart_wallet_count}</b></div>
+ <div class="dr-stat"><span>Smart buy volume</span><b>${fmtSol(coin.proven_buy_sol)}◎</b></div>
+ <div class="dr-stat"><span>Total buy volume</span><b>${fmtSol(coin.total_buy_sol)}◎</b></div>
+ </div>
+ <div class="dr-sec">Notable wallets buying</div>
+ ${rows}
+ <a class="btn primary" style="margin-top:18px" href="https://pump.fun/${esc(coin.mint)}" target="_blank" rel="noopener">Open on pump.fun →</a>`;
+ } catch (e) {
+ $('drBody').innerHTML = `<div class="state"><b>Not scored yet.</b>This coin hasn't been picked up by the radar.</div>`;
+ }
+ }
+
+ async function openWallet(wallet) {
+ openDrawer('Loading…', '<div class="skel" style="height:120px"></div>');
+ try {
+ const { wallet: w, recent_coins } = await getJSON(`${API}?wallet=${encodeURIComponent(wallet)}`);
+ $('drTitle').textContent = short(w.wallet);
+ const coins = (recent_coins || []).slice(0, 16).map((c) => `<div class="nwallet">
+ <div class="lw"><span class="lw-addr">${esc(c.symbol || c.mint.slice(0, 8))}</span>${c.graduated ? '<span class="nlabel lb-smart_money">graduated</span>' : ''}</div>
+ <div class="lstat">${fmtSol(c.buy_sol)}◎</div>
+ <a class="solscan" href="https://pump.fun/${esc(c.mint)}" target="_blank" rel="noopener">open</a>
+ </div>`).join('') || '<p style="color:var(--muted)">No recent coins on record.</p>';
+ $('drBody').innerHTML = `
+ <div style="margin-bottom:14px"><span class="nlabel lb-${w.label}">${labelText[w.label] || w.label}</span></div>
+ <div class="dr-stats">
+ <div class="dr-stat"><span>Reputation</span><b class="${scoreClass(w.smart_money_score)}">${Math.round(w.smart_money_score)}</b></div>
+ <div class="dr-stat"><span>Win rate</span><b>${Math.round(w.win_rate)}%</b></div>
+ <div class="dr-stat"><span>Wins / judged</span><b>${w.wins}/${w.coins_judged}</b></div>
+ <div class="dr-stat"><span>Dump rate</span><b>${Math.round(w.dump_rate)}%</b></div>
+ </div>
+ <a class="solscan" href="https://solscan.io/account/${esc(w.wallet)}" target="_blank" rel="noopener" style="display:inline-block;margin-bottom:6px">View ${short(w.wallet)} on Solscan →</a>
+ <div class="dr-sec">Recent coins bought</div>
+ ${coins}`;
+ } catch (e) {
+ $('drBody').innerHTML = `<div class="state"><b>No track record yet.</b>We haven't recorded judged trades for this wallet.</div>`;
+ }
+ }
+
+ function openDrawer(title, body) {
+ $('drTitle').textContent = title; $('drBody').innerHTML = body;
+ $('drawer').classList.add('open');
+ }
+ function closeDrawer() { $('drawer').classList.remove('open'); }
+ $('drBack').addEventListener('click', closeDrawer);
+ $('drClose').addEventListener('click', closeDrawer);
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeDrawer(); });
+
+ document.querySelectorAll('.tab').forEach((t) => t.addEventListener('click', () => {
+ document.querySelectorAll('.tab').forEach((x) => x.classList.toggle('on', x === t));
+ document.querySelectorAll('.view').forEach((v) => v.classList.toggle('on', v.id === `view-${t.dataset.view}`));
+ }));
+
+ async function refresh() {
+ try {
+ const [feed, board] = await Promise.all([
+ getJSON(`${API}?limit=60`),
+ getJSON(`${API}?leaderboard=1&limit=60`),
+ ]);
+ renderFeed(feed.coins || []);
+ renderWallets(board.wallets || []);
+ const proven = (board.wallets || []).filter((w) => w.label === 'smart_money').length;
+ $('stProven').textContent = proven;
+ $('stRanked').textContent = (board.wallets || []).length;
+ $('stCoins').textContent = (feed.coins || []).length;
+ $('stUpdated').textContent = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
+ } catch (e) {
+ $('feedGrid').innerHTML = `<div class="state" style="grid-column:1/-1"><b>Couldn't reach the radar.</b>${esc(e.message)}<button class="btn primary" id="retry">Retry</button></div>`;
+ const r = $('retry'); if (r) r.addEventListener('click', refresh);
+ }
+ }
+
+ // initial skeletons
+ $('feedGrid').innerHTML = Array.from({ length: 6 }, () => '<div class="skel"></div>').join('');
+ refresh();
+ timer = setInterval(refresh, 20000);
+ document.addEventListener('visibilitychange', () => {
+ if (document.hidden) { clearInterval(timer); timer = null; }
+ else if (!timer) { refresh(); timer = setInterval(refresh, 20000); }
+ });
+ </script>
+</body>
+</html>
diff --git a/pages/trader.html b/pages/trader.html
new file mode 100644
index 000000000..c75a37ba7
--- /dev/null
+++ b/pages/trader.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Trader · three.ws</title>
+ <meta name="description" content="A pump.fun trader's provable track record on three.ws — realized P&L, win rate, drawdown, and every trade traceable to its on-chain transaction." />
+ <meta property="og:type" content="profile" />
+ <meta property="og:site_name" content="three.ws" />
+ <meta property="og:title" content="Trader track record · three.ws" />
+ <meta property="og:description" content="A provable pump.fun track record — every number traceable to its transaction." />
+ <meta property="og:image" content="https://three.ws/og-image.png" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="theme-color" content="#0a0a0a" />
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ <link rel="manifest" href="/site.webmanifest" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <link rel="stylesheet" href="/src/leaderboard.css" />
+ <link rel="stylesheet" href="/src/trader.css" />
+ <link rel="stylesheet" href="/footer.css" />
+ <script defer src="/footer-newsletter.js"></script>
+ </head>
+ <body>
+ <header><div id="nav-container"></div></header>
+ <script src="/nav.js"></script>
+
+ <main class="tp-shell" id="tp-root" aria-busy="true">
+ <a class="tp-back" href="/leaderboard">← Leaderboard</a>
+ <div id="tp-content"></div>
+ </main>
+
+ <script type="module" src="/src/trader.js"></script>
+ <script src="/brand.js" defer></script>
+ <div id="footer-container"></div>
+ <script src="/footer.js"></script>
+ </body>
+</html>
diff --git a/public/changelog.json b/public/changelog.json
index d426a08b6..afc6411c9 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,11 +1,31 @@
{
- "generated_at": "2026-06-15T22:14:11.659Z",
+ "generated_at": "2026-06-15T22:28:22.020Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
"url": "https://three.ws"
},
"entries": [
+ {
+ "date": "2026-06-15",
+ "type": "launch",
+ "title": "Coin Intelligence",
+ "summary": "Every pump.fun launch watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals predict winners.",
+ "link": "/coin-intel",
+ "tags": [
+ "launch"
+ ]
+ },
+ {
+ "date": "2026-06-15",
+ "type": "launch",
+ "title": "Coin Radar",
+ "summary": "Live pump.fun launch intelligence: every new coin scored in its first ~90 seconds — bundle vs organic, wallet concentration, dev behaviour, and risk flags from the Coin Intelligence Engine.",
+ "link": "/radar",
+ "tags": [
+ "launch"
+ ]
+ },
{
"date": "2026-06-15",
"type": "launch",
@@ -36,6 +56,16 @@
"launch"
]
},
+ {
+ "date": "2026-06-15",
+ "type": "launch",
+ "title": "Trader Leaderboard",
+ "summary": "Pump.fun traders ranked by a provable, on-chain track record — realized P&L, win rate, drawdown — with every number traceable to its transaction.",
+ "link": "/leaderboard",
+ "tags": [
+ "launch"
+ ]
+ },
{
"date": "2026-06-15",
"type": "update",
@@ -488,6 +518,16 @@
"infra"
]
},
+ {
+ "date": "2026-06-15",
+ "type": "update",
+ "title": "Trader Leaderboard — pump.fun traders ranked by a track record you can verify",
+ "summary": "A new leaderboard ranks every trading agent by a single Trader Score that blends realized P&L, win rate, profit factor, consistency and drawdown — then holds back judgment until a trader has enough closed trades to trust. Losing trades are counted, never hidden, and fast in-and-out churn is penalized rather than rewarded. Filter by time window (24h / 7d / 30d / all-time), rank by score, P&L, win rate or ROI, and show verified traders only. Open any trader for a full profile: a score gauge, a realized-equity curve, every key metric, their open positions, and a Proof tab where each closed trade links straight to its on-chain buy and sell transaction on Solscan — the numbers come from those, nothing else. The headline score is also committed on-chain daily as a signed attestation, so it can't be quietly edited after the fact. Share any track record as a one-tap PnL card.",
+ "link": "/leaderboard",
+ "tags": [
+ "feature"
+ ]
+ },
{
"date": "2026-06-15",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index f969d5e64..ef27d17b1 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -6,6 +6,22 @@
<atom:link href="https://three.ws/changelog.xml" rel="self" type="application/rss+xml"/>
<description>What's new on three.ws — features, improvements, and releases, newest first.</description>
<language>en</language>
+ <item>
+ <title>Coin Intelligence</title>
+ <link>https://three.ws/coin-intel</link>
+ <guid isPermaLink="false">2026-06-15:Coin Intelligence</guid>
+ <pubDate>Mon, 15 Jun 2026 12:00:00 GMT</pubDate>
+ <category>launch</category>
+ <description>Every pump.fun launch watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals predict winners.</description>
+ </item>
+ <item>
+ <title>Coin Radar</title>
+ <link>https://three.ws/radar</link>
+ <guid isPermaLink="false">2026-06-15:Coin Radar</guid>
+ <pubDate>Mon, 15 Jun 2026 12:00:00 GMT</pubDate>
+ <category>launch</category>
+ <description>Live pump.fun launch intelligence: every new coin scored in its first ~90 seconds — bundle vs organic, wallet concentration, dev behaviour, and risk flags from the Coin Intelligence Engine.</description>
+ </item>
<item>
<title>Launch a Coin</title>
<link>https://three.ws/launch</link>
@@ -30,6 +46,14 @@
<category>launch</category>
<description>How three.ws charges in $THREE, the only coin: pay-per-use pricing for AI compute, hold-to-access holder tiers with lower fees, rare *.threews.sol names, and a holder-rewards loop. No burns — every spend funds the treasury or reflects back to holders.</description>
</item>
+ <item>
+ <title>Trader Leaderboard</title>
+ <link>https://three.ws/leaderboard</link>
+ <guid isPermaLink="false">2026-06-15:Trader Leaderboard</guid>
+ <pubDate>Mon, 15 Jun 2026 12:00:00 GMT</pubDate>
+ <category>launch</category>
+ <description>Pump.fun traders ranked by a provable, on-chain track record — realized P&amp;L, win rate, drawdown — with every number traceable to its transaction.</description>
+ </item>
<item>
<title>After you launch a coin, jump straight to viewing or managing it</title>
<link>https://three.ws/pump-dashboard</link>
@@ -382,6 +406,14 @@
<category>feature</category>
<description>The platform that helps you put your agents on-chain now does the same for itself. three.ws publishes a 3D Agent Card — a verifiable manifest of its name, its default 3D avatar, and its A2A/MCP/x402 service endpoints — at three.ws/.well-known/3d-agent-card.json, and ships a one-command tool that mints the platform agent in the canonical ERC-8004 IdentityRegistry on Base (with a Base Sepolia rehearsal first). The card cryptographically commits to the avatar: the SHA-256 in the card matches the exact GLB bytes served, so any indexer or wallet can independently verify the model hasn't been swapped. Other agents and directories can now discover and trust three.ws the same way three.ws lets them be discovered.</description>
</item>
+ <item>
+ <title>Trader Leaderboard — pump.fun traders ranked by a track record you can verify</title>
+ <link>https://three.ws/leaderboard</link>
+ <guid isPermaLink="false">2026-06-15:Trader Leaderboard — pump.fun traders ranked by a track record you can verify</guid>
+ <pubDate>Mon, 15 Jun 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>A new leaderboard ranks every trading agent by a single Trader Score that blends realized P&amp;L, win rate, profit factor, consistency and drawdown — then holds back judgment until a trader has enough closed trades to trust. Losing trades are counted, never hidden, and fast in-and-out churn is penalized rather than rewarded. Filter by time window (24h / 7d / 30d / all-time), rank by score, P&amp;L, win rate or ROI, and show verified traders only. Open any trader for a full profile: a score gauge, a realized-equity curve, every key metric, their open positions, and a Proof tab where each closed trade links straight to its on-chain buy and sell transaction on Solscan — the numbers come from those, nothing else. The headline score is also committed on-chain daily as a signed attestation, so it can't be quietly edited after the fact. Share any track record as a one-tap PnL card.</description>
+ </item>
<item>
<title>USDC-paired agent coins now record and display correct trade amounts</title>
<link>https://three.ws/changelog</link>
diff --git a/public/features.json b/public/features.json
index 0da967cc1..626ef4e3d 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-15T22:14:11.646Z",
+ "generated_at": "2026-06-15T22:28:21.999Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
@@ -526,6 +526,16 @@
"tags": [],
"showcase": false
},
+ {
+ "path": "/leaderboard",
+ "title": "Trader Leaderboard",
+ "description": "Pump.fun traders ranked by a provable, on-chain track record — realized P&L, win rate, drawdown — with every number traceable to its transaction.",
+ "added": "2026-06-15",
+ "auth": null,
+ "indexable": true,
+ "tags": [],
+ "showcase": false
+ },
{
"path": "/pay",
"title": "Pay (x402)",
@@ -576,6 +586,16 @@
"tags": [],
"showcase": false
},
+ {
+ "path": "/radar",
+ "title": "Coin Radar",
+ "description": "Live pump.fun launch intelligence: every new coin scored in its first ~90 seconds — bundle vs organic, wallet concentration, dev behaviour, and risk flags from the Coin Intelligence Engine.",
+ "added": "2026-06-15",
+ "auth": null,
+ "indexable": true,
+ "tags": [],
+ "showcase": false
+ },
{
"path": "/pump-dashboard",
"title": "Pump Dashboard",
@@ -626,6 +646,16 @@
"tags": [],
"showcase": false
},
+ {
+ "path": "/coin-intel",
+ "title": "Coin Intelligence",
+ "description": "Every pump.fun launch watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals predict winners.",
+ "added": "2026-06-15",
+ "auth": null,
+ "indexable": true,
+ "tags": [],
+ "showcase": false
+ },
{
"path": "/constellation",
"title": "watsonx Constellation",
diff --git a/public/llms-full.txt b/public/llms-full.txt
index 5dff051b4..745c2f2ee 100644
--- a/public/llms-full.txt
+++ b/public/llms-full.txt
@@ -320,6 +320,12 @@ URL: https://three.ws/launches
Live public feed of every coin launched by a three.ws agent — market caps, graduation status, and the agent behind each launch.
+### Trader Leaderboard
+
+URL: https://three.ws/leaderboard
+
+Pump.fun traders ranked by a provable, on-chain track record — realized P&L, win rate, drawdown — with every number traceable to its transaction.
+
### Pay (x402)
URL: https://three.ws/pay
@@ -350,6 +356,12 @@ URL: https://three.ws/pump-live
Real-time feed of every pump.fun launch as it happens, with a 3D agent that reacts live.
+### Coin Radar
+
+URL: https://three.ws/radar
+
+Live pump.fun launch intelligence: every new coin scored in its first ~90 seconds — bundle vs organic, wallet concentration, dev behaviour, and risk flags from the Coin Intelligence Engine.
+
### Pump Dashboard
URL: https://three.ws/pump-dashboard
@@ -380,6 +392,12 @@ URL: https://three.ws/pump-visualizer
3D visualizer of trending pump.fun tokens — live market data rendered as an interactive scene.
+### Coin Intelligence
+
+URL: https://three.ws/coin-intel
+
+Every pump.fun launch watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals predict winners.
+
### watsonx Constellation
URL: https://three.ws/constellation
diff --git a/public/llms.txt b/public/llms.txt
index cb1c31840..fa2dc4c4d 100644
--- a/public/llms.txt
+++ b/public/llms.txt
@@ -74,16 +74,19 @@ On-chain features: pay-per-call, token launches, vanity wallets.
- [Launch a Coin](https://three.ws/launch): Mint a coin for your 3D AI agent in one flow — pick an agent, set the name, symbol, and image, then launch on pump.fun straight from your wallet with an optional three.ws-branded vanity mint.
- [Agent Launches](https://three.ws/launches): Live public feed of every coin launched by a three.ws agent — market caps, graduation status, and the agent behind each launch.
+- [Trader Leaderboard](https://three.ws/leaderboard): Pump.fun traders ranked by a provable, on-chain track record — realized P&L, win rate, drawdown — with every number traceable to its transaction.
- [Pay (x402)](https://three.ws/pay): Pay-per-call gateway: invoke any x402-protocol paid API with a USDC micro-transaction.
- [Agent Wallet (x402 on Solana)](https://three.ws/play/agent-wallet): Watch your 3D avatar walk up to a paid endpoint and pay for it with its agent wallet — a real USDC micropayment signed by the agent and settled on Solana.
- [Sniper Arena — autonomous AI agents trading live](https://three.ws/play/arena): Watch three.ws AI agents trade pump.fun autonomously in real time. Live P&L leaderboard, each trade signed by the agent's own wallet and verifiable on-chain.
- [Pump.fun Stream](https://three.ws/pumpfun): Mint and trade pump.fun agent tokens on Solana. Live feed of every launch.
- [Pump Live](https://three.ws/pump-live): Real-time feed of every pump.fun launch as it happens, with a 3D agent that reacts live.
+- [Coin Radar](https://three.ws/radar): Live pump.fun launch intelligence: every new coin scored in its first ~90 seconds — bundle vs organic, wallet concentration, dev behaviour, and risk flags from the Coin Intelligence Engine.
- [Pump Dashboard](https://three.ws/pump-dashboard): Pump.fun trading desk: watchlists, scanner, quotes, portfolio, and live charts.
- [Strategy Lab](https://three.ws/strategy-lab): Build DCA and subscription strategies that trade on-chain on your behalf.
- [Solana Vanity Wallet](https://three.ws/vanity-wallet): Grind a Solana address with a custom prefix using your browser's GPU.
- [ETH Vanity (CREATE2)](https://three.ws/eth-vanity): Grind a vanity smart-contract address using the ThreeWSFactory CREATE2 deployer on BSC.
- [Pump Visualizer](https://three.ws/pump-visualizer): 3D visualizer of trending pump.fun tokens — live market data rendered as an interactive scene.
+- [Coin Intelligence](https://three.ws/coin-intel): Every pump.fun launch watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals predict winners.
- [watsonx Constellation](https://three.ws/constellation): Live Solana tokens in a 3D galaxy, positioned in semantic space by IBM Granite embeddings on watsonx.ai. Click a star for a live IBM Granite analysis.
- [x402 Bazaar](https://three.ws/bazaar): Search and browse the x402 facilitator catalog. Filter by network, price, and extensions. Pay any service in one click.
- [Agent Lookup](https://three.ws/lookup): Resolve any three.ws agent by Solana mint, agent ID, avatar ID, or slug — renders its interactive 3D avatar alongside its on-chain identity (collection, owner, agent wallet, Active/x402 status, Metaplex/Solscan/Magic Eden links).
diff --git a/public/nav-data.js b/public/nav-data.js
index df323f695..b3150e695 100644
--- a/public/nav-data.js
+++ b/public/nav-data.js
@@ -88,6 +88,24 @@ export const NAV_GROUPS = [
href: '/launch',
desc: 'Mint a coin for your agent on pump.fun',
},
+ {
+ title: 'Coin Intelligence',
+ href: '/coin-intel',
+ badge: 'New',
+ badgeTone: 'live',
+ desc: 'Every launch classified — organic vs bundle, the wallets, a learning score',
+ },
+ {
+ title: 'Trader Leaderboard',
+ href: '/leaderboard',
+ badge: 'New',
+ desc: 'Top traders ranked by a provable track record',
+ },
+ {
+ title: 'Sniper Arena',
+ href: '/play/arena',
+ desc: 'Watch AI agents trade pump.fun live',
+ },
{
title: 'Live Stream',
href: '/pump-live',
@@ -95,6 +113,19 @@ export const NAV_GROUPS = [
badgeTone: 'live',
desc: 'Real-time new launches',
},
+ {
+ title: 'Coin Radar',
+ href: '/radar',
+ badge: 'Live',
+ badgeTone: 'live',
+ desc: 'Live pump.fun launch intelligence — bundle vs organic, scored',
+ },
+ {
+ title: 'Smart Money Radar',
+ href: '/smart-money',
+ badge: 'New',
+ desc: 'Which wallets actually win — and what the proven money is buying now',
+ },
{
title: '3D Visualizer',
href: '/pump-visualizer',
diff --git a/public/sitemap/index.html b/public/sitemap/index.html
index 39cc982a5..c1f2fe0f4 100644
--- a/public/sitemap/index.html
+++ b/public/sitemap/index.html
@@ -65,7 +65,7 @@
<main class="sm-wrap">
<div class="sm-hero">
<h1>Sitemap</h1>
- <p>All 265 pages on three.ws, grouped by purpose. Looking for the machine-readable versions?</p>
+ <p>All 268 pages on three.ws, grouped by purpose. Looking for the machine-readable versions?</p>
<div class="sm-formats">
<a href="/sitemap.xml"><code>sitemap.xml</code> · for search engines</a>
<a href="/llms.txt"><code>llms.txt</code> · for AI agents</a>
@@ -77,7 +77,7 @@
</div>
<div class="sm-filter">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
- <input id="sm-filter-input" type="search" placeholder="Filter 265 pages by name, path, or description…" aria-label="Filter pages" autocomplete="off" spellcheck="false" />
+ <input id="sm-filter-input" type="search" placeholder="Filter 268 pages by name, path, or description…" aria-label="Filter pages" autocomplete="off" spellcheck="false" />
<kbd aria-hidden="true">/</kbd>
</div>
<p class="sm-filter-count" id="sm-filter-count" role="status" aria-live="polite"></p>
@@ -452,7 +452,7 @@
<section class="sm-section" id="crypto">
<header>
- <h2>Crypto<span class="sm-count" data-count>34</span></h2>
+ <h2>Crypto<span class="sm-count" data-count>37</span></h2>
<p class="sm-section-desc">On-chain features: pay-per-call, token launches, vanity wallets.</p>
</header>
<ul class="sm-list">
@@ -470,6 +470,13 @@
<span class="sm-desc">Live public feed of every coin launched by a three.ws agent — market caps, graduation status, and the agent behind each launch.</span>
</a>
</li>
+ <li>
+ <a href="/leaderboard">
+ <span class="sm-title">Trader Leaderboard</span>
+ <span class="sm-path">/leaderboard</span>
+ <span class="sm-desc">Pump.fun traders ranked by a provable, on-chain track record — realized P&amp;L, win rate, drawdown — with every number traceable to its transaction.</span>
+ </a>
+ </li>
<li>
<a href="/pay">
<span class="sm-title">Pay (x402)</span>
@@ -505,6 +512,13 @@
<span class="sm-desc">Real-time feed of every pump.fun launch as it happens, with a 3D agent that reacts live.</span>
</a>
</li>
+ <li>
+ <a href="/radar">
+ <span class="sm-title">Coin Radar</span>
+ <span class="sm-path">/radar</span>
+ <span class="sm-desc">Live pump.fun launch intelligence: every new coin scored in its first ~90 seconds — bundle vs organic, wallet concentration, dev behaviour, and risk flags from the Coin Intelligence Engine.</span>
+ </a>
+ </li>
<li>
<a href="/pump-dashboard">
<span class="sm-title">Pump Dashboard</span>
@@ -540,6 +554,13 @@
<span class="sm-desc">3D visualizer of trending pump.fun tokens — live market data rendered as an interactive scene.</span>
</a>
</li>
+ <li>
+ <a href="/coin-intel">
+ <span class="sm-title">Coin Intelligence</span>
+ <span class="sm-path">/coin-intel</span>
+ <span class="sm-desc">Every pump.fun launch watched and classified in real time — organic vs bundle, the wallets behind it, a transparent quality score, and a model that learns which signals predict winners.</span>
+ </a>
+ </li>
<li>
<a href="/constellation">
<span class="sm-title">watsonx Constellation</span>
diff --git a/src/dashboard-next/nav.js b/src/dashboard-next/nav.js
index ca4db9c64..2fd59404c 100644
--- a/src/dashboard-next/nav.js
+++ b/src/dashboard-next/nav.js
@@ -47,6 +47,7 @@ export const NAV = [
{ path: '/community', label: 'Community', icon: 'community', group: 'Explore', tags: ['social', 'forum', 'connect', 'members'], external: true },
{ path: '/demos', label: 'Demos', icon: 'play', group: 'Explore', tags: ['examples', 'showcase', 'interactive', 'try'], external: true },
{ path: '/pump-live', label: 'Pump.fun Live', icon: 'live', group: 'Explore', tags: ['feed', 'trending', 'tokens', 'trade', 'realtime'], external: true },
+ { path: '/radar', label: 'Coin Radar', icon: 'live', group: 'Explore', tags: ['intelligence', 'bundle', 'organic', 'rug', 'risk', 'score', 'pump.fun', 'launch', 'snipe', 'concentration'], external: true },
// ── Account ─────────────────────────────────────────────────────────
{ path: '/dashboard/account', label: 'Account', icon: 'user', group: 'Account', tags: ['wallets', 'sns', 'delegation', 'profile', 'action log', 'provider keys'] },
diff --git a/src/leaderboard.js b/src/leaderboard.js
new file mode 100644
index 000000000..5dcbd7662
--- /dev/null
+++ b/src/leaderboard.js
@@ -0,0 +1,265 @@
+/**
+ * Trader Leaderboard controller.
+ *
+ * Renders /api/sniper/leaderboard into a ranked, filterable, live-refreshing
+ * board. State (window / sort / network / verified) is reflected into the URL so
+ * any view is shareable. Every row deep-links to the trader's profile, where each
+ * number can be followed to its on-chain transaction.
+ */
+
+import {
+ escapeHtml, fmtSol, fmtUsd, fmtPct, pnlClass, shortAddr, holdTime, relTime,
+ identicon, verifiedBadge,
+} from './trader-format.js';
+
+const API = '/api/sniper/leaderboard';
+const REFRESH_MS = 20_000;
+const WINDOWS = new Set(['24h', '7d', '30d', 'all']);
+const SORTS = new Set(['score', 'pnl', 'winrate', 'roi']);
+const NETWORKS = new Set(['mainnet', 'devnet']);
+
+const $ = (sel, root = document) => root.querySelector(sel);
+
+const state = { network: 'mainnet', window: '30d', sort: 'score', verified: false };
+let timer = null;
+let firstLoad = true;
+
+// --- URL <-> state -----------------------------------------------------------
+function readUrl() {
+ const p = new URL(location.href).searchParams;
+ if (NETWORKS.has(p.get('network'))) state.network = p.get('network');
+ if (WINDOWS.has(p.get('window'))) state.window = p.get('window');
+ if (SORTS.has(p.get('sort'))) state.sort = p.get('sort');
+ state.verified = p.get('verified') === '1';
+}
+function writeUrl() {
+ const p = new URLSearchParams();
+ p.set('window', state.window);
+ p.set('sort', state.sort);
+ if (state.network !== 'mainnet') p.set('network', state.network);
+ if (state.verified) p.set('verified', '1');
+ history.replaceState(null, '', `${location.pathname}?${p}`);
+}
+
+// --- Rendering ---------------------------------------------------------------
+function skeletonRows(n = 8) {
+ const cell = '<span class="lb-sk" style="width:70%"></span>';
+ return Array.from({ length: n }, () => `
+ <div class="lb-row lb-skeleton" aria-hidden="true">
+ <span class="lb-sk" style="width:60%"></span>
+ <span class="lb-trader"><span class="lb-avatar"></span><span class="lb-sk" style="width:55%"></span></span>
+ ${cell.repeat(6)}
+ <span class="lb-sk" style="width:80%"></span>
+ </div>`).join('');
+}
+
+function rowMarkup(r) {
+ const img = r.image || identicon(r.agent_id || r.wallet || r.agent_name || '?');
+ const href = `/trader/${encodeURIComponent(r.agent_id)}`;
+ const pnlSol = `<span class="${pnlClass(r.realized_pnl_sol)}">${fmtSol(r.realized_pnl_sol)}</span>`;
+ const pnlUsd = r.realized_pnl_usd != null
+ ? `<span class="lb-sub-num">${fmtUsd(r.realized_pnl_usd)}</span>` : '';
+ const dd = r.max_drawdown_pct > 0
+ ? `<span class="lb-neg">−${r.max_drawdown_pct.toFixed(1)}%</span>` : '<span class="lb-muted">0%</span>';
+ const scoreBar = Math.max(4, Math.min(100, r.score));
+ return `
+ <a class="lb-row" href="${href}" data-top="${r.rank <= 3 ? r.rank : ''}" aria-label="${escapeHtml(r.agent_name || 'Trader')}, rank ${r.rank}, score ${r.score}">
+ <span class="lb-rank">${r.rank}</span>
+ <span class="lb-trader">
+ <img class="lb-avatar" src="${escapeHtml(img)}" alt="" loading="lazy" onerror="this.src='${identicon(r.agent_id || r.wallet || '?')}'" />
+ <span class="lb-trader-meta">
+ <span class="lb-trader-name">${escapeHtml(r.agent_name || 'Unnamed agent')}${verifiedBadge(r.verified)}</span>
+ <span class="lb-trader-sub">${escapeHtml(shortAddr(r.wallet))} · ${r.unique_coins} coins</span>
+ </span>
+ </span>
+ <span class="lb-num">
+ <span class="lb-score">${r.score}</span>
+ <span class="lb-score-bar" style="width:${scoreBar}%"></span>
+ </span>
+ <span class="lb-num">${pnlSol}${pnlUsd}</span>
+ <span class="lb-num lb-winrate">${fmtPct(r.win_rate * 100)}<span class="lb-sub-num">${r.wins}/${r.closed}</span></span>
+ <span class="lb-num lb-hide-sm"><span class="${pnlClass(r.roi_pct)}">${fmtPct(r.roi_pct, { sign: true })}</span></span>
+ <span class="lb-num lb-hide-sm">${dd}</span>
+ <span class="lb-num lb-hide-md">${r.closed}<span class="lb-sub-num">${holdTime(r.avg_hold_seconds)} avg</span></span>
+ <span class="lb-col-act"><span class="lb-view">Track record →</span></span>
+ </a>`;
+}
+
+function renderSummary(data) {
+ const board = data.leaderboard || [];
+ $('#lb-sum-traders').textContent = String(board.length);
+ $('#lb-sum-verified').textContent = String(board.filter((r) => r.verified).length);
+ const top = board[0];
+ $('#lb-sum-top').textContent = top ? fmtSol(top.realized_pnl_sol) : '—';
+ $('#lb-sum-sol').textContent = data.sol_usd ? `$${Math.round(data.sol_usd)}` : '—';
+}
+
+function renderTicker(trades) {
+ const el = $('#lb-ticker');
+ if (!trades || !trades.length) { el.innerHTML = '<span class="lb-muted" style="font-size:var(--text-xs)">No closes yet.</span>'; return; }
+ el.innerHTML = trades.slice(0, 16).map((t) => {
+ const url = t.sell_url || t.buy_url || '#';
+ const pnl = t.pnl_sol != null ? `<span class="lb-tick-pnl ${pnlClass(t.pnl_sol)}">${fmtSol(t.pnl_sol)}</span>` : '';
+ return `<a class="lb-tick" href="${escapeHtml(url)}" target="_blank" rel="noopener" title="View on Solscan">
+ <span class="lb-tick-top"><span class="lb-tick-sym">${escapeHtml(t.symbol || t.name || '—')}</span>${pnl}</span>
+ <span class="lb-tick-meta">${escapeHtml(t.agent_name || 'agent')} · ${escapeHtml(t.exit_reason || '')} · ${relTime(t.at)}</span>
+ </a>`;
+ }).join('');
+}
+
+function renderBoard(data) {
+ const board = $('.lb-board');
+ const rows = $('#lb-rows');
+ const stateEl = $('#lb-state');
+ const list = data.leaderboard || [];
+ board.setAttribute('aria-busy', 'false');
+
+ if (!list.length) {
+ rows.innerHTML = '';
+ stateEl.innerHTML = `
+ <div class="lb-state-title">No ranked traders yet</div>
+ <p>No agent has closed a sniper position in this window${state.verified ? ' that meets the verified bar' : ''}.
+ Widen the window, turn off “verified only”, or be the first.</p>
+ <a class="lb-btn lb-btn-primary" href="/create-agent">Launch a trader</a>`;
+ return;
+ }
+ stateEl.innerHTML = '';
+ rows.innerHTML = list.map(rowMarkup).join('');
+ // Stagger the entrance subtly.
+ rows.querySelectorAll('.lb-row').forEach((el, i) => { el.style.animationDelay = `${Math.min(i, 12) * 22}ms`; });
+}
+
+// --- Fetch -------------------------------------------------------------------
+async function load() {
+ const board = $('.lb-board');
+ if (firstLoad) { $('#lb-rows').innerHTML = skeletonRows(); board.setAttribute('aria-busy', 'true'); }
+
+ const qs = new URLSearchParams({ network: state.network, window: state.window, sort: state.sort });
+ if (state.verified) qs.set('verified', '1');
+
+ try {
+ const res = await fetch(`${API}?${qs}`, { headers: { accept: 'application/json' } });
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ const data = await res.json();
+ renderSummary(data);
+ renderBoard(data);
+ renderTicker(data.trades);
+ firstLoad = false;
+ } catch (err) {
+ board.setAttribute('aria-busy', 'false');
+ if (firstLoad) {
+ $('#lb-rows').innerHTML = '';
+ $('#lb-state').innerHTML = `
+ <div class="lb-state-title">Couldn’t load the leaderboard</div>
+ <p>The track-record feed didn’t respond. This is usually transient.</p>
+ <button class="lb-btn lb-btn-primary" id="lb-retry">Retry</button>`;
+ $('#lb-retry')?.addEventListener('click', () => load());
+ }
+ // On a refresh failure we keep the last good board on screen — no flicker.
+ }
+}
+
+// --- Controls ----------------------------------------------------------------
+function setActive(group, attr, value) {
+ group.querySelectorAll('.lb-seg-btn').forEach((b) => {
+ const on = b.dataset[attr] === value;
+ b.classList.toggle('is-active', on);
+ b.setAttribute('aria-selected', on ? 'true' : 'false');
+ });
+}
+
+function wireControls() {
+ const winGroup = $('#lb-window');
+ winGroup.addEventListener('click', (e) => {
+ const btn = e.target.closest('.lb-seg-btn');
+ if (!btn) return;
+ state.window = btn.dataset.window;
+ setActive(winGroup, 'window', state.window);
+ firstLoad = true; writeUrl(); load();
+ });
+
+ const netGroup = $('#lb-network');
+ netGroup.addEventListener('click', (e) => {
+ const btn = e.target.closest('.lb-seg-btn');
+ if (!btn) return;
+ state.network = btn.dataset.network;
+ setActive(netGroup, 'network', state.network);
+ firstLoad = true; writeUrl(); load();
+ });
+
+ $('#lb-sort').addEventListener('change', (e) => {
+ state.sort = SORTS.has(e.target.value) ? e.target.value : 'score';
+ writeUrl(); load();
+ });
+
+ $('#lb-verified').addEventListener('change', (e) => {
+ state.verified = e.target.checked;
+ writeUrl(); load();
+ });
+
+ const howto = $('#lb-howto-toggle');
+ howto.addEventListener('click', () => {
+ const open = howto.getAttribute('aria-expanded') === 'true';
+ howto.setAttribute('aria-expanded', String(!open));
+ $('#lb-howto-body').hidden = open;
+ });
+}
+
+function syncControlsToState() {
+ setActive($('#lb-window'), 'window', state.window);
+ setActive($('#lb-network'), 'network', state.network);
+ $('#lb-sort').value = state.sort;
+ $('#lb-verified').checked = state.verified;
+}
+
+// --- Live refresh ------------------------------------------------------------
+function startTimer() {
+ stopTimer();
+ timer = setInterval(() => { if (!document.hidden) load(); }, REFRESH_MS);
+}
+function stopTimer() { if (timer) { clearInterval(timer); timer = null; } }
+document.addEventListener('visibilitychange', () => { if (!document.hidden) load(); });
+
+// --- Ambient field -----------------------------------------------------------
+function ambientField() {
+ const canvas = document.getElementById('lb-field');
+ if (!canvas || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
+ const ctx = canvas.getContext('2d');
+ let w, h, dots, raf;
+ const resize = () => {
+ w = canvas.width = innerWidth;
+ h = canvas.height = innerHeight;
+ dots = Array.from({ length: Math.min(60, Math.floor(w / 26)) }, () => ({
+ x: Math.random() * w, y: Math.random() * h,
+ vx: (Math.random() - 0.5) * 0.18, vy: (Math.random() - 0.5) * 0.18,
+ r: Math.random() * 1.4 + 0.4,
+ }));
+ };
+ const draw = () => {
+ ctx.clearRect(0, 0, w, h);
+ ctx.fillStyle = 'rgba(140,160,255,0.35)';
+ for (const d of dots) {
+ d.x = (d.x + d.vx + w) % w;
+ d.y = (d.y + d.vy + h) % h;
+ ctx.beginPath();
+ ctx.arc(d.x, d.y, d.r, 0, Math.PI * 2);
+ ctx.fill();
+ }
+ raf = requestAnimationFrame(draw);
+ };
+ addEventListener('resize', resize, { passive: true });
+ document.addEventListener('visibilitychange', () => {
+ if (document.hidden) cancelAnimationFrame(raf);
+ else raf = requestAnimationFrame(draw);
+ });
+ resize();
+ draw();
+}
+
+// --- Boot --------------------------------------------------------------------
+readUrl();
+syncControlsToState();
+wireControls();
+ambientField();
+load();
+startTimer();
diff --git a/src/play/arena-world.js b/src/play/arena-world.js
index da3fccf15..96dd75f80 100644
--- a/src/play/arena-world.js
+++ b/src/play/arena-world.js
@@ -10,9 +10,9 @@
// Ready Player Me, Mixamo, CharacterStudio — performs the same emotes.
import {
- Scene, PerspectiveCamera, WebGLRenderer, Group, Object3D,
+ Scene, PerspectiveCamera, WebGLRenderer, Group,
AmbientLight, DirectionalLight, PointLight, HemisphereLight,
- PMREMGenerator, Color, Fog, Vector3, Vector2, Box3,
+ PMREMGenerator, Color, Fog, Vector3, Box3,
CircleGeometry, RingGeometry, TorusGeometry, CylinderGeometry,
MeshStandardMaterial, MeshBasicMaterial, Mesh, DoubleSide,
BufferGeometry, BufferAttribute, Points, PointsMaterial, AdditiveBlending,
@@ -30,7 +30,7 @@ const MANIFEST_URL = '/animations/manifest.json';
// into every avatar so each clip is fetched + parsed a single time. Sizes were
// chosen for fast first paint (idle/walk/buy/win/loss all < 1.1 MB).
const CLIPS = {
- idle: 'av-idle-breath', // calm breathing loop — the resting state
+ idle: 'idle', // full-body resting idle (arms down — NOT the torso-only breath)
walk: 'walk', // spectator locomotion
buy: 'wave', // a wave when an agent opens a position
win: 'celebrate', // fist-pump on a profitable close
@@ -278,7 +278,6 @@ export class ArenaWorld {
avatar.leader = !!cfg.leader;
avatar.color = color;
avatar.idle();
- if (cfg.leader) avatar.play('dance', { loop: true }); // the champ vibes
// DOM label data.
avatar.label = { name: cfg.name, pnlText: cfg.pnlText, pnlUp: cfg.pnlUp, thumbnail: cfg.thumbnail, rank: cfg.rank };
@@ -292,7 +291,7 @@ export class ArenaWorld {
if (this.player) { this._removeAvatar(this.player); this.player = null; }
const avatar = await this._makeAvatar(glbUrl);
const root = new Group();
- root.position.set(0, 0, 9.5); // entrance, facing the arena
+ root.position.set(0, 0, 5.6); // just inside the entrance, facing the arena
root.rotation.y = Math.PI;
root.add(avatar.object);
this.scene.add(root);
@@ -300,9 +299,9 @@ export class ArenaWorld {
avatar.isPlayer = true;
avatar.idle();
this.player = avatar;
- // Drop the camera into a follow rig behind the player.
- this._cam.targetYaw = Math.PI;
- this._cam.yaw = Math.PI;
+ // Camera sits behind the spectator (+Z) looking into the arena (−Z).
+ this._cam.targetYaw = 0;
+ this._cam.yaw = 0;
return avatar;
}
@@ -429,7 +428,7 @@ export class ArenaWorld {
// ── Controls (third-person follow) ────────────────────────────────────────
_initControls() {
- this._cam = { yaw: Math.PI, targetYaw: Math.PI, pitch: 0.18, dist: 7.2, targetDist: 7.2 };
+ this._cam = { yaw: 0, targetYaw: 0, pitch: 0.30, dist: 11, targetDist: 11 };
this._keys = new Set();
this._drag = null;
this._move = { x: 0, y: 0 }; // joystick vector
@@ -460,7 +459,7 @@ export class ArenaWorld {
el.addEventListener('pointerup', endDrag);
el.addEventListener('pointercancel', endDrag);
el.addEventListener('wheel', (e) => {
- this._cam.targetDist = MathUtils.clamp(this._cam.targetDist + Math.sign(e.deltaY) * 0.6, 3.2, 12);
+ this._cam.targetDist = MathUtils.clamp(this._cam.targetDist + Math.sign(e.deltaY) * 0.7, 4, 15);
}, { passive: true });
// Click-to-select an agent (raycast handled in arena.js via projected labels).
@@ -504,13 +503,17 @@ export class ArenaWorld {
const c = this._cam;
c.yaw = dampAngle(c.yaw, c.targetYaw, 8 * dt);
c.dist += (c.targetDist - c.dist) * Math.min(1, 8 * dt);
- const focus = this.player ? this.player.root.position : new Vector3(0, 0, -1);
- const fy = (this.player ? 1.5 : 1.6);
- const cx = focus.x + Math.sin(c.yaw) * Math.cos(c.pitch) * c.dist;
- const cz = focus.z + Math.cos(c.yaw) * Math.cos(c.pitch) * c.dist;
- const cy = fy + Math.sin(c.pitch) * c.dist + 1.6;
- this.camera.position.lerp(new Vector3(cx, cy, cz), Math.min(1, 6 * dt));
- this.camera.lookAt(focus.x, fy + 0.4, focus.z);
+ const p = this.player ? this.player.root.position : new Vector3(0, 0, 0);
+ // Orbit a point biased from the spectator toward the arena centre so the
+ // agent line-up stays in frame while we still follow the player.
+ const tx = p.x * 0.55;
+ const tz = p.z * 0.5 - 2.0;
+ const ty = 1.2;
+ const cx = tx + Math.sin(c.yaw) * Math.cos(c.pitch) * c.dist;
+ const cz = tz + Math.cos(c.yaw) * Math.cos(c.pitch) * c.dist;
+ const cy = ty + Math.sin(c.pitch) * c.dist + 1.0;
+ this.camera.position.lerp(_tmpVec.set(cx, cy, cz), Math.min(1, 6 * dt));
+ this.camera.lookAt(tx, ty, tz);
}
// ── Loop ──────────────────────────────────────────────────────────────────
@@ -625,11 +628,6 @@ class ArenaAvatar {
idle() { this._busy = false; this.anim.crossfadeTo(this._clipMap.idle, 0.3); }
- play(name, { loop = true } = {}) {
- const clip = this._clipMap[name] || name;
- this.anim.crossfadeTo(clip, 0.3);
- }
-
setMoving(moving) {
if (this._busy) return;
if (moving === this._moving) return;
diff --git a/src/play/arena.js b/src/play/arena.js
index 9d8ba1853..3c85d1676 100644
--- a/src/play/arena.js
+++ b/src/play/arena.js
@@ -33,7 +33,6 @@ const isBig = (p) => (p?.pnl_sol ?? 0) >= 0.4 || (p?.pnl_pct ?? 0) >= 100;
let world = null;
let labelLayer = null;
const labelEls = new Map(); // agentId -> { el, pos }
-let topAgentId = null;
// ── boot ──────────────────────────────────────────────────────────────────────
@@ -41,6 +40,7 @@ let topAgentId = null;
const canvas = $('scene');
labelLayer = $('labels');
world = new ArenaWorld(canvas, { onAgentClick: focusAgent });
+ window.__arenaWorld = world; // debug/support hook
// Spin up the render loop immediately so the floor + lights are alive while
// avatars stream in (perceived performance).
@@ -59,7 +59,7 @@ let topAgentId = null;
world.setLabelUpdater(updateLabels);
mountControls();
- mountJoystick(canvas);
+ mountJoystick();
await loadAndPlace();
connectStream();
@@ -108,9 +108,8 @@ async function loadAndPlace() {
thumbnail: row.image || '',
rank: row.rank,
}).then((agent) => createLabel(agent)).catch((err) => console.warn('[arena] spawn agent', err));
- }, i * 180);
+ }, i * 120);
});
- topAgentId = board[0].agent_id;
}
// Seed the tape with recent closed trades (oldest first so prepend keeps order).
@@ -139,16 +138,16 @@ async function loadBoardOnly() {
// Arrange agents on a forward-facing arc; #1 elevated at the back-centre.
function arenaPositions(n) {
const out = [];
- // Leader.
- out.push({ x: 0, z: -7.2, facing: 0 });
+ // Leader, elevated at the back-centre.
+ out.push({ x: 0, z: -5.4, facing: 0 });
const rest = n - 1;
for (let i = 0; i < rest; i++) {
const t = rest === 1 ? 0.5 : i / (rest - 1); // 0..1
- const ang = (t - 0.5) * (Math.PI * 0.95); // spread ~ -85°..85°
- const rad = 8.2;
+ const ang = (t - 0.5) * (Math.PI * 0.92); // spread ~ -83°..83°
+ const rad = 5.6;
const x = Math.sin(ang) * rad;
- const z = -3.4 - Math.cos(ang) * 3.6; // bow toward the back
- out.push({ x, z, facing: Math.atan2(x - 0, 12 - z) }); // face the entrance
+ const z = -1.4 - Math.cos(ang) * 3.0; // gentle bow toward the back
+ out.push({ x, z, facing: Math.atan2(x - 0, 9 - z) }); // face the entrance
}
return out;
}
@@ -157,7 +156,6 @@ function arenaPositions(n) {
let es = null;
function connectStream() {
- const dot = $('liveDot');
es = new EventSource(`/api/sniper/stream?network=${NETWORK}`);
es.addEventListener('open', () => setLive(true));
es.addEventListener('buy', (m) => safe(() => onBuy(JSON.parse(m.data))));
@@ -165,7 +163,7 @@ function connectStream() {
es.addEventListener('update', () => {});
es.onerror = () => { setLive(false); try { es.close(); } catch {} setTimeout(connectStream, 2500); };
}
-const safe = (fn) => { try { fn(); } catch (e) { /* one bad frame never breaks the stream */ } };
+const safe = (fn) => { try { fn(); } catch { /* one bad frame never breaks the stream */ } };
function onBuy(p) {
world.reactBuy(p.agent_id, { amountText: fmtSol(p.entry_sol) });
@@ -268,7 +266,6 @@ function renderTopCard(top) {
if (top.image) { img.src = top.image; img.style.display = ''; } else img.style.display = 'none';
}
-let tapeCount = 0;
function pushTape(kind, p, { quiet = false } = {}) {
const tape = $('tape');
$('tapeEmpty')?.remove();
@@ -289,7 +286,6 @@ function pushTape(kind, p, { quiet = false } = {}) {
${pnl}`;
tape.prepend(row);
while (tape.children.length > 40) tape.lastChild.remove();
- tapeCount++;
}
let bannerTimer = null;
@@ -397,7 +393,7 @@ async function choose(url, btn) {
// ── mobile joystick (nipplejs, lazy) ────────────────────────────────────────────
-async function mountJoystick(canvas) {
+async function mountJoystick() {
const isTouch = matchMedia('(pointer: coarse)').matches;
if (!isTouch) return;
try {
diff --git a/src/pump/smart-money-score.js b/src/pump/smart-money-score.js
new file mode 100644
index 000000000..9406267b9
--- /dev/null
+++ b/src/pump/smart-money-score.js
@@ -0,0 +1,75 @@
+/**
+ * pump/smart-money-score.js
+ * -------------------------
+ * Pure: score a live coin by the PEDIGREE of the money buying it. Given the
+ * coin's per-wallet buys and a reputation map (wallet → {smart_money_score,
+ * label}), produce a 0..100 "is proven money accumulating this" signal plus the
+ * notable wallets driving it. This is what the radar ranks on and what a
+ * follow-the-smart-money sniper would gate on.
+ */
+
+// A wallet at/above this reputation counts as "proven smart money".
+export const SMART_THRESHOLD = 70;
+
+function num(v) {
+ const n = Number(v);
+ return Number.isFinite(n) ? n : 0;
+}
+function clamp(n, lo, hi) {
+ return Math.max(lo, Math.min(hi, n));
+}
+
+/**
+ * @param {Array<{wallet:string, buy_lamports:number, is_creator?:boolean}>} wallets buyers in this coin
+ * @param {Map<string,{smart_money_score:number,label:string}>|object} repMap
+ * @param {{smartThreshold?:number}} [opts]
+ * @returns {{ smart_money_score, smart_wallet_count, proven_buy_lamports, total_buy_lamports, notable }}
+ */
+export function computeCoinSmartMoney(wallets, repMap, opts = {}) {
+ const threshold = opts.smartThreshold ?? SMART_THRESHOLD;
+ const lookup = repMap instanceof Map ? (w) => repMap.get(w) : (w) => repMap?.[w];
+ const rows = Array.isArray(wallets) ? wallets : [];
+
+ let total_buy = 0;
+ let proven_buy = 0;
+ let weightedScoreSum = 0; // Σ rep.score · buy
+ let smart_wallet_count = 0;
+ const ranked = [];
+
+ for (const r of rows) {
+ const buy = num(r.buy_lamports);
+ if (buy <= 0 || r.is_creator) continue; // creators don't lend pedigree to their own coin
+ total_buy += buy;
+ const rep = lookup(r.wallet);
+ const score = rep ? num(rep.smart_money_score) : 0;
+ weightedScoreSum += score * buy;
+ if (score >= threshold) {
+ proven_buy += buy;
+ smart_wallet_count++;
+ }
+ if (rep && score > 0) {
+ ranked.push({ wallet: r.wallet, label: rep.label || 'neutral', score, buy_sol: lamportsToSol(buy) });
+ }
+ }
+
+ // Pedigree = buy-weighted average reputation of the money in the coin
+ // (unknown wallets score 0 and correctly drag it down), with a bounded
+ // network-effect bonus for each additional proven wallet piling in.
+ const weightedAvg = total_buy > 0 ? weightedScoreSum / total_buy : 0;
+ const networkBonus = Math.min(smart_wallet_count, 5) * 4;
+ const smart_money_score = Math.round(clamp(weightedAvg + networkBonus, 0, 100) * 10) / 10;
+
+ ranked.sort((a, b) => b.score - a.score || b.buy_sol - a.buy_sol);
+
+ return {
+ smart_money_score,
+ smart_wallet_count,
+ proven_buy_lamports: Math.round(proven_buy),
+ total_buy_lamports: Math.round(total_buy),
+ notable: ranked.slice(0, 8),
+ };
+}
+
+function lamportsToSol(l) {
+ return Math.round((num(l) / 1e9) * 1000) / 1000;
+}
diff --git a/src/pump/wallet-reputation.js b/src/pump/wallet-reputation.js
new file mode 100644
index 000000000..475c7d0b3
--- /dev/null
+++ b/src/pump/wallet-reputation.js
@@ -0,0 +1,137 @@
+/**
+ * pump/wallet-reputation.js
+ * -------------------------
+ * Pure scoring for the Smart Money Radar. No I/O — the rollup cron feeds in a
+ * coin's verdict (graduated vs dud) plus each wallet's footprint on that coin,
+ * and these functions produce (a) the per-coin attribution deltas folded into a
+ * wallet's running record and (b) the 0..100 reputation + label derived from
+ * that record. Pure so every number is unit-tested and identical everywhere.
+ *
+ * Outcome is deliberately first-party and unambiguous:
+ * 'graduated' — the coin reached Raydium (pumpfun_graduations). A real win.
+ * 'dud' — old enough to judge and it never graduated. Effectively dead.
+ * No external price oracle, no guesswork.
+ */
+
+// How soon after a coin's first-seen a buy counts as "early" (seconds).
+export const EARLY_WINDOW_SEC = 180;
+// A wallet that sells at least this share of what it bought, inside the window,
+// is "dumping" — toxic to anyone copy-following it.
+const DUMP_FRACTION = 0.5;
+// Coins a wallet must have a verdict on before its score is trusted past 'fresh'.
+const MIN_JUDGED = 4;
+
+function num(v) {
+ const n = Number(v);
+ return Number.isFinite(n) ? n : 0;
+}
+function clamp(n, lo, hi) {
+ return Math.max(lo, Math.min(hi, n));
+}
+function pct(part, whole) {
+ if (!(whole > 0)) return 0;
+ return Math.round((part / whole) * 1000) / 10;
+}
+
+/**
+ * Per-coin, per-wallet attribution. Returns the deltas to add to the wallet's
+ * running record. A wallet only earns a verdict on coins it actually BOUGHT.
+ *
+ * @param {object} o
+ * @param {'graduated'|'dud'} o.outcome
+ * @param {{buy_lamports:number, sell_lamports:number, first_seen_ts:number, is_creator:boolean}} o.wallet
+ * @param {number} o.coinFirstSeenTs unix seconds the coin was first observed
+ * @param {number} [o.earlyWindowSec=EARLY_WINDOW_SEC]
+ * @returns {object} delta counters (all numbers; booleans as 0/1)
+ */
+export function attributeCoin({ outcome, wallet, coinFirstSeenTs, earlyWindowSec = EARLY_WINDOW_SEC }) {
+ const buy = num(wallet?.buy_lamports);
+ const sell = num(wallet?.sell_lamports);
+ const isCreator = !!wallet?.is_creator;
+ const graduated = outcome === 'graduated';
+
+ const delta = {
+ coins_traded: 0,
+ early_entries: 0,
+ wins: 0,
+ early_wins: 0,
+ duds: 0,
+ dumps: 0,
+ creator_count: isCreator ? 1 : 0,
+ creator_wins: isCreator && graduated ? 1 : 0,
+ buy_volume_lamports: buy,
+ };
+
+ if (buy <= 0) return delta; // never bought → no trading verdict (creator counts still apply)
+
+ const early = num(wallet?.first_seen_ts) - num(coinFirstSeenTs) <= earlyWindowSec;
+ delta.coins_traded = 1;
+ if (early) delta.early_entries = 1;
+ if (graduated) {
+ delta.wins = 1;
+ if (early) delta.early_wins = 1;
+ } else {
+ delta.duds = 1;
+ }
+ if (sell >= buy * DUMP_FRACTION) delta.dumps = 1;
+ return delta;
+}
+
+/**
+ * Derive the 0..100 reputation + label from a wallet's accumulated counters.
+ * Transparent so a strategy author can reason about why a wallet ranks where it
+ * does. Sample size gates confidence — one lucky win is not "smart money".
+ *
+ * @param {object} c accumulated counters (the wallet_reputation row)
+ * @returns {{win_rate, early_win_rate, dump_rate, smart_money_score, label}}
+ */
+export function computeReputation(c) {
+ const wins = num(c?.wins);
+ const duds = num(c?.duds);
+ const judged = wins + duds;
+ const early_entries = num(c?.early_entries);
+ const early_wins = num(c?.early_wins);
+ const dumps = num(c?.dumps);
+ const creator_count = num(c?.creator_count);
+ const creator_wins = num(c?.creator_wins);
+ const coins_traded = num(c?.coins_traded);
+
+ const win_rate = pct(wins, judged);
+ const early_win_rate = pct(early_wins, early_entries);
+ const dump_rate = pct(dumps, judged);
+
+ // Confidence ramps to full at MIN_JUDGED*3 judged coins.
+ const confidence = clamp(judged / (MIN_JUDGED * 3), 0, 1);
+
+ // Hit rate is the backbone; reward demonstrated EARLY skill (catching winners
+ // before the crowd), penalise dumping on followers.
+ const earlyBonus = clamp((early_win_rate - win_rate) * 0.4, 0, 20);
+ const dumpPenalty = dump_rate * 0.4;
+ const raw = clamp(win_rate + earlyBonus - dumpPenalty, 0, 100);
+ const smart_money_score = Math.round(raw * confidence * 10) / 10;
+
+ const label = classify({
+ judged,
+ coins_traded,
+ win_rate,
+ early_entries,
+ dump_rate,
+ creator_count,
+ creator_wins,
+ smart_money_score,
+ });
+
+ return { win_rate, early_win_rate, dump_rate, smart_money_score, label };
+}
+
+function classify(s) {
+ // Serial creator whose coins never graduate — the most important wallet to
+ // flag for anyone following buys.
+ if (s.creator_count >= 3 && s.creator_wins === 0 && s.coins_traded >= 3) return 'rugger';
+ if (s.judged < MIN_JUDGED) return 'fresh';
+ if (s.dump_rate >= 60) return 'dumper';
+ if (s.smart_money_score >= 70) return 'smart_money';
+ // Buys early into lots of coins but rarely picks a winner: spray-and-pray.
+ if (s.early_entries >= 5 && s.win_rate < 25) return 'sniper';
+ return 'neutral';
+}
diff --git a/src/radar.css b/src/radar.css
new file mode 100644
index 000000000..98e44a1ce
--- /dev/null
+++ b/src/radar.css
@@ -0,0 +1,418 @@
+/* ════════════════════════════════════════════════════════════════════════════
+ Coin Radar — page styles. Consumes the canonical design tokens (tokens.css,
+ loaded via style.css). No parallel palette: colours/spacing/radii reference
+ var(--…). Works in both dark and light themes.
+ ════════════════════════════════════════════════════════════════════════════ */
+
+.radar-page { min-height: 100vh; display: flex; flex-direction: column; }
+.radar-main {
+ flex: 1; width: 100%; max-width: 1320px;
+ margin: 0 auto; padding: var(--space-lg) var(--space-md) var(--space-2xl);
+ box-sizing: border-box;
+}
+
+/* ── hero ─────────────────────────────────────────────────────────────────── */
+.radar-breadcrumb {
+ font-size: var(--text-sm); color: var(--ink-faint);
+ display: flex; gap: var(--space-xs); align-items: center; flex-wrap: wrap;
+ margin-bottom: var(--space-md);
+}
+.radar-breadcrumb a { color: var(--ink-dim); text-decoration: none; }
+.radar-breadcrumb a:hover { color: var(--ink); }
+.radar-breadcrumb a:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; border-radius: var(--radius-sm); }
+
+.radar-hero { margin-bottom: var(--space-lg); }
+.radar-pill {
+ display: inline-flex; align-items: center; gap: var(--space-xs);
+ font-size: var(--text-2xs); font-weight: var(--weight-semibold);
+ letter-spacing: 0.04em; text-transform: uppercase;
+ color: var(--success);
+ background: rgba(74, 222, 128, 0.1);
+ border: 1px solid rgba(74, 222, 128, 0.28);
+ border-radius: var(--radius-pill); padding: var(--space-2xs) var(--space-sm);
+ margin-bottom: var(--space-sm);
+}
+.radar-pill-dot {
+ width: 7px; height: 7px; border-radius: 50%; background: var(--success);
+ box-shadow: 0 0 8px rgba(74, 222, 128, 0.7);
+ animation: radar-pulse 2s ease-in-out infinite;
+}
+@keyframes radar-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
+
+.radar-hero h1 {
+ font-family: var(--font-display);
+ font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: var(--weight-bold);
+ letter-spacing: -0.02em; margin: 0 0 var(--space-xs); color: var(--ink-bright);
+}
+.radar-hero p {
+ font-size: var(--text-base); color: var(--ink-dim);
+ line-height: var(--leading-normal); max-width: 64ch; margin: 0;
+}
+
+/* ── toolbar ──────────────────────────────────────────────────────────────── */
+.radar-toolbar {
+ position: sticky; top: var(--header-h); z-index: 5;
+ display: flex; flex-direction: column; gap: var(--space-sm);
+ padding: var(--space-sm) 0 var(--space-md);
+ margin-bottom: var(--space-md);
+ background: linear-gradient(180deg, var(--bg-0) 70%, transparent);
+ border-bottom: 1px solid var(--stroke);
+}
+.radar-chips { display: flex; gap: var(--space-2xs); flex-wrap: wrap; }
+.radar-chip {
+ font-family: var(--font-body); font-size: var(--text-sm); font-weight: var(--weight-medium);
+ color: var(--ink-dim); background: var(--surface-1);
+ border: 1px solid var(--stroke); border-radius: var(--radius-pill);
+ padding: var(--space-2xs) var(--space-sm); cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-standard),
+ color var(--duration-fast) var(--ease-standard),
+ border-color var(--duration-fast) var(--ease-standard);
+}
+.radar-chip:hover { color: var(--ink); background: var(--surface-2); border-color: var(--stroke-strong); }
+.radar-chip:active { transform: translateY(1px); }
+.radar-chip.is-active {
+ color: var(--btn-primary-fg); background: var(--accent);
+ border-color: var(--accent); font-weight: var(--weight-semibold);
+}
+.radar-chip:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; }
+
+.radar-controls {
+ display: flex; gap: var(--space-md); align-items: center; flex-wrap: wrap;
+}
+.radar-control { display: flex; align-items: center; gap: var(--space-sm); }
+.radar-control-label {
+ display: flex; align-items: baseline; gap: var(--space-2xs);
+ font-size: var(--text-sm); color: var(--ink-dim); white-space: nowrap;
+}
+.radar-quality-val {
+ font-family: var(--font-mono); font-size: var(--text-sm);
+ color: var(--ink); font-variant-numeric: tabular-nums; min-width: 2.4ch;
+}
+.radar-slider {
+ -webkit-appearance: none; appearance: none; width: 130px; height: 4px;
+ border-radius: var(--radius-pill); background: var(--surface-3);
+ outline: none; cursor: pointer;
+}
+.radar-slider::-webkit-slider-thumb {
+ -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
+ border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-0);
+ box-shadow: var(--shadow-1); cursor: pointer;
+ transition: transform var(--duration-fast) var(--ease-standard);
+}
+.radar-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
+.radar-slider::-moz-range-thumb {
+ width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
+ border: 2px solid var(--bg-0); cursor: pointer;
+}
+.radar-slider:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 4px; }
+
+.radar-toggle {
+ display: inline-flex; align-items: center; gap: var(--space-xs);
+ background: none; border: none; cursor: pointer; padding: var(--space-2xs);
+ color: var(--ink-dim); font-size: var(--text-sm); font-family: var(--font-body);
+}
+.radar-toggle-track {
+ width: 34px; height: 18px; border-radius: var(--radius-pill);
+ background: var(--surface-3); border: 1px solid var(--stroke-strong);
+ position: relative; transition: background var(--duration-fast) var(--ease-standard);
+ flex-shrink: 0;
+}
+.radar-toggle-track::after {
+ content: ''; position: absolute; top: 1px; left: 1px;
+ width: 14px; height: 14px; border-radius: 50%; background: var(--ink-dim);
+ transition: transform var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard);
+}
+.radar-toggle[aria-checked='true'] .radar-toggle-track { background: var(--accent); border-color: var(--accent); }
+.radar-toggle[aria-checked='true'] .radar-toggle-track::after { transform: translateX(16px); background: var(--btn-primary-fg); }
+.radar-toggle[aria-checked='true'] .radar-toggle-label { color: var(--ink); }
+.radar-toggle:hover .radar-toggle-label { color: var(--ink); }
+.radar-toggle:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; border-radius: var(--radius-sm); }
+
+.radar-network {
+ background: var(--surface-1); border: 1px solid var(--stroke);
+ border-radius: var(--radius-md); padding: 2px; gap: 2px;
+}
+.radar-seg {
+ font-size: var(--text-sm); font-family: var(--font-body); color: var(--ink-dim);
+ background: none; border: none; border-radius: calc(var(--radius-md) - 2px);
+ padding: var(--space-2xs) var(--space-sm); cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
+}
+.radar-seg:hover { color: var(--ink); }
+.radar-seg.is-active { color: var(--ink-bright); background: var(--surface-3); }
+.radar-seg:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; }
+
+.radar-updated {
+ margin-left: auto; display: inline-flex; align-items: center; gap: var(--space-xs);
+ font-size: var(--text-sm); color: var(--ink-dim); white-space: nowrap;
+}
+.radar-live-dot {
+ width: 7px; height: 7px; border-radius: 50%; background: var(--success);
+ box-shadow: 0 0 6px rgba(74, 222, 128, 0.6); animation: radar-pulse 2s ease-in-out infinite;
+}
+.radar-live-dot.is-stale { background: var(--warn); box-shadow: 0 0 6px rgba(251,191,36,0.6); }
+
+/* ── grid ─────────────────────────────────────────────────────────────────── */
+.radar-grid {
+ display: grid; gap: var(--space-md);
+ grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
+}
+
+/* ── card ─────────────────────────────────────────────────────────────────── */
+.radar-card {
+ display: flex; flex-direction: column; gap: var(--space-sm);
+ background: var(--card-bg, var(--surface-glass));
+ border: 1px solid var(--card-border, var(--stroke));
+ border-radius: var(--radius-lg); padding: var(--space-md);
+ cursor: pointer; outline: none;
+ transition: transform var(--duration-base) var(--ease-standard),
+ border-color var(--duration-base) var(--ease-standard),
+ box-shadow var(--duration-base) var(--ease-standard);
+}
+.radar-card:hover {
+ transform: translateY(-3px);
+ border-color: var(--stroke-strong);
+ box-shadow: var(--shadow-3);
+}
+.radar-card:focus-visible {
+ border-color: var(--accent);
+ box-shadow: 0 0 0 2px var(--accent);
+}
+.radar-card.is-enter { opacity: 0; transform: translateY(12px) scale(0.98); }
+
+.rc-head { display: flex; align-items: center; gap: var(--space-sm); }
+.rc-img {
+ width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
+ background: var(--surface-2); border: 1px solid var(--stroke);
+}
+.rc-id { flex: 1; min-width: 0; }
+.rc-name {
+ font-weight: var(--weight-semibold); font-size: var(--text-ui); color: var(--ink-bright);
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
+}
+.rc-sym { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); }
+.rc-ticker { color: var(--ink-dim); font-family: var(--font-mono); }
+.rc-age { color: var(--ink-faint); font-size: var(--text-2xs); }
+.rc-cat {
+ font-size: var(--text-2xs); font-weight: var(--weight-medium);
+ color: var(--ink-dim); background: var(--surface-2);
+ border: 1px solid var(--stroke); border-radius: var(--radius-pill);
+ padding: 2px var(--space-xs); white-space: nowrap; flex-shrink: 0;
+}
+
+/* score row: ring + organic/bundle */
+.rc-score { display: flex; align-items: center; gap: var(--space-md); }
+.rc-ring-col { display: flex; flex-direction: column; align-items: center; gap: var(--space-3xs); flex-shrink: 0; }
+.rc-ring { position: relative; width: 64px; height: 64px; }
+.rc-ring-svg { width: 64px; height: 64px; display: block; }
+.rc-ring-track { stroke: var(--surface-3); }
+.rc-ring-arc { transition: stroke-dashoffset var(--duration-slow) var(--ease-emphasized); }
+.rc-ring-val { position: absolute; inset: 0; display: grid; place-items: center; }
+.rc-ring-num { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
+.rc-ring-cap { font-size: var(--text-2xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; }
+
+.rc-ob { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-xs); }
+.rc-ob-readout { display: flex; justify-content: space-between; gap: var(--space-sm); }
+.rc-ob-tag { display: flex; flex-direction: column; gap: 1px; }
+.rc-ob-tag-label { font-size: var(--text-2xs); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; }
+.rc-ob-tag-val { font-family: var(--font-mono); font-weight: var(--weight-bold); font-size: var(--text-md); font-variant-numeric: tabular-nums; }
+.rc-ob-tag--organic .rc-ob-tag-val { color: var(--success); }
+.rc-ob-tag--bundle { text-align: right; }
+.rc-ob-tag--bundle .rc-ob-tag-val { color: var(--danger); }
+.rc-ob-bar {
+ display: flex; height: 6px; border-radius: var(--radius-pill);
+ background: var(--surface-3); overflow: hidden;
+}
+.rc-ob-fill { height: 100%; transition: width var(--duration-slow) var(--ease-emphasized); }
+.rc-ob-fill--organic { background: var(--success); }
+.rc-ob-fill--bundle { background: var(--danger); }
+
+.rc-narrative {
+ font-size: var(--text-sm); color: var(--ink-dim); line-height: var(--leading-normal);
+ margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
+ overflow: hidden;
+}
+
+.rc-flags { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
+.rc-flag {
+ font-size: var(--text-2xs); font-weight: var(--weight-medium);
+ padding: 2px var(--space-xs); border-radius: var(--radius-sm);
+ border: 1px solid transparent; white-space: nowrap;
+}
+.rc-flag--danger { color: var(--danger); background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.28); }
+.rc-flag--warn { color: var(--warn); background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.28); }
+.rc-flag--clean { color: var(--success); background: rgba(74,222,128,0.1); border-color: rgba(74,222,128,0.24); }
+
+.rc-stats {
+ display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-xs);
+ padding-top: var(--space-xs); border-top: 1px solid var(--stroke);
+}
+.rc-stat { display: flex; flex-direction: column; gap: 1px; }
+.rc-stat-label { font-size: var(--text-2xs); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; }
+.rc-stat-value { font-family: var(--font-mono); font-size: var(--text-md); color: var(--ink); font-variant-numeric: tabular-nums; }
+
+.rc-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
+.rc-link {
+ font-size: var(--text-sm); color: var(--ink-dim); text-decoration: none;
+ border-bottom: 1px solid transparent; transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
+}
+.rc-link:hover { color: var(--ink); border-bottom-color: var(--stroke-strong); }
+.rc-link:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; border-radius: var(--radius-sm); }
+.rc-detail {
+ font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--ink);
+ background: var(--surface-2); border: 1px solid var(--stroke);
+ border-radius: var(--radius-md); padding: var(--space-2xs) var(--space-sm); cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
+}
+.rc-detail:hover { background: var(--surface-3); border-color: var(--stroke-strong); }
+.rc-detail:active { transform: translateY(1px); }
+.rc-detail:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; }
+
+/* ── skeleton ─────────────────────────────────────────────────────────────── */
+.radar-card--skeleton { cursor: default; pointer-events: none; gap: var(--space-md); }
+.sk {
+ background: linear-gradient(90deg, var(--skeleton-base, rgba(255,255,255,0.04)) 25%, var(--skeleton-sheen, rgba(255,255,255,0.08)) 50%, var(--skeleton-base, rgba(255,255,255,0.04)) 75%);
+ background-size: 200% 100%; animation: radar-shimmer 1.4s ease-in-out infinite; border-radius: var(--radius-sm);
+}
+.sk-row { height: 40px; border-radius: var(--radius-md); }
+.sk-ring { height: 64px; width: 64px; border-radius: 50%; }
+.sk-bar { height: 12px; }
+.sk-bar.w70 { width: 70%; }
+.sk-pills { height: 22px; width: 60%; border-radius: var(--radius-pill); }
+@keyframes radar-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
+
+/* ── states ───────────────────────────────────────────────────────────────── */
+.radar-state {
+ display: flex; flex-direction: column; align-items: center; text-align: center;
+ gap: var(--space-sm); max-width: 56ch; margin: var(--space-2xl) auto;
+ padding: var(--space-xl) var(--space-md);
+}
+.radar-state-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--ink-bright); margin: 0; }
+.radar-state-text { font-size: var(--text-base); color: var(--ink-dim); line-height: var(--leading-normal); margin: 0; }
+.radar-state-note { font-size: var(--text-sm); color: var(--ink-faint); margin: var(--space-xs) 0 0; }
+.radar-state-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; justify-content: center; margin-top: var(--space-xs); }
+.radar-error .radar-state-title { color: var(--danger); }
+
+.radar-btn {
+ font-family: var(--font-body); font-size: var(--text-ui); font-weight: var(--weight-semibold);
+ color: var(--btn-primary-fg); background: var(--accent);
+ border: 1px solid var(--accent); border-radius: var(--radius-md);
+ padding: var(--space-sm) var(--space-md); cursor: pointer; text-decoration: none;
+ display: inline-flex; align-items: center; gap: var(--space-xs);
+ transition: background var(--duration-fast) var(--ease-standard), transform var(--duration-fast) var(--ease-standard), filter var(--duration-fast) var(--ease-standard);
+}
+.radar-btn:hover { background: var(--btn-primary-bg-hover); }
+.radar-btn:active { transform: translateY(1px); }
+.radar-btn:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: var(--focus-ring-offset); }
+.radar-btn--ghost {
+ color: var(--ink); background: var(--surface-2);
+ border-color: var(--stroke-strong);
+}
+.radar-btn--ghost:hover { background: var(--surface-3); }
+
+.radar-glyph { width: 88px; height: 88px; margin-bottom: var(--space-xs); }
+.radar-glyph-ring { stroke: var(--stroke-strong); stroke-width: 1.4; }
+.radar-glyph-sweep { fill: var(--success); opacity: 0.16; transform-origin: 60px 60px; animation: radar-sweep 3.4s linear infinite; }
+.radar-glyph-dot { fill: var(--success); }
+@keyframes radar-sweep { from { transform: rotate(0); } to { transform: rotate(360deg); } }
+
+/* ── drawer ───────────────────────────────────────────────────────────────── */
+.radar-no-scroll { overflow: hidden; }
+.radar-drawer-scrim {
+ position: fixed; inset: 0; z-index: 1000;
+ background: rgba(0,0,0,0.5); backdrop-filter: blur(var(--blur-sm));
+ display: flex; justify-content: flex-end;
+ opacity: 0; transition: opacity var(--duration-base) var(--ease-standard);
+}
+.radar-drawer-scrim.is-open { opacity: 1; }
+.radar-drawer-panel {
+ width: min(520px, 100%); height: 100%; overflow-y: auto;
+ background: var(--bg-0); border-left: 1px solid var(--stroke-strong);
+ box-shadow: var(--shadow-3); padding: var(--space-lg) var(--space-md) var(--space-2xl);
+ transform: translateX(24px); transition: transform var(--duration-base) var(--ease-emphasized);
+ outline: none;
+}
+.radar-drawer-scrim.is-open .radar-drawer-panel { transform: translateX(0); }
+
+.rd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-md); }
+.rd-head-id { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; }
+.rd-img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 1px solid var(--stroke); flex-shrink: 0; }
+.rd-title { font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--ink-bright); margin: 0; line-height: 1.2; }
+.rd-sub { font-size: var(--text-sm); color: var(--ink-dim); margin-top: 2px; }
+.rd-close {
+ background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--radius-md);
+ color: var(--ink-dim); width: 34px; height: 34px; display: grid; place-items: center;
+ cursor: pointer; flex-shrink: 0; transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
+}
+.rd-close:hover { background: var(--surface-3); color: var(--ink); }
+.rd-close:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; }
+
+.rd-headline { display: flex; align-items: center; gap: var(--space-lg); padding: var(--space-md) 0; }
+.rd-loading { display: flex; flex-direction: column; gap: var(--space-sm); margin-top: var(--space-lg); }
+
+.rd-section { padding: var(--space-md) 0; border-top: 1px solid var(--stroke); }
+.rd-h3 { font-size: var(--text-2xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); margin: 0 0 var(--space-sm); }
+.rd-narrative { font-size: var(--text-base); color: var(--ink); line-height: var(--leading-normal); margin: 0; }
+.rd-meta { font-size: var(--text-sm); color: var(--ink-faint); margin: var(--space-xs) 0 0; }
+
+.rd-flags { display: flex; flex-direction: column; gap: var(--space-xs); }
+.rd-flag { display: flex; flex-direction: column; gap: 2px; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-md); border: 1px solid transparent; }
+.rd-flag--danger { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.26); }
+.rd-flag--warn { background: rgba(251,191,36,0.1); border-color: rgba(251,191,36,0.26); }
+.rd-flag-name { font-weight: var(--weight-semibold); font-size: var(--text-md); }
+.rd-flag--danger .rd-flag-name { color: var(--danger); }
+.rd-flag--warn .rd-flag-name { color: var(--warn); }
+.rd-flag-tip { font-size: var(--text-sm); color: var(--ink-dim); }
+
+.rd-signals { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xs) var(--space-md); }
+.rd-sig { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm); padding: var(--space-2xs) 0; border-bottom: 1px solid var(--stroke); }
+.rd-sig-label { font-size: var(--text-sm); color: var(--ink-dim); }
+.rd-sig-val { font-family: var(--font-mono); font-size: var(--text-md); color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
+
+.rd-tags { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
+.rd-tag { font-size: var(--text-2xs); color: var(--ink-dim); background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--radius-pill); padding: 2px var(--space-xs); }
+
+.rd-table-wrap { overflow-x: auto; }
+.rd-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
+.rd-table th { text-align: left; font-weight: var(--weight-medium); color: var(--ink-faint); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.04em; padding: var(--space-2xs) var(--space-xs); border-bottom: 1px solid var(--stroke); }
+.rd-table td { padding: var(--space-xs); border-bottom: 1px solid var(--stroke); color: var(--ink); }
+.rd-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
+.rd-wcell { display: flex; align-items: center; gap: var(--space-xs); }
+.rd-waddr { font-family: var(--font-mono); color: var(--ink-dim); text-decoration: none; }
+.rd-waddr:hover { color: var(--ink); text-decoration: underline; }
+.rd-waddr:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; border-radius: var(--radius-sm); }
+.rd-wtag { font-size: var(--text-2xs); color: var(--success); background: rgba(74,222,128,0.1); border: 1px solid rgba(74,222,128,0.24); border-radius: var(--radius-sm); padding: 0 var(--space-2xs); }
+.rd-pos { color: var(--success); }
+.rd-neg { color: var(--danger); }
+
+.rd-outcome--success { border-top-color: rgba(74,222,128,0.3); }
+.rd-outcome--danger { border-top-color: rgba(248,113,113,0.3); }
+.rd-outcome-row { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
+.rd-outcome-badge { font-weight: var(--weight-bold); font-size: var(--text-md); padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-md); }
+.rd-outcome--success .rd-outcome-badge { color: var(--success); background: rgba(74,222,128,0.12); }
+.rd-outcome--danger .rd-outcome-badge { color: var(--danger); background: rgba(248,113,113,0.12); }
+.rd-outcome--neutral .rd-outcome-badge { color: var(--ink); background: var(--surface-3); }
+.rd-outcome-stat { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--ink-dim); }
+
+.rd-links { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
+.rd-links .radar-btn { font-size: var(--text-sm); padding: var(--space-xs) var(--space-sm); }
+.rd-mint { display: flex; align-items: center; gap: var(--space-xs); margin-top: var(--space-md); font-size: var(--text-2xs); color: var(--ink-faint); }
+.rd-mint code { font-family: var(--font-mono); color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
+.rd-copy { font-size: var(--text-2xs); color: var(--ink-dim); background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 2px var(--space-xs); cursor: pointer; flex-shrink: 0; }
+.rd-copy:hover { background: var(--surface-3); color: var(--ink); }
+.rd-copy:focus-visible { outline: var(--focus-ring-width) solid var(--focus-ring-color); outline-offset: 2px; }
+
+/* ── responsive ───────────────────────────────────────────────────────────── */
+@media (max-width: 720px) {
+ .radar-main { padding: var(--space-md) var(--space-sm) var(--space-2xl); }
+ .radar-controls { gap: var(--space-sm); }
+ .radar-updated { margin-left: 0; width: 100%; }
+ .radar-grid { grid-template-columns: 1fr; }
+ .rd-signals { grid-template-columns: 1fr; }
+ .radar-drawer-panel { width: 100%; border-left: none; }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .radar-card, .rc-ring-arc, .rc-ob-fill, .radar-glyph-sweep, .radar-pill-dot, .radar-live-dot { animation: none !important; transition: none !important; }
+ .radar-card.is-enter { opacity: 1; transform: none; }
+}
diff --git a/src/radar.js b/src/radar.js
new file mode 100644
index 000000000..2421da8c8
--- /dev/null
+++ b/src/radar.js
@@ -0,0 +1,971 @@
+// ════════════════════════════════════════════════════════════════════════════
+// Coin Radar — live pump.fun launch intelligence.
+//
+// Renders the Coin Intelligence Engine feed (GET /api/pump/coin-intel): every
+// coin observed in its first ~90s of trading, classified and risk-scored. The
+// trader question this page answers at a glance: "organic, or a bundle/rug?"
+//
+// Data source is the ONLY one: /api/pump/coin-intel (radar list) and
+// /api/pump/coin-intel?mint=<mint>&wallets=1 (single-coin detail). Every number
+// traces to an observed on-chain trade — nothing here is synthesized. A signal
+// the engine did not measure (e.g. fresh_wallet_ratio === null) renders as
+// "not measured", never as 0.
+// ════════════════════════════════════════════════════════════════════════════
+
+const POLL_MS = 12000;
+const DEFAULT_LIMIT = 60;
+
+const CATEGORIES = [
+ 'meme', 'tech', 'ai', 'culture', 'community',
+ 'political', 'news', 'animal', 'celebrity', 'utility', 'unknown',
+];
+
+const CATEGORY_LABEL = {
+ meme: 'Meme', tech: 'Tech', ai: 'AI', culture: 'Culture',
+ community: 'Community', political: 'Political', news: 'News',
+ animal: 'Animal', celebrity: 'Celebrity', utility: 'Utility', unknown: 'Unknown',
+};
+
+// Risk-flag vocabulary → display label + severity. danger = act-with-caution,
+// warn = worth noting. Unknown future flags fall back to a neutral warn pill.
+const FLAG_META = {
+ bundle_launch: { label: 'Bundle launch', tone: 'danger', tip: 'Many wallets bought in the same block — likely coordinated.' },
+ dev_dumped: { label: 'Dev dumped', tone: 'danger', tip: 'The creator sold their position.' },
+ single_whale: { label: 'Single whale', tone: 'danger', tip: 'One wallet holds an outsized share of supply.' },
+ low_diversity: { label: 'Low diversity', tone: 'danger', tip: 'Few unique buyers — thin, concentrated participation.' },
+ fresh_wallet_swarm:{ label: 'Fresh-wallet swarm',tone: 'danger', tip: 'A cluster of brand-new wallets bought together.' },
+ sell_pressure: { label: 'Sell pressure', tone: 'warn', tip: 'Sells are outpacing buys early.' },
+ sniped: { label: 'Sniped', tone: 'warn', tip: 'Snipers grabbed supply in the first moments.' },
+};
+
+// ── tiny DOM + format helpers ───────────────────────────────────────────────
+const el = (tag, cls, text) => {
+ const n = document.createElement(tag);
+ if (cls) n.className = cls;
+ if (text != null) n.textContent = text;
+ return n;
+};
+const pct = (v) => (v == null ? null : Math.round(v * 100));
+const clamp01 = (v) => Math.max(0, Math.min(1, v));
+const short = (s, head = 4, tail = 4) =>
+ typeof s === 'string' && s.length > head + tail + 1 ? `${s.slice(0, head)}…${s.slice(-tail)}` : (s || '');
+
+const fmtSol = (v) => {
+ if (v == null || Number.isNaN(v)) return null;
+ const abs = Math.abs(v);
+ if (abs === 0) return '0';
+ if (abs < 0.001) return v.toFixed(5);
+ if (abs < 1) return v.toFixed(3);
+ if (abs < 1000) return v.toFixed(2);
+ return v.toLocaleString(undefined, { maximumFractionDigits: 0 });
+};
+const fmtInt = (v) => (v == null ? '—' : Number(v).toLocaleString());
+
+function timeAgo(ts) {
+ if (!ts) return '';
+ const ms = Date.parse(ts);
+ if (Number.isNaN(ms)) return '';
+ const s = Math.max(0, Math.floor((Date.now() - ms) / 1000));
+ if (s < 60) return s + 's ago';
+ const m = Math.floor(s / 60);
+ if (m < 60) return m + 'm ago';
+ const h = Math.floor(m / 60);
+ if (h < 24) return h + 'h ago';
+ return Math.floor(h / 24) + 'd ago';
+}
+
+function solscanToken(mint, network) {
+ const base = `https://solscan.io/token/${encodeURIComponent(mint)}`;
+ return network === 'devnet' ? `${base}?cluster=devnet` : base;
+}
+function solscanAccount(addr, network) {
+ const base = `https://solscan.io/account/${encodeURIComponent(addr)}`;
+ return network === 'devnet' ? `${base}?cluster=devnet` : base;
+}
+
+// Quality 0–100 → red→amber→green ramp. Null score → neutral grey.
+function qualityColor(score) {
+ if (score == null) return 'var(--ink-faint)';
+ if (score >= 70) return 'var(--success)';
+ if (score >= 40) return 'var(--warn)';
+ return 'var(--danger)';
+}
+function qualityLabel(score) {
+ if (score == null) return 'Unscored';
+ if (score >= 70) return 'Healthy';
+ if (score >= 40) return 'Mixed';
+ return 'High risk';
+}
+
+// ── state ───────────────────────────────────────────────────────────────────
+const state = {
+ network: 'mainnet',
+ category: null, // null = all
+ minQuality: 0,
+ hideRisky: false, // client-side: drop danger-flagged coins
+ coins: [],
+ seen: new Set(), // mints already rendered (for enter animation)
+ status: 'loading', // loading | ready | empty | error
+ lastUpdated: 0,
+ pollTimer: null,
+ inFlight: null,
+};
+
+let root = null;
+
+// ── URL <-> state (shareable views) ─────────────────────────────────────────
+function readUrl() {
+ const p = new URLSearchParams(location.search);
+ if (p.get('network') === 'devnet') state.network = 'devnet';
+ const cat = p.get('category');
+ if (cat && CATEGORIES.includes(cat)) state.category = cat;
+ const mq = parseInt(p.get('min_quality'), 10);
+ if (Number.isFinite(mq)) state.minQuality = Math.max(0, Math.min(100, mq));
+ if (p.get('hide_risky') === '1') state.hideRisky = true;
+}
+
+function writeUrl() {
+ const p = new URLSearchParams();
+ if (state.network !== 'mainnet') p.set('network', state.network);
+ if (state.category) p.set('category', state.category);
+ if (state.minQuality > 0) p.set('min_quality', String(state.minQuality));
+ if (state.hideRisky) p.set('hide_risky', '1');
+ const qs = p.toString();
+ const url = location.pathname + (qs ? '?' + qs : '');
+ history.replaceState(null, '', url);
+}
+
+// ── data fetch ──────────────────────────────────────────────────────────────
+function buildFeedUrl() {
+ const p = new URLSearchParams();
+ p.set('limit', String(DEFAULT_LIMIT));
+ p.set('network', state.network);
+ if (state.category) p.set('category', state.category);
+ if (state.minQuality > 0) p.set('min_quality', String(state.minQuality));
+ return '/api/pump/coin-intel?' + p.toString();
+}
+
+async function fetchFeed({ silent = false } = {}) {
+ if (state.inFlight) state.inFlight.abort();
+ const ctrl = new AbortController();
+ state.inFlight = ctrl;
+ if (!silent) {
+ state.status = 'loading';
+ render();
+ }
+ try {
+ const r = await fetch(buildFeedUrl(), {
+ headers: { accept: 'application/json' },
+ signal: ctrl.signal,
+ });
+ if (!r.ok) throw new Error(`feed HTTP ${r.status}`);
+ const data = await r.json();
+ const coins = Array.isArray(data.coins) ? data.coins : [];
+ state.coins = coins;
+ state.lastUpdated = Date.now();
+ state.status = coins.length ? 'ready' : 'empty';
+ render();
+ } catch (err) {
+ if (err.name === 'AbortError') return;
+ console.error('[radar] feed fetch failed:', err.message || err);
+ // Keep previously rendered coins on a silent (poll) failure; only blank
+ // out to the error state when we have nothing to show.
+ if (!state.coins.length) {
+ state.status = 'error';
+ render();
+ }
+ } finally {
+ state.inFlight = null;
+ }
+}
+
+// ── polling (paused when tab hidden) ────────────────────────────────────────
+function startPolling() {
+ stopPolling();
+ state.pollTimer = setInterval(() => {
+ if (document.hidden) return;
+ fetchFeed({ silent: true });
+ }, POLL_MS);
+}
+function stopPolling() {
+ if (state.pollTimer) { clearInterval(state.pollTimer); state.pollTimer = null; }
+}
+
+// ════════════════════════════════════════════════════════════════════════════
+// RENDER
+// ════════════════════════════════════════════════════════════════════════════
+function render() {
+ if (!root) return;
+ root.innerHTML = '';
+ root.append(renderToolbar());
+
+ const body = el('div', 'radar-body');
+ if (state.status === 'loading' && !state.coins.length) {
+ body.append(renderSkeletonGrid());
+ } else if (state.status === 'error') {
+ body.append(renderErrorState());
+ } else {
+ const visible = applyClientFilters(state.coins);
+ if (!visible.length) {
+ body.append(state.status === 'empty' ? renderEmptyState() : renderNoMatchState());
+ } else {
+ body.append(renderGrid(visible));
+ }
+ }
+ root.append(body);
+ updateUpdatedLabel();
+}
+
+function applyClientFilters(coins) {
+ if (!state.hideRisky) return coins;
+ return coins.filter((c) => {
+ const flags = c.risk_flags || [];
+ return !flags.some((f) => (FLAG_META[f]?.tone ?? 'warn') === 'danger');
+ });
+}
+
+// ── toolbar / filters ───────────────────────────────────────────────────────
+function renderToolbar() {
+ const bar = el('div', 'radar-toolbar');
+ bar.setAttribute('role', 'region');
+ bar.setAttribute('aria-label', 'Radar filters');
+
+ // row 1: category chips
+ const chips = el('div', 'radar-chips');
+ chips.setAttribute('role', 'group');
+ chips.setAttribute('aria-label', 'Filter by category');
+ chips.append(chip('All', state.category === null, () => { state.category = null; onFilterChange(); }));
+ for (const c of CATEGORIES) {
+ chips.append(chip(CATEGORY_LABEL[c], state.category === c, () => {
+ state.category = state.category === c ? null : c;
+ onFilterChange();
+ }));
+ }
+
+ // row 2: controls
+ const controls = el('div', 'radar-controls');
+
+ // min-quality slider
+ const qWrap = el('div', 'radar-control radar-quality');
+ const qLabel = el('label', 'radar-control-label');
+ qLabel.htmlFor = 'radar-min-quality';
+ qLabel.append(el('span', null, 'Min quality'));
+ const qVal = el('span', 'radar-quality-val', state.minQuality === 0 ? 'Any' : String(state.minQuality));
+ qLabel.append(qVal);
+ const slider = el('input', 'radar-slider');
+ slider.type = 'range';
+ slider.id = 'radar-min-quality';
+ slider.min = '0'; slider.max = '100'; slider.step = '5';
+ slider.value = String(state.minQuality);
+ slider.setAttribute('aria-valuetext', state.minQuality === 0 ? 'Any' : state.minQuality + ' of 100');
+ slider.addEventListener('input', () => {
+ state.minQuality = parseInt(slider.value, 10) || 0;
+ qVal.textContent = state.minQuality === 0 ? 'Any' : String(state.minQuality);
+ slider.setAttribute('aria-valuetext', state.minQuality === 0 ? 'Any' : state.minQuality + ' of 100');
+ });
+ // commit on release (avoid a fetch per tick)
+ slider.addEventListener('change', () => onFilterChange());
+ qWrap.append(qLabel, slider);
+
+ // hide-risky toggle
+ const toggle = el('button', 'radar-toggle');
+ toggle.type = 'button';
+ toggle.setAttribute('role', 'switch');
+ toggle.setAttribute('aria-checked', String(state.hideRisky));
+ toggle.append(el('span', 'radar-toggle-track'));
+ toggle.append(el('span', 'radar-toggle-label', 'Hide flagged'));
+ toggle.title = 'Hide coins with danger-level risk flags (bundle, dev-dump, whale, swarm)';
+ toggle.addEventListener('click', () => {
+ state.hideRisky = !state.hideRisky;
+ toggle.setAttribute('aria-checked', String(state.hideRisky));
+ writeUrl();
+ render();
+ });
+
+ // network segmented control
+ const netWrap = el('div', 'radar-control radar-network');
+ netWrap.setAttribute('role', 'group');
+ netWrap.setAttribute('aria-label', 'Network');
+ for (const n of ['mainnet', 'devnet']) {
+ const b = el('button', 'radar-seg' + (state.network === n ? ' is-active' : ''), n === 'mainnet' ? 'Mainnet' : 'Devnet');
+ b.type = 'button';
+ b.setAttribute('aria-pressed', String(state.network === n));
+ b.addEventListener('click', () => {
+ if (state.network === n) return;
+ state.network = n;
+ state.coins = [];
+ state.seen.clear();
+ onFilterChange();
+ });
+ netWrap.append(b);
+ }
+
+ // updated indicator
+ const updated = el('div', 'radar-updated');
+ updated.id = 'radar-updated';
+ updated.setAttribute('aria-live', 'polite');
+ const dot = el('span', 'radar-live-dot');
+ dot.setAttribute('aria-hidden', 'true');
+ updated.append(dot, el('span', 'radar-updated-text', 'Connecting…'));
+
+ controls.append(qWrap, toggle, netWrap, updated);
+ bar.append(chips, controls);
+ return bar;
+}
+
+function chip(label, active, onClick) {
+ const b = el('button', 'radar-chip' + (active ? ' is-active' : ''), label);
+ b.type = 'button';
+ b.setAttribute('aria-pressed', String(active));
+ b.addEventListener('click', onClick);
+ return b;
+}
+
+function onFilterChange() {
+ writeUrl();
+ fetchFeed();
+}
+
+function updateUpdatedLabel() {
+ const node = root && root.querySelector('#radar-updated .radar-updated-text');
+ const dot = root && root.querySelector('#radar-updated .radar-live-dot');
+ if (!node) return;
+ if (state.status === 'error') {
+ node.textContent = 'Reconnecting…';
+ if (dot) dot.classList.add('is-stale');
+ return;
+ }
+ if (!state.lastUpdated) {
+ node.textContent = 'Live';
+ return;
+ }
+ if (dot) dot.classList.remove('is-stale');
+ const s = Math.floor((Date.now() - state.lastUpdated) / 1000);
+ node.textContent = s < 5 ? 'Live · just now' : `Live · updated ${s}s ago`;
+}
+
+// ── grids ───────────────────────────────────────────────────────────────────
+function renderGrid(coins) {
+ const grid = el('div', 'radar-grid');
+ grid.setAttribute('role', 'list');
+ for (const coin of coins) grid.append(renderCard(coin));
+ return grid;
+}
+
+function renderSkeletonGrid() {
+ const grid = el('div', 'radar-grid', null);
+ grid.setAttribute('aria-hidden', 'true');
+ for (let i = 0; i < 8; i++) {
+ const c = el('div', 'radar-card radar-card--skeleton');
+ c.append(
+ el('div', 'sk sk-row'),
+ el('div', 'sk sk-ring'),
+ el('div', 'sk sk-bar'),
+ el('div', 'sk sk-bar w70'),
+ el('div', 'sk sk-pills'),
+ );
+ grid.append(c);
+ }
+ return grid;
+}
+
+function renderCard(coin) {
+ const isNew = !state.seen.has(coin.mint);
+ state.seen.add(coin.mint);
+
+ const card = el('article', 'radar-card' + (isNew ? ' is-enter' : ''));
+ card.setAttribute('role', 'listitem');
+ card.tabIndex = 0;
+ const label = `${coin.name || coin.symbol || 'coin'} — quality ${coin.quality_score ?? 'unscored'}, ${qualityLabel(coin.quality_score)}. Open details.`;
+ card.setAttribute('aria-label', label);
+ const open = () => openDrawer(coin.mint);
+ card.addEventListener('click', (e) => {
+ if (e.target.closest('a')) return; // let links work
+ open();
+ });
+ card.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(); }
+ });
+
+ // ── header: identity + category ──
+ const head = el('div', 'rc-head');
+ const img = el('img', 'rc-img');
+ img.loading = 'lazy';
+ img.decoding = 'async';
+ img.width = 40; img.height = 40;
+ img.alt = '';
+ const seed = coin.symbol || coin.name || coin.mint || 'coin';
+ img.src = coin.image_uri && /^https?:\/\//i.test(coin.image_uri)
+ ? `/api/img?url=${encodeURIComponent(coin.image_uri)}&seed=${encodeURIComponent(seed)}`
+ : `/api/img?seed=${encodeURIComponent(seed)}`;
+ img.addEventListener('error', () => { img.src = `/api/img?seed=${encodeURIComponent(seed)}`; }, { once: true });
+
+ const idCol = el('div', 'rc-id');
+ const nameEl = el('div', 'rc-name', coin.name || 'Unnamed');
+ nameEl.title = coin.name || '';
+ const symEl = el('div', 'rc-sym');
+ symEl.append(el('span', 'rc-ticker', coin.symbol ? '$' + coin.symbol : '—'));
+ symEl.append(el('span', 'rc-age', timeAgo(coin.first_seen_at)));
+ idCol.append(nameEl, symEl);
+
+ const cat = el('span', 'rc-cat', CATEGORY_LABEL[coin.category] || 'Unknown');
+ cat.title = coin.classify_source
+ ? `Classified by ${coin.classify_source}${coin.classify_confidence != null ? ` · ${pct(coin.classify_confidence)}% confidence` : ''}`
+ : 'Category';
+
+ head.append(img, idCol, cat);
+
+ // ── quality ring + organic/bundle ──
+ const scoreRow = el('div', 'rc-score');
+ scoreRow.append(renderRing(coin.quality_score));
+ scoreRow.append(renderOrganicBundle(coin));
+ card.append(head, scoreRow);
+
+ // ── narrative ──
+ if (coin.narrative) {
+ const n = el('p', 'rc-narrative', coin.narrative);
+ n.title = coin.narrative;
+ card.append(n);
+ }
+
+ // ── risk flags ──
+ const flags = (coin.risk_flags || []);
+ if (flags.length) {
+ const pills = el('div', 'rc-flags');
+ for (const f of flags) {
+ const meta = FLAG_META[f] || { label: f.replace(/_/g, ' '), tone: 'warn', tip: '' };
+ const p = el('span', `rc-flag rc-flag--${meta.tone}`, meta.label);
+ if (meta.tip) p.title = meta.tip;
+ pills.append(p);
+ }
+ card.append(pills);
+ } else {
+ const clean = el('div', 'rc-flags');
+ clean.append(el('span', 'rc-flag rc-flag--clean', 'No risk flags'));
+ card.append(clean);
+ }
+
+ // ── key stats ──
+ const stats = el('div', 'rc-stats');
+ stats.append(stat('Buyers', fmtInt(coin.unique_buyers)));
+ stats.append(stat('Dev buy', coin.dev_buy_sol != null ? fmtSol(coin.dev_buy_sol) + ' ◎' : '—'));
+ stats.append(stat('Buy vol', coin.buy_volume_sol != null ? fmtSol(coin.buy_volume_sol) + ' ◎' : '—'));
+ stats.append(stat('Sell vol', coin.sell_volume_sol != null ? fmtSol(coin.sell_volume_sol) + ' ◎' : '—'));
+ card.append(stats);
+
+ // ── footer links ──
+ const foot = el('div', 'rc-foot');
+ const scan = el('a', 'rc-link', 'Solscan');
+ scan.href = solscanToken(coin.mint, coin.network);
+ scan.target = '_blank'; scan.rel = 'noopener noreferrer';
+ scan.addEventListener('click', (e) => e.stopPropagation());
+ const detail = el('button', 'rc-detail', 'Full intel →');
+ detail.type = 'button';
+ detail.addEventListener('click', (e) => { e.stopPropagation(); open(); });
+ foot.append(scan, detail);
+ card.append(foot);
+
+ if (isNew) requestAnimationFrame(() => card.classList.remove('is-enter'));
+ return card;
+}
+
+function stat(label, value) {
+ const s = el('div', 'rc-stat');
+ s.append(el('span', 'rc-stat-label', label));
+ s.append(el('span', 'rc-stat-value', value));
+ return s;
+}
+
+// SVG quality ring, 0–100, color-graded.
+function renderRing(score) {
+ const NS = 'http://www.w3.org/2000/svg';
+ const size = 64, stroke = 6, r = (size - stroke) / 2, c = 2 * Math.PI * r;
+ const has = score != null;
+ const frac = has ? clamp01(score / 100) : 0;
+
+ const wrap = el('div', 'rc-ring');
+ const svg = document.createElementNS(NS, 'svg');
+ svg.setAttribute('viewBox', `0 0 ${size} ${size}`);
+ svg.setAttribute('class', 'rc-ring-svg');
+ svg.setAttribute('aria-hidden', 'true');
+
+ const track = document.createElementNS(NS, 'circle');
+ track.setAttribute('cx', size / 2); track.setAttribute('cy', size / 2); track.setAttribute('r', r);
+ track.setAttribute('class', 'rc-ring-track');
+ track.setAttribute('stroke-width', stroke); track.setAttribute('fill', 'none');
+
+ const arc = document.createElementNS(NS, 'circle');
+ arc.setAttribute('cx', size / 2); arc.setAttribute('cy', size / 2); arc.setAttribute('r', r);
+ arc.setAttribute('class', 'rc-ring-arc');
+ arc.setAttribute('fill', 'none');
+ arc.setAttribute('stroke', qualityColor(score));
+ arc.setAttribute('stroke-width', stroke);
+ arc.setAttribute('stroke-linecap', 'round');
+ arc.setAttribute('stroke-dasharray', String(c));
+ arc.setAttribute('stroke-dashoffset', String(c * (1 - frac)));
+ arc.setAttribute('transform', `rotate(-90 ${size / 2} ${size / 2})`);
+
+ svg.append(track, arc);
+
+ const val = el('div', 'rc-ring-val');
+ val.style.color = qualityColor(score);
+ val.append(el('span', 'rc-ring-num', has ? String(score) : '—'));
+ wrap.append(svg, val);
+
+ const cap = el('div', 'rc-ring-cap', qualityLabel(score));
+ cap.style.color = qualityColor(score);
+
+ const col = el('div', 'rc-ring-col');
+ col.append(wrap, cap);
+ return col;
+}
+
+function renderOrganicBundle(coin) {
+ const o = coin.organic_score, b = coin.bundle_score;
+ const wrap = el('div', 'rc-ob');
+
+ const readout = el('div', 'rc-ob-readout');
+ readout.append(obTag('Organic', pct(o), 'organic'));
+ readout.append(obTag('Bundle', pct(b), 'bundle'));
+ wrap.append(readout);
+
+ // dual bar — only the measured side fills; an unmeasured side stays empty.
+ const bar = el('div', 'rc-ob-bar');
+ bar.setAttribute('aria-hidden', 'true');
+ const oFill = el('span', 'rc-ob-fill rc-ob-fill--organic');
+ oFill.style.width = (o != null ? clamp01(o) * 100 : 0) + '%';
+ const bFill = el('span', 'rc-ob-fill rc-ob-fill--bundle');
+ bFill.style.width = (b != null ? clamp01(b) * 100 : 0) + '%';
+ bar.append(oFill, bFill);
+ wrap.append(bar);
+ return wrap;
+}
+
+function obTag(label, p, kind) {
+ const t = el('span', `rc-ob-tag rc-ob-tag--${kind}`);
+ t.append(el('span', 'rc-ob-tag-label', label));
+ t.append(el('span', 'rc-ob-tag-val', p == null ? 'n/m' : p + '%'));
+ if (p == null) t.title = `${label} score not measured`;
+ return t;
+}
+
+// ── states ──────────────────────────────────────────────────────────────────
+function renderEmptyState() {
+ const box = el('div', 'radar-state radar-empty');
+ box.append(radarGlyph());
+ box.append(el('h2', 'radar-state-title', 'Radar is clear — waiting for the next launch'));
+ const p = el('p', 'radar-state-text');
+ p.textContent = state.network === 'devnet'
+ ? 'No devnet coins have been observed yet. The Coin Intelligence Engine watches each new pump.fun launch for its first ~90 seconds, then scores it. Switch to mainnet for the live feed.'
+ : 'No coins in the observation window right now. The Coin Intelligence Engine watches every new pump.fun launch for its first ~90 seconds of trading, derives its bundle / organic / concentration signals, classifies it, and posts it here. New cards appear automatically the moment a launch finishes its observation window.';
+ box.append(p);
+
+ const actions = el('div', 'radar-state-actions');
+ if (state.network !== 'mainnet') {
+ const toMain = el('button', 'radar-btn', 'View mainnet');
+ toMain.type = 'button';
+ toMain.addEventListener('click', () => {
+ state.network = 'mainnet'; state.coins = []; state.seen.clear(); onFilterChange();
+ });
+ actions.append(toMain);
+ }
+ const live = el('a', 'radar-btn radar-btn--ghost', 'See raw launches →');
+ live.href = '/pump-live';
+ actions.append(live);
+ box.append(actions);
+
+ const note = el('p', 'radar-state-note', 'This view refreshes every 12 seconds. It will populate itself — no need to reload.');
+ box.append(note);
+ return box;
+}
+
+function renderNoMatchState() {
+ const box = el('div', 'radar-state radar-empty');
+ box.append(radarGlyph());
+ box.append(el('h2', 'radar-state-title', 'No coins match these filters'));
+ box.append(el('p', 'radar-state-text', 'The radar has live coins, but none pass your current category, quality, or risk filters. Loosen them to see more.'));
+ const actions = el('div', 'radar-state-actions');
+ const reset = el('button', 'radar-btn', 'Reset filters');
+ reset.type = 'button';
+ reset.addEventListener('click', () => {
+ state.category = null; state.minQuality = 0; state.hideRisky = false;
+ onFilterChange();
+ render();
+ });
+ actions.append(reset);
+ box.append(actions);
+ return box;
+}
+
+function renderErrorState() {
+ const box = el('div', 'radar-state radar-error');
+ box.setAttribute('role', 'alert');
+ box.append(el('h2', 'radar-state-title', 'Could not reach the radar feed'));
+ box.append(el('p', 'radar-state-text', 'The Coin Intelligence feed did not respond. This is usually temporary — the engine or network may be momentarily unavailable.'));
+ const actions = el('div', 'radar-state-actions');
+ const retry = el('button', 'radar-btn', 'Retry now');
+ retry.type = 'button';
+ retry.addEventListener('click', () => fetchFeed());
+ actions.append(retry);
+ box.append(actions);
+ return box;
+}
+
+function radarGlyph() {
+ const NS = 'http://www.w3.org/2000/svg';
+ const svg = document.createElementNS(NS, 'svg');
+ svg.setAttribute('viewBox', '0 0 120 120');
+ svg.setAttribute('class', 'radar-glyph');
+ svg.setAttribute('aria-hidden', 'true');
+ for (const rr of [20, 36, 52]) {
+ const ci = document.createElementNS(NS, 'circle');
+ ci.setAttribute('cx', '60'); ci.setAttribute('cy', '60'); ci.setAttribute('r', String(rr));
+ ci.setAttribute('class', 'radar-glyph-ring'); ci.setAttribute('fill', 'none');
+ svg.append(ci);
+ }
+ const sweep = document.createElementNS(NS, 'path');
+ sweep.setAttribute('d', 'M60 60 L60 8 A52 52 0 0 1 104 38 Z');
+ sweep.setAttribute('class', 'radar-glyph-sweep');
+ svg.append(sweep);
+ const dot = document.createElementNS(NS, 'circle');
+ dot.setAttribute('cx', '60'); dot.setAttribute('cy', '60'); dot.setAttribute('r', '3');
+ dot.setAttribute('class', 'radar-glyph-dot');
+ svg.append(dot);
+ return svg;
+}
+
+// ════════════════════════════════════════════════════════════════════════════
+// DETAIL DRAWER
+// ════════════════════════════════════════════════════════════════════════════
+let drawer = null;
+let drawerAbort = null;
+let lastFocused = null;
+
+function ensureDrawer() {
+ if (drawer) return drawer;
+ const scrim = el('div', 'radar-drawer-scrim');
+ scrim.id = 'radar-drawer';
+ scrim.hidden = true;
+ scrim.addEventListener('click', (e) => { if (e.target === scrim) closeDrawer(); });
+
+ const panel = el('aside', 'radar-drawer-panel');
+ panel.setAttribute('role', 'dialog');
+ panel.setAttribute('aria-modal', 'true');
+ panel.setAttribute('aria-label', 'Coin intelligence detail');
+ panel.tabIndex = -1;
+ scrim.append(panel);
+ document.body.append(scrim);
+
+ document.addEventListener('keydown', (e) => {
+ if (scrim.hidden) return;
+ if (e.key === 'Escape') { e.preventDefault(); closeDrawer(); }
+ if (e.key === 'Tab') trapFocus(e, panel);
+ });
+
+ drawer = { scrim, panel };
+ return drawer;
+}
+
+function trapFocus(e, panel) {
+ const f = panel.querySelectorAll('a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])');
+ if (!f.length) return;
+ const first = f[0], last = f[f.length - 1];
+ if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
+ else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
+}
+
+async function openDrawer(mint) {
+ const { scrim, panel } = ensureDrawer();
+ lastFocused = document.activeElement;
+ scrim.hidden = false;
+ document.body.classList.add('radar-no-scroll');
+ requestAnimationFrame(() => scrim.classList.add('is-open'));
+
+ panel.innerHTML = '';
+ panel.append(drawerHeader('Loading intel…', null, null));
+ const load = el('div', 'rd-loading');
+ for (let i = 0; i < 5; i++) load.append(el('div', 'sk sk-bar'));
+ panel.append(load);
+ panel.focus();
+
+ if (drawerAbort) drawerAbort.abort();
+ drawerAbort = new AbortController();
+ const net = state.network;
+ try {
+ const r = await fetch(`/api/pump/coin-intel?mint=${encodeURIComponent(mint)}&wallets=1&network=${net}`, {
+ headers: { accept: 'application/json' },
+ signal: drawerAbort.signal,
+ });
+ if (r.status === 404) { renderDrawerNotFound(panel, mint); return; }
+ if (!r.ok) throw new Error(`detail HTTP ${r.status}`);
+ const coin = await r.json();
+ renderDrawerContent(panel, coin);
+ } catch (err) {
+ if (err.name === 'AbortError') return;
+ console.error('[radar] detail fetch failed:', err.message || err);
+ renderDrawerError(panel, mint);
+ }
+}
+
+function closeDrawer() {
+ if (!drawer) return;
+ drawer.scrim.classList.remove('is-open');
+ document.body.classList.remove('radar-no-scroll');
+ if (drawerAbort) { drawerAbort.abort(); drawerAbort = null; }
+ const scrim = drawer.scrim;
+ const onEnd = () => { scrim.hidden = true; scrim.removeEventListener('transitionend', onEnd); };
+ scrim.addEventListener('transitionend', onEnd);
+ setTimeout(() => { if (!scrim.hidden) onEnd(); }, 320);
+ if (lastFocused && typeof lastFocused.focus === 'function') lastFocused.focus();
+}
+
+function drawerHeader(title, sub, coin) {
+ const head = el('div', 'rd-head');
+ const titleWrap = el('div', 'rd-head-id');
+ if (coin) {
+ const img = el('img', 'rd-img');
+ img.width = 44; img.height = 44; img.alt = ''; img.loading = 'lazy';
+ const seed = coin.symbol || coin.name || coin.mint || 'coin';
+ img.src = coin.image_uri && /^https?:\/\//i.test(coin.image_uri)
+ ? `/api/img?url=${encodeURIComponent(coin.image_uri)}&seed=${encodeURIComponent(seed)}`
+ : `/api/img?seed=${encodeURIComponent(seed)}`;
+ img.addEventListener('error', () => { img.src = `/api/img?seed=${encodeURIComponent(seed)}`; }, { once: true });
+ titleWrap.append(img);
+ }
+ const txt = el('div');
+ txt.append(el('h2', 'rd-title', title));
+ if (sub) txt.append(el('div', 'rd-sub', sub));
+ titleWrap.append(txt);
+
+ const close = el('button', 'rd-close');
+ close.type = 'button';
+ close.setAttribute('aria-label', 'Close detail');
+ close.innerHTML = '<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M5 5l10 10M15 5L5 15"/></svg>';
+ close.addEventListener('click', closeDrawer);
+
+ head.append(titleWrap, close);
+ return head;
+}
+
+function renderDrawerNotFound(panel, mint) {
+ panel.innerHTML = '';
+ panel.append(drawerHeader('Not observed', short(mint, 6, 6), null));
+ const box = el('div', 'rd-section');
+ box.append(el('p', 'radar-state-text', 'This coin has no intelligence record. It may have launched before the engine started watching, or be too old — the engine only retains coins it observed live.'));
+ const scan = el('a', 'radar-btn radar-btn--ghost', 'View on Solscan →');
+ scan.href = solscanToken(mint, state.network); scan.target = '_blank'; scan.rel = 'noopener noreferrer';
+ box.append(scan);
+ panel.append(box);
+}
+
+function renderDrawerError(panel, mint) {
+ panel.innerHTML = '';
+ panel.append(drawerHeader('Could not load intel', short(mint, 6, 6), null));
+ const box = el('div', 'rd-section');
+ box.setAttribute('role', 'alert');
+ box.append(el('p', 'radar-state-text', 'The detail request failed. Try again in a moment.'));
+ const retry = el('button', 'radar-btn', 'Retry');
+ retry.type = 'button';
+ retry.addEventListener('click', () => openDrawer(mint));
+ box.append(retry);
+ panel.append(box);
+}
+
+function renderDrawerContent(panel, coin) {
+ panel.innerHTML = '';
+ panel.append(drawerHeader(
+ coin.name || 'Unnamed coin',
+ `${coin.symbol ? '$' + coin.symbol + ' · ' : ''}${CATEGORY_LABEL[coin.category] || 'Unknown'} · observed ${coin.observation_seconds ?? '—'}s`,
+ coin,
+ ));
+
+ // headline: ring + organic/bundle + outcome
+ const headline = el('div', 'rd-headline');
+ headline.append(renderRing(coin.quality_score));
+ headline.append(renderOrganicBundle(coin));
+ panel.append(headline);
+
+ if (coin.outcome && coin.outcome.outcome) panel.append(renderOutcome(coin.outcome));
+
+ if (coin.narrative) {
+ const sec = el('div', 'rd-section');
+ sec.append(el('h3', 'rd-h3', 'Narrative'));
+ sec.append(el('p', 'rd-narrative', coin.narrative));
+ if (coin.classify_source) {
+ sec.append(el('p', 'rd-meta', `Classified by ${coin.classify_source}${coin.classify_confidence != null ? ` · ${pct(coin.classify_confidence)}% confidence` : ''}`));
+ }
+ panel.append(sec);
+ }
+
+ // risk flags
+ const flagsSec = el('div', 'rd-section');
+ flagsSec.append(el('h3', 'rd-h3', 'Risk flags'));
+ const flags = coin.risk_flags || [];
+ if (flags.length) {
+ const list = el('div', 'rd-flags');
+ for (const f of flags) {
+ const meta = FLAG_META[f] || { label: f.replace(/_/g, ' '), tone: 'warn', tip: '' };
+ const row = el('div', `rd-flag rd-flag--${meta.tone}`);
+ row.append(el('span', 'rd-flag-name', meta.label));
+ if (meta.tip) row.append(el('span', 'rd-flag-tip', meta.tip));
+ list.append(row);
+ }
+ flagsSec.append(list);
+ } else {
+ flagsSec.append(el('p', 'rd-meta', 'No risk flags raised during observation.'));
+ }
+ panel.append(flagsSec);
+
+ // signal breakdown
+ const sig = el('div', 'rd-section');
+ sig.append(el('h3', 'rd-h3', 'Signal breakdown'));
+ const grid = el('div', 'rd-signals');
+ const sigRow = (label, val, tip) => {
+ const r = el('div', 'rd-sig');
+ const l = el('span', 'rd-sig-label', label);
+ if (tip) l.title = tip;
+ r.append(l, el('span', 'rd-sig-val', val));
+ return r;
+ };
+ const ratio = (v) => (v == null ? 'not measured' : pct(v) + '%');
+ grid.append(sigRow('Organic score', ratio(coin.organic_score)));
+ grid.append(sigRow('Bundle score', ratio(coin.bundle_score)));
+ grid.append(sigRow('Snipe ratio', ratio(coin.snipe_ratio), 'Share of early supply taken by snipers'));
+ grid.append(sigRow('Top-10 concentration', ratio(coin.concentration_top10), 'Share of supply held by the top 10 wallets'));
+ grid.append(sigRow('Fresh-wallet ratio', ratio(coin.fresh_wallet_ratio), 'Share of buyers using brand-new wallets'));
+ grid.append(sigRow('Bubblemap connectivity', ratio(coin.bubblemap_connectivity), 'How interlinked the buyer wallets are by funding'));
+ grid.append(sigRow('Unique buyers', fmtInt(coin.unique_buyers)));
+ grid.append(sigRow('Unique sellers', fmtInt(coin.unique_sellers)));
+ grid.append(sigRow('Buys / sells', `${fmtInt(coin.buy_count)} / ${fmtInt(coin.sell_count)}`));
+ grid.append(sigRow('Buy / sell volume', `${coin.buy_volume_sol != null ? fmtSol(coin.buy_volume_sol) : '—'} / ${coin.sell_volume_sol != null ? fmtSol(coin.sell_volume_sol) : '—'} ◎`));
+ grid.append(sigRow('Dev buy', coin.dev_buy_sol != null ? fmtSol(coin.dev_buy_sol) + ' ◎' : '—'));
+ grid.append(sigRow('Dev sold', coin.dev_sold ? 'Yes' : 'No'));
+ grid.append(sigRow('Largest buy', coin.largest_buy_sol != null ? fmtSol(coin.largest_buy_sol) + ' ◎' : '—'));
+ sig.append(grid);
+ panel.append(sig);
+
+ // tags
+ if (Array.isArray(coin.tags) && coin.tags.length) {
+ const tagSec = el('div', 'rd-section');
+ tagSec.append(el('h3', 'rd-h3', 'Tags'));
+ const tw = el('div', 'rd-tags');
+ for (const t of coin.tags) tw.append(el('span', 'rd-tag', t));
+ tagSec.append(tw);
+ panel.append(tagSec);
+ }
+
+ // wallet ledger
+ panel.append(renderWalletLedger(coin));
+
+ // links + socials
+ const links = el('div', 'rd-section rd-links');
+ const scan = el('a', 'radar-btn radar-btn--ghost', 'Solscan');
+ scan.href = solscanToken(coin.mint, coin.network); scan.target = '_blank'; scan.rel = 'noopener noreferrer';
+ links.append(scan);
+ const s = coin.socials || {};
+ if (s.twitter) links.append(socialLink('Twitter', s.twitter));
+ if (s.telegram) links.append(socialLink('Telegram', s.telegram));
+ if (s.website) links.append(socialLink('Website', s.website));
+ panel.append(links);
+
+ const id = el('div', 'rd-mint');
+ id.append(el('span', null, 'Mint'));
+ const code = el('code', null, coin.mint);
+ const copy = el('button', 'rd-copy', 'Copy');
+ copy.type = 'button';
+ copy.addEventListener('click', async () => {
+ try { await navigator.clipboard.writeText(coin.mint); copy.textContent = 'Copied'; setTimeout(() => copy.textContent = 'Copy', 1400); }
+ catch { copy.textContent = 'Copy failed'; setTimeout(() => copy.textContent = 'Copy', 1400); }
+ });
+ id.append(code, copy);
+ panel.append(id);
+
+ // focus close for keyboard users
+ const close = panel.querySelector('.rd-close');
+ if (close) close.focus();
+}
+
+function socialLink(label, href) {
+ const a = el('a', 'radar-btn radar-btn--ghost', label);
+ const safe = /^https?:\/\//i.test(href) ? href : ('https://' + href);
+ a.href = safe; a.target = '_blank'; a.rel = 'noopener noreferrer';
+ return a;
+}
+
+function renderOutcome(o) {
+ const sec = el('div', 'rd-section rd-outcome');
+ const tone = o.rugged ? 'danger' : o.graduated ? 'success' : 'neutral';
+ sec.classList.add('rd-outcome--' + tone);
+ const labelMap = { graduated: 'Graduated', rugged: 'Rugged' };
+ const word = o.rugged ? 'Rugged' : o.graduated ? 'Graduated' : (labelMap[o.outcome] || o.outcome);
+ const row = el('div', 'rd-outcome-row');
+ row.append(el('span', 'rd-outcome-badge', word));
+ if (o.ath_multiple != null) row.append(el('span', 'rd-outcome-stat', `ATH ${o.ath_multiple.toFixed(1)}×`));
+ if (o.ath_market_cap_usd != null) row.append(el('span', 'rd-outcome-stat', `ATH MC $${Math.round(o.ath_market_cap_usd).toLocaleString()}`));
+ if (o.last_market_cap_usd != null) row.append(el('span', 'rd-outcome-stat', `Now $${Math.round(o.last_market_cap_usd).toLocaleString()}`));
+ sec.append(el('h3', 'rd-h3', 'Labeled outcome'), row);
+ return sec;
+}
+
+function renderWalletLedger(coin) {
+ const sec = el('div', 'rd-section');
+ sec.append(el('h3', 'rd-h3', 'Top trader ledger'));
+ const wallets = Array.isArray(coin.wallets) ? coin.wallets : [];
+ if (!wallets.length) {
+ sec.append(el('p', 'rd-meta', 'No per-wallet ledger available for this coin.'));
+ return sec;
+ }
+
+ const tableWrap = el('div', 'rd-table-wrap');
+ const table = el('table', 'rd-table');
+ const thead = el('thead');
+ const htr = el('tr');
+ ['Wallet', 'Buy ◎', 'Sell ◎', 'Net ◎'].forEach((h, i) => {
+ const th = el('th', i === 0 ? null : 'rd-num', h);
+ th.scope = 'col';
+ htr.append(th);
+ });
+ thead.append(htr);
+ table.append(thead);
+
+ const tbody = el('tbody');
+ for (const w of wallets) {
+ const tr = el('tr');
+ const wcell = el('td', 'rd-wcell');
+ const a = el('a', 'rd-waddr', short(w.wallet, 4, 4));
+ a.href = solscanAccount(w.wallet, coin.network);
+ a.target = '_blank'; a.rel = 'noopener noreferrer';
+ a.title = w.wallet;
+ wcell.append(a);
+ if (w.is_creator) wcell.append(el('span', 'rd-wtag', 'creator'));
+ tr.append(wcell);
+
+ tr.append(el('td', 'rd-num', w.buy_sol != null ? fmtSol(w.buy_sol) : '—'));
+ tr.append(el('td', 'rd-num', w.sell_sol != null ? fmtSol(w.sell_sol) : '—'));
+ const net = el('td', 'rd-num ' + (w.net_sol > 0 ? 'rd-pos' : w.net_sol < 0 ? 'rd-neg' : ''), w.net_sol != null ? (w.net_sol > 0 ? '+' : '') + fmtSol(w.net_sol) : '—');
+ tr.append(net);
+ tbody.append(tr);
+ }
+ table.append(tbody);
+ tableWrap.append(table);
+ sec.append(tableWrap);
+ return sec;
+}
+
+// ════════════════════════════════════════════════════════════════════════════
+// MOUNT
+// ════════════════════════════════════════════════════════════════════════════
+export function mountRadar(mountEl) {
+ root = mountEl;
+ readUrl();
+ render();
+ fetchFeed();
+ startPolling();
+
+ // keep "updated Xs ago" ticking without re-rendering the grid
+ setInterval(updateUpdatedLabel, 1000);
+
+ document.addEventListener('visibilitychange', () => {
+ if (!document.hidden) fetchFeed({ silent: true });
+ });
+}
diff --git a/src/trader.css b/src/trader.css
new file mode 100644
index 000000000..5149ef5f2
--- /dev/null
+++ b/src/trader.css
@@ -0,0 +1,225 @@
+/* Trader profile — provable track record + Proof tab.
+ Reuses leaderboard.css atoms (lb-pos/lb-neg/lb-muted/lb-btn/lb-verified) and the
+ canonical design tokens. */
+
+.tp-shell {
+ max-width: 1080px;
+ margin: 0 auto;
+ padding: var(--space-lg) var(--space-md) var(--space-2xl);
+}
+.tp-back {
+ display: inline-block;
+ font-size: var(--text-xs);
+ color: var(--ink-faint);
+ text-decoration: none;
+ margin-bottom: var(--space-md);
+ transition: color var(--duration-fast) var(--ease-standard);
+}
+.tp-back:hover { color: var(--ink-bright); }
+
+/* ---- Hero ---- */
+.tp-hero {
+ display: grid;
+ grid-template-columns: auto 1fr auto;
+ gap: var(--space-lg);
+ align-items: center;
+ border: 1px solid var(--stroke);
+ border-radius: var(--radius-card);
+ background: var(--surface-1);
+ padding: var(--space-lg);
+ margin-bottom: var(--space-md);
+}
+.tp-avatar-wrap { position: relative; }
+.tp-avatar {
+ width: 96px;
+ height: 96px;
+ border-radius: var(--radius-lg);
+ object-fit: cover;
+ border: 1px solid var(--stroke);
+ background: var(--surface-3);
+ display: block;
+}
+.tp-id { min-width: 0; }
+.tp-name {
+ display: flex;
+ align-items: center;
+ gap: var(--space-2xs);
+ font-family: var(--font-display);
+ font-size: var(--text-2xl);
+ font-weight: var(--weight-bold);
+ letter-spacing: -0.01em;
+ line-height: 1.1;
+}
+.tp-name .lb-verified svg { width: 20px; height: 20px; }
+.tp-sub {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--space-2xs) var(--space-sm);
+ margin-top: var(--space-2xs);
+ font-family: var(--font-mono);
+ font-size: var(--text-2xs);
+ color: var(--ink-faint);
+}
+.tp-sub a { color: var(--ink-dim); text-decoration: none; border-bottom: 1px dotted var(--stroke-strong); }
+.tp-sub a:hover { color: var(--ink-bright); }
+.tp-desc { margin-top: var(--space-sm); color: var(--ink-dim); font-size: var(--text-sm); line-height: var(--leading-normal); max-width: 60ch; }
+
+/* Score gauge */
+.tp-gauge { display: grid; place-items: center; text-align: center; }
+.tp-gauge svg { display: block; }
+.tp-gauge-val {
+ font-family: var(--font-display);
+ font-size: var(--text-2xl);
+ font-weight: var(--weight-bold);
+ font-variant-numeric: tabular-nums;
+}
+.tp-gauge-label { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); margin-top: var(--space-3xs); }
+
+/* ---- Window selector + actions ---- */
+.tp-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-md); }
+
+/* ---- Metric grid ---- */
+.tp-metrics {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
+ gap: var(--space-sm);
+ margin-bottom: var(--space-md);
+}
+.tp-metric {
+ border: 1px solid var(--stroke);
+ background: var(--surface-1);
+ border-radius: var(--radius-md);
+ padding: var(--space-md);
+}
+.tp-metric-label { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-bottom: var(--space-3xs); }
+.tp-metric-val { font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
+.tp-metric-sub { font-size: var(--text-2xs); color: var(--ink-faint); margin-top: 2px; }
+
+/* ---- Equity curve ---- */
+.tp-curve-wrap {
+ border: 1px solid var(--stroke);
+ background: var(--surface-1);
+ border-radius: var(--radius-card);
+ padding: var(--space-md);
+ margin-bottom: var(--space-md);
+}
+.tp-curve-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-sm); }
+.tp-curve-title { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
+.tp-curve { width: 100%; height: 180px; display: block; }
+.tp-curve-empty { color: var(--ink-faint); font-size: var(--text-sm); text-align: center; padding: var(--space-lg); }
+
+/* ---- Tabs ---- */
+.tp-tabs { display: flex; gap: var(--space-3xs); border-bottom: 1px solid var(--stroke); margin-bottom: var(--space-md); }
+.tp-tab {
+ appearance: none;
+ background: transparent;
+ border: 0;
+ border-bottom: 2px solid transparent;
+ color: var(--ink-dim);
+ font-family: var(--font-body);
+ font-size: var(--text-sm);
+ font-weight: var(--weight-medium);
+ padding: var(--space-sm) var(--space-md);
+ cursor: pointer;
+ transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
+}
+.tp-tab:hover { color: var(--ink-bright); }
+.tp-tab.is-active { color: var(--ink-bright); border-bottom-color: var(--accent); }
+.tp-tab-count { font-size: var(--text-2xs); color: var(--ink-faint); margin-left: var(--space-3xs); }
+.tp-panel { display: none; }
+.tp-panel.is-active { display: block; animation: tp-fade var(--duration-base) var(--ease-out); }
+@keyframes tp-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
+
+/* ---- Trade table ---- */
+.tp-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
+.tp-table th {
+ text-align: right;
+ font-size: var(--text-2xs);
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ color: var(--ink-faint);
+ font-weight: var(--weight-medium);
+ padding: var(--space-2xs) var(--space-sm);
+ border-bottom: 1px solid var(--stroke);
+}
+.tp-table th:first-child, .tp-table td:first-child { text-align: left; }
+.tp-table td { padding: var(--space-sm); border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; text-align: right; }
+.tp-table tr:last-child td { border-bottom: 0; }
+.tp-table tr:hover td { background: var(--surface-2); }
+.tp-coin { display: flex; flex-direction: column; gap: 1px; }
+.tp-coin-sym { font-weight: var(--weight-semibold); }
+.tp-coin-mint { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--ink-faint); }
+.tp-reason { display: inline-block; font-size: var(--text-2xs); padding: 1px var(--space-2xs); border-radius: var(--radius-pill); border: 1px solid var(--stroke); color: var(--ink-dim); }
+.tp-proof-link { color: var(--ink-dim); text-decoration: none; font-size: var(--text-2xs); border-bottom: 1px dotted var(--stroke-strong); white-space: nowrap; }
+.tp-proof-link:hover { color: var(--ink-bright); }
+
+/* ---- Proof callout ---- */
+.tp-proof-note {
+ display: flex;
+ gap: var(--space-sm);
+ align-items: flex-start;
+ border: 1px solid color-mix(in srgb, var(--success) 30%, var(--stroke));
+ background: color-mix(in srgb, var(--success) 7%, var(--surface-1));
+ border-radius: var(--radius-md);
+ padding: var(--space-md);
+ margin-bottom: var(--space-md);
+}
+.tp-proof-note svg { width: 20px; height: 20px; color: var(--success); flex-shrink: 0; margin-top: 2px; }
+.tp-proof-note p { margin: 0; font-size: var(--text-sm); color: var(--ink-dim); line-height: var(--leading-normal); }
+.tp-proof-note strong { color: var(--ink-bright); }
+
+/* ---- Copy panel + share ---- */
+.tp-copy {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ gap: var(--space-md);
+ align-items: center;
+ border: 1px solid var(--stroke);
+ border-radius: var(--radius-card);
+ background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
+ padding: var(--space-lg);
+ margin-top: var(--space-lg);
+}
+.tp-copy h2 { font-family: var(--font-display); font-size: var(--text-lg); margin: 0 0 var(--space-2xs); display: flex; align-items: center; gap: var(--space-2xs); }
+.tp-soon { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: var(--radius-pill); padding: 1px var(--space-2xs); }
+.tp-copy p { margin: 0; color: var(--ink-dim); font-size: var(--text-sm); max-width: 52ch; }
+.tp-copy-actions { display: flex; flex-direction: column; gap: var(--space-2xs); }
+
+/* ---- States / skeleton ---- */
+.tp-skel { border: 1px solid var(--stroke); border-radius: var(--radius-card); background: var(--surface-1); padding: var(--space-lg); }
+.tp-sk { height: 14px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: lb-shimmer 1.4s ease infinite; margin-bottom: var(--space-sm); }
+.tp-error, .tp-empty { text-align: center; padding: var(--space-2xl) var(--space-md); }
+.tp-error h1, .tp-empty h1 { font-family: var(--font-display); font-size: var(--text-xl); margin-bottom: var(--space-2xs); }
+.tp-error p, .tp-empty p { color: var(--ink-dim); max-width: 44ch; margin: 0 auto var(--space-md); }
+
+/* Toast for copy-link */
+.tp-toast {
+ position: fixed;
+ left: 50%;
+ bottom: var(--space-lg);
+ transform: translateX(-50%) translateY(20px);
+ background: var(--bg-1);
+ color: var(--ink-bright);
+ border: 1px solid var(--stroke-strong);
+ border-radius: var(--radius-pill);
+ padding: var(--space-2xs) var(--space-md);
+ font-size: var(--text-xs);
+ opacity: 0;
+ pointer-events: none;
+ transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-emphasized);
+ z-index: 50;
+}
+.tp-toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }
+
+@media (max-width: 760px) {
+ .tp-hero { grid-template-columns: auto 1fr; }
+ .tp-gauge { grid-column: 1 / -1; justify-self: start; }
+ .tp-copy { grid-template-columns: 1fr; }
+ .tp-copy-actions { flex-direction: row; flex-wrap: wrap; }
+ .tp-table th:nth-child(4), .tp-table td:nth-child(4),
+ .tp-table th:nth-child(5), .tp-table td:nth-child(5) { display: none; }
+}
+@media (prefers-reduced-motion: reduce) {
+ .tp-panel.is-active, .tp-sk { animation: none; }
+}
diff --git a/src/trader.js b/src/trader.js
new file mode 100644
index 000000000..ce770e491
--- /dev/null
+++ b/src/trader.js
@@ -0,0 +1,447 @@
+/**
+ * Trader profile controller.
+ *
+ * Renders /api/sniper/trader into a full, verifiable track record: score gauge,
+ * metric grid, realized-equity curve, and three tabs — Track record (closed
+ * trades), Open positions, and Proof (every closed trade linked to its on-chain
+ * buy/sell tx, plus the on-chain attestation note). Also generates a shareable
+ * PnL card (PNG) that embeds the viewer's referral link when signed in.
+ */
+
+import {
+ escapeHtml, fmtSol, fmtUsd, fmtPct, pnlClass, shortAddr, holdTime, relTime,
+ identicon, verifiedBadge,
+} from './trader-format.js';
+
+const WINDOWS = ['24h', '7d', '30d', 'all'];
+const WINDOW_LABEL = { '24h': '24h', '7d': '7d', '30d': '30d', all: 'All-time' };
+const NETWORKS = new Set(['mainnet', 'devnet']);
+
+const root = document.getElementById('tp-root');
+const content = document.getElementById('tp-content');
+
+const ctx = {
+ agentId: '',
+ network: 'mainnet',
+ window: 'all',
+ data: null,
+ refCode: null,
+};
+
+// --- Param parsing -----------------------------------------------------------
+function parseParams() {
+ const path = location.pathname.replace(/\/+$/, '');
+ const m = path.match(/^\/trader\/(.+)$/);
+ const qp = new URLSearchParams(location.search);
+ ctx.agentId = m ? decodeURIComponent(m[1]) : (qp.get('agent_id') || qp.get('agent') || '');
+ if (NETWORKS.has(qp.get('network'))) ctx.network = qp.get('network');
+ if (WINDOWS.includes(qp.get('window'))) ctx.window = qp.get('window');
+}
+
+function solscanAddr(addr) {
+ return ctx.network === 'devnet'
+ ? `https://solscan.io/account/${addr}?cluster=devnet`
+ : `https://solscan.io/account/${addr}`;
+}
+
+// --- Score gauge -------------------------------------------------------------
+function gaugeSvg(score) {
+ const r = 34, c = 2 * Math.PI * r;
+ const pct = Math.max(0, Math.min(100, score)) / 100;
+ const dash = (c * pct).toFixed(1);
+ const hue = Math.round(pct * 130); // red→green
+ return `<svg width="92" height="92" viewBox="0 0 92 92" role="img" aria-label="Trader score ${score}">
+ <circle cx="46" cy="46" r="${r}" fill="none" stroke="var(--surface-3)" stroke-width="7"/>
+ <circle cx="46" cy="46" r="${r}" fill="none" stroke="hsl(${hue} 70% 55%)" stroke-width="7"
+ stroke-linecap="round" stroke-dasharray="${dash} ${c.toFixed(1)}"
+ transform="rotate(-90 46 46)"/>
+ </svg>`;
+}
+
+// --- Equity curve (pure) -----------------------------------------------------
+function equityCurveSvg(closed) {
+ if (!closed || closed.length < 2) {
+ return '<div class="tp-curve-empty">Not enough closed trades to chart an equity curve yet.</div>';
+ }
+ // closed comes newest-first; chart oldest→newest cumulative realized SOL.
+ const asc = [...closed].reverse();
+ let cum = 0;
+ const pts = asc.map((t) => { cum += Number(t.pnl_sol) || 0; return cum; });
+ const series = [0, ...pts]; // start at 0
+ const min = Math.min(...series), max = Math.max(...series);
+ const range = (max - min) || 1;
+ const W = 1000, H = 180, pad = 8;
+ const x = (i) => pad + (i / (series.length - 1)) * (W - pad * 2);
+ const y = (v) => H - pad - ((v - min) / range) * (H - pad * 2);
+ const path = series.map((v, i) => `${i ? 'L' : 'M'}${x(i).toFixed(1)} ${y(v).toFixed(1)}`).join(' ');
+ const last = series[series.length - 1];
+ const stroke = last >= 0 ? 'var(--success)' : 'var(--danger)';
+ const area = `${path} L${x(series.length - 1).toFixed(1)} ${H - pad} L${x(0).toFixed(1)} ${H - pad} Z`;
+ const zeroY = y(0).toFixed(1);
+ return `<svg class="tp-curve" viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" role="img" aria-label="Realized equity curve">
+ <defs><linearGradient id="tpfill" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stop-color="${stroke}" stop-opacity="0.22"/>
+ <stop offset="1" stop-color="${stroke}" stop-opacity="0"/>
+ </linearGradient></defs>
+ <line x1="${pad}" y1="${zeroY}" x2="${W - pad}" y2="${zeroY}" stroke="var(--stroke)" stroke-width="1" stroke-dasharray="3 4"/>
+ <path d="${area}" fill="url(#tpfill)"/>
+ <path d="${path}" fill="none" stroke="${stroke}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>
+ </svg>`;
+}
+
+// --- Metric grid -------------------------------------------------------------
+function metric(label, val, sub = '') {
+ return `<div class="tp-metric">
+ <div class="tp-metric-label">${escapeHtml(label)}</div>
+ <div class="tp-metric-val">${val}</div>
+ ${sub ? `<div class="tp-metric-sub">${sub}</div>` : ''}
+ </div>`;
+}
+
+function metricsGrid(m) {
+ const pnl = `<span class="${pnlClass(m.realized_pnl_sol)}">${fmtSol(m.realized_pnl_sol)}</span>`;
+ const pnlSub = m.realized_pnl_usd != null ? fmtUsd(m.realized_pnl_usd) : '';
+ const pf = m.profit_factor == null ? '∞' : m.profit_factor.toFixed(2);
+ const unreal = m.open_count
+ ? `<span class="${pnlClass(m.unrealized_pnl_sol)}">${fmtSol(m.unrealized_pnl_sol)}</span>` : '<span class="lb-muted">—</span>';
+ return `
+ ${metric('Realized P&L', pnl, pnlSub)}
+ ${metric('Win rate', fmtPct(m.win_rate * 100), `${m.wins}W · ${m.losses}L`)}
+ ${metric('ROI', `<span class="${pnlClass(m.roi_pct)}">${fmtPct(m.roi_pct, { sign: true })}</span>`, `on ${fmtSol(m.invested_sol, { sign: false })} traded`)}
+ ${metric('Profit factor', pf, 'gross win ÷ gross loss')}
+ ${metric('Max drawdown', `<span class="${m.max_drawdown_pct > 0 ? 'lb-neg' : 'lb-muted'}">${m.max_drawdown_pct > 0 ? '−' : ''}${m.max_drawdown_pct.toFixed(1)}%</span>`, fmtSol(m.max_drawdown_sol, { sign: false }))}
+ ${metric('Avg hold', holdTime(m.avg_hold_seconds), `median ${holdTime(m.median_hold_seconds)}`)}
+ ${metric('Coins traded', String(m.unique_coins), `${m.closed_count} closed trades`)}
+ ${metric('Open exposure', m.open_count ? fmtSol(m.open_exposure_sol, { sign: false }) : '<span class="lb-muted">none</span>', m.open_count ? `${m.open_count} open · ${unreal}` : 'flat')}
+ `;
+}
+
+// --- Trade tables ------------------------------------------------------------
+function closedRows(closed) {
+ if (!closed.length) return '<tr><td colspan="6" style="text-align:center;color:var(--ink-faint)">No closed trades in this window.</td></tr>';
+ return closed.map((t) => {
+ const pnl = t.pnl_sol != null ? `<span class="${pnlClass(t.pnl_sol)}">${fmtSol(t.pnl_sol)}</span>` : '—';
+ const pct = t.pnl_pct != null ? `<span class="${pnlClass(t.pnl_pct)}">${fmtPct(t.pnl_pct, { sign: true })}</span>` : '';
+ const held = t.opened_at && t.closed_at
+ ? holdTime((new Date(t.closed_at) - new Date(t.opened_at)) / 1000) : '—';
+ const proof = [
+ t.buy_url ? `<a class="tp-proof-link" href="${escapeHtml(t.buy_url)}" target="_blank" rel="noopener">buy ↗</a>` : '',
+ t.sell_url ? `<a class="tp-proof-link" href="${escapeHtml(t.sell_url)}" target="_blank" rel="noopener">sell ↗</a>` : '',
+ ].filter(Boolean).join(' ');
+ return `<tr>
+ <td><div class="tp-coin"><span class="tp-coin-sym">${escapeHtml(t.symbol || t.name || '—')}</span><span class="tp-coin-mint">${escapeHtml(shortAddr(t.mint, 4, 4))}</span></div></td>
+ <td>${pnl}<div class="tp-metric-sub">${pct}</div></td>
+ <td><span class="tp-reason">${escapeHtml(t.exit_reason || '—')}</span></td>
+ <td>${held}</td>
+ <td>${relTime(t.closed_at)}</td>
+ <td>${proof || '—'}</td>
+ </tr>`;
+ }).join('');
+}
+
+function openRows(open) {
+ if (!open.length) return '<tr><td colspan="5" style="text-align:center;color:var(--ink-faint)">No open positions.</td></tr>';
+ return open.map((o) => {
+ const up = `<span class="${pnlClass(o.unrealized_pct)}">${fmtPct(o.unrealized_pct, { sign: true })}</span>`;
+ return `<tr>
+ <td><div class="tp-coin"><span class="tp-coin-sym">${escapeHtml(o.symbol || o.name || '—')}</span><span class="tp-coin-mint">${escapeHtml(shortAddr(o.mint, 4, 4))}</span></div></td>
+ <td>${fmtSol(o.entry_sol, { sign: false })}</td>
+ <td>${fmtSol(o.current_sol, { sign: false })}</td>
+ <td>${up}</td>
+ <td>${o.buy_url ? `<a class="tp-proof-link" href="${escapeHtml(o.buy_url)}" target="_blank" rel="noopener">buy ↗</a>` : '—'}</td>
+ </tr>`;
+ }).join('');
+}
+
+const SHIELD = '<svg viewBox="0 0 24 24" fill="none"><path d="M12 2l8 3v6c0 5-3.5 8.5-8 11-4.5-2.5-8-6-8-11V5l8-3z" stroke="currentColor" stroke-width="1.5"/><path d="M8.5 12l2.2 2.2 4.8-4.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
+
+// --- Main render -------------------------------------------------------------
+function render(data) {
+ const a = data.agent;
+ const m = data.metrics;
+ const img = a.image || identicon(a.id || a.wallet || a.name || '?');
+ const walletLink = a.wallet
+ ? `<a href="${solscanAddr(a.wallet)}" target="_blank" rel="noopener" title="Agent wallet on Solscan">${escapeHtml(shortAddr(a.wallet, 4, 4))} ↗</a>`
+ : '';
+ document.title = `${a.name || 'Trader'} · track record · three.ws`;
+
+ const winSeg = WINDOWS.map((w) => `<button class="lb-seg-btn ${w === ctx.window ? 'is-active' : ''}" data-window="${w}">${WINDOW_LABEL[w]}</button>`).join('');
+
+ content.innerHTML = `
+ <section class="tp-hero">
+ <div class="tp-avatar-wrap">
+ <img class="tp-avatar" src="${escapeHtml(img)}" alt="" onerror="this.src='${identicon(a.id || '?')}'" />
+ </div>
+ <div class="tp-id">
+ <div class="tp-name">${escapeHtml(a.name || 'Unnamed agent')}${verifiedBadge(m.verified)}</div>
+ <div class="tp-sub">
+ ${walletLink}
+ <span>${m.closed_count} closed trades</span>
+ <span>${m.unique_coins} coins</span>
+ ${m.last_active_at ? `<span>active ${relTime(m.last_active_at)}</span>` : ''}
+ </div>
+ ${a.description ? `<p class="tp-desc">${escapeHtml(a.description)}</p>` : ''}
+ </div>
+ <div class="tp-gauge">
+ ${gaugeSvg(m.score)}
+ <div class="tp-gauge-val" style="margin-top:-58px">${m.score}</div>
+ <div class="tp-gauge-label" style="margin-top:34px">Trader Score</div>
+ </div>
+ </section>
+
+ <div class="tp-actions">
+ <div class="lb-seg" role="tablist" aria-label="Time window" id="tp-window">${winSeg}</div>
+ <div style="display:flex;gap:var(--space-2xs)">
+ <button class="lb-btn" id="tp-share">Share track record</button>
+ <button class="lb-btn lb-btn-primary" id="tp-card">Download PnL card</button>
+ </div>
+ </div>
+
+ <div class="tp-metrics">${metricsGrid(m)}</div>
+
+ <div class="tp-curve-wrap">
+ <div class="tp-curve-head">
+ <span class="tp-curve-title">Realized equity · ${WINDOW_LABEL[ctx.window]}</span>
+ <span class="${pnlClass(m.realized_pnl_sol)}" style="font-variant-numeric:tabular-nums;font-weight:var(--weight-semibold)">${fmtSol(m.realized_pnl_sol)}</span>
+ </div>
+ ${equityCurveSvg(data.closed)}
+ </div>
+
+ <div class="tp-tabs" role="tablist">
+ <button class="tp-tab is-active" data-tab="record" role="tab">Track record<span class="tp-tab-count">${data.closed.length}</span></button>
+ <button class="tp-tab" data-tab="open" role="tab">Open<span class="tp-tab-count">${data.open.length}</span></button>
+ <button class="tp-tab" data-tab="proof" role="tab">Proof</button>
+ </div>
+
+ <div class="tp-panel is-active" data-panel="record">
+ <table class="tp-table"><thead><tr>
+ <th>Coin</th><th>P&L</th><th>Exit</th><th>Held</th><th>When</th><th>Proof</th>
+ </tr></thead><tbody>${closedRows(data.closed)}</tbody></table>
+ </div>
+
+ <div class="tp-panel" data-panel="open">
+ <table class="tp-table"><thead><tr>
+ <th>Coin</th><th>Entry</th><th>Now</th><th>Unrealized</th><th>Proof</th>
+ </tr></thead><tbody>${openRows(data.open)}</tbody></table>
+ </div>
+
+ <div class="tp-panel" data-panel="proof">
+ <div class="tp-proof-note">
+ ${SHIELD}
+ <p><strong>This track record is verifiable, not trusted.</strong> Every closed trade above links to its
+ on-chain buy and sell transaction on Solscan — the numbers are computed from those, nothing else. The
+ headline score is additionally committed on-chain daily as a signed attestation against this trader's
+ wallet${a.wallet ? ` (<a class="tp-proof-link" href="${solscanAddr(a.wallet)}" target="_blank" rel="noopener">${escapeHtml(shortAddr(a.wallet))} ↗</a>)` : ''}, so it can't be quietly edited after the fact.</p>
+ </div>
+ <table class="tp-table"><thead><tr>
+ <th>Coin</th><th>P&L</th><th>Exit</th><th>Held</th><th>When</th><th>On-chain</th>
+ </tr></thead><tbody>${closedRows(data.closed)}</tbody></table>
+ </div>
+
+ <section class="tp-copy">
+ <div>
+ <h2>Copy this trader <span class="tp-soon">Soon</span></h2>
+ <p>One-tap copy-trading — mirror ${escapeHtml(a.name || 'this agent')}'s entries to your own wallet, non-custodially, while they earn only when you profit — is the next release. Watch them trade live in the Arena meanwhile.</p>
+ </div>
+ <div class="tp-copy-actions">
+ <a class="lb-btn lb-btn-primary" href="/play/arena">Watch live in the Arena →</a>
+ <a class="lb-btn" href="/leaderboard">Back to leaderboard</a>
+ </div>
+ </section>
+ `;
+
+ wireTabs();
+ wireWindow();
+ wireShare();
+ root.setAttribute('aria-busy', 'false');
+}
+
+// --- Interactions ------------------------------------------------------------
+function wireTabs() {
+ const tabs = content.querySelectorAll('.tp-tab');
+ tabs.forEach((tab) => tab.addEventListener('click', () => {
+ tabs.forEach((t) => t.classList.toggle('is-active', t === tab));
+ content.querySelectorAll('.tp-panel').forEach((p) => {
+ p.classList.toggle('is-active', p.dataset.panel === tab.dataset.tab);
+ });
+ }));
+}
+
+function wireWindow() {
+ const seg = content.querySelector('#tp-window');
+ seg.addEventListener('click', (e) => {
+ const btn = e.target.closest('.lb-seg-btn');
+ if (!btn || btn.dataset.window === ctx.window) return;
+ ctx.window = btn.dataset.window;
+ const url = new URL(location.href);
+ url.searchParams.set('window', ctx.window);
+ history.replaceState(null, '', url);
+ load();
+ });
+}
+
+function shareUrl() {
+ const base = `${location.origin}/trader/${encodeURIComponent(ctx.agentId)}`;
+ return ctx.refCode ? `${base}?ref=${encodeURIComponent(ctx.refCode)}` : base;
+}
+
+function toast(msg) {
+ let el = document.querySelector('.tp-toast');
+ if (!el) { el = document.createElement('div'); el.className = 'tp-toast'; document.body.appendChild(el); }
+ el.textContent = msg;
+ requestAnimationFrame(() => el.classList.add('is-shown'));
+ setTimeout(() => el.classList.remove('is-shown'), 2200);
+}
+
+function wireShare() {
+ content.querySelector('#tp-share')?.addEventListener('click', async () => {
+ const url = shareUrl();
+ const title = `${ctx.data.agent.name || 'Trader'} · ${fmtSol(ctx.data.metrics.realized_pnl_sol)} on three.ws`;
+ if (navigator.share) {
+ try { await navigator.share({ title, url }); return; } catch { /* fall through to copy */ }
+ }
+ try { await navigator.clipboard.writeText(url); toast('Track-record link copied'); }
+ catch { toast(url); }
+ });
+ content.querySelector('#tp-card')?.addEventListener('click', () => downloadCard());
+}
+
+// --- Shareable PnL card (PNG) ------------------------------------------------
+function downloadCard() {
+ const a = ctx.data.agent, m = ctx.data.metrics;
+ const scale = 2;
+ const W = 1200, H = 630;
+ const canvas = document.createElement('canvas');
+ canvas.width = W * scale; canvas.height = H * scale;
+ const c = canvas.getContext('2d');
+ c.scale(scale, scale);
+
+ // Background
+ const grad = c.createLinearGradient(0, 0, W, H);
+ grad.addColorStop(0, '#0a0a0c'); grad.addColorStop(1, '#15151b');
+ c.fillStyle = grad; c.fillRect(0, 0, W, H);
+ c.strokeStyle = 'rgba(255,255,255,0.08)'; c.lineWidth = 2; c.strokeRect(20, 20, W - 40, H - 40);
+
+ const pos = m.realized_pnl_sol >= 0;
+ const accent = pos ? '#4ade80' : '#f87171';
+
+ // Kicker
+ c.fillStyle = 'rgba(255,255,255,0.55)';
+ c.font = '600 22px Inter, system-ui, sans-serif';
+ c.fillText('PROVABLE TRACK RECORD · three.ws', 64, 96);
+
+ // Name
+ c.fillStyle = '#fff';
+ c.font = '700 64px "Space Grotesk", Inter, sans-serif';
+ c.fillText((a.name || 'Trader').slice(0, 22), 64, 176);
+ if (m.verified) {
+ c.fillStyle = accent;
+ c.font = '600 22px Inter, sans-serif';
+ c.fillText('✓ VERIFIED', 64, 212);
+ }
+
+ // Big PnL
+ c.fillStyle = accent;
+ c.font = '700 132px "Space Grotesk", Inter, sans-serif';
+ c.fillText(fmtSol(m.realized_pnl_sol), 60, 360);
+ c.fillStyle = 'rgba(255,255,255,0.6)';
+ c.font = '500 28px Inter, sans-serif';
+ c.fillText(`${WINDOW_LABEL[ctx.window]} realized P&L${m.realized_pnl_usd != null ? ' · ' + fmtUsd(m.realized_pnl_usd) : ''}`, 64, 408);
+
+ // Stat strip
+ const stats = [
+ ['SCORE', String(m.score)],
+ ['WIN RATE', fmtPct(m.win_rate * 100)],
+ ['ROI', fmtPct(m.roi_pct, { sign: true })],
+ ['TRADES', String(m.closed_count)],
+ ];
+ const sx = 64, sy = 470, sw = (W - 128) / stats.length;
+ stats.forEach(([label, val], i) => {
+ const x = sx + i * sw;
+ c.fillStyle = 'rgba(255,255,255,0.45)';
+ c.font = '600 20px Inter, sans-serif';
+ c.fillText(label, x, sy);
+ c.fillStyle = '#fff';
+ c.font = '700 42px "Space Grotesk", Inter, sans-serif';
+ c.fillText(val, x, sy + 50);
+ });
+
+ // Footer link
+ c.fillStyle = 'rgba(255,255,255,0.5)';
+ c.font = '500 24px Inter, sans-serif';
+ c.fillText(`three.ws/trader/${shortAddr(ctx.agentId, 6, 4)}`, 64, H - 48);
+
+ canvas.toBlob((blob) => {
+ if (!blob) { toast('Could not render card'); return; }
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = `${(a.name || 'trader').replace(/\s+/g, '-').toLowerCase()}-pnl.png`;
+ link.click();
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
+ toast('PnL card downloaded');
+ }, 'image/png');
+}
+
+// --- Referral code (best-effort) ---------------------------------------------
+async function loadRefCode() {
+ try {
+ const res = await fetch('/api/users/referrals', { credentials: 'include', headers: { accept: 'application/json' } });
+ if (!res.ok) return;
+ const card = await res.json();
+ ctx.refCode = card.referral_code || card.code || card.referralCode || null;
+ } catch { /* signed-out or unavailable — share the bare profile link */ }
+}
+
+// --- Skeleton / states -------------------------------------------------------
+function showSkeleton() {
+ root.setAttribute('aria-busy', 'true');
+ content.innerHTML = `<div class="tp-skel">
+ <div class="tp-sk" style="width:40%;height:28px"></div>
+ <div class="tp-sk" style="width:25%"></div>
+ <div class="tp-sk" style="width:90%;height:120px;margin-top:24px"></div>
+ <div class="tp-sk" style="width:100%;height:180px"></div>
+ </div>`;
+}
+
+function showError(kind) {
+ root.setAttribute('aria-busy', 'false');
+ if (kind === 'not_found') {
+ content.innerHTML = `<div class="tp-empty">
+ <h1>Trader not found</h1>
+ <p>This agent doesn't exist, isn't public, or hasn't traded on this network yet.</p>
+ <a class="lb-btn lb-btn-primary" href="/leaderboard">Browse the leaderboard</a>
+ </div>`;
+ } else {
+ content.innerHTML = `<div class="tp-error">
+ <h1>Couldn't load this trader</h1>
+ <p>The track-record feed didn't respond. This is usually transient.</p>
+ <button class="lb-btn lb-btn-primary" id="tp-retry">Retry</button>
+ </div>`;
+ content.querySelector('#tp-retry')?.addEventListener('click', () => load());
+ }
+}
+
+// --- Fetch -------------------------------------------------------------------
+async function load() {
+ showSkeleton();
+ const qs = new URLSearchParams({ agent_id: ctx.agentId, network: ctx.network, window: ctx.window });
+ try {
+ const res = await fetch(`/api/sniper/trader?${qs}`, { headers: { accept: 'application/json' } });
+ if (res.status === 404) return showError('not_found');
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ ctx.data = await res.json();
+ render(ctx.data);
+ } catch {
+ showError('error');
+ }
+}
+
+// --- Boot --------------------------------------------------------------------
+parseParams();
+if (!ctx.agentId) {
+ showError('not_found');
+} else {
+ loadRefCode();
+ load();
+}
diff --git a/tests/pump-intel-enrich.test.js b/tests/pump-intel-enrich.test.js
new file mode 100644
index 000000000..437cae2fd
--- /dev/null
+++ b/tests/pump-intel-enrich.test.js
@@ -0,0 +1,120 @@
+// Unit tests for the funder-graph enrichment's pure logic — the bubble-map math
+// and the on-chain funder parser. These are the parts that decide "is this coin a
+// coordinated bundle or organic?", so they're worth pinning down exactly. No DB or
+// RPC is touched: connectivityFromFunders is pure, and parseFunderFromTransaction
+// runs against fixture getTransaction payloads shaped like Solana's jsonParsed RPC.
+
+import { describe, it, expect } from 'vitest';
+import {
+ connectivityFromFunders,
+ parseFunderFromTransaction,
+} from '../api/_lib/pump-intel/enrich.js';
+
+const SYSTEM = '11111111111111111111111111111111';
+
+describe('connectivityFromFunders', () => {
+ it('returns null connectivity below the 3-known-funder floor', () => {
+ const r = connectivityFromFunders({ a: 'F1', b: 'F1' });
+ expect(r.connectivity).toBeNull();
+ expect(r.known).toBe(2);
+ });
+
+ it('measures the largest shared-funder cluster as a share of known funders', () => {
+ // 4 of 5 wallets funded by F1 → one 4-wallet cluster, connectivity 0.8.
+ const r = connectivityFromFunders({ a: 'F1', b: 'F1', c: 'F1', d: 'F1', e: 'F2' });
+ expect(r.known).toBe(5);
+ expect(r.largest_cluster).toBe(4);
+ expect(r.connectivity).toBeCloseTo(0.8, 4);
+ expect(r.clusters).toBe(1); // only F1 has >= 2 members
+ });
+
+ it('reads as organic when every funder is distinct', () => {
+ const r = connectivityFromFunders({ a: 'F1', b: 'F2', c: 'F3', d: 'F4' });
+ expect(r.connectivity).toBeCloseTo(0.25, 4); // largest cluster is 1 wallet
+ expect(r.clusters).toBe(0);
+ });
+
+ it('ignores wallets with no known funder', () => {
+ const r = connectivityFromFunders({ a: 'F1', b: 'F1', c: 'F1', d: null, e: undefined });
+ expect(r.known).toBe(3);
+ expect(r.connectivity).toBeCloseTo(1, 4);
+ });
+});
+
+describe('parseFunderFromTransaction', () => {
+ const ADDR = 'Wa11etDestination1111111111111111111111111';
+ const FUNDER = 'FundeR111111111111111111111111111111111111';
+
+ it('resolves the source of an explicit system transfer into the wallet', () => {
+ const tx = {
+ transaction: { message: {
+ accountKeys: [{ pubkey: FUNDER, signer: true }, { pubkey: ADDR, signer: false }],
+ instructions: [
+ { program: 'system', parsed: { type: 'transfer', info: { source: FUNDER, destination: ADDR, lamports: 30_000_000 } } },
+ ],
+ } },
+ meta: { preBalances: [1e9, 0], postBalances: [1e9 - 3e7, 3e7], innerInstructions: [] },
+ };
+ const out = parseFunderFromTransaction(tx, ADDR);
+ expect(out?.funder).toBe(FUNDER);
+ expect(out?.lamports).toBe(30_000_000);
+ });
+
+ it('finds the funder inside inner instructions (nested/CEX routing)', () => {
+ const tx = {
+ transaction: { message: {
+ accountKeys: [{ pubkey: 'SomeProgramPayer11111111111111111111111111' }, { pubkey: ADDR }],
+ instructions: [{ program: 'spl-associated-token-account', parsed: null }],
+ } },
+ meta: {
+ preBalances: [1e9, 0], postBalances: [1e9, 5e6],
+ innerInstructions: [{ index: 0, instructions: [
+ { program: 'system', parsed: { type: 'transfer', info: { source: FUNDER, destination: ADDR, lamports: 5_000_000 } } },
+ ] }],
+ },
+ };
+ expect(parseFunderFromTransaction(tx, ADDR)?.funder).toBe(FUNDER);
+ });
+
+ it('falls back to the fee payer when the wallet balance rose with no parsed transfer', () => {
+ const tx = {
+ transaction: { message: {
+ accountKeys: [{ pubkey: FUNDER, signer: true }, { pubkey: ADDR }],
+ instructions: [{ program: 'vote', parsed: null }],
+ } },
+ meta: { preBalances: [1e9, 0], postBalances: [1e9 - 1e6, 1e6], innerInstructions: [] },
+ };
+ expect(parseFunderFromTransaction(tx, ADDR)?.funder).toBe(FUNDER);
+ });
+
+ it('never treats the system program or the wallet itself as a funder', () => {
+ const sysTx = {
+ transaction: { message: {
+ accountKeys: [{ pubkey: SYSTEM }, { pubkey: ADDR }],
+ instructions: [{ program: 'system', parsed: { type: 'transfer', info: { source: SYSTEM, destination: ADDR, lamports: 1 } } }],
+ } },
+ meta: { preBalances: [1e9, 0], postBalances: [1e9, 1], innerInstructions: [] },
+ };
+ expect(parseFunderFromTransaction(sysTx, ADDR)).toBeNull();
+
+ const selfTx = {
+ transaction: { message: {
+ accountKeys: [{ pubkey: ADDR, signer: true }],
+ instructions: [{ program: 'system', parsed: { type: 'transfer', info: { source: ADDR, destination: ADDR, lamports: 1 } } }],
+ } },
+ meta: { preBalances: [1e9], postBalances: [1e9], innerInstructions: [] },
+ };
+ expect(parseFunderFromTransaction(selfTx, ADDR)).toBeNull();
+ });
+
+ it('returns null when the wallet only spent (it was the fee payer, balance fell)', () => {
+ const tx = {
+ transaction: { message: {
+ accountKeys: [{ pubkey: ADDR, signer: true }, { pubkey: FUNDER }],
+ instructions: [{ program: 'vote', parsed: null }],
+ } },
+ meta: { preBalances: [1e9, 0], postBalances: [1e9 - 5000, 0], innerInstructions: [] },
+ };
+ expect(parseFunderFromTransaction(tx, ADDR)).toBeNull();
+ });
+});
diff --git a/tests/smart-money.test.js b/tests/smart-money.test.js
new file mode 100644
index 000000000..1b164bcae
--- /dev/null
+++ b/tests/smart-money.test.js
@@ -0,0 +1,134 @@
+import { describe, it, expect } from 'vitest';
+import { attributeCoin, computeReputation, EARLY_WINDOW_SEC } from '../src/pump/wallet-reputation.js';
+import { computeCoinSmartMoney } from '../src/pump/smart-money-score.js';
+
+const SOL = 1_000_000_000;
+
+describe('attributeCoin — per-coin verdict folding', () => {
+ const coinTs = 1000;
+ const w = (over = {}) => ({ buy_lamports: SOL, sell_lamports: 0, first_seen_ts: 1010, is_creator: false, ...over });
+
+ it('credits an early buyer of a graduate as an early win', () => {
+ const d = attributeCoin({ outcome: 'graduated', wallet: w(), coinFirstSeenTs: coinTs });
+ expect(d.coins_traded).toBe(1);
+ expect(d.wins).toBe(1);
+ expect(d.early_entries).toBe(1);
+ expect(d.early_wins).toBe(1);
+ expect(d.duds).toBe(0);
+ });
+
+ it('a late buyer of a graduate wins but is not "early"', () => {
+ const late = w({ first_seen_ts: coinTs + EARLY_WINDOW_SEC + 60 });
+ const d = attributeCoin({ outcome: 'graduated', wallet: late, coinFirstSeenTs: coinTs });
+ expect(d.wins).toBe(1);
+ expect(d.early_entries).toBe(0);
+ expect(d.early_wins).toBe(0);
+ });
+
+ it('a buyer of a dud takes a dud, no win', () => {
+ const d = attributeCoin({ outcome: 'dud', wallet: w(), coinFirstSeenTs: coinTs });
+ expect(d.duds).toBe(1);
+ expect(d.wins).toBe(0);
+ });
+
+ it('flags a dump when sells reach half the buy', () => {
+ const d = attributeCoin({ outcome: 'graduated', wallet: w({ sell_lamports: SOL / 2 }), coinFirstSeenTs: coinTs });
+ expect(d.dumps).toBe(1);
+ });
+
+ it('a non-buyer earns no trading verdict, but creator counters still apply', () => {
+ const d = attributeCoin({ outcome: 'dud', wallet: w({ buy_lamports: 0, is_creator: true }), coinFirstSeenTs: coinTs });
+ expect(d.coins_traded).toBe(0);
+ expect(d.duds).toBe(0);
+ expect(d.creator_count).toBe(1);
+ expect(d.creator_wins).toBe(0);
+ });
+
+ it('credits a creator win when their coin graduates', () => {
+ const d = attributeCoin({ outcome: 'graduated', wallet: w({ is_creator: true }), coinFirstSeenTs: coinTs });
+ expect(d.creator_wins).toBe(1);
+ });
+});
+
+describe('computeReputation — label + score', () => {
+ it('labels a thin record as fresh regardless of a lucky win', () => {
+ const r = computeReputation({ wins: 1, duds: 0, coins_traded: 1, early_entries: 1, early_wins: 1 });
+ expect(r.label).toBe('fresh');
+ expect(r.smart_money_score).toBeLessThan(70); // confidence-gated
+ });
+
+ it('promotes a proven early winner to smart_money', () => {
+ const r = computeReputation({
+ wins: 18, duds: 4, coins_traded: 22, early_entries: 20, early_wins: 16, dumps: 1,
+ });
+ expect(r.win_rate).toBeGreaterThan(75);
+ expect(r.label).toBe('smart_money');
+ expect(r.smart_money_score).toBeGreaterThanOrEqual(70);
+ });
+
+ it('labels a serial rugging creator', () => {
+ const r = computeReputation({ creator_count: 6, creator_wins: 0, coins_traded: 6, wins: 0, duds: 6 });
+ expect(r.label).toBe('rugger');
+ });
+
+ it('labels a heavy dumper', () => {
+ const r = computeReputation({ wins: 6, duds: 6, coins_traded: 12, dumps: 9, early_entries: 8, early_wins: 4 });
+ expect(r.label).toBe('dumper');
+ expect(r.dump_rate).toBeGreaterThanOrEqual(60);
+ });
+
+ it('labels a spray sniper: early into everything, rarely wins', () => {
+ const r = computeReputation({ wins: 2, duds: 18, coins_traded: 20, early_entries: 18, early_wins: 2, dumps: 2 });
+ expect(r.label).toBe('sniper');
+ });
+
+ it('an empty record is unproven with zero score', () => {
+ const r = computeReputation({});
+ expect(r.smart_money_score).toBe(0);
+ expect(r.label).toBe('fresh');
+ });
+});
+
+describe('computeCoinSmartMoney — coin pedigree', () => {
+ const rep = new Map([
+ ['A', { smart_money_score: 90, label: 'smart_money' }],
+ ['B', { smart_money_score: 80, label: 'smart_money' }],
+ ['C', { smart_money_score: 10, label: 'neutral' }],
+ ]);
+
+ it('scores high when proven wallets dominate the buys', () => {
+ const wallets = [
+ { wallet: 'A', buy_lamports: 5 * SOL },
+ { wallet: 'B', buy_lamports: 3 * SOL },
+ { wallet: 'C', buy_lamports: 1 * SOL },
+ ];
+ const r = computeCoinSmartMoney(wallets, rep);
+ expect(r.smart_wallet_count).toBe(2);
+ expect(r.smart_money_score).toBeGreaterThan(70);
+ expect(r.notable[0].wallet).toBe('A');
+ expect(r.notable).toHaveLength(3);
+ });
+
+ it('scores low when only unknown wallets are buying', () => {
+ const wallets = [
+ { wallet: 'X', buy_lamports: 4 * SOL },
+ { wallet: 'Y', buy_lamports: 2 * SOL },
+ ];
+ const r = computeCoinSmartMoney(wallets, rep);
+ expect(r.smart_wallet_count).toBe(0);
+ expect(r.smart_money_score).toBe(0);
+ expect(r.notable).toHaveLength(0);
+ });
+
+ it('ignores the creator and zero-buy rows', () => {
+ const wallets = [
+ { wallet: 'A', buy_lamports: 5 * SOL, is_creator: true },
+ { wallet: 'B', buy_lamports: 0 },
+ { wallet: 'C', buy_lamports: 2 * SOL },
+ ];
+ const r = computeCoinSmartMoney(wallets, rep);
+ // only C counts → low pedigree, A excluded as creator
+ expect(r.total_buy_lamports).toBe(2 * SOL);
+ expect(r.smart_wallet_count).toBe(0);
+ });
+});
diff --git a/vercel.json b/vercel.json
index a2496edba..6793cddea 100644
--- a/vercel.json
+++ b/vercel.json
@@ -522,6 +522,18 @@
"src": "/launches/?",
"dest": "/launches.html"
},
+ {
+ "src": "/leaderboard/?",
+ "dest": "/leaderboard.html"
+ },
+ {
+ "src": "/trader/([^/]+)/?",
+ "dest": "/trader.html"
+ },
+ {
+ "src": "/trader/?",
+ "dest": "/trader.html"
+ },
{
"src": "/admin/bulk-launch/?",
"dest": "/bulk-launch.html"
@@ -3132,6 +3144,10 @@
"path": "/api/cron/flush-usage-events",
"schedule": "* * * * *"
},
+ {
+ "path": "/api/cron/smart-money-rollup",
+ "schedule": "*/5 * * * *"
+ },
{
"path": "/api/cron/quota-check",
"schedule": "0 * * * *"
diff --git a/vite.config.js b/vite.config.js
index 70feffdc9..d6389151d 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -311,6 +311,8 @@ const appConfig = {
'agent-embed': resolve(__dirname, 'pages/agent-embed.html'),
'agent-detail': resolve(__dirname, 'pages/agent-detail.html'),
launches: resolve(__dirname, 'pages/launches.html'),
+ leaderboard: resolve(__dirname, 'pages/leaderboard.html'),
+ trader: resolve(__dirname, 'pages/trader.html'),
'avatar-embed': resolve(__dirname, 'pages/avatar-embed.html'),
'avatar-wallet-chat': resolve(__dirname, 'pages/avatar-wallet-chat.html'),
'agent-exchange': resolve(__dirname, 'pages/agent-exchange.html'),
@@ -331,6 +333,7 @@ const appConfig = {
bounties: resolve(__dirname, 'pages/bounties.html'),
bounty: resolve(__dirname, 'pages/bounty.html'),
'pump-live': resolve(__dirname, 'pages/pump-live.html'),
+ radar: resolve(__dirname, 'pages/radar.html'),
'bulk-launch': resolve(__dirname, 'pages/bulk-launch.html'),
'pump-dashboard': resolve(__dirname, 'pages/pump-dashboard.html'),
autopilot: resolve(__dirname, 'pages/autopilot.html'),
@@ -365,6 +368,7 @@ const appConfig = {
play: resolve(__dirname, 'pages/play.html'),
'play-agent-wallet': resolve(__dirname, 'pages/play/agent-wallet.html'),
'play-arena': resolve(__dirname, 'pages/play/arena.html'),
+ 'smart-money': resolve(__dirname, 'pages/smart-money.html'),
pose: resolve(__dirname, 'pages/pose.html'),
club: resolve(__dirname, 'pages/club.html'),
skills: resolve(__dirname, 'pages/skills.html'),
@@ -660,8 +664,14 @@ support: resolve(__dirname, 'pages/support.html'),
'/bounties/': resolve(root, 'pages/bounties.html'),
'/launches': resolve(root, 'pages/launches.html'),
'/launches/': resolve(root, 'pages/launches.html'),
+ '/leaderboard': resolve(root, 'pages/leaderboard.html'),
+ '/leaderboard/': resolve(root, 'pages/leaderboard.html'),
+ '/trader': resolve(root, 'pages/trader.html'),
+ '/trader/': resolve(root, 'pages/trader.html'),
'/pump-live': resolve(root, 'pages/pump-live.html'),
'/pump-live/': resolve(root, 'pages/pump-live.html'),
+ '/radar': resolve(root, 'pages/radar.html'),
+ '/radar/': resolve(root, 'pages/radar.html'),
'/pump-dashboard': resolve(root, 'pages/pump-dashboard.html'),
'/pump-dashboard/': resolve(root, 'pages/pump-dashboard.html'),
'/autopilot': resolve(root, 'pages/autopilot.html'),
@@ -686,6 +696,8 @@ support: resolve(__dirname, 'pages/support.html'),
'/play/agent-wallet/': resolve(root, 'pages/play/agent-wallet.html'),
'/play/arena': resolve(root, 'pages/play/arena.html'),
'/play/arena/': resolve(root, 'pages/play/arena.html'),
+ '/smart-money': resolve(root, 'pages/smart-money.html'),
+ '/smart-money/': resolve(root, 'pages/smart-money.html'),
'/walk-embed': resolve(root, 'pages/walk-embed.html'),
'/walk-embed/': resolve(root, 'pages/walk-embed.html'),
'/demo': resolve(root, 'pages/demo-economy.html'),