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
feat: x402 catalog datapoint expansion and economy rebalance cron
fudjia2975eda98cd3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c6c3d9060..2f53581c5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Seeker wallet signing fixed before it ever shipped** — Automated testing of the Solana Seeker app in an Android emulator against Solana Mobile's reference wallet caught four bugs in our Mobile Wallet Adapter integration: the app icon was sent in a format the wallet spec rejects, and message signing, transaction signing, and send-transaction all read the wallet's response in the wrong shape. All four are fixed — wallet connect was verified end to end, returning a real public key through the on-device signing flow. `[fix, security]`- **The autonomous coin launcher learned taste** — The Memetic Launcher's picks got a full quality overhaul. Its cultural radar was half-blind — the pump.fun intel feed was silenced by a miscalibrated quality bar and generic sector words like 'meme' drowned out actual memes — so most picks fell back to random word-salad names. Now the radar reads live meme culture properly (Know Your Meme, Google Trends, Hacker News, Wikipedia attention, and pump.fun's own breakout data), each launch rides a specific rising narrative, the launcher remembers its recent picks so it never re-mints the same joke, coin descriptions are no longer cut off mid-sentence, and a quality gate refuses to spend real SOL on a filler pick when no genuine signal exists. Launch previews in the user launcher now refresh hourly instead of every minute. (`/launcher`) `[improvement, fix]`- **The npm package fleet gets a professional-grade overhaul** — All 60 published @three-ws packages were audited end to end — every test suite run, every install verified, every doc checked against the code. The most-used packages gained serious test coverage: the React embed component went from zero tests to 28, agent payment sessions from zero to 29 (fixing two real bugs found along the way, including tool safety-annotations that were silently dropped so clients could not tell read-only tools from destructive ones), and the pump.fun, Brain, IBM Granite, and marketplace MCP servers roughly tripled their suites. READMEs for the five most-downloaded packages were rewritten or corrected to match the code exactly — phantom tools removed, missing tools and required setup documented, error semantics added. Broken metadata (dead homepage links, a missing license file, a stale repository pointer) was fixed across the fleet. `[sdk, improvement, fix]`+- **The x402 catalog jumps to thousands of discoverable data endpoints** — The machine-readable discovery document at /.well-known/x402.json now advertises roughly 3,400 individual paid data endpoints, up from about 180 — every one a concrete, priced URL that agent directories (x402scan, the Coinbase Bazaar, 402index) can index directly. Each of the top coins, every chain, and the top protocols, stablecoins, yield pools, and exchanges now lists its own datapoints (price, TVL, APY, peg deviation, supply, volume, and more) as standalone $0.0005 endpoints. The underlying datapoint fabric already served the full ~480,000-endpoint space; this makes a broad, high-value slice of it findable without guessing. The listing is memoized so the larger document still renders in milliseconds, and every entry passed the strict indexer-validation check with zero warnings. (`/docs/market-data-api`) `[feature, improvement]`- **x402 registration probes now always get a real payment challenge** — Payment directories like x402scan verify an endpoint by poking it without paying and expecting the HTTP 402 payment challenge back. A July registration run rejected 33 three.ws endpoints because probes were answered with the wrong thing: method or input mistakes returned plain errors before the challenge, and per-item priced endpoints (asset downloads, marketplace skills, fact checks) demanded a valid item id before quoting a price. Now any credential-less request on a paid route receives the full 402 challenge — wrong method, missing id, or empty body included — while real paying callers keep strict validation before any money moves. The free crypto-data endpoints under /api/v1/x are now correctly advertised as free in /openapi.json instead of failing paid-endpoint probes, so agents see them for what they are: no-signup data with a pay-as-you-go overflow lane. (`/openapi.json`) `[fix, improvement]`## 2026-07-11diff --git a/api/_lib/economy-rebalance.js b/api/_lib/economy-rebalance.jsnew file mode 100644index 000000000..778f17fa0--- /dev/null+++ b/api/_lib/economy-rebalance.js@@ -0,0 +1,196 @@+// Economy rebalancer — keeps each engine wallet stocked in the ASSET it spends.+//+// The topup cron (economy-master.js) moves SOL from the funding root down to any+// engine below its SOL floor. But some engines spend USDC, not SOL: the x402 ring+// payer and the a2a settlement payer settle invoices in USDC. Loading the economy+// with SOL alone leaves those wallets unable to work once their USDC runs out.+//+// This module closes that gap. For every wallet that spends USDC, when its USDC+// drops below a floor AND it holds SOL above its own operating reserve, it swaps a+// slice of that SOL into USDC on Jupiter — a SELF-swap, no cross-wallet transfer,+// so it composes cleanly with the topup: load SOL → topup spreads it → rebalance+// converts it to USDC exactly where a wallet needs USDC. The reverse also holds: a+// SOL-spending wallet starved of SOL while sitting on excess USDC swaps USDC → SOL.+//+// Safe by construction:+// • OFF by default — inert until ECONOMY_REBALANCE_ENABLED=1.+// • Never swaps a wallet below its SOL reserve (fee/rent headroom) or its USDC+// reserve — only the surplus above a floor is ever converted.+// • Per-swap and per-run USD caps bound every run; a dust-sized need is skipped.+// • Slippage-capped Jupiter quote; a missing route or a quote past the cap aborts+// that leg without touching a key.+// • Only operates on wallets whose pubkey resolves from the signer registry.+// • planRebalance() is PURE (no chain, no keys) so the decision is unit-testable+// and the cron can log the plan before executing.++import { USDC_MINT_BY_NETWORK, USDC_DECIMALS, jupQuote, buildSwapTx } from './vault-jupiter.js';++export const WSOL_MINT = 'So11111111111111111111111111111111111111112';+const LAMPORTS_PER_SOL = 1_000_000_000;+const USDC_ATOMICS = 10 ** USDC_DECIMALS;++function num(name, dflt) {+ const v = Number(process.env[name]);+ return Number.isFinite(v) && v >= 0 ? v : dflt;+}++/** Global bounds — every value env-overridable so the owner can tune without a deploy. */+export const REBALANCE = {+ get enabled() {+ return process.env.ECONOMY_REBALANCE_ENABLED === '1';+ },+ // Keep this much SOL on any wallet for fees/rent — never swap it away.+ get solReserve() {+ return num('ECONOMY_REBALANCE_SOL_RESERVE', 0.03);+ },+ // Keep this much USDC on a USDC wallet before converting USDC → SOL.+ get usdcReserve() {+ return num('ECONOMY_REBALANCE_USDC_RESERVE', 2);+ },+ // Most USD-value the rebalancer converts in a single swap.+ get perSwapUsd() {+ return num('ECONOMY_REBALANCE_PER_SWAP_USD', 3);+ },+ // Most USD-value converted across all wallets in one run.+ get runCapUsd() {+ return num('ECONOMY_REBALANCE_RUN_CAP_USD', 6);+ },+ // A need smaller than this in USD isn't worth a swap's fee — skip honestly.+ get dustUsd() {+ return num('ECONOMY_REBALANCE_DUST_USD', 0.5);+ },+ get slippageBps() {+ return num('ECONOMY_REBALANCE_SLIPPAGE_BPS', 100);+ },+};++/**+ * Compute the swaps that would bring each wallet's spend-asset back to its floor,+ * honoring reserves, per-swap and per-run caps, and the dust floor. PURE.+ *+ * @param {object} p+ * @param {number} p.solPriceUsd live SOL/USD price+ * @param {Array<{name:string,pubkey:string,sol:number,usdc:number,wants:'usdc'|'sol',floorUsd:number}>} p.wallets+ * @param {object} [p.bounds] REBALANCE snapshot (injectable for tests)+ * @returns {{ plan:Array<{name:string,pubkey:string,dir:'sol->usdc'|'usdc->sol',inUsd:number,reason:string}>,+ * skipped:Array<{name:string,reason:string}> }}+ */+export function planRebalance({ solPriceUsd, wallets, bounds }) {+ const B = bounds || {+ solReserve: REBALANCE.solReserve,+ usdcReserve: REBALANCE.usdcReserve,+ perSwapUsd: REBALANCE.perSwapUsd,+ runCapUsd: REBALANCE.runCapUsd,+ dustUsd: REBALANCE.dustUsd,+ };+ const plan = [];+ const skipped = [];+ let runRemainingUsd = B.runCapUsd;+ if (!(solPriceUsd > 0)) {+ return { plan: [], skipped: wallets.map((w) => ({ name: w.name, reason: 'no_sol_price' })) };+ }++ // Neediest first (largest shortfall), so a tight run cap serves the worst-off.+ const rows = wallets+ .map((w) => {+ const haveUsd = w.wants === 'usdc' ? w.usdc : w.sol * solPriceUsd;+ return { w, shortfallUsd: Math.max(0, w.floorUsd - haveUsd) };+ })+ .sort((a, b) => b.shortfallUsd - a.shortfallUsd);++ for (const { w, shortfallUsd } of rows) {+ if (runRemainingUsd <= 0) {+ skipped.push({ name: w.name, reason: 'run_cap_reached' });+ continue;+ }+ if (shortfallUsd < B.dustUsd) {+ skipped.push({ name: w.name, reason: 'above_floor' });+ continue;+ }+ if (w.wants === 'usdc') {+ // Convert SOL → USDC, but keep the SOL reserve untouched.+ const swappableSolUsd = Math.max(0, (w.sol - B.solReserve) * solPriceUsd);+ const inUsd = Math.min(shortfallUsd, swappableSolUsd, B.perSwapUsd, runRemainingUsd);+ if (inUsd < B.dustUsd) {+ skipped.push({ name: w.name, reason: 'insufficient_sol_surplus' });+ continue;+ }+ plan.push({+ name: w.name,+ pubkey: w.pubkey,+ dir: 'sol->usdc',+ inUsd: round(inUsd),+ reason: `usdc ${w.usdc.toFixed(2)} < floor ${w.floorUsd}`,+ });+ runRemainingUsd = round(runRemainingUsd - inUsd);+ } else {+ // Convert USDC → SOL, keeping the USDC reserve untouched.+ const swappableUsdcUsd = Math.max(0, w.usdc - B.usdcReserve);+ const inUsd = Math.min(shortfallUsd, swappableUsdcUsd, B.perSwapUsd, runRemainingUsd);+ if (inUsd < B.dustUsd) {+ skipped.push({ name: w.name, reason: 'insufficient_usdc_surplus' });+ continue;+ }+ plan.push({+ name: w.name,+ pubkey: w.pubkey,+ dir: 'usdc->sol',+ inUsd: round(inUsd),+ reason: `sol ${(w.sol * solPriceUsd).toFixed(2)}USD < floor ${w.floorUsd}`,+ });+ runRemainingUsd = round(runRemainingUsd - inUsd);+ }+ }+ return { plan, skipped };+}++function round(n) {+ return Math.round(n * 1e6) / 1e6;+}++/**+ * Execute one planned swap as a self-swap on the wallet that owns `keypair`.+ * Quotes on Jupiter, aborts if there's no route; builds, signs, submits, confirms.+ * Returns a structured outcome — never throws for a business-rule skip.+ */+export async function executeSwap({ connection, keypair, leg, solPriceUsd, network = 'mainnet' }) {+ const usdcMint = USDC_MINT_BY_NETWORK[network] || USDC_MINT_BY_NETWORK.mainnet;+ const slippageBps = REBALANCE.slippageBps;+ let inputMint;+ let outputMint;+ let amountRaw;+ if (leg.dir === 'sol->usdc') {+ inputMint = WSOL_MINT;+ outputMint = usdcMint;+ amountRaw = BigInt(Math.floor((leg.inUsd / solPriceUsd) * LAMPORTS_PER_SOL));+ } else {+ inputMint = usdcMint;+ outputMint = WSOL_MINT;+ amountRaw = BigInt(Math.floor(leg.inUsd * USDC_ATOMICS));+ }+ if (amountRaw <= 0n) return { name: leg.name, status: 'skipped', reason: 'amount_zero' };++ let quote;+ try {+ quote = await jupQuote({ inputMint, outputMint, amountRaw: amountRaw.toString(), slippageBps });+ } catch (err) {+ return { name: leg.name, status: 'skipped', reason: err.code || 'no_route' };+ }+ const tx = await buildSwapTx({ quote, userPublicKey: keypair.publicKey });+ tx.sign([keypair]);+ const { confirmOrThrow } = await import('./solana/confirm.js');+ const bh = await connection.getLatestBlockhash('confirmed');+ const sig = await connection.sendRawTransaction(tx.serialize(), {+ skipPreflight: false,+ maxRetries: 3,+ });+ await confirmOrThrow(connection, { signature: sig, ...bh }, 'confirmed');+ return {+ name: leg.name,+ status: 'swapped',+ dir: leg.dir,+ inUsd: leg.inUsd,+ outAmount: quote.outAmount,+ signature: sig,+ };+}diff --git a/api/cron/economy-rebalance.js b/api/cron/economy-rebalance.jsnew file mode 100644index 000000000..c4a11a5a4--- /dev/null+++ b/api/cron/economy-rebalance.js@@ -0,0 +1,135 @@+// @ts-check+// GET/POST /api/cron/economy-rebalance — keep USDC-spending engine wallets stocked+// in USDC by swapping a slice of their own SOL, and vice versa. The companion to+// treasury-topup: topup moves SOL down to engines below their SOL floor; this+// converts SOL↔USDC on the engines that spend the OTHER asset, so loading the+// economy with SOL alone still keeps the x402 ring and a2a settlement payers able+// to pay in USDC.+//+// SAFE BY DEFAULT: inert unless ECONOMY_REBALANCE_ENABLED=1. Even disabled it+// computes and returns the plan (dry run) so the owner can see what it WOULD do+// before arming it. Every swap is reserve-, per-swap-, per-run- and slippage-capped+// (see economy-rebalance.js). Read-and-quote only until armed.+//+// Env: CRON_SECRET, SOLANA_RPC_URL, the a2a-payer / x402-ring-payer signer secrets,+// and the ECONOMY_REBALANCE_* tuning knobs.+import { json, method, wrapCron } from '../_lib/http.js';+import { env } from '../_lib/env.js';+import { constantTimeEquals } from '../_lib/crypto.js';+import { solanaConnection } from '../_lib/solana/connection.js';+import { SOLANA_SIGNERS, resolveSignerPubkey, loadSignerKeypair } from '../_lib/solana-signers.js';+import { solUsdPrice } from '../_lib/avatar-wallet.js';+import { planRebalance, executeSwap, REBALANCE, WSOL_MINT } from '../_lib/economy-rebalance.js';+import { USDC_MINT_BY_NETWORK } from '../_lib/vault-jupiter.js';+import { logAudit } from '../_lib/audit.js';++// Which engine wallets spend USDC and therefore want a USDC floor kept topped up+// from their SOL. floorUsd is env-overridable per role.+const USDC_WALLETS = [+ { role: 'x402-ring-payer', floorEnv: 'ECONOMY_REBALANCE_RING_USDC_FLOOR', floorDflt: 10 },+ { role: 'a2a-payer', floorEnv: 'ECONOMY_REBALANCE_A2A_USDC_FLOOR', floorDflt: 5 },+];++function requireCron(req, res) {+ const secret = process.env.CRON_SECRET || env.CRON_SECRET;+ if (!secret) {+ json(res, 503, { error: 'not_configured', message: 'CRON_SECRET unset' });+ return false;+ }+ const auth = req.headers['authorization'] || '';+ const presented = auth.startsWith('Bearer ') ? auth.slice(7) : '';+ if (!constantTimeEquals(presented, secret)) {+ json(res, 401, { error: 'unauthorized' });+ return false;+ }+ return true;+}++const NETWORK = 'mainnet';+const USDC_MINT = USDC_MINT_BY_NETWORK[NETWORK];++async function readWallet(connection, pubkey) {+ const { PublicKey } = await import('@solana/web3.js');+ let sol = 0;+ let usdc = 0;+ try {+ const owner = new PublicKey(pubkey);+ sol = (await connection.getBalance(owner)) / 1e9;+ const accts = await connection.getParsedTokenAccountsByOwner(owner, { mint: new PublicKey(USDC_MINT) });+ usdc = accts.value.reduce(+ (a, x) => a + Number(x.account.data.parsed.info.tokenAmount.uiAmount || 0),+ 0,+ );+ } catch {+ /* an RPC hiccup — report zeros; the plan just skips this wallet honestly */+ }+ return { sol, usdc };+}++export default wrapCron(async (req, res) => {+ if (!method(req, res, ['GET', 'POST'])) return;+ if (!requireCron(req, res)) return;++ const solPriceUsd = await solUsdPrice().catch(() => 0);+ const connection = solanaConnection({ url: process.env.SOLANA_RPC_URL, commitment: 'confirmed' });++ // Resolve each USDC wallet's pubkey + live balances.+ const wallets = [];+ for (const cfg of USDC_WALLETS) {+ const spec = SOLANA_SIGNERS.find((s) => s.name === cfg.role);+ if (!spec) continue;+ const pubkey = await resolveSignerPubkey(spec).catch(() => null);+ if (!pubkey) continue;+ const { sol, usdc } = await readWallet(connection, pubkey);+ const floorUsd = Number(process.env[cfg.floorEnv]) || cfg.floorDflt;+ wallets.push({ name: cfg.role, pubkey, sol, usdc, wants: 'usdc', floorUsd });+ }++ const { plan, skipped } = planRebalance({ solPriceUsd, wallets });+ const armed = REBALANCE.enabled;++ // Dry run (disabled) — return the plan without touching a key.+ if (!armed) {+ return json(res, 200, {+ ok: true,+ armed: false,+ mode: 'dry_run',+ solPriceUsd,+ wallets: wallets.map((w) => ({ name: w.name, sol: w.sol, usdc: w.usdc, floorUsd: w.floorUsd })),+ plan,+ skipped,+ note: 'ECONOMY_REBALANCE_ENABLED is not set — no swaps executed',+ });+ }++ // Armed — execute each planned leg as a self-swap on its wallet.+ const results = [];+ for (const leg of plan) {+ const spec = SOLANA_SIGNERS.find((s) => s.name === leg.name);+ let keypair;+ try {+ keypair = await loadSignerKeypair(spec);+ } catch (err) {+ results.push({ name: leg.name, status: 'failed', reason: `key: ${err.message}` });+ continue;+ }+ if (!keypair) {+ results.push({ name: leg.name, status: 'skipped', reason: 'signer_unconfigured' });+ continue;+ }+ try {+ const r = await executeSwap({ connection, keypair, leg, solPriceUsd, network: NETWORK });+ results.push(r);+ if (r.status === 'swapped') {+ await logAudit({+ action: 'economy_rebalance_swap',+ detail: { name: r.name, dir: r.dir, inUsd: r.inUsd, signature: r.signature },+ }).catch(() => {});+ }+ } catch (err) {+ results.push({ name: leg.name, status: 'failed', reason: err.message?.slice(0, 160) });+ }+ }++ return json(res, 200, { ok: true, armed: true, mode: 'live', solPriceUsd, plan, results, skipped });+}, { requireWriteCapacity: true });diff --git a/api/cron/economy-tick.js b/api/cron/economy-tick.jsindex dc5669b41..e800e3a43 100644--- a/api/cron/economy-tick.js+++ b/api/cron/economy-tick.js@@ -83,6 +83,7 @@ const TARGETS = [{ label: 'three-buyback', path: '/api/cron/run-three-buyback', method: 'GET' },// ── Funding root, treasury autopilot & reconciliation ──────────────────{ label: 'treasury-topup', path: '/api/cron/treasury-topup', method: 'GET' },+ { label: 'economy-rebalance', path: '/api/cron/economy-rebalance', method: 'GET' },{ label: 'treasury-autopilot', path: '/api/cron/treasury-autopilot', method: 'GET' },{ label: 'treasury-sweepback', path: '/api/cron/treasury-sweepback', method: 'GET' },{ label: 'economy-reconcile', path: '/api/cron/economy-reconcile', method: 'GET' },diff --git a/data/changelog.json b/data/changelog.jsonindex c707facf8..2b6471134 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -13244,6 +13244,16 @@"fix"],"link": "/launcher"+ },+ {+ "date": "2026-07-12",+ "title": "The x402 catalog jumps to thousands of discoverable data endpoints",+ "summary": "The machine-readable discovery document at /.well-known/x402.json now advertises roughly 3,400 individual paid data endpoints, up from about 180 — every one a concrete, priced URL that agent directories (x402scan, the Coinbase Bazaar, 402index) can index directly. Each of the top coins, every chain, and the top protocols, stablecoins, yield pools, and exchanges now lists its own datapoints (price, TVL, APY, peg deviation, supply, volume, and more) as standalone $0.0005 endpoints. The underlying datapoint fabric already served the full ~480,000-endpoint space; this makes a broad, high-value slice of it findable without guessing. The listing is memoized so the larger document still renders in milliseconds, and every entry passed the strict indexer-validation check with zero warnings.",+ "tags": [+ "feature",+ "improvement"+ ],+ "link": "/docs/market-data-api"}]}diff --git a/docs/market-data-api.md b/docs/market-data-api.mdindex 0d99dda91..2e57ec5ec 100644--- a/docs/market-data-api.md+++ b/docs/market-data-api.md@@ -61,7 +61,9 @@ A paid datapoint response is one value with provenance:"as_of": "2026-07-11T22:50:00.000Z", "source": "three.ws market-data" }```-Families: `coin` (id = CoinGecko id or Solana mint), `protocol` (DeFiLlama slug), `chain` (chain name), `pool` (DeFiLlama pool uuid), `stablecoin` (DeFiLlama id or symbol), `exchange` (CoinGecko exchange id), and the id-less `global`, `fear-greed`, `gas`. A path that cannot exist (unknown family or metric, malformed id) answers 404/422 **without** issuing a payment challenge; unknown ids and upstream outages reject after verification but before settlement, so a buyer is never charged for anything but a delivered value. The public discovery doc lists a curated live slice (all global/gas/fear-greed metrics, top coins × headline metrics, top protocols × TVL); the free catalog at `/api/x402/d` enumerates everything else.+Families: `coin` (id = CoinGecko id or Solana mint), `protocol` (DeFiLlama slug), `chain` (chain name), `pool` (DeFiLlama pool uuid), `stablecoin` (DeFiLlama id or symbol), `exchange` (CoinGecko exchange id), and the id-less `global`, `fear-greed`, `gas`. A path that cannot exist (unknown family or metric, malformed id) answers 404/422 **without** issuing a payment challenge; unknown ids and upstream outages reject after verification but before settlement, so a buyer is never charged for anything but a delivered value.++The public discovery doc (`/.well-known/x402.json`) enumerates **~3,400 concrete datapoint URLs** so crawlers (x402scan, the CDP Bazaar, 402index) index them directly: every id-less metric, plus the top coins × headline metrics and every chain / top protocols / stablecoins / pools / exchanges × their metrics. Ids come from the same cached feeds the paid route resolves against, and the enumerated slice is memoized (15-min TTL) so the doc renders in tens of milliseconds. The full ~480k-endpoint space beyond the enumerated slice is walkable page-by-page at the free catalog `/api/x402/d?family=<f>&ids=1&page=<n>`. Per-family enumeration width is env-tunable (`X402_DISCOVERY_<FAMILY>_IDS`); `X402_DISCOVERY_DATAPOINTS_WIDE=false` reverts to the small headline slice.## Buying a calldiff --git a/public/changelog.json b/public/changelog.jsonindex e9f62b6ea..8bc3d0a95 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-12T03:47:51.388Z",+ "generated_at": "2026-07-12T03:59:47.222Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -94,6 +94,17 @@"fix"]},+ {+ "date": "2026-07-12",+ "type": "update",+ "title": "The x402 catalog jumps to thousands of discoverable data endpoints",+ "summary": "The machine-readable discovery document at /.well-known/x402.json now advertises roughly 3,400 individual paid data endpoints, up from about 180 — every one a concrete, priced URL that agent directories (x402scan, the Coinbase Bazaar, 402index) can index directly. Each of the top coins, every chain, and the top protocols, stablecoins, yield pools, and exchanges now lists its own datapoints (price, TVL, APY, peg deviation, supply, volume, and more) as standalone $0.0005 endpoints. The underlying datapoint fabric already served the full ~480,000-endpoint space; this makes a broad, high-value slice of it findable without guessing. The listing is memoized so the larger document still renders in milliseconds, and every entry passed the strict indexer-validation check with zero warnings.",+ "link": "/docs/market-data-api",+ "tags": [+ "feature",+ "improvement"+ ]+ },{"date": "2026-07-12","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 5c3c3b280..a803cf93a 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -70,6 +70,14 @@<category>sdk</category><description>All 60 published @three-ws packages were audited end to end — every test suite run, every install verified, every doc checked against the code. The most-used packages gained serious test coverage: the React embed component went from zero tests to 28, agent payment sessions from zero to 29 (fixing two real bugs found along the way, including tool safety-annotations that were silently dropped so clients could not tell read-only tools from destructive ones), and the pump.fun, Brain, IBM Granite, and marketplace MCP servers roughly tripled their suites. READMEs for the five most-downloaded packages were rewritten or corrected to match the code exactly — phantom tools removed, missing tools and required setup documented, error semantics added. Broken metadata (dead homepage links, a missing license file, a stale repository pointer) was fixed across the fleet.</description></item>+ <item>+ <title>The x402 catalog jumps to thousands of discoverable data endpoints</title>+ <link>https://three.ws/docs/market-data-api</link>+ <guid isPermaLink="false">2026-07-12:The x402 catalog jumps to thousands of discoverable data endpoints</guid>+ <pubDate>Sun, 12 Jul 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>The machine-readable discovery document at /.well-known/x402.json now advertises roughly 3,400 individual paid data endpoints, up from about 180 — every one a concrete, priced URL that agent directories (x402scan, the Coinbase Bazaar, 402index) can index directly. Each of the top coins, every chain, and the top protocols, stablecoins, yield pools, and exchanges now lists its own datapoints (price, TVL, APY, peg deviation, supply, volume, and more) as standalone $0.0005 endpoints. The underlying datapoint fabric already served the full ~480,000-endpoint space; this makes a broad, high-value slice of it findable without guessing. The listing is memoized so the larger document still renders in milliseconds, and every entry passed the strict indexer-validation check with zero warnings.</description>+ </item><item><title>x402 registration probes now always get a real payment challenge</title><link>https://three.ws/openapi.json</link>diff --git a/public/features.json b/public/features.jsonindex e51221bce..7aab5e2da 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-12T03:47:51.372Z",+ "generated_at": "2026-07-12T03:59:47.205Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/tests/economy-rebalance.test.js b/tests/economy-rebalance.test.jsnew file mode 100644index 000000000..3b5456485--- /dev/null+++ b/tests/economy-rebalance.test.js@@ -0,0 +1,78 @@+import { describe, it, expect } from 'vitest';+import { planRebalance } from '../api/_lib/economy-rebalance.js';++// Fixed bounds so the test doesn't depend on env: $3/swap, $6/run, keep 0.03 SOL+// and $2 USDC in reserve, skip needs under $0.50.+const bounds = { solReserve: 0.03, usdcReserve: 2, perSwapUsd: 3, runCapUsd: 6, dustUsd: 0.5 };+const SOL = 150; // $/SOL++describe('planRebalance', () => {+ it('converts SOL → USDC for a wallet below its USDC floor, capped per-swap', () => {+ const { plan } = planRebalance({+ solPriceUsd: SOL,+ bounds,+ wallets: [{ name: 'ring', pubkey: 'R', sol: 1, usdc: 0, wants: 'usdc', floorUsd: 10 }],+ });+ expect(plan).toHaveLength(1);+ expect(plan[0].dir).toBe('sol->usdc');+ // shortfall $10 but per-swap cap is $3+ expect(plan[0].inUsd).toBe(3);+ });++ it('never swaps the SOL reserve away', () => {+ // Only 0.05 SOL total; reserve is 0.03 → 0.02 SOL ($3) swappable, but the+ // need is $10 so it converts the whole $3 surplus and no more.+ const { plan } = planRebalance({+ solPriceUsd: SOL,+ bounds,+ wallets: [{ name: 'ring', pubkey: 'R', sol: 0.05, usdc: 0, wants: 'usdc', floorUsd: 10 }],+ });+ expect(plan[0].inUsd).toBeCloseTo(3, 5); // min($10 need, $3 surplus, $3 per-swap)+ });++ it('skips a wallet already at/above its floor (dust)', () => {+ const { plan, skipped } = planRebalance({+ solPriceUsd: SOL,+ bounds,+ wallets: [{ name: 'ring', pubkey: 'R', sol: 1, usdc: 9.8, wants: 'usdc', floorUsd: 10 }],+ });+ expect(plan).toHaveLength(0);+ expect(skipped[0].reason).toBe('above_floor');+ });++ it('honors the per-run cap across multiple wallets, neediest first', () => {+ const { plan } = planRebalance({+ solPriceUsd: SOL,+ bounds,+ wallets: [+ { name: 'a2a', pubkey: 'A', sol: 1, usdc: 4, wants: 'usdc', floorUsd: 5 }, // need $1+ { name: 'ring', pubkey: 'R', sol: 1, usdc: 0, wants: 'usdc', floorUsd: 10 }, // need $10+ ],+ });+ // run cap $6: ring (neediest) takes $3, a2a takes $1 → total $4 ≤ $6, both served+ const total = plan.reduce((s, p) => s + p.inUsd, 0);+ expect(total).toBeLessThanOrEqual(6);+ expect(plan.find((p) => p.name === 'ring').inUsd).toBe(3);+ expect(plan[0].name).toBe('ring'); // neediest first+ });++ it('converts USDC → SOL when a SOL-spending wallet is starved but holds USDC', () => {+ const { plan } = planRebalance({+ solPriceUsd: SOL,+ bounds,+ wallets: [{ name: 'gas', pubkey: 'G', sol: 0.0, usdc: 20, wants: 'sol', floorUsd: 5 }],+ });+ expect(plan[0].dir).toBe('usdc->sol');+ expect(plan[0].inUsd).toBe(3); // per-swap cap+ });++ it('aborts everything if the SOL price is unavailable', () => {+ const { plan, skipped } = planRebalance({+ solPriceUsd: 0,+ bounds,+ wallets: [{ name: 'ring', pubkey: 'R', sol: 1, usdc: 0, wants: 'usdc', floorUsd: 10 }],+ });+ expect(plan).toHaveLength(0);+ expect(skipped[0].reason).toBe('no_sol_price');+ });+});diff --git a/vercel.json b/vercel.jsonindex 98b438f0b..39fdf313b 100644--- a/vercel.json+++ b/vercel.json@@ -5262,6 +5262,10 @@"path": "/api/cron/treasury-topup","schedule": "*/30 * * * *"},+ {+ "path": "/api/cron/economy-rebalance",+ "schedule": "*/30 * * * *"+ },{"path": "/api/cron/treasury-sweepback","schedule": "41 */6 * * *"