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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix: pump.fun v2/USDC trade correctness + presence brand filtering
nirholas1cfcfa87a202
diff --git a/agent-payments-sdk/FORK_NOTES.md b/agent-payments-sdk/FORK_NOTES.mdnew file mode 100644index 000000000..4d57d32d6--- /dev/null+++ b/agent-payments-sdk/FORK_NOTES.md@@ -0,0 +1,84 @@+# Fork notes — `@pump-fun/agent-payments-sdk` (local 3.1.0)++This directory is a **deliberate three.ws fork** of `@pump-fun/agent-payments-sdk`,+not a stale copy. It is wired as a local npm workspace (listed in the root+`package.json` `workspaces`), so in-repo installs always resolve `^3.1.0` to this+source and the published npm release is never fetched.++## Relationship to upstream++| | Upstream npm `3.0.3` (`latest`) | This fork `3.1.0` |+|---|---|---|+| Author | Pump Fun | nirholas |+| Scope | Solana only | Solana **+ EVM + cross-chain** |+| Ship shape | single bundle (`dist/index.*`) | 7 export subpaths |+| Runtime deps | 3 | 13 |+| Source | not published (`files: ["dist"]`) | full `src/` tree (~14.8k LOC) |++Upstream `3.0.3` exports a single Solana surface: `PumpAgent`, `PumpAgentOffline`,+the PDA helpers, account decoders, and the program constants/types for the agent+payments program (`AgenTMiC2hvxGebTsgmsD4HHBa8WEcqGFf87iwRRxLo7`). The published+package is restricted/private and ships only `dist`; there is no public upstream+source repo to diff against, so the Solana core here was **reverse-engineered**+from the published bundle (see `README.md`).++> Note: npm `latest` tops out at `3.0.3`. There is **no published `3.1.0`** — the+> `3.1.0` version number is ours and signals "upstream Solana core + three.ws+> extensions." This is intentional; do not "fix" the `^3.1.0` pin as if it were+> a broken/missing version.++## What we add on top of the upstream Solana core++Everything below is **net-new in this fork** and has no equivalent in upstream+`3.0.3`. All of it is consumed elsewhere in the repo (see "Consumers"):++- **EVM** (`./evm`) — `EvmAgent`, `EvmAgentOffline`, ABI, addresses, on-chain+ events, invoice/quote/transaction builders, validation.+- **x402** — HTTP 402 payment protocol on both chains:+ - `./x402` (EVM): client + facilitator.+ - `./solana/x402`: client, facilitator, header codecs, types.+- **a2a** (`./a2a`) — agent-to-agent payment helpers.+- **Cross-chain** — `CrossChainPaymentClient` tying the Solana and EVM agents+ together behind one client.+- **solana-agent-kit** (`./solana/solana-agent-kit`) — action adapters for the+ solana-agent-kit runtime.+- **legacy-agent-payments** (`./solana/legacy-agent-payments`) — the prior+ program variant, kept (with tests) for back-compat.+- **Event subscriptions** — `events.ts` / `pump-events.ts` WebSocket decoding and+ live subscriptions over the Solana core.++## Why we keep it as a fork (not "track upstream")++Switching the dependency to the published `^3.0.3` would drop every extension+above — EVM, x402, a2a, cross-chain, solana-agent-kit, legacy — all of which are+imported by `api/` routes and skills today. There is no upstream artifact that+provides them, so "tracking upstream" is not a drop-in; it would be a feature+regression. The fork is the right call.++## Keeping the Solana core in sync with upstream++Because upstream ships no source, sync is a manual, periodic check of the+**Solana core only** (PumpAgent / PDAs / decoders / program constants):++```bash+# Is there a release newer than what we forked from?+npm view @pump-fun/agent-payments-sdk dist-tags version++# Pull the published bundle and diff its public surface against ours.+cd "$(mktemp -d)" && npm pack @pump-fun/agent-payments-sdk@latest \+ && tar xzf *.tgz && grep -E '^export' package/dist/index.d.ts+```++If upstream changes the program ID, PDA seeds, IDL, or account layouts, port those+into `src/solana/` (and `src/solana/idl/`) and re-run `npm run build`. Leave the+extensions untouched. Bump our local version (e.g. `3.1.1`) when we port a sync.++## Consumers (repo-wide, excluding the fork itself)++`api/pump/[action].js`, `api/_lib/pump.js`, `api/_lib/pump-swap-ix.js`,+`api/agents/payments/[action].js`, `api/agents/pumpfun/[action].js`,+`api/cron/[name].js`, `scripts/buyback-devnet-smoke.mjs`,+`pump-fun-skills/create-coin/`, `pump-fun-skills/tokenized-agents/`,+`solana-agent-sdk/`, plus `src/agent-skills-*.js`. All resolve via the workspace+symlink; `npm run build` here regenerates `dist/` (the root `postinstall`+rebuilds it on demand via `scripts/build-cache.mjs`).diff --git a/api/_lib/pump-swap-ix.js b/api/_lib/pump-swap-ix.jsindex 8e82b9ef1..c33bdb386 100644--- a/api/_lib/pump-swap-ix.js+++ b/api/_lib/pump-swap-ix.js@@ -50,9 +50,13 @@ const BUY_EXACT_QUOTE_IN_V2_DISCRIMINATOR = Buffer.from([194, 171, 28, 70, 104, 77, 91, 47,]);-// Static buyback-fee-recipient pool. Mirrors-// `BUYBACK_FEE_RECIPIENTS` in agent-payments-sdk/src/solana/constants.ts-// (not re-exported from the SDK index, so duplicated here verbatim).+// Static buyback-fee-recipient pool used as a fallback only. The bonding-curve+// program validates `buyback_fee_recipient` against the live on-chain Global+// config (`global.buybackFeeRecipients`), which is the authoritative source —+// see `pickBuybackFeeRecipient`. This list mirrors `BUYBACK_FEE_RECIPIENTS` in+// agent-payments-sdk/src/solana/constants.ts (not re-exported from the SDK+// index) and docs/pumpfun-program/docs/FEE_RECIPIENTS.md, and is only consulted+// when an older Global account layout omits the field.const BUYBACK_FEE_RECIPIENTS = ['5YxQFdt3Tr9zJLvkFccqXVUwhdTWJQc1fFg2YPbxvxeD','9M4giFFMxmFGXtc3feFzRai56WbBqehoSeRE5GK7gf7',@@ -97,8 +101,16 @@ function pickFeeRecipient(global, mayhemMode) {return pickRandom(pool);}-function pickBuybackFeeRecipient() {- return pickRandom(BUYBACK_FEE_RECIPIENTS);+function pickBuybackFeeRecipient(global) {+ // Prefer the live on-chain list from the decoded Global — the program checks+ // `buyback_fee_recipient` against it, so a rotated/extended set must come from+ // chain, not a vendored constant. Fall back to the static list only when an+ // older Global layout omits `buybackFeeRecipients`.+ const pool =+ global && Array.isArray(global.buybackFeeRecipients) && global.buybackFeeRecipients.length+ ? global.buybackFeeRecipients+ : BUYBACK_FEE_RECIPIENTS;+ return pickRandom(pool);}/**@@ -236,7 +248,7 @@ export async function buildPumpSwapInnerIx({const mayhemMode = bondingCurve.isMayhemMode ?? false;const feeRecipient = pickFeeRecipient(global, mayhemMode);- const buybackFeeRecipient = pickBuybackFeeRecipient();+ const buybackFeeRecipient = pickBuybackFeeRecipient(global);const creatorVault = creatorVaultPda(bondingCurve.creator);const userVolAcc = userVolumeAccumulatorPda(burnAuthority);diff --git a/api/pump/[action].js b/api/pump/[action].jsindex dea0e4589..83c7204c1 100644--- a/api/pump/[action].js+++ b/api/pump/[action].js@@ -270,6 +270,10 @@ async function handleBuyPrep(req, res) {if (!quoteMintPk) quoteMintPk = solanaPubkey(WSOL_MINT);const isUsdcQuote = !isLegacyQuoteMint(quoteMintPk);+ // On-chain SOL curves store quoteMint as PublicKey.default (all-zeros).+ // Surface wrapped SOL in the API response instead of the zero pubkey so+ // clients see a real, usable mint for every coin type.+ const quoteMintDisplay = isUsdcQuote ? quoteMintPk.toString() : WSOL_MINT;if (buyState && buyState.bondingCurve && !buyState.bondingCurve.complete) {const global = await sdk.fetchGlobal();@@ -297,7 +301,7 @@ async function handleBuyPrep(req, res) {route: 'bonding_curve',mint: body.mint,network: body.network,- quote_mint: quoteMintPk.toString(),+ quote_mint: quoteMintDisplay,usdc_in: body.usdc_amount,slippage_bps: body.slippage_bps,tx_base64,@@ -326,7 +330,7 @@ async function handleBuyPrep(req, res) {route: 'bonding_curve',mint: body.mint,network: body.network,- quote_mint: quoteMintPk.toString(),+ quote_mint: quoteMintDisplay,sol_in: body.sol,slippage_bps: body.slippage_bps,tx_base64,@@ -357,7 +361,7 @@ async function handleBuyPrep(req, res) {pool: amm.poolKey.toString(),mint: body.mint,network: body.network,- quote_mint: quoteMintPk.toString(),+ quote_mint: quoteMintDisplay,...(isUsdcQuote ? { usdc_in: body.usdc_amount } : { sol_in: body.sol }),slippage_bps: body.slippage_bps,tx_base64,@@ -374,15 +378,24 @@ async function handleBuyPrep(req, res) {// ── buy-confirm ────────────────────────────────────────────────────────────-const buyConfirmSchema = z.object({- mint: z.string().min(32).max(44),- network: z.enum(['mainnet', 'devnet']).default('mainnet'),- tx_signature: z.string().min(80).max(100),- wallet_address: z.string().min(32).max(44),- sol: z.number().positive().max(50),- route: z.enum(['bonding_curve', 'amm']),- slippage_bps: z.number().int().min(0).max(5000).optional(),-});+const buyConfirmSchema = z+ .object({+ mint: z.string().min(32).max(44),+ network: z.enum(['mainnet', 'devnet']).default('mainnet'),+ tx_signature: z.string().min(80).max(100),+ wallet_address: z.string().min(32).max(44),+ // SOL-paired coins record `sol`; USDC-paired (v2) coins record `usdc_amount`.+ // Both optional so either quote asset can confirm; the tx itself is the+ // source of truth (verified on-chain below), these only label the trade row.+ sol: z.number().nonnegative().max(50).optional(),+ usdc_amount: z.number().nonnegative().max(1_000_000).optional(),+ route: z.enum(['bonding_curve', 'amm']),+ slippage_bps: z.number().int().min(0).max(5000).optional(),+ })+ .refine((v) => (v.sol ?? 0) > 0 || (v.usdc_amount ?? 0) > 0, {+ message: 'sol or usdc_amount required',+ path: ['sol'],+ });async function handleBuyConfirm(req, res) {if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;@@ -414,13 +427,16 @@ async function handleBuyConfirm(req, res) {return error(res, 422, 'wallet_not_in_tx', 'wallet not in tx');if (mintId) {- const lamports = BigInt(Math.floor(body.sol * 1_000_000_000));+ // `sol_amount` is a lamports column — only set for SOL-paired buys. USDC+ // buys leave it null (no quote-amount column yet; see AUDIT follow-ups).+ const lamports =+ body.sol && body.sol > 0 ? BigInt(Math.floor(body.sol * 1_000_000_000)) : null;await sql`insert into pump_agent_trades(mint_id, user_id, wallet, direction, route, sol_amount, slippage_bps, tx_signature, network)values(${mintId}, ${user.id}, ${body.wallet_address}, 'buy', ${body.route},- ${lamports.toString()}, ${body.slippage_bps ?? null}, ${body.tx_signature}, ${body.network})+ ${lamports != null ? lamports.toString() : null}, ${body.slippage_bps ?? null}, ${body.tx_signature}, ${body.network})on conflict (tx_signature, network) do nothing`;}@@ -433,7 +449,8 @@ async function handleBuyConfirm(req, res) {ts: Date.now(),actor: shortAddr(body.wallet_address),mint: body.mint,- sol: body.sol,+ ...(body.sol && body.sol > 0 ? { sol: body.sol } : {}),+ ...(body.usdc_amount && body.usdc_amount > 0 ? { usdc: body.usdc_amount } : {}),network: body.network,}).catch(() => {});@@ -500,6 +517,8 @@ async function handleSellPrep(req, res) {if (!quoteMintPk) quoteMintPk = solanaPubkey(WSOL_MINT);const isUsdcQuote = !isLegacyQuoteMint(quoteMintPk);+ // SOL curves store quoteMint as PublicKey.default — surface wrapped SOL.+ const quoteMintDisplay = isUsdcQuote ? quoteMintPk.toString() : WSOL_MINT;if (sellState && sellState.bondingCurve && !sellState.bondingCurve.complete) {const global = await sdk.fetchGlobal();@@ -537,7 +556,7 @@ async function handleSellPrep(req, res) {route: 'bonding_curve',mint: body.mint,network: body.network,- quote_mint: quoteMintPk.toString(),+ quote_mint: quoteMintDisplay,tokens_in: body.tokens,slippage_bps: body.slippage_bps,tx_base64,@@ -560,7 +579,7 @@ async function handleSellPrep(req, res) {pool: amm.poolKey.toString(),mint: body.mint,network: body.network,- quote_mint: quoteMintPk.toString(),+ quote_mint: quoteMintDisplay,tokens_in: body.tokens,slippage_bps: body.slippage_bps,tx_base64,@@ -798,8 +817,12 @@ async function buildLaunchInstructions({const pumpSdk = await import('@pump-fun/pump-sdk');if (hasBuy) {const quoteAmount = new BN(Math.round(usdcBuyIn * 1_000_000));+ // Pass `quoteMint` so the SDK seeds a fresh curve from+ // `initial_virtual_quote_reserves` (USDC) rather than the SOL reserves —+ // otherwise the base-token estimate is priced against the wrong pool and+ // the create+buy can over/under-spend or revert on max_quote_cost.const tokenAmount = pumpSdk.getBuyTokenAmountFromSolAmount({- global, feeConfig: null, mintSupply: null, bondingCurve: null, amount: quoteAmount,+ global, feeConfig: null, mintSupply: null, bondingCurve: null, amount: quoteAmount, quoteMint,});const ixs = await sdk.createV2AndBuyV2Instructions({global, mint, name, symbol, uri,@@ -2076,7 +2099,8 @@ async function handleQuote(req, res) {mint: mintStr,network,graduated: false,- quote_mint: quoteMintPk.toString(),+ // SOL curves store quoteMint as PublicKey.default — surface wSOL.+ quote_mint: isUsdcQuote ? quoteMintPk.toString() : WSOL_MINT,bonding_curve: {real_quote_reserves: curve.realQuoteReserves?.toString?.() ?? curve.realSolReserves?.toString?.() ?? null,real_token_reserves: curve.realTokenReserves?.toString?.() ?? null,diff --git a/public/features.json b/public/features.jsonindex 08263703e..03ae324a8 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-08T04:05:22.926Z",+ "generated_at": "2026-06-08T04:53:56.117Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/scripts/three-ws-presence.mjs b/scripts/three-ws-presence.mjsindex bf27cbff0..fea4d930b 100644--- a/scripts/three-ws-presence.mjs+++ b/scripts/three-ws-presence.mjs@@ -37,7 +37,17 @@ const ENV_PATH = path.join(ROOT, '.env');const SITE = 'three.ws';const HANDLE = 'trythreews';const CONTRACT = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';-const DEFAULT_QUERIES = [`"${SITE}"`, HANDLE, `"3D AI agent" ${SITE}`, CONTRACT];+// The brand filter (keepBrand) cleans junk downstream, so queries can be broad enough+// to surface the site + press without an exact-token match (quoting "three.ws" is too+// strict for a .ws domain and hides the homepage). The handle stays quoted because+// unquoted Google reads "trythreews" as "try three ws" and floods music/gov results.+const DEFAULT_QUERIES = [+ SITE,+ `"${HANDLE}"`,+ `${SITE} 3D AI agent Solana`,+ `${SITE} $THREE token`,+ CONTRACT,+];const NPM_PACKAGES = ['three.ws', '@three-ws/avatar-agent'];const GITHUB_REPO = 'nirholas/three.ws';const REQUEST_TIMEOUT_MS = 20_000;@@ -120,6 +130,14 @@ function hostOf(url) {}}+// Web-search engines fuzzy-match the brand into unrelated tokens (try, three, ws),+// so keep only SERP hits that actually name three.ws, the $three coin, the contract,+// or the product category. Deliberately does NOT match bare "three" (catches songs).+const BRAND = /three\.ws|trythreews|\$three\b|3d\s*ai\s*agent|3d\s*agent|FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump/i;+function keepBrand(h) {+ return BRAND.test(`${h.url} ${h.title} ${h.snippet}`);+}+function hit({ url, title, snippet, date, source }) {return {url: canonicalUrl(url),@@ -355,7 +373,7 @@ async function providerSerper(queries) {const body = await getJson('https://google.serper.dev/search', {method: 'POST',headers: { 'x-api-key': key, 'content-type': 'application/json' },- body: JSON.stringify({ q, num: 20 }),+ body: JSON.stringify({ q, num: 30 }),});for (const r of body.organic || [])hits.push(hit({ url: r.link, title: r.title, snippet: r.snippet, date: r.date, source: 'serper' }));@@ -365,7 +383,7 @@ async function providerSerper(queries) {if (process.env.DEBUG) console.error(` serper "${q}": ${err.message}`);}}- return { name: 'serper', ran: true, hits };+ return { name: 'serper', ran: true, hits: hits.filter(keepBrand) };}async function providerExa(queries) {@@ -387,7 +405,7 @@ async function providerExa(queries) {if (process.env.DEBUG) console.error(` exa "${q}": ${err.message}`);}}- return { name: 'exa', ran: true, hits };+ return { name: 'exa', ran: true, hits: hits.filter(keepBrand) };}async function providerBrave(queries) {@@ -408,7 +426,7 @@ async function providerBrave(queries) {if (process.env.DEBUG) console.error(` brave "${q}": ${err.message}`);}}- return { name: 'brave', ran: true, hits };+ return { name: 'brave', ran: true, hits: hits.filter(keepBrand) };}async function providerTavily(queries) {@@ -428,7 +446,7 @@ async function providerTavily(queries) {if (process.env.DEBUG) console.error(` tavily "${q}": ${err.message}`);}}- return { name: 'tavily', ran: true, hits };+ return { name: 'tavily', ran: true, hits: hits.filter(keepBrand) };}async function providerSerpApi(queries) {@@ -447,7 +465,7 @@ async function providerSerpApi(queries) {if (process.env.DEBUG) console.error(` serpapi "${q}": ${err.message}`);}}- return { name: 'serpapi', ran: true, hits };+ return { name: 'serpapi', ran: true, hits: hits.filter(keepBrand) };}// ── Dedupe + grouping ─────────────────────────────────────────────────────────diff --git a/src/agent-skills-pumpfun.js b/src/agent-skills-pumpfun.jsindex d5569327b..21369a6ae 100644--- a/src/agent-skills-pumpfun.js+++ b/src/agent-skills-pumpfun.js@@ -390,7 +390,9 @@ export function registerPumpFunSkills(skills) {mint: args.mint,network,wallet_address: pk.toBase58(),- sol: solAmount ?? 0,+ // Record whichever quote asset funded the buy. USDC-paired v2+ // coins have no `sol`, so sending `sol: 0` would 400 at confirm.+ ...(usdcAmount != null ? { usdc_amount: usdcAmount } : { sol: solAmount }),slippage_bps: slippageBps,route: prep.route,}),diff --git a/tasks/week-2026-06-08/A1-pump-curve-404-storm.md b/tasks/week-2026-06-08/A1-pump-curve-404-storm.mdnew file mode 100644index 000000000..cb541c1ca--- /dev/null+++ b/tasks/week-2026-06-08/A1-pump-curve-404-storm.md@@ -0,0 +1,108 @@+# A1 — Stop the `/api/pump/curve` 404 + Solana-RPC storm++**Track:** A — production fire · **Priority:** P0 · **Effort:** 2–3h · **Depends on:** none++## Context (evidence)++In the last 24h of production logs (`docs/3dagent-log-export-2026-06-07T03-58-54.json`):++- **1,716 × HTTP 404** on `GET /api/pump/curve` — **1,712 of them for the exact same mint**:+ `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` (this is **USDC**, which has no pump.fun bonding+ curve and never will).+- This single endpoint is the platform's **heaviest function** (567 MB / 4096 MB per call).+- Each call fires **3 Solana RPC reads that 429** — `[sdk-bridge] getBondingCurveState/getGraduationProgress/getTokenPrice failed: Account does not exist or has no data` — which together are the bulk of the 1,408 `level:warning` lines in the export.++### Root cause (already investigated — do not re-investigate, verify)++The polling widget `src/widgets/bonding-curve.js` (`poll()` at lines 495–540) **already self-terminates+on a 404** (`stopPolling()` at line 514). So this is **not** one runaway poller. It is **~850 fresh+mounts/day of a bonding-curve widget that is misconfigured with the USDC mint**, each firing ~2+curve calls before stopping. The comment at line 507 even documents the prior incident:+"exactly what turned a misconfigured demo into a 404 storm." The stop-on-404 patch treated the+symptom; the **USDC misconfiguration that re-triggers on every mount still exists**.++## What to do++Two layers. **Layer 1 is the robust, caller-agnostic fix and is mandatory. Layer 2 removes the+trigger.**++### Layer 1 — Server-side short-circuit (mandatory)++In the curve handler — `api/pump/[action].js`, the `handleCurve` function (the branch that serves+`/api/pump/curve`) — return early for any mint that **cannot** have a pump.fun bonding curve,+**before** issuing any Solana RPC call:++- A pump.fun mint address ends in the literal suffix `pump`. Any mint that does **not** end in+ `pump` is not a pump token.+- Additionally short-circuit a small known-non-curve set: USDC+ (`EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`), wrapped SOL+ (`So11111111111111111111111111111111111111112`), USDC-devnet+ (whatever `SOLANA_USDC_MINT_DEVNET` resolves to in `api/_lib/`), and USDT+ (`Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB`).+- For those, respond **without touching RPC**. Return `404` with a clear JSON body+ (e.g. `{ error: 'not_a_pump_mint', message: 'mint has no pump.fun bonding curve' }`) so the+ client's existing stop-on-404 path fires. Keep the response shape consistent with the current+ 404 the handler already returns.+- Add a short negative-cache header (e.g. `Cache-Control: public, s-maxage=300`) on this+ short-circuit response so repeated probes from scanners are served from the CDN edge, not the+ function.++This caps the blast radius regardless of which client misconfigures: no 567 MB cold start, no+RPC 429s, no warning spam.++> Do **not** define the non-pump suffix check as the only gate if the codebase already has a+> canonical "is this a pump mint" helper — search `api/_lib/` (e.g. `pump.js`) first and reuse it.+> If none exists, add a tiny `isPumpMint(mint)` helper next to the handler and use it.++### Layer 2 — Fix the USDC-misconfigured mount (remove the trigger)++Find the client that mounts a bonding-curve widget with the USDC mint and correct it.++- The only direct callers of `/api/pump/curve` are `src/widgets/bonding-curve.js` (the poller) and+ `src/communities.js` (one-shot fetch). Start there.+- Trace what `mint` value is passed in. The widget is mounted via `mountBondingCurve(...)` and via+ the generic `<three-ws-widget type="bonding-curve" mint="…">` custom element (registered in+ `src/widgets/kol-trades.js`, dispatched from `src/app.js`). Check `src/widget-types.js` for a+ default mint.+- The correct $THREE mint is `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`. If a curve widget is+ meant to show $THREE but is wired to USDC, fix the wiring. If a widget is being mounted for a+ settlement token (USDC) where a bonding curve makes no sense, **don't mount the curve widget+ there at all** — guard the mount with the same non-pump-mint check.++If, after tracing, the USDC mount turns out to come from an external embed you don't control,+Layer 1 still fully resolves the production impact — document that finding in your commit message+and the negative-cache header becomes the durable mitigation.++## Acceptance criteria++- [ ] `GET /api/pump/curve?mint=<USDC>` returns its 404 **without any Solana RPC call** (no+ `[sdk-bridge] … failed` warnings emitted for that request).+- [ ] `GET /api/pump/curve?mint=<a real pump mint ending in "pump">` still returns live curve data+ exactly as before (no regression).+- [ ] The short-circuit response carries a negative-cache header.+- [ ] The USDC-misconfigured mount is located and corrected, **or** documented as external with+ justification.+- [ ] No new console warnings/errors from your changed code.++## Verification++1. Run the unit tests touching the curve widget: `npx vitest run src/widgets/bonding-curve.test.js`.+2. `npm run dev` (port 3000). In the browser, exercise the page(s) that previously mounted the+ curve widget; confirm the Network tab shows **no** `/api/pump/curve?mint=<USDC>` requests, and+ that a real pump token's curve still renders.+3. Hit the endpoint directly for both a USDC mint and a real pump mint; confirm correct status ++ body + that the USDC one is fast (no RPC latency).++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). No mocks, no fake data. Never hardcode or surface a non-$THREE+mint as a *promoted* token — the mint constants here are coin-agnostic settlement plumbing (the+allowed mechanical exception), used only to *exclude* them from curve lookups.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/A1-pump-curve-404-storm.md`.+3. Commit your code change **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "fix(pump): short-circuit non-pump mints in /api/pump/curve to kill 404+RPC storm; close A1"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/A2-chat-llm-fallback-502.md b/tasks/week-2026-06-08/A2-chat-llm-fallback-502.mdnew file mode 100644index 000000000..d54a6564a--- /dev/null+++ b/tasks/week-2026-06-08/A2-chat-llm-fallback-502.md@@ -0,0 +1,115 @@+# A2 — Fix `/api/chat` 502s by hardening the LLM fallback chain++**Track:** A — production fire · **Priority:** P0 · **Effort:** ~half day · **Depends on:** none+**Human prerequisite:** confirm `ANTHROPIC_API_KEY` is set in Vercel prod (see below) before relying on the code fix.++## Context (evidence)++`/api/chat` is the **single most-used endpoint** in production and is failing **~38% of the time**:+in the last 24h, **102 × 200 vs 66 × 502 + 4 × 500**. The same root cause also 502s+`/api/marketplace/agents/:id/preview` (8×) and `/api/persona/extract` (2×).++Log lines:+- `[chat:openrouter] <code> (final — all <n> route(s) exhausted) Provider returned error`+- `[chat:groq] Rate limit reached for model llama-3.3-70b-versatile`+- `[brain:gpt-4o-mini] native provider failed (You exceeded your current quota...)`+- `[preview:openai] You exceeded your current quota`++### Root cause (already investigated — verify, then fix)++The deployed fallback chain is effectively **`groq (429) → openrouter (flaky free tier) → openai+(quota-dead)`**. The one reliable paid link, **Anthropic**, is (a) likely **unset in prod** and+(b) **structurally starved**: `MAX_FALLBACK_ATTEMPTS = 3` with the primary + a *same-Groq-account*+sibling occupying slots 0–1, so Anthropic (4th in default order) often never gets a slot. When+Groq throttles and OpenRouter 5xxes in the same request, the terminal path returns a **hard 502**+instead of degrading.++Key locations (confirm before editing — line numbers may have drifted):+- `api/_lib/chat-models.js:122` — `DEFAULT_PROVIDER_ORDER = ['groq','openrouter','anthropic','openai']`+- `api/_lib/chat-models.js:150` — `MAX_FALLBACK_ATTEMPTS = 3`+- `api/chat.js:711-735` — `pickProvider` (skips providers whose key is falsy)+- `api/chat.js:747-752` — `FALLBACK_SIBLINGS` (the same-account Groq sibling)+- `api/chat.js:770-801` — `buildFallbackChain`+- `api/chat.js:576-586` — terminal response (the hard 502)+- `api/chat.js:404-423` — existing per-call/total timeout-budget pattern to mirror elsewhere+- `api/brain/chat.js:21, 363-375` — `maxDuration=120`, `streamText` with no abort budget (caused a 30.7s near-timeout)+- `api/persona/extract.js:191-201` and `api/persona/preview.js:137-147` — single-shot, **no failover**+- `api/marketplace/[action].js:804, 806, 845` — preview chain order + failover condition + 502+- `api/_lib/llm.js:78, 115-148` — shared `llmComplete` with ordered failover + per-attempt `AbortSignal.timeout` (currently only adds Anthropic for BYOK)+- `api/_lib/cache.js` — exists, currently unused by chat; use it for the circuit-breaker++## Human prerequisite (do this first)++Confirm `ANTHROPIC_API_KEY` is present in Vercel production env for **both** deploy targets. If+absent, set it (the platform has Anthropic access per CLAUDE.md). Also **remove or top up** the+quota-dead `OPENAI_API_KEY` — as-is it only burns the final attempt before the 502. Note the+outcome in your commit message. The code changes below assume Anthropic is keyed.++## What to do (code)++1. **Reorder the chain to Anthropic-first** in `api/_lib/chat-models.js:122`:+ `DEFAULT_PROVIDER_ORDER = ['anthropic', 'groq', 'openrouter', 'openai']`.+ Mirror the same order in the preview chain at `api/marketplace/[action].js:845`.++2. **Stop wasting a fallback slot on the same Groq account.** Either drop the Groq sibling from+ `FALLBACK_SIBLINGS.groq` (`api/chat.js:749`) so a fallback slot goes to a *different* provider,+ or raise `MAX_FALLBACK_ATTEMPTS` to `4` (`chat-models.js:150`). Prefer dropping the same-account+ sibling — real provider diversity beats a second attempt against the throttled account.++3. **Never return a hard 502 on capacity exhaustion.** In the terminal path+ (`api/chat.js:576-586`), broaden the "rate limited" branch so that **any** all-routes-exhausted+ outcome (429 *or* upstream 5xx / "Provider returned error") returns **`503` with a+ `Retry-After` header**, not a 502. The client already knows how to back off on 503+Retry-After.+ (Optional, nicer: emit a graceful `200` SSE `done` with a short "assistant is briefly at+ capacity, try again" message so the chat UI never shows a hard error.)++4. **Add a provider-health circuit breaker.** When a provider returns 429/5xx, record a short+ cooldown (30–60s) in `api/_lib/cache.js`; have `buildFallbackChain` (`api/chat.js:770-801`) skip+ a provider that is in cooldown. This stops every request from re-hitting Groq while it is+ globally throttling — the mechanism that turns one throttle window into dozens of 502s.++5. **Bound `/api/brain/chat`.** Add an `abortSignal: AbortSignal.timeout(budgetMs)` to each+ `streamText` attempt (`api/brain/chat.js:363-375`), where `budgetMs` is a per-attempt ceiling+ (~20s) bounded by remaining wall-clock — mirror the `api/chat.js:404-423` pattern. A hung native+ provider must abort fast and hand off to the OpenRouter fallback while time remains.++6. **Give persona/extract + persona/preview real failover.** Replace the hand-rolled single-shot+ `resolveProvider()` calls (`extract.js:191-201`, `preview.js:137-147`) with the shared+ `llmComplete` from `api/_lib/llm.js`. Extend `llm.js` `providerChain` (`llm.js:78`) to also use a+ **server** `env.ANTHROPIC_API_KEY` (today it only adds Anthropic for a passed BYOK key) so these+ endpoints get the same Anthropic-first ordered failover.++## Acceptance criteria++- [ ] With Anthropic keyed, the happy path resolves on attempt 0 (Anthropic); fallbacks only+ engage when Anthropic itself errors.+- [ ] An exhausted chain returns **503 + Retry-After**, never a hard 502.+- [ ] A throttled provider is skipped for a cooldown window on subsequent requests.+- [ ] `/api/brain/chat` cannot exceed its abort budget per attempt; no more ~30s hangs.+- [ ] `/api/persona/extract` and `/api/persona/preview` fail over across providers instead of+ 502-ing on the first non-2xx.+- [ ] No regression to streaming, tool-calling, or rate-limit headers on `/api/chat`.++## Verification++1. `npx vitest run` for any chat/LLM tests under `api/` and `tests/`.+2. Locally (`npm run dev`), drive `/api/chat` with a normal prompt and confirm a 200 stream.+3. Simulate exhaustion: temporarily unset the upstream keys in a local env and confirm the endpoint+ returns **503 + Retry-After** (not 502), and that the cooldown path is exercised.+4. Confirm `/api/brain/chat` aborts an artificially slow attempt within budget and still answers via+ fallback.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). No mocks. Default to the latest Claude models for the Anthropic+link (e.g. `claude-sonnet-4-6` for chat); do not invent model IDs — verify against the codebase's+existing Anthropic model constants. If you touch model selection, consult the `claude-api` skill+reference rather than guessing IDs.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/A2-chat-llm-fallback-502.md`.+3. Commit your code change **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "fix(chat): Anthropic-first fallback, 503-not-502 on exhaustion, provider cooldown, brain abort budget; close A2"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/A3-forge-views-used-migration.md b/tasks/week-2026-06-08/A3-forge-views-used-migration.mdnew file mode 100644index 000000000..d52cebbf2--- /dev/null+++ b/tasks/week-2026-06-08/A3-forge-views-used-migration.md@@ -0,0 +1,76 @@+# A3 — Apply the forge `views_used` migration in production++**Track:** A — production fire · **Priority:** P1 · **Effort:** 30m–1h · **Depends on:** none++## Context (evidence)++Production logs show repeated:++```+[forge-store] listCreations failed: column "views_used" does not exist+```++The forge gallery (`GET /api/forge-gallery`, and `listCreations` in `api/_lib/forge-store.js`) is+**broken in prod** because the runtime queries columns that the production database does not have.++The migration that adds them already exists in-repo and is correct:++`api/_lib/migrations/20260606000000_forge_multiview.sql`+```sql+alter table forge_creations add column if not exists views_requested smallint;+alter table forge_creations add column if not exists views_used smallint;+alter table forge_creations add column if not exists multiview boolean;+alter table forge_creations add column if not exists backend text;+```++It was committed Jun 6 but **has not been applied to the production Neon database** — the error+fired *after* the migration landed in the repo.++## What to do++1. Determine how migrations are run in this repo. Search for the runner and any+ already-applied bookkeeping: look in `api/_lib/migrations/` for a runner, `scripts/` for a+ `migrate*`/`db*` script, and `package.json` scripts. Do **not** invent a new mechanism — use+ the established one.+2. Apply the pending migration(s) to the **production** database. The columns use+ `add column if not exists`, so the migration is idempotent and safe to re-run.+3. Confirm the production `forge_creations` table now has `views_requested`, `views_used`,+ `multiview`, `backend`.+4. Audit for **other** unapplied migrations dated on/around 2026-06-06+ that may be in the same+ state, and apply any that are genuinely pending (be conservative — only apply migrations that+ are committed and intended for prod).++> This task is primarily an **operational** action against the prod DB. If running it requires the+> production `DATABASE_URL` / Neon credentials that are not available to you, do **not** guess or+> hardcode anything: complete the code/verification portions, then clearly document in your commit+> message and in a short note that the human must run the migration runner against prod, naming the+> exact command. The acceptance criterion below for "prod has the columns" may then be handed off.++## Acceptance criteria++- [ ] The migration mechanism used is the repo's existing one (no ad-hoc SQL outside the+ migrations system).+- [ ] Production `forge_creations` has the four new columns (or a precise, documented hand-off if+ prod credentials are unavailable to the agent).+- [ ] `listCreations` / `GET /api/forge-gallery` no longer errors on the missing column.+- [ ] No code regression to forge submit/poll responses that read these columns+ (`api/forge.js:408, 550`, `src/forge.js`).++## Verification++1. After applying, hit `GET /api/forge-gallery` against the environment you migrated and confirm a+ 200 with creations (or an empty list — not a 500).+2. Grep confirms the reading code paths (`rg -n views_used api src`) align with the column names+ the migration creates.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Real DB, real migration — no schema mocking.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/A3-forge-views-used-migration.md`.+3. Commit (any code/doc changes) **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "chore(db): apply forge_multiview migration to prod; close A3"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/A4-pump-by-agent-uuid-guard.md b/tasks/week-2026-06-08/A4-pump-by-agent-uuid-guard.mdnew file mode 100644index 000000000..bab22484b--- /dev/null+++ b/tasks/week-2026-06-08/A4-pump-by-agent-uuid-guard.md@@ -0,0 +1,63 @@+# A4 — Guard `/api/pump/by-agent` (and audit siblings) against non-UUID input++**Track:** A — production fire · **Priority:** P1 · **Effort:** 1–2h · **Depends on:** none++## Context (evidence)++Production logs:++```+[api] unhandled NeonDbError: invalid input syntax for type uuid: "agent"+ at execute (file:///var/task/api/pump/[action].js:...)+```++`GET /api/pump/by-agent` (handled by `handleByAgent` in `api/pump/[action].js`, registered around+line 129 / defined around line 1915) passes a non-UUID value (the literal string `"agent"`) straight+into a `uuid`-typed SQL query, which throws `NeonDbError` and 500s. This is the same class of bug+the agents and bounties routes were already hardened against (see+`api/bounties/[id].js:14` — `if (!isUuid(id)) return error(res, 404, ...)`).++## What to do++1. In `handleByAgent` (`api/pump/[action].js`), validate the agent identifier **before** it reaches+ any `uuid`-typed query. Use the existing helper: `import { isUuid } from '../_lib/validate.js'`+ (confirm the relative path from this file). If the id is missing or not a UUID, return a clean+ `400 validation_error` (or `404 not_found` if that matches the endpoint's contract for "unknown+ agent") — **never** let it reach the DB.+ - Determine where the bad `"agent"` value originates: is it `req.query.agent` /+ `req.query.agent_id` defaulting to the literal `"agent"`, or a path segment being misparsed?+ Fix the source too, not just the guard, if it's a parsing bug.+2. **Audit the whole dispatcher** `api/pump/[action].js` for any other handler that interpolates a+ user-supplied value into a `uuid`/typed column without validation. Add the same guard wherever a+ raw id reaches SQL. (`handleByAgent` is the one in the logs, but harden siblings while you're+ here.)+3. Ensure errors in this dispatcher are caught at the boundary and logged with a structured prefix+ (e.g. `console.error('[pump/by-agent]', ...)`) rather than surfacing as `unhandled NeonDbError`.++## Acceptance criteria++- [ ] `GET /api/pump/by-agent` with a missing/non-UUID agent id returns a clean 400/404, **no**+ `NeonDbError`, **no** 500.+- [ ] A valid agent UUID still returns the correct mint + stats + burn history (no regression).+- [ ] Other id-consuming branches in `api/pump/[action].js` are guarded the same way.+- [ ] The dispatcher logs structured errors at the boundary.++## Verification++1. `npm run dev`, then:+ - `curl '/api/pump/by-agent'` → clean 400/404.+ - `curl '/api/pump/by-agent?agent_id=not-a-uuid'` → clean 400/404.+ - `curl '/api/pump/by-agent?agent_id=<real uuid>'` → 200 with data.+2. Run any existing pump API tests: `npx vitest run` (filter to pump if available).++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Errors handled at boundaries; internal code trusts itself.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/A4-pump-by-agent-uuid-guard.md`.+3. Commit your code change **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "fix(pump): UUID-guard by-agent and sibling handlers to stop NeonDbError 500s; close A4"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/A5-neon-coldstart-pooling.md b/tasks/week-2026-06-08/A5-neon-coldstart-pooling.mdnew file mode 100644index 000000000..76ad87835--- /dev/null+++ b/tasks/week-2026-06-08/A5-neon-coldstart-pooling.md@@ -0,0 +1,71 @@+# A5 — Harden against Neon cold-start failures (auto-agent + seed)++**Track:** A — production fire · **Priority:** P2 · **Effort:** 2–4h · **Depends on:** none++## Context (evidence)++Production logs show intermittent database connection failures, not query bugs:++```+[avatars] auto-agent failed { avatarId: ..., userId: ..., error: 'Error connecting to database: fetch failed' } (×several)+[seed-default-agent] first attempt failed, retrying { userId: ..., error: 'Error connecting to database: fetch failed' }+[seed-default-agent] failed { userId: ..., error: 'Error connecting to database: fetch failed' }+[audit] insert failed { action: 'logout', error: 'Error connecting to database: fetch failed' }+```++These are **Neon serverless cold-start / transient connection** failures (`fetch failed` from the+Neon HTTP driver), not SQL errors. `api/_lib/seed-default-agent.js` already has a 1s retry, but it+still ultimately fails sometimes, and the avatar **auto-agent** path appears to have weaker+resilience.++## What to do++1. **Locate the shared DB client** (`api/_lib/db.js`) and understand how connections are made+ (Neon HTTP driver vs pooled `Pool`). Determine whether these failing call sites use the+ pooled/cached client or create fresh connections per invocation.+2. **Add bounded retry-with-backoff for transient connection errors** at the right layer:+ - Prefer a single shared helper (e.g. a `withDbRetry(fn)` in `api/_lib/db.js`) that retries only+ on connection-class errors (`fetch failed`, connection reset, ECONNRESET, Neon+ `NeonDbError` with a connection cause) — **not** on query/constraint errors. 2–3 attempts with+ short exponential backoff (e.g. 150ms, 400ms, 900ms) + jitter.+ - Apply it to: the avatar **auto-agent** creation path (find it — search+ `rg -n "auto-agent failed" api`), `api/_lib/seed-default-agent.js` (upgrade its existing single+ retry to use the shared helper), and the audit-insert path (`rg -n "\\[audit\\] insert failed" api`).+3. **Make non-critical writes non-fatal.** `seed-default-agent` and audit-log inserts must never+ block the user-facing request: on final failure they should log and continue (seed already does+ this — confirm; audit insert should too). The avatar auto-agent failure should degrade+ gracefully — the avatar must still be created even if agent auto-provisioning fails; surface a+ retriable state rather than losing the avatar.+4. **Confirm the connection strategy is appropriate for Vercel serverless.** If the code opens a new+ un-pooled connection per request, switch to the Neon pooled connection string / cached client+ pattern already used elsewhere in `api/_lib/` (do not introduce a new dependency).++## Acceptance criteria++- [ ] Transient `fetch failed` connection errors are retried with backoff; query/constraint errors+ are **not** retried.+- [ ] The avatar auto-agent path no longer loses the avatar on a DB blip; it retries or degrades+ cleanly with a structured log.+- [ ] `seed-default-agent` and audit-insert failures never propagate to the user request.+- [ ] The retry logic is centralized (one helper), not copy-pasted per call site.+- [ ] No retry on success and no infinite loops; attempts are bounded.++## Verification++1. `npx vitest run` for any db/auth/avatar tests.+2. Add or extend a unit test that simulates a `fetch failed` on the first attempt and a success on+ the second, asserting the helper retries and resolves.+3. Manually trace each of the three failing call sites and confirm they route through the new helper.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Real retries against the real driver — no fake delays to "look+busy," no swallowing of genuine query errors.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/A5-neon-coldstart-pooling.md`.+3. Commit your code change **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "fix(db): bounded connection-error retry for auto-agent/seed/audit; close A5"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/B1-coin-purity-sweep.md b/tasks/week-2026-06-08/B1-coin-purity-sweep.mdnew file mode 100644index 000000000..726c9398b--- /dev/null+++ b/tasks/week-2026-06-08/B1-coin-purity-sweep.md@@ -0,0 +1,107 @@+# B1 — Coin-purity sweep: purge every non-$THREE token reference++**Track:** B — complete feature · **Priority:** P0 (non-negotiable rule) · **Effort:** 2–3h · **Depends on:** none++## Context++[CLAUDE.md](../../CLAUDE.md) is absolute: **the only coin/token the platform may ever name,+display, link, or promote is `$THREE`** (`FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`). No+BONK, JUP, WIF, USDT, PYTH, JTO, or any other token — anywhere in shipped UI, examples, fixtures,+or docs. Treat any other coin reference like a leaked secret: remove it.++**The one allowed exception (do not "fix" these):** generic, coin-agnostic **settlement/quote**+plumbing where **USDC** or **wrapped SOL (wSOL)** is the settlement currency (x402 pays in USDC;+swaps quote against SOL/USDC). USDC/wSOL used purely as a settlement or quote asset is fine. USDT+is **not** in this exception. A token presented as a *selectable tile / example coin / promoted+symbol* is **never** fine, even USDC.++This sweep was already audited file-by-file. The exact edits are below. Apply them, then run your+own ripgrep pass to catch anything new.++## Edits to apply (verified)++| # | File:line | Current | Change to |+|---|-----------|---------|-----------|+| 1 | `src/swap-jupiter.js:30-39` | `QUICK_TOKENS` tiles incl. USDT, BONK, JUP, WIF, PYTH, JTO | Reduce to **SOL, USDC, THREE** only (array below). Custom mints still work via paste. |+| 2 | `api/x402/mint-to-mesh.js:66` | `DISCOVERY_INPUT_EXAMPLE = { mint: 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263' }` (Bonk) | `{ mint: 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump' }` |+| 3 | `api/x402/mint-to-mesh.js:84-90` | `DISCOVERY_OUTPUT_EXAMPLE`: Bonk mint, `name:'Bonk'`, `symbol:'Bonk'`, Bonk arweave `imageUrl` | $THREE mint, `name:'three'`, `symbol:'THREE'`; drop the Bonk `imageUrl` (set `hasImage:false` or a $THREE asset URL). Keep illustrative `color`/`bytes`. |+| 4 | `api/wk.js:612` | `input: { mint: 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263' }` (Bonk) | `input: { mint: 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump' }` |+| 5 | `src/marketplace.js:5613` | `if (mint === 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') return 'USDT';` | **Delete this line.** Keep the `USDC` branch above it; unknown mints already fall through to a short-mint label. |+| 6 | `src/shared/skill-purchase.js:118` | `if (mint === 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') return 'USDT';` | **Delete this line.** Keep the `USDC` branch above it. |+| 7 | `src/solana/pyth-price.js:18-19` | `BONK: '72b0...'`, `WIF: '4ca4...'` in `PRICE_FEED_IDS` | **Remove the BONK and WIF entries.** Keep SOL/BTC/ETH/USDC. (This list is exposed via the live `pyth-price` agent skill.) |+| 8 | `src/agent-skills-jupiter.js:5` | Header comment: `...SOL, BTC, ETH, USDC, BONK, WIF, JUP, PYTH.` | `...SOL, BTC, ETH, USDC.` |+| 9 | `src/agent-skills-jupiter.js:68` | `description: 'Input token symbol (SOL, USDC, BONK, …) or raw mint address'` | `description: 'Input token symbol (SOL, USDC, …) or raw mint address'` |+| 10 | `src/agent-skills-jupiter.js:195` | `description: 'Token symbol to look up (e.g. BONK, WIF)'` | `description: 'Token symbol to look up (e.g. SOL, USDC)'` |+| 11 | `api/demo-economy.js:58` | Fallback pool row `{ name: 'JUP/SOL', ... }` | Replace with `{ name: 'THREE/SOL', ... }` (or drop to a single `SOL/USDC` row). Keep the existing `SOL/USDC` row. |+| 12 | `src/widgets/pumpfun-feed.js:469` | Photon link uses referral handle `@bonk`: `https://photon-sol.tinyastro.io/en/r/@bonk/${mint}` | Use the project's own Photon referral code (e.g. `/r/three.ws/`), or drop the PHO link. No literal `bonk` in shipped links. |+| 13 | `src/kol/wallets.json:17` | `"wallet": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"` (Bonk mint posing as a wallet; **served at runtime** by `api/kol/[action].js`) | Replace with a synthetic placeholder, e.g. `"THREEsynthetic2222222222222222222222222222"`. |+| 14 | `src/kol/radar-fixture.json:58-61` | `"mint": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"` (real USDT mint; **imported at runtime** by `src/kol/radar.js`) | Replace the mint with a synthetic placeholder, e.g. `"THREEsynthetic1111111111111111111111111111"`. Keep the fake name/symbol. |++### Exact replacement for `QUICK_TOKENS` (#1)++```js+const THREE_MINT = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';++const QUICK_TOKENS = [+ { symbol: 'SOL', name: 'Solana', mint: SOL_MINT, decimals: 9, logoURI: 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png' },+ { symbol: 'USDC', name: 'USD Coin', mint: USDC_MINT, decimals: 6, logoURI: 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png' },+ { symbol: 'THREE', name: 'three', mint: THREE_MINT, decimals: 6, logoURI: '' },+];+```++`QUICK_TOKENS[0]`/`[1]` are still referenced as `defaultInputMint`/`defaultOutputMint` (around+`src/swap-jupiter.js:804-806`), so SOL→USDC remains the default pair — preserved. **Verify $THREE+decimals on-chain before applying** (pump.fun mints are typically 6); the modal also reads decimals+via the custom-mint path if needed.++## Do NOT flag these (verified allowed)++- `src/swap-jupiter.js:24-25` `SOL_MINT` / `USDC_MINT` constants (settlement/quote defaults).+- `api/x402/mint-to-mesh.js:167,181` `'USD Coin'`/`'USDC'` in `buildRequirements` (x402 settlement).+- `src/shared/skill-purchase.js:117` / `src/marketplace.js:5612` USDC branches (settlement asset).+- `src/game/ambient-crowd.js` `pepe`/`gigachad` (NPC usernames, not tokens).+- `public/three.svg` base64 substring matches (false positives).+- `public/chat/assets/*` build artifacts (gitignored; regenerated — fixing #2/#4 clears them).++## Then: your own sweep++After applying the table, run a fresh pass to catch anything missed or newly added:++```+rg -n -i '\b(bonk|wif|jup|pyth|jto|pepe|popcat|mew|bome|usdt|tether)\b' src api public workers \+ --glob '!*.test.js' --glob '!node_modules' --glob '!dist*' --glob '!*.map'+```++Judge each hit against the rule + the allowed exception. Fix real violations; leave settlement+plumbing. Low-priority cleanup (optional, do if quick): swap `bonk`/`doge`/`BONK` example strings in+JSDoc/comments at `api/x402/crypto-intel.js:36`, `api/pump/search.js:1`, `src/solana/jupiter-swap.js:138`+for `sol`/`three`.++## Acceptance criteria++- [ ] All 14 edits applied exactly (or with a documented, justified deviation).+- [ ] No selectable token tile, example coin, price-feed symbol, fixture mint, or referral handle+ references any token other than $THREE (USDC/wSOL settlement plumbing excepted).+- [ ] The two runtime-served fixtures (`src/kol/wallets.json`, `src/kol/radar-fixture.json`) contain+ no real third-party mainnet mints.+- [ ] Your fresh ripgrep pass returns only allowed settlement references or false positives.+- [ ] Swap modal still functions (SOL/USDC default pair intact; custom mint paste still works).++## Verification++1. `npx vitest run` (the swap + bonding-curve + skill-purchase tests must still pass).+2. `npm run dev`; open the swap modal — confirm only SOL/USDC/THREE tiles, custom paste works.+3. Re-run the ripgrep sweep; confirm a clean result.++## Rules++This is the platform's most important rule. When in doubt, remove rather than keep. Obey+[CLAUDE.md](../../CLAUDE.md).++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/B1-coin-purity-sweep.md`.+3. Commit your changes **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "fix: purge all non-$THREE token references (tiles, examples, fixtures, feeds); close B1"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/B2-evm-marketplace-purchase.md b/tasks/week-2026-06-08/B2-evm-marketplace-purchase.mdnew file mode 100644index 000000000..daeb9e82e--- /dev/null+++ b/tasks/week-2026-06-08/B2-evm-marketplace-purchase.md@@ -0,0 +1,71 @@+# B2 — Implement EVM marketplace purchase confirmation (close the 501 dead-end)++**Track:** B — complete feature · **Priority:** P1 · **Effort:** 1–2 days · **Depends on:** none++## Context++The marketplace buy flow **dead-ends for any non-Solana chain**. Both purchase-confirm handlers+return `501 not_implemented` the moment the chain isn't Solana:++- `api/marketplace/purchase.js:259` — `chain '${pur.chain}' confirmation not yet supported`+- `api/marketplace/buy-asset.js:253` — same++So a buyer can begin an EVM (Base, etc.) purchase but can never confirm it. This violates the+"every state must be reachable / no dead paths" rule and the "no `not_implemented`" rule.++The Solana confirmation path in those same files is the reference implementation — mirror its+shape (verify the on-chain payment, mark the purchase paid, grant the entitlement, record the+receipt) for EVM.++## What to do++1. **Read both handlers fully** and the Solana confirm path they already implement. Identify the+ exact post-payment steps Solana does: signature/tx verification, amount/recipient/mint checks,+ idempotency, DB state transition (pending → paid), entitlement grant, receipt/audit write.+2. **Find the existing EVM verification primitives** — this repo already does EVM/x402 on Base.+ Search `api/_lib/` for EVM helpers (`rg -n "base|evm|viem|ethers|verifyTransaction|usdc" api/_lib`).+ x402 settlement on Base + EVM RPC reads almost certainly already exist (the x402 stack). Reuse+ them — do **not** add a new web3 dependency or re-implement RPC plumbing.+3. **Implement EVM confirmation** for the chain(s) the marketplace actually offers (confirm which:+ Base at minimum). For an EVM purchase, verify the on-chain transfer (correct token = USDC+ settlement, correct amount, correct recipient/treasury, sufficient confirmations), enforce+ idempotency (same tx can't grant twice), then run the **same** state-transition + entitlement ++ receipt steps as Solana.+4. **De-duplicate.** `purchase.js` and `buy-asset.js` carry a near-identical expire/confirm/501+ ladder. Extract the shared confirm logic into one helper in `api/_lib/` (e.g.+ `marketplace-confirm.js`) so the EVM path is implemented **once** and both endpoints call it.+ Don't fix the same gap twice.+5. **Error boundaries:** invalid / unconfirmed tx → clear 4xx with an actionable message; transient+ RPC failure → retriable 5xx; never a bare `501`.++## Acceptance criteria++- [ ] An EVM (Base) purchase can be confirmed end-to-end: on-chain payment verified, purchase+ marked paid, entitlement granted, receipt recorded.+- [ ] Replaying the same confirmation (same tx) is idempotent — no double-grant.+- [ ] Wrong token / wrong amount / wrong recipient / unconfirmed tx each return a clear,+ actionable 4xx (not 501, not a silent success).+- [ ] Shared confirm logic is extracted to one helper; both `purchase.js` and `buy-asset.js` use it.+- [ ] Solana confirmation is unchanged (no regression).+- [ ] No `not_implemented` / 501 remains in the purchase-confirm path for supported chains.++## Verification++1. `npx vitest run` for marketplace tests; add tests for the EVM confirm path (valid tx, replay,+ wrong-amount, unconfirmed) using the repo's existing EVM test helpers/fixtures (use $THREE or a+ clearly-synthetic placeholder mint — never a real third-party mint).+2. `npm run dev`; walk the marketplace buy flow for an EVM item if a testable path exists, and+ confirm the confirm step succeeds and the entitlement appears.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). No mocks, real chain verification. Settlement in USDC on Base is+the allowed coin-agnostic plumbing — do not surface any non-$THREE token symbol in UI copy.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/B2-evm-marketplace-purchase.md`.+3. Commit your code change **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "feat(marketplace): EVM purchase confirmation + shared confirm helper; close B2"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/B3-dead-file-skill-collection.md b/tasks/week-2026-06-08/B3-dead-file-skill-collection.mdnew file mode 100644index 000000000..568619d8f--- /dev/null+++ b/tasks/week-2026-06-08/B3-dead-file-skill-collection.md@@ -0,0 +1,50 @@+# B3 — Resolve the empty `api/agents/[id]/skill-collection.js`++**Track:** B — complete feature · **Priority:** P2 · **Effort:** 30m (delete) – 2h (implement) · **Depends on:** none++## Context++`api/agents/[id]/skill-collection.js` is a **1-byte (empty) file**. It exports nothing and is+referenced nowhere in `api/`, `src/`, or `vercel.json`. It is the single genuinely-dead endpoint+file in the API surface. Empty handler files are hazardous in this repo because the dispatcher-shim+pattern makes thin files look normal — a zero-byte file can masquerade as a real endpoint.++## Decision++Choose one, based on a quick check of intent:++1. **Search for any intended consumer / spec.** Grep `src/`, `api/`, `docs/`, `specs/`, `tasks/`+ for `skill-collection`, "skill NFT", "Metaplex", "skill collection" to see if a feature was+ planned (the name suggests a Metaplex on-chain collection of an agent's skills).+2. **If there is no live consumer and no committed spec → delete the file.** This is the default and+ correct action; do not leave dead scaffolding.+3. **If there is a clear, committed spec/consumer that this was meant to satisfy → implement it+ fully** (real Metaplex mint / collection read, wired into a reachable route in `vercel.json` and+ a UI entry point), per the no-stubs rule. Only do this if the scope is genuinely small and+ specified; otherwise delete and, if the feature is still wanted, it belongs in its own task —+ note that in your commit message rather than half-building it here.++## Acceptance criteria++- [ ] The empty file no longer exists, **or** it is a complete, reachable, real implementation+ (no stub, no `not_implemented`, wired into a route + UI).+- [ ] No dangling import/route references remain.+- [ ] If deleted: a one-line note in the commit message explains it was dead (no consumer/spec).++## Verification++1. `rg -n "skill-collection" .` returns no live code references (only, at most, this resolved state).+2. `npm run build` (or the relevant lint/knip step) passes with no new unused-file/route warnings.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md): delete aggressively; no stubs; if it exists, it must work and be+reachable.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/B3-dead-file-skill-collection.md`.+3. Commit your change **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "chore(api): remove dead empty skill-collection.js endpoint; close B3"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/B4-docs-ci-hygiene.md b/tasks/week-2026-06-08/B4-docs-ci-hygiene.mdnew file mode 100644index 000000000..5196eaadd--- /dev/null+++ b/tasks/week-2026-06-08/B4-docs-ci-hygiene.md@@ -0,0 +1,67 @@+# B4 — Docs + CI hygiene: document the texture worker, guard against zero-byte handlers++**Track:** B — complete feature · **Priority:** P2 · **Effort:** 2–3h · **Depends on:** none++## Context++The API/worker audit surfaced two low-risk but real gaps:++1. **`workers/texture/` is fully built** (Dockerfile, cloudbuild.yaml, ~870-LOC `main.py` mesh-+ texturing Cloud Run service) **but is undocumented in `workers/README.md`.** Every other worker+ is listed there. An undocumented-but-deployed service risks being orphaned operationally.+2. **There is no guard against zero-byte / empty handler files.** The dispatcher-shim pattern makes+ thin files normal, so an empty file (see B3 — `api/agents/[id]/skill-collection.js`) can pass+ unnoticed. A trivial CI/lint check would catch this class permanently.++## What to do++### Part 1 — Document the texture worker++1. Read `workers/README.md` and the existing entries' format (purpose, runtime, build/deploy+ command, any env vars).+2. Read enough of `workers/texture/` (`main.py`, `Dockerfile`, `cloudbuild.yaml`) to describe it+ accurately: what it does (mesh texturing), its endpoint/contract, how it's built and deployed+ (Cloud Run), and which env/config it needs.+3. Add a `workers/texture/` entry to `workers/README.md` matching the existing style exactly. Be+ accurate — no aspirational claims; describe what the code actually does.++### Part 2 — CI guard for zero-byte handlers++1. Find where repo checks run — `.github/workflows/` and `package.json` scripts (there are existing+ `audit:*` scripts). Pick the established mechanism; do not invent a parallel one.+2. Add a check that **fails** if any `api/**/*.js` file is effectively empty (e.g. size < 2 bytes,+ or no `export`). A minimal approach: a small Node script under `scripts/` (e.g.+ `scripts/audit-empty-handlers.mjs`) wired into the existing prebuild/audit step and/or a CI+ workflow. It should print the offending paths and exit non-zero.+3. Run it once to confirm it would catch the B3 file (if B3 hasn't run yet) and otherwise passes on+ the current tree. Ensure it does **not** false-positive on legitimately-tiny shim files that+ *do* export something — the check is "empty/no export," not "short."++## Acceptance criteria++- [ ] `workers/README.md` has an accurate `workers/texture/` entry in the existing format.+- [ ] A committed check fails on empty/no-export `api/**/*.js` files and is wired into the repo's+ existing audit/CI flow.+- [ ] The check passes on the current tree (after B3, or it flags exactly the B3 file if B3 is still+ open — note which in your commit).+- [ ] No false positives on valid thin dispatcher shims.++## Verification++1. Run the new check locally: `node scripts/audit-empty-handlers.mjs` (or whatever you named it) —+ confirm exit code + output behave as specified.+2. `npm run prebuild` (or the audit script you hooked into) still succeeds on the clean tree.+3. Temporarily `touch api/_tmp-empty-test.js`, re-run, confirm it fails, then remove the temp file.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Keep the repo root clean — any new script goes in `scripts/`, not+the root. No scratch files committed.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified (and no temp test file remains).+2. Delete this file: `tasks/week-2026-06-08/B4-docs-ci-hygiene.md`.+3. Commit your changes **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "chore: document texture worker + CI guard for empty api handlers; close B4"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/C1-three-token-data-hook.md b/tasks/week-2026-06-08/C1-three-token-data-hook.mdnew file mode 100644index 000000000..3b12dedab--- /dev/null+++ b/tasks/week-2026-06-08/C1-three-token-data-hook.md@@ -0,0 +1,114 @@+# C1 — Build the `three-token-data.js` shared data hook (keystone)++**Track:** C — build next · **Priority:** P1 · **Effort:** ~half day · **Depends on:** none+**Unblocks:** C2, C4, C5 (and optionally C6). Build this first.++## Context++The $THREE holder feature set (Tasks 14/16/17 in `tasks/wow-sprint/`) all need a **single source of+truth** for $THREE data. That module — `src/pump/three-token-data.js` — **does not exist yet**.+Today the closest thing is inline boot logic in `src/dashboard-next/pages/three-token.js`+(~lines 112–117) that does `Promise.all([stats, revenue-share, activity, tokenConfig])`. Generalize+that into a reusable, subscribable store so every holder surface reads from one place and they don't+drift.++**Do not invent new fetch primitives.** Every backend it needs already exists.++### Existing endpoints it wraps (all live; `api/three-token/[action].js` dispatcher)++- `GET /api/three-token/stats` (public, edge-cached ~20s) → `{ token:{ mint, symbol, price_usd,+ price_change_24h, market_cap, volume_24h, holders, liquidity, supply, decimals, source },+ protocol:{ total_agents, total_revenue_usd, total_payments, revenue_share_pool_pct, agent_deploy_burn } }`+- `GET /api/three-token/revenue-share` (authed; `401` if not signed in) → pro-rata math+ `{ user_id, token_price, total_supply, total_holders, platform_revenue_usd, revenue_share_pool_pct,+ revenue_share_pool_usd, per_token_yield }`. **This is protocol-level math, NOT a per-wallet+ claimable balance.**+- `GET /api/three-token/activity` → `{ events: [...] }` (recent revenue events)+- `GET /api/three-token/burns` → `{ burns:[...], total_burned, burn_per_deploy }`+- `POST /api/wallet/balances` with `{ chain:'solana', address }` → per-wallet token balances (used+ to compute the holder's $THREE position). Helper: `getBalances` in `api/_lib/balances.js`.++### Existing client helpers to reuse++- `src/dashboard-next/api.js` — `get`, `post`, `requireUser`, `ApiError` (typed 401), `esc`, `relTime`.+- `$THREE` mint constant: confirm the canonical one in the client (e.g. `src/token-pay.js`+ `fetchTokenConfig`) — value is `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`.+- Self-cleanup `MutationObserver` pattern already in `three-token.js` (~lines 430–435).++## What to build++Create `src/pump/three-token-data.js` exporting a factory that returns a subscribable store (a+plain store, **not** a React hook — this codebase is vanilla JS modules):++```js+createThreeTokenData({ pollMs = 30000 }) => {+ getState(): ThreeTokenState, // last snapshot, synchronous+ subscribe(fn): () => void, // fires on every refresh; returns unsubscribe+ refresh(): Promise<void>, // force a full fetch now+ refreshPosition(): Promise<void>, // re-fetch only the wallet position (after a trade/claim)+ destroy(): void, // clear interval + observers+}+```++`ThreeTokenState` — each field carries its **own** status so widgets render independent+loading/empty/error states:++```+{+ protocol: { status: 'loading'|'ok'|'error', token:{...stats.token}, protocol:{...stats.protocol}, source, updatedAt },+ revenueShare: { status, ...revenue-share fields | unauthenticated: true },+ activity: { status, events: [] },+ burns: { status, burns: [], total_burned, burn_per_deploy },+ position: { status: 'idle'|'loading'|'unauthenticated'|'zero'|'ok'|'error',+ wallet, amount, usd, pctOfSupply, price } // null until a wallet is known+}+```++Behavior:+- `protocol` ← `get('/api/three-token/stats')`; `activity` ← `.../activity`; `burns` ← `.../burns`.+- `revenueShare` ← `get('/api/three-token/revenue-share')`; treat `ApiError` 401 as+ `{ status:'ok', unauthenticated:true }`, not an error.+- `position` ← resolve the signed-in user's linked Solana wallet, then+ `post('/api/wallet/balances', { chain:'solana', address })`, find the `$THREE` mint row, compute+ `pctOfSupply = amount / protocol.token.supply`. `idle` until a wallet is known; `unauthenticated`+ if not signed in; `zero` if the wallet holds no $THREE; `ok` otherwise.+- Polling refreshes `protocol` + `activity` on `pollMs`. `position` refreshes on demand only+ (`refreshPosition`) — don't hammer `/api/wallet/balances` on every tick.+- `destroy()` clears the interval and any observer. Include the `MutationObserver` self-cleanup so+ a store tied to a detached DOM node tears itself down (copy the `three-token.js` pattern).+- All fetches go through `src/dashboard-next/api.js` (`get`/`post`) — never raw `fetch`.++## Acceptance criteria++- [ ] `src/pump/three-token-data.js` exists and exports `createThreeTokenData` with the signature+ above.+- [ ] Each state field exposes an independent `status`; 401 on revenue-share is handled as+ `unauthenticated`, not an error.+- [ ] Position computes real `amount`/`usd`/`pctOfSupply` from `/api/wallet/balances` for a+ connected wallet, and reports `zero`/`unauthenticated`/`idle` correctly otherwise.+- [ ] Polling refreshes protocol/activity only; position is on-demand.+- [ ] `destroy()` fully tears down (no leaked intervals/observers).+- [ ] A focused unit test covers state transitions (loading → ok, 401 → unauthenticated, zero+ balance → zero) with the network layer stubbed at the `api.js` boundary.+- [ ] No other module needs to fetch $THREE data directly anymore (this is the one place).++## Verification++1. `npx vitest run src/pump/three-token-data.test.js` (add this test).+2. Temporarily wire the store into `three-token.js` boot (or a scratch harness in dev) and confirm,+ in a real browser with a connected wallet, that protocol/activity/position populate from real+ API responses (Network tab shows the real calls).++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Real endpoints only — no sample arrays, no fake balances. Only+$THREE. Design loading/empty/error states deliberately (the per-field `status` exists for exactly+this).++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/C1-three-token-data-hook.md`.+3. Commit your code **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "feat(pump): three-token-data shared store as single source of truth for $THREE; close C1"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/C2-holder-position-widget.md b/tasks/week-2026-06-08/C2-holder-position-widget.mdnew file mode 100644index 000000000..917c2a39c--- /dev/null+++ b/tasks/week-2026-06-08/C2-holder-position-widget.md@@ -0,0 +1,73 @@+# C2 — $THREE holder "Your position" widget (wow-sprint Task 14)++**Track:** C — build next · **Priority:** P1 · **Effort:** ~1 day · **Depends on:** **C1** (the shared hook)++## Context++`tasks/wow-sprint/14-holder-dashboard.md` calls for a $THREE holder dashboard — "the reason to log+in." Most of it is **already built**: `src/dashboard-next/pages/three-token.js` renders hero+metrics, the revenue-share calculator, deploy-burn, activity feed, and token info from the real+endpoints (~60% done). **The missing piece is the "Your position" widget**: the connected wallet's+real $THREE holding — amount, USD value, % of supply — plus a proper connect-wallet empty state.++Read `tasks/wow-sprint/14-holder-dashboard.md` in full before starting.++## Prerequisite++This task consumes the `createThreeTokenData` store from **C1** (`src/pump/three-token-data.js`),+specifically its `position` field. **Do not start until C1 is merged.** Do not re-fetch+`/api/wallet/balances` directly — use the store's `position` + `refreshPosition()`.++## What to build++1. **Refactor `three-token.js` to consume the C1 store.** Replace the inline `Promise.all` boot+ (~lines 112–117) with `createThreeTokenData(...)` + `subscribe(...)`. Existing sections+ (hero metrics, calculator, burns, activity) should now read from the store's fields instead of+ their own fetches. Keep the existing renderers (`renderHeroMetrics`, `fmtUsd`, `fmtCompact`,+ `fmtPct`, `pctColor`, `toast`, `safeGet`) — just change their data source.+2. **Add the "Your position" widget** as a new section near the top of the page:+ - **Connected + holding:** show $THREE balance, USD value, % of supply, and (if cheaply+ available from the store) price. Use the existing number formatters.+ - **Connected + zero balance (`position.status === 'zero'`):** show a "you don't hold $THREE yet"+ state with a clear CTA to acquire it (link to the token/swap page — coin-agnostic copy, only+ $THREE named).+ - **Not signed in (`unauthenticated`):** show a connect-wallet empty state with a sign-in CTA+ (reuse the page's existing `ApiError 401 → /login` convention).+ - **Loading:** skeleton (use the page's `skeletonBlock`/`skeletonGrid`).+ - **Error:** designed, actionable error state (not a blank void).+3. **Refresh on relevant events.** After a sign-in or a trade completes, call+ `store.refreshPosition()` so the widget updates without a full reload.+4. **States, motion, a11y:** every interactive element gets hover/active/focus states; transitions+ on opacity/transform; semantic markup + ARIA labels; works at 320 / 768 / 1440px.++## Acceptance criteria++- [ ] `three-token.js` reads all data from the C1 store; no duplicate $THREE fetching remains.+- [ ] "Your position" shows real balance / USD / % supply for a connected, holding wallet.+- [ ] All four non-happy states are designed: zero-balance, unauthenticated, loading, error.+- [ ] Position updates after sign-in / trade via `refreshPosition()` (no full reload needed).+- [ ] No console errors/warnings from changed code; Network tab shows real calls succeeding.+- [ ] Responsive + accessible + hover/active/focus on all interactive elements.++## Verification++1. `npm run dev`; open the holder dashboard route.+2. With **no** wallet/session: confirm the connect-wallet empty state + working sign-in CTA.+3. With a connected wallet holding $THREE: confirm real position numbers; cross-check the balance+ against `/api/wallet/balances` in the Network tab.+4. With a connected wallet holding **no** $THREE: confirm the zero-state + acquire CTA.+5. Throttle/offline to confirm the error state renders (not a blank).+6. `npx vitest run` — existing dashboard tests still pass.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Only $THREE. No fake balances or placeholder numbers — if the+store has no data yet, show the loading/empty state, never invented values.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/C2-holder-position-widget.md`.+3. Commit your code **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "feat(holder): your-position widget on $THREE dashboard via shared store; close C2"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/C3-holder-leaderboard-badge.md b/tasks/week-2026-06-08/C3-holder-leaderboard-badge.mdnew file mode 100644index 000000000..519aeb9c0--- /dev/null+++ b/tasks/week-2026-06-08/C3-holder-leaderboard-badge.md@@ -0,0 +1,89 @@+# C3 — $THREE holder leaderboard + endpoint + gated 3D badge (wow-sprint Task 15)++**Track:** C — build next · **Priority:** P1 · **Effort:** 1–2 days+**Depends on:** the new endpoint is independent; the client surface uses **C1**'s store for the+viewer's own rank. C1 not strictly blocking for the backend half — build the endpoint in parallel.++## Context++`tasks/wow-sprint/15-holder-leaderboard-and-badges.md` wants a public $THREE holder leaderboard plus+a holder-gated, shareable 3D badge — the strongest growth flywheel in the backlog. **This is mostly+net-new** (~10% exists). Read the task doc fully first.++### What already exists to reuse (do NOT rebuild)++- **Holder data reader:** `fetchHolderBalances({ mint })` in `api/_lib/coin/holders.js` returns+ `Map<owner, bigint>` of every holder via Helius DAS `getTokenAccounts` (handles Token-2022,+ paginates). This is the canonical holder-list source — wrap it; don't write new RPC.+- **Leaderboard endpoint pattern:** `api/cosmetics/leaderboard.js` and `api/bounties/leaderboard.js`+ — `wrap()` + `cors` + `method` + strict-whitelist params + `Cache-Control: s-maxage=...` ++ **empty-board-on-error (never 500)**. Copy this shape.+- **Server-side hold gate:** `api/community/holder-pass.js` + `signHolderPass`/`HOLDER_MIN_USD` in+ `api/_lib/holder-pass.js` — read authed wallet → `getBalances` → `solanaMintUsdPrice` → sign.+ This is the template for gating the badge **server-side** (never trust a client-reported balance).+- **Market/supply:** `fetchTokenMarketData(mint)` in `api/_lib/market/token-market.js` for+ `supply` (to compute `pctOfSupply`) and price.+- **Name resolution:** `src/solana/sns.js` to resolve holder addresses to SNS names in the board.+- **Badge export:** `exportAvatar`/`downloadAvatar` in `src/avatar-export.js` (PNG/GLB);+ `public/agent-badge.html` / `public/agent-passport.html` for markup patterns; `pages/three-live.html`+ for the Three.js scene patterns if the badge is a 3D render.+- **$THREE mint config:** `TOKEN_MINT` in `api/_lib/token/config.js`.++## What to build++### Backend (independent — can start now)++1. **Add `?action=leaderboard`** to `api/three-token/[action].js` (a new branch, **not** a new+ file — match how `stats`/`burns`/`activity` live there). It should:+ - Call `fetchHolderBalances({ mint: TOKEN_MINT })`, aggregate per owner, sort desc.+ - Paginate via whitelisted `?limit` (clamp, e.g. ≤100) and `?offset`.+ - Attach `pctOfSupply` using `fetchTokenMarketData().supply`; optionally resolve SNS names.+ - Truncate/format addresses for display; never leak more than needed.+ - `Cache-Control: s-maxage=60` (holder sets change slowly); **empty board on error, never 500**.+2. **Add `?action=holder`** (authed branch) — server-verified per-wallet $THREE balance + tier ++ rank, reusing `getBalances`/`solanaMintUsdPrice`. This is the **server-side gate** for the badge+ (don't trust client balance). Optionally fold badge-eligibility into this response.++### Frontend (uses C1 for the viewer's own rank)++3. **Holders page** — new `src/dashboard-next/pages/holders.js` + `pages/dashboard-next/holders.html`+ (wire the route in `vite.config.js` and add a nav entry in `src/dashboard-next/nav.js`). Render:+ - The leaderboard (rank, address/SNS, amount, % supply) with pagination, real loading/empty/error+ states, and the viewer's own row highlighted (from C1 `position` / the `holder` endpoint).+ - A **holder-gated 3D badge**: gate visibility/minting on the **server** `holder` response (not a+ client balance check). For eligible holders, render a shareable badge (reuse the 3D scene ++ `avatar-export` for PNG/GLB download) and an OG-style share path.+4. **States, motion, a11y, responsive** — per CLAUDE.md UI standards. Empty board = a helpful+ "be the first / how to acquire $THREE" state, not a blank.++## Acceptance criteria++- [ ] `GET /api/three-token/leaderboard?limit&offset` returns a real, paginated, sorted holder+ board with `pctOfSupply`; empty board (not 500) on upstream failure; cached.+- [ ] `GET /api/three-token/holder` (authed) returns server-verified balance + tier + rank.+- [ ] The holders page renders the board with pagination + the viewer's highlighted rank.+- [ ] The 3D badge is gated **server-side**; eligible holders can render + download (PNG/GLB) + share.+- [ ] All states designed (loading/empty/error/overflow); responsive; accessible; hover/active/focus.+- [ ] No console errors; Network tab shows real Helius-backed data.++## Verification++1. `curl '/api/three-token/leaderboard?limit=20'` → real ranked holders; `&offset=20` paginates;+ simulate an upstream failure → empty board, 200, not 500.+2. `npm run dev`; open the holders route — confirm board, pagination, your-rank highlight, and that+ the badge only appears/mints for a server-verified holder.+3. Confirm a non-holder (or signed-out) cannot mint/download the badge (gate is server-side).+4. `npx vitest run` for any new endpoint/page tests you add.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Only $THREE. Real Helius holder data — no sample holders. Gate on+the server; never trust client-reported balances. Design every state.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/C3-holder-leaderboard-badge.md`.+3. Commit your code **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "feat(holder): $THREE leaderboard + holder endpoint + gated 3D badge; close C3"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/C4-token-page-upgrade.md b/tasks/week-2026-06-08/C4-token-page-upgrade.mdnew file mode 100644index 000000000..7cf6e2d73--- /dev/null+++ b/tasks/week-2026-06-08/C4-token-page-upgrade.md@@ -0,0 +1,72 @@+# C4 — $THREE token page upgrade: real curve + live trade tape + swap (wow-sprint Task 16)++**Track:** C — build next · **Priority:** P2 · **Effort:** 1–2 days · **Depends on:** **C1** (price header)++## Context++`tasks/wow-sprint/16-token-page-upgrade.md` wants a canonical $THREE coin page that is trustworthy:+a real bonding-curve/price header, a **live trade tape**, and a working swap. The pieces exist but+are scattered; the canonical page does **not**. Read the task doc fully first.++The `/api/pump/trades-stream` P0 (broken SSE contract) was **already fixed** — the live tape is now+buildable.++### Existing pieces to assemble (do NOT rebuild)++- Price/curve: `src/pump/bonding-curve-chart.js`, `src/components/bonding-curve.js`,+ `api/pump/curve.js` (note: also being hardened in **A1** — coordinate; for $THREE, which is a real+ pump mint, the curve endpoint works normally).+- Swap quote/exec: `src/pump/pump-swap-quote.js`, `src/swap-jupiter.js` (after **B1** trims its+ tiles).+- Live trades: `api/pump/trades-stream.js` (SSE, fixed) and/or `api/pump/coin-trades.js` (REST),+ with the polling pattern in `src/home-live-token.js` as a reference.+- Price header data: the **C1** store (`protocol.token` price/market-cap/volume). Use it — don't+ add another price fetch.+- $THREE mint: `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`.++## What to build++1. **New canonical page** `pages/three-token.html` (route in `vite.config.js`) + `src/pages/three-token-coin.js`,+ assembling:+ - A **price header** fed by the C1 store (price, 24h change, market cap, volume, holders).+ - The **bonding-curve / price chart** for $THREE (reuse `bonding-curve-chart.js`).+ - A **live trade tape**: subscribe to `api/pump/trades-stream.js` (SSE) with a reconnect loop and+ a REST fallback to `coin-trades.js`; render buys/sells with amount + USD + relative time;+ respect `prefers-reduced-motion` for any tape animation.+ - A **working swap** widget for $THREE (reuse `pump-swap-quote.js` / `swap-jupiter.js`); SOL/USDC+ are the allowed quote/settlement assets.+2. **Cross-link** the page from the holder dashboard (C2), the leaderboard (C3 "acquire $THREE"+ CTA), and nav — no dead ends.+3. **All states + motion + a11y + responsive** per CLAUDE.md. Empty trade tape = a designed "no+ recent trades" state. Graduated-token edge case handled (if/when the curve completes).++## Acceptance criteria++- [ ] `pages/three-token.html` exists, is routed, and is reachable from nav + holder surfaces.+- [ ] Price header reads from the C1 store (no separate price fetch).+- [ ] Live trade tape streams real trades via SSE with a working reconnect + REST fallback.+- [ ] Swap widget executes a real $THREE swap (quote → confirm) with SOL/USDC as quote/settlement.+- [ ] All states designed (loading/empty/error/graduated); responsive; accessible; reduced-motion+ respected.+- [ ] No console errors; Network tab shows real curve/trades/quote calls.++## Verification++1. `npm run dev`; open `/three-token` (or the chosen route).+2. Confirm the price header matches `/api/three-token/stats`, the tape shows live trades and+ reconnects after a forced disconnect, and a swap quote returns a real route.+3. Test at 320 / 768 / 1440px; toggle reduced-motion; throttle to confirm the error/empty states.+4. `npx vitest run` for any new tests.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Only $THREE on the page. No mock trades, no fake price. Real SSE,+real swap. Coordinate with **A1** if you touch `api/pump/curve.js`.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/C4-token-page-upgrade.md`.+3. Commit your code **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "feat(token): canonical $THREE coin page — curve + live tape + swap; close C4"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/C5-rewards-surface.md b/tasks/week-2026-06-08/C5-rewards-surface.mdnew file mode 100644index 000000000..adfb406d3--- /dev/null+++ b/tasks/week-2026-06-08/C5-rewards-surface.md@@ -0,0 +1,77 @@+# C5 — Holder rewards / revenue-share surface (wow-sprint Task 17)++**Track:** C — build next · **Priority:** P2 · **Effort:** ~1 day · **Depends on:** **C1** (the shared hook)++## Context++`tasks/wow-sprint/17-holder-rewards-surface.md` wants a surface that shows $THREE holders the+protocol revenue-share they're accruing. ~40% exists: the revenue-share **calculator** already+renders in `src/dashboard-next/pages/three-token.js` (~lines 442–580) from+`/api/three-token/revenue-share`. The missing piece is a dedicated, honest rewards surface driven by+the holder's real position. Read the task doc fully first.++## HARD CORRECTNESS CONSTRAINT (read this twice)++**There is NO on-chain rewards/claim program.** `contracts/` has no rewards program, and+`/api/three-token/revenue-share` returns protocol-level **pro-rata math**, not a per-wallet+claimable balance. Therefore:++- This surface is an **accrual / calculator** view only.+- **Do NOT add a "Claim" button that performs (or pretends to perform) a transaction.** A button+ wired to nothing, a `setTimeout` fake success, or a stubbed claim are all hard CLAUDE.md+ violations.+- If you show a claim affordance at all, it must be clearly labeled **"coming"** / disabled with an+ honest explanation — never a fake action.++## Prerequisite++Consume the **C1** store (`src/pump/three-token-data.js`): `revenueShare` for the pool math and+`position` for the holder's $THREE amount → their accrued share. Do not re-fetch directly.++## What to build++1. **Rewards surface** — either a new `src/dashboard-next/pages/rewards.js` ++ `pages/dashboard-next/rewards.html` (routed in `vite.config.js`, nav entry added), **or** a+ dedicated section within `three-token.js` if the team prefers one page. Decide based on the task+ doc; default to a dedicated section to avoid page sprawl unless the doc says otherwise.+2. Render, from the C1 store:+ - The protocol revenue-share pool (USD), pool %, total holders, per-token yield (from+ `revenueShare`).+ - **The viewer's accrued share** = their $THREE `position.amount` × `per_token_yield` (or the+ correct formula per the endpoint's fields). Show amount + USD, with an honest "estimated+ accrual" label and a short explainer of how it's computed.+ - Historical/over-time context if the activity feed supports it (reuse `activity`).+3. **States:** signed-out (CTA to connect), holding-zero (CTA to acquire $THREE), loading skeleton,+ error. The "claiming coming" note where a claim would eventually live.+4. **Motion + a11y + responsive** per CLAUDE.md.++## Acceptance criteria++- [ ] The surface shows the real pool math + the viewer's **estimated accrued** share from their+ actual position (via the C1 store).+- [ ] No claim transaction exists; any claim affordance is honestly labeled "coming"/disabled.+- [ ] All states designed (signed-out / zero / loading / error); responsive; accessible.+- [ ] No duplicate revenue-share fetching — all via the C1 store.+- [ ] No console errors; numbers trace to `/api/three-token/revenue-share` + `/api/wallet/balances`.++## Verification++1. `npm run dev`; open the rewards surface.+2. Connected holder: accrued share = position × yield, USD correct, "estimated/coming" labeling+ present.+3. Signed-out and zero-balance states render their CTAs.+4. Confirm there is no network call or button that attempts a non-existent claim.+5. `npx vitest run` for any new tests.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Only $THREE. **No fake claim.** Honesty over polish — label+estimates as estimates. Design every state.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/C5-rewards-surface.md`.+3. Commit your code **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "feat(holder): honest revenue-share accrual surface via shared store; close C5"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/C6-three-live-reconcile.md b/tasks/week-2026-06-08/C6-three-live-reconcile.mdnew file mode 100644index 000000000..08b394d51--- /dev/null+++ b/tasks/week-2026-06-08/C6-three-live-reconcile.md@@ -0,0 +1,68 @@+# C6 — Reconcile + polish `/three-live` against Task 13 (don't rebuild it)++**Track:** C — build next · **Priority:** P3 · **Effort:** ~half day · **Depends on:** none+(optionally adopts the **C1** store)++## Context++`tasks/wow-sprint/13-onchain-activity-visualization.md` specs a reactive 3D onchain-activity+visualization, and points at `pages/pump-visualizer.html`. But the real $THREE implementation+already exists and is **~80% done**: `pages/three-live.html` ("$THREE Live · Protocol Pulse",+routed at `/three-live` in `vite.config.js`) — a Three.js scene with an `EventSource` trade stream,+particle bursts, whale shockwaves, a reconnect loop, `prefers-reduced-motion` handling, a+`requestAnimationFrame` loop, and a HUD reading `/api/three-token/stats` + `/api/agents/pumpfun-feed`.++Meanwhile `pages/pump-visualizer.html` (routed at `/pump-visualizer`) is a separate **generic**+pump.fun visualizer, not $THREE-scoped. **Do not build a third scene, and do not fork.**++## What to do (reconcile, then polish)++1. **Read both** `pages/three-live.html` and `pages/pump-visualizer.html`, plus+ `tasks/wow-sprint/13-onchain-activity-visualization.md`. Produce (in your commit message or a+ short note) a clear statement of what Task 13 asked for vs what `three-live.html` already+ delivers — i.e. **close the gap, don't restart**.+2. **Decide the canonical surface.** `three-live.html` is the $THREE one — treat it as canonical.+ If `pump-visualizer.html` overlaps and is redundant/unmaintained, either keep it explicitly as+ the generic-token tool (clearly distinct) or, if it's dead, propose removing it (don't delete+ without confirming it's unreferenced — check `vite.config.js`, nav, and links first).+3. **Polish `three-live.html` to fully satisfy Task 13's checklist:** verify every item the doc+ lists is present and working — reactive intensity tied to real trade volume, whale emphasis,+ reduced-motion path, reconnect resilience, empty/idle state when no trades, HUD accuracy, mobile+ behavior, and accessibility. Fix whatever is missing or rough.+4. **Optional:** retrofit the HUD to read from the **C1** store (`src/pump/three-token-data.js`)+ instead of its own `/api/three-token/stats` fetch, for consistency. Only if C1 is merged and it's+ a clean swap.+5. **Cross-link** `/three-live` from the holder dashboard / token page / nav so it's discoverable+ (it's a screenshot-worthy surface — make sure people can find it).++## Acceptance criteria++- [ ] A written reconciliation of Task 13 vs `three-live.html` (what was already done, what you+ closed) is captured in the commit message.+- [ ] Every Task 13 checklist item is satisfied by `three-live.html` (verified, not assumed).+- [ ] No third/forked scene introduced; `pump-visualizer.html`'s status (kept-as-generic or+ proposed-for-removal) is resolved explicitly.+- [ ] Idle/empty (no trades), reconnect, and reduced-motion states all work; mobile + a11y verified.+- [ ] `/three-live` is reachable from at least one holder surface + nav.+- [ ] No console errors; the trade stream shows real activity and reconnects cleanly.++## Verification++1. `npm run dev`; open `/three-live`. Confirm real trades animate, whales emphasized, HUD matches+ `/api/three-token/stats`.+2. Force-disconnect the stream → confirm reconnect; idle period → confirm the no-trades state.+3. Toggle `prefers-reduced-motion` → confirm the reduced path. Test on a narrow viewport.+4. Confirm the cross-links resolve.++## Rules++Obey [CLAUDE.md](../../CLAUDE.md). Only $THREE on this surface. Real trade stream — no synthetic+activity. Don't duplicate an existing surface.++## Completion protocol++1. Re-read your diff (`git diff`) and confirm every line is justified.+2. Delete this file: `tasks/week-2026-06-08/C6-three-live-reconcile.md`.+3. Commit your code **and** this file's deletion together, e.g.:+ `git add -A && git commit -m "polish(three-live): satisfy Task 13 checklist + reconcile vs pump-visualizer; close C6"`+4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/README.md b/tasks/week-2026-06-08/README.mdnew file mode 100644index 000000000..6620bfc97--- /dev/null+++ b/tasks/week-2026-06-08/README.md@@ -0,0 +1,59 @@+# Week of 2026-06-08 — Task Board++Source of truth for this week's work. Derived from a full-codebase audit on 2026-06-08:+production logs (Jun 6–7 export), an incomplete-feature/rule-violation sweep, the API+surface map, and the roadmap backlog.++Each file in this directory is a **self-contained prompt for one agent**. An agent should:++1. Read exactly one task file.+2. Complete it fully and professionally, obeying [CLAUDE.md](../../CLAUDE.md).+3. Verify the work (build/tests/manual as specified in the task).+4. **Delete the task file it just read** as the final step (see each task's "Completion protocol").+5. Commit the change **and** the file deletion together. Do **not** push — pushes are the human's call.++No mocks, no stubs, no placeholders, no TODOs. The only coin that may ever appear anywhere+is `$THREE` (`FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`).++---++## Tasks++| ID | Title | Track | Priority | Depends on | Effort |+|----|-------|-------|----------|------------|--------|+| A1 | `/api/pump/curve` 404 + RPC storm | A — prod fire | P0 | — | 2–3h |+| A2 | `/api/chat` 502s — harden LLM fallback chain | A — prod fire | P0 | — | ~half day |+| A3 | Forge `views_used` migration not applied in prod | A — prod fire | P1 | — | 30m–1h |+| A4 | `/api/pump/by-agent` 500 — add UUID guard | A — prod fire | P1 | — | 1–2h |+| A5 | Neon cold-start failures (auto-agent + seed) | A — prod fire | P2 | — | 2–4h |+| B1 | Coin-purity sweep — purge all non-$THREE tokens | B — complete | P0 | — | 2–3h |+| B2 | EVM marketplace purchase confirmation (501 dead-end) | B — complete | P1 | — | 1–2 days |+| B3 | Remove/implement empty `skill-collection.js` | B — complete | P2 | — | 30m–2h |+| B4 | Docs + CI hygiene (texture worker, zero-byte guard) | B — complete | P2 | — | 2–3h |+| C1 | `three-token-data.js` shared hook (keystone) | C — build | P1 | — | ~half day |+| C2 | $THREE holder "your position" widget (Task 14) | C — build | P1 | C1 | 1 day |+| C3 | Holder leaderboard + endpoint + gated 3D badge (Task 15) | C — build | P1 | C1 | 1–2 days |+| C4 | $THREE token page upgrade (Task 16) | C — build | P2 | C1 | 1–2 days |+| C5 | Holder rewards / revenue-share surface (Task 17) | C — build | P2 | C1 | 1 day |+| C6 | Reconcile + polish `/three-live` (Task 13) | C — build | P3 | — | half day |++## Recommended order++- **Day 1 (parallel):** A1, A2, A3, B1 — independent, low-risk, highest impact.+- **Day 2:** A4, A5, B3, B4 — cleanup; start **C1** (keystone).+- **Day 3+:** C2 and C3 in parallel once C1 lands; B2 in its own lane; then C4/C5; C6 last.++## Dependency notes++- **C2, C4, C5 all consume the C1 hook.** Do not start them before C1 is merged, or they will+ re-implement $THREE data fetching and drift.+- **C3** depends on C1 only for the client surface; its new `?action=leaderboard` endpoint is+ independent and can be built in parallel.+- **A2 has an operational prerequisite** (confirm `ANTHROPIC_API_KEY` is set in Vercel prod) that+ the human must verify — see the task.++## Hard correctness flag for Track C++There is **no on-chain rewards/claim program** in `contracts/`. `/api/three-token/revenue-share`+returns pro-rata *math*, not a claimable balance. C5 must be an accrual/calculator surface that+labels claiming as "coming" — do **not** wire a claim button with no backing program.diff --git a/tests/pump-swap-ix.test.js b/tests/pump-swap-ix.test.jsindex f5e290a6d..58227de28 100644--- a/tests/pump-swap-ix.test.js+++ b/tests/pump-swap-ix.test.js@@ -36,6 +36,7 @@ vi.mock('@pump-fun/pump-sdk', async (importOriginal) => {const {buildPumpSwapInnerIx,BUY_EXACT_QUOTE_IN_V2_DISCRIMINATOR,+ BUYBACK_FEE_RECIPIENTS,PUMP_PROGRAM_ID,} = await import('../api/_lib/pump-swap-ix.js');const {@@ -255,6 +256,46 @@ describe('buildPumpSwapInnerIx', () => {expect(signerIdxs).toEqual([13]);});+ it('selects the buyback fee recipient from on-chain global.buybackFeeRecipients when present', async () => {+ // The program validates `buyback_fee_recipient` against the live Global+ // config, so a single-entry on-chain list must win over the static fallback.+ const onchainBuyback = new PublicKey('3BpXnfJaUTiwXnJNe7Ej1rcbzqTTQUvLShZaWazebsVR');+ mockDecodeGlobal.mockReturnValueOnce({+ feeRecipient: FEE_RECIPIENT,+ feeRecipients: [],+ reservedFeeRecipient: FEE_RECIPIENT,+ reservedFeeRecipients: [],+ buybackFeeRecipients: [onchainBuyback],+ });+ const { accounts } = await buildPumpSwapInnerIx({+ mint: MINT,+ currency: CURRENCY,+ amountIn: 1_000_000n,+ minAmountOut: 0n,+ cluster: 'devnet',+ connection: fakeConnection(),+ });+ // account 8 (0-based) = buyback_fee_recipient per the buy_exact_quote_in_v2 IDL.+ expect(accounts[8].pubkey.equals(onchainBuyback)).toBe(true);+ // account 9 = its associated quote ATA, owned by that same recipient.+ const expectedAta = getAssociatedTokenAddressSync(CURRENCY, onchainBuyback, true, TOKEN_PROGRAM_ID);+ expect(accounts[9].pubkey.equals(expectedAta)).toBe(true);+ });++ it('falls back to the static buyback list when global omits buybackFeeRecipients', async () => {+ // setDecodedDefaults() (beforeEach) provides no buybackFeeRecipients and+ // Math.random is pinned to 0, so the fallback picks BUYBACK_FEE_RECIPIENTS[0].+ const { accounts } = await buildPumpSwapInnerIx({+ mint: MINT,+ currency: CURRENCY,+ amountIn: 1_000_000n,+ minAmountOut: 0n,+ cluster: 'devnet',+ connection: fakeConnection(),+ });+ expect(accounts[8].pubkey.equals(BUYBACK_FEE_RECIPIENTS[0])).toBe(true);+ });+it('throws when the bonding curve has graduated', async () => {mockDecodeBondingCurve.mockReturnValueOnce({complete: true,