Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: enhance price chart functionality and spawn logic

nirholas0403b43e9e33
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c352d1c88..997859818 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Coin intelligence engine now backs off cleanly when the database is full** — The pump.fun intelligence firehose — the engine behind the coin-intel feed, the smart-money leaderboard and the oracle scores — used to keep writing to the database even after it hit its storage cap, failing thousands of times an hour and burning compute on work that could never be saved. It now checks free space before each run and pauses ingestion while the automatic cleanup reclaims room, then resumes on its own. The result: the engine self-heals instead of storming its logs, and the feeds it powers recover cleanly the moment space frees up. `[infra]`
- **Every coin world now gets the full town experience** — The flagship town's whole cast and economy now travel to every coin world on /play. Walk into any community and you'll find the full crew of twelve townsfolk selling real paid services — market reads, fact checks, security scans, vanity addresses, 3D mesh forging, coin launches and more, each settled on-chain in USDC — plus the ORACLE and NOVA agent exchange striking live x402 deals in the plaza, and an intel kiosk selling live market data for that world's own coin ($0.01 USDC, paid from your own wallet). The $THREE town keeps its signature frontier look and stays the front door of the metaverse. (`/play`) `[feature]`
- **Every pump.fun coin now has its own full Oracle page** — Opening a coin on Oracle used to give you a slide-over drawer, and the shareable link just bounced back into that drawer. Now every coin has a real standalone page at three.ws/oracle/coin/<mint> — and it resolves for any pump.fun mint, even a launch Oracle has never scored. Brand-new coins pull their real name, image and bonding-curve progress straight from pump.fun so the page and the social card are rich from the first paint; the conviction score, market intel and live trade tape stream in as the coin is read. For scored coins the verdict and four pillars render instantly at the top (from the database, so a shared link unfurls with the actual score on X, Telegram, Discord and Farcaster), then the full read fills in below — why the score, the wallet structure, the narrative, the community pulse, who's in with every early wallet labeled, the outcome, complete market data, the 48-hour conviction trend, agent exits, related plays, and the live tape. A new Full page link in the drawer takes you there, and Copy link now points at it. (`/oracle`) `[feature]`
+- **Hardened the economy's funding wallet so SOL can only reach platform wallets** — The platform runs a single master wallet that keeps every autonomous engine — x402 agent-to-agent payments, tips, coin launches — topped up with just enough SOL to operate. We tightened it so it can never leak funds: the funding wallet now enforces, in code, that SOL only ever moves to a wallet the platform holds the key for, never to an outside address and never to itself. There is no charity or user-payout path on it. It also always sends at the lowest available network fee, keeps a protected reserve, and caps how much can move per engine and per run. We also corrected the wallet address it was pinned to (a single-character case difference had it pointing at an empty account) and documented the whole system. `[security, infra, docs]`
- **Live agent screens now reach the 3D world, and coin art loads everywhere** — The in-world agent desk monitor in /play now renders the same live browser feed as the 2D watch panel and the live wall — previously it could only show the activity fallback because it listened on a stream that was never deployed. Coin art in the world lobby is now served through the platform's own image proxy, so tokens whose images live on flaky or retired IPFS/Arweave gateways still show their art instead of a broken tile. The paid crypto-intel feed also gained a second live price source, so a rate-limited upstream no longer makes paid calls fail — and if both sources are down you are never charged. Assorted console warnings from multiplayer connections closing mid-session are gone. (`/play`) `[fix, improvement]`
- **One funding wallet now keeps every economy engine topped up** — The platform's on-chain engines — the buyback relayer, coin-launch funder, treasury signers, subdomain minter and more — each hold their own small SOL balance to pay network fees. A new funding root now watches all of them and automatically tops up any that dip below their floor, from a single master wallet, every 30 minutes. It only ever sends to the platform's own registered engine wallets, never trades or launches, and is bounded by a reserve floor plus per-engine and per-sweep caps so it can't overspend. Until the master is funded it does nothing and the existing low-balance alerts keep running. `[infra]`
- **Oracle 3D graph is visible again** — The Oracle's 3D conviction graph — every scored coin as a sphere you can orbit, with size showing the conviction score and brightness showing the tier — was rendering as a black void: the spheres were lit only by a near-black ambient light and carried no glow of their own, so nothing showed even though the data was loading fine. Each coin now self-illuminates in its tier color and feeds the bloom pass, with real key and rim lighting giving the spheres depth. Prime coins burn brightest, and the whole constellation reads clearly against the dark backdrop. Open it from the Oracle's "3D graph" tab. (`/oracle`) `[fix]`
diff --git a/STRUCTURE.md b/STRUCTURE.md
index d518b2f55..ceb2dc3e7 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -40,6 +40,7 @@ bottom.
| MCP integration | [mcp-server/](mcp-server), [mcp-bridge/](mcp-bridge), [packages/*-mcp/](packages) | 31 npm servers + 6 hosted remote, all in the [MCP registry](https://registry.modelcontextprotocol.io/?q=io.github.nirholas) | Model Context Protocol surface — full server list in [docs/mcp.md](docs/mcp.md) |
| SNS naming + pay-by-name | [api/sns.js](api/sns.js), [api/sns-subdomain.js](api/sns-subdomain.js), [api/threews/subdomain.js](api/threews/subdomain.js), [api/x402/pay-by-name.js](api/x402/pay-by-name.js), [src/solana/sns-subdomain.js](src/solana/sns-subdomain.js), [pages/threews-claim.html](pages/threews-claim.html) | In-repo | `*.threews.sol` subdomain mint, x402 payments addressed by name. Env: `THREEWS_SOL_PARENT_SECRET_BASE58`. See [SNS_PARTNERSHIP_PROPOSAL.md](docs/internal/SNS_PARTNERSHIP_PROPOSAL.md) |
| Self-hosted x402 facilitator + ring economy | [api/x402-facilitator/[action].js](api/x402-facilitator/[action].js), [api/_lib/x402/self-facilitator.js](api/_lib/x402/self-facilitator.js), [api/x402/ring-settle.js](api/x402/ring-settle.js), [api/_lib/x402/pipelines/ring-rebalance.js](api/_lib/x402/pipelines/ring-rebalance.js), [api/x402-ring.js](api/x402-ring.js), [scripts/x402-ring-setup.mjs](scripts/x402-ring-setup.mjs) | In-repo (off by default) | Closed-loop agent-to-agent x402: platform wallets pay platform endpoints, settled in-house (no external facilitator). Fee-minimized, SOL-floor guarded, internal-labeled. Env: `X402_SELF_FACILITATOR_ENABLED`, `X402_FEE_PAYER_SECRET_BASE58`, `X402_TREASURY_SECRET_BASE58`. See [docs/x402-ring-economy.md](docs/x402-ring-economy.md) |
+| Economy funding root (master wallet) | [api/_lib/economy-master.js](api/_lib/economy-master.js), cron [api/cron/treasury-topup.js](api/cron/treasury-topup.js), registry [api/_lib/solana-signers.js](api/_lib/solana-signers.js) | In-repo (inert until keyed) | One master wallet (`WwwuGbq…T3WwW`, `ECONOMY_MASTER_SECRET_BASE58`) auto-tops-up every other Solana engine below its floor. Funder-only — never trades/settles; reserve/per-engine/per-run guarded; allowlisted to registry wallets; fee-minimized. See [docs/economy-master.md](docs/economy-master.md) + [SOLANA-SIGNERS.md](tasks/onchain-deployment/SOLANA-SIGNERS.md) |
## npm workspaces
diff --git a/api/_lib/economy-master.js b/api/_lib/economy-master.js
index 7285a9816..1eaf6e30d 100644
--- a/api/_lib/economy-master.js
+++ b/api/_lib/economy-master.js
@@ -10,7 +10,7 @@
// the caller derived from SOLANA_SIGNERS). This is the "masters fund engines,
// engines do the work" model applied platform-wide.
//
-// Address (mainnet vanity): wwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW
+// Address (mainnet vanity): WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW
//
// Inert until ECONOMY_MASTER_SECRET_BASE58 is set: loadEconomyMaster() returns
// null when unconfigured, so shipping this changes nothing until the operator
@@ -33,7 +33,7 @@ import { getSolBalance, sendSol, LAMPORTS_PER_SOL } from './avatar-wallet.js';
// (a mis-paste must never silently drain a different wallet). Override with
// ECONOMY_MASTER_ADDRESS if the master is ever rotated.
export const ECONOMY_MASTER_ADDRESS =
- process.env.ECONOMY_MASTER_ADDRESS || 'wwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW';
+ process.env.ECONOMY_MASTER_ADDRESS || 'WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW';
// Dust threshold: skip a top-up smaller than this to avoid fee churn on engines
// that are only a hair under their target.
diff --git a/api/_lib/solana-signers.js b/api/_lib/solana-signers.js
index 54b26a9d6..36c5ca0ef 100644
--- a/api/_lib/solana-signers.js
+++ b/api/_lib/solana-signers.js
@@ -38,7 +38,7 @@ export const SOLANA_SIGNERS = [
minSol: 1,
isMaster: true,
purpose:
- 'economy funding root (wwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW): auto-tops-up every other engine signer below its floor. Funder-only — never trades, launches, or settles.',
+ 'economy funding root (WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW): auto-tops-up every other engine signer below its floor. Funder-only — never trades, launches, or settles.',
network: 'mainnet',
},
{
diff --git a/api/cron/treasury-topup.js b/api/cron/treasury-topup.js
index 05c0ecf4c..b56794d0f 100644
--- a/api/cron/treasury-topup.js
+++ b/api/cron/treasury-topup.js
@@ -10,7 +10,7 @@
// Safe by construction:
// • Inert until ECONOMY_MASTER_SECRET_BASE58 is set — with no master it does
// nothing (relayer-balance-check keeps alerting), so shipping it is a no-op
-// until the operator funds wwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW.
+// until the operator funds WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW.
// • Only ever pays pubkeys derived from SOLANA_SIGNERS (the registry is the
// allowlist). The master never trades, launches, or settles.
// • Reserve floor + per-engine cap + per-run cap (see economy-master.js) bound
diff --git a/data/changelog.json b/data/changelog.json
index 79e24aea1..8cfc8c237 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,16 @@
{
"$comment": "Curated changelog entries for three.ws \u2014 the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-07-02",
+ "title": "Hardened the economy's funding wallet so SOL can only reach platform wallets",
+ "summary": "The platform runs a single master wallet that keeps every autonomous engine — x402 agent-to-agent payments, tips, coin launches — topped up with just enough SOL to operate. We tightened it so it can never leak funds: the funding wallet now enforces, in code, that SOL only ever moves to a wallet the platform holds the key for, never to an outside address and never to itself. There is no charity or user-payout path on it. It also always sends at the lowest available network fee, keeps a protected reserve, and caps how much can move per engine and per run. We also corrected the wallet address it was pinned to (a single-character case difference had it pointing at an empty account) and documented the whole system.",
+ "tags": [
+ "security",
+ "infra",
+ "docs"
+ ]
+ },
{
"date": "2026-07-02",
"title": "Every pump.fun coin now has its own full Oracle page",
diff --git a/docs/economy-master.md b/docs/economy-master.md
new file mode 100644
index 000000000..bd14f9a15
--- /dev/null
+++ b/docs/economy-master.md
@@ -0,0 +1,138 @@
+# Economy funding root (the master wallet)
+
+The economy funding root is **one master wallet that funds every other Solana
+engine on the platform** and does nothing else. It never trades, launches, tips,
+snipes, or settles a payment — its only on-chain action is a native SOL transfer
+that tops up an engine signer when that signer drops below its floor. This is the
+"masters fund engines, engines do the work" model applied platform-wide.
+
+> Source: [`api/_lib/economy-master.js`](../api/_lib/economy-master.js) (the
+> guard logic + sweep), cron entry
+> [`api/cron/treasury-topup.js`](../api/cron/treasury-topup.js), registry
+> [`api/_lib/solana-signers.js`](../api/_lib/solana-signers.js). Operator runbook:
+> [`tasks/onchain-deployment/SOLANA-SIGNERS.md`](../tasks/onchain-deployment/SOLANA-SIGNERS.md).
+
+**Address (mainnet vanity):** `WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW`
+
+The address is case-sensitive base58 — the leading character is a **capital `W`**.
+A lowercase `wwwu…` is a *different, empty* keypair; the `loadEconomyMaster()`
+pubkey guard exists precisely so a mis-cased or mis-pasted key can never load and
+drain the wrong wallet.
+
+---
+
+## How it works
+
+1. A single master wallet (funded by the operator) is the root of the tree.
+2. Every 30 minutes the `treasury-topup` cron reads the on-chain SOL balance of
+ every **configured, mainnet** engine signer in the `SOLANA_SIGNERS` registry.
+3. For each signer below its `minSol` floor, it computes a top-up to bring it up
+ to `refillTo` (default `minSol × 3`), subject to the guards below.
+4. It transfers the planned SOL from the master to each engine, fee-minimized,
+ and emits an ops alert per top-up (and one if the master itself is too drained
+ to cover a real deficit — the one condition a human must act on).
+5. With `ECONOMY_MASTER_SECRET_BASE58` unset the whole thing is **inert**:
+ `loadEconomyMaster()` returns `null`, the sweep is a no-op, and the existing
+ `relayer-balance-check` cron keeps alerting. Shipping it changes nothing until
+ the operator funds the master and installs the key.
+
+## Funder-only, by construction
+
+The master is never a *target* of a top-up — it funds the others, not itself
+(`isMaster: true` in the registry excludes it, and the sweep's allowlist rejects
+its own pubkey as `is_master`). It holds no product logic: it cannot call a DEX,
+a pump.fun program, or an x402 settlement. If you need SOL to *do* something, that
+belongs in an engine signer the master funds — not in the master.
+
+## The guards (every guard is enforced on every sweep)
+
+| Guard | Env | Default | What it bounds |
+|---|---|---|---|
+| Reserve floor | `ECONOMY_MASTER_RESERVE_SOL` | `1` | Never spend the master below this — its own working reserve + rent + fees. An on-chain read, so it holds even with no database. |
+| Per-engine cap | `ECONOMY_MASTER_PER_TOPUP_MAX_SOL` | `0.5` | Most SOL moved to any single engine in one sweep. |
+| Per-run cap | `ECONOMY_MASTER_RUN_CAP_SOL` | `2` | Most SOL moved across all engines in one sweep. Neediest engine funded first, so a tight cap protects the most-drained flow. |
+| Dust skip | — | `0.005` | Skip a top-up smaller than this to avoid fee churn. |
+| Pubkey match | `ECONOMY_MASTER_ADDRESS` | the address above | The installed secret must derive to the expected pubkey or `loadEconomyMaster()` throws `master_mismatch` — a mis-paste never silently drains a different wallet. |
+
+`planTopUps()` is pure (no RPC), so all of the above are unit-tested in
+[`tests/economy-master.test.js`](../tests/economy-master.test.js) without a key.
+
+## The leak invariant (no SOL leaves the owner-controlled set)
+
+SOL can **only** move from the master to a wallet the platform holds the key for.
+This is enforced twice:
+
+1. **The cron** builds its target list solely from `SOLANA_SIGNERS` — it never
+ passes an arbitrary address.
+2. **The sweep** (`filterToRegistry`) independently resolves the registry and
+ rejects any target whose pubkey is not a resolved registry signer, and rejects
+ the master's own pubkey. An off-registry target is refused and ops-alerted;
+ no SOL moves. So even a buggy or tampered caller cannot route funds out of the
+ registry.
+
+There is **no charity path and no user-payout path** on the master. (The
+per-merchant "charity split" you may see in the x402 checkout code is a *buyer*-
+funded donation on a merchant's own sale — it never touches this wallet.)
+
+## Lowest fees
+
+Every transfer routes through `submitProtected` with `tipMode: 'off'` — **no Jito
+tip**, just a data-driven priority fee floored at 1000 µLamports/CU (see
+[`api/_lib/execution-engine.js`](../api/_lib/execution-engine.js)). A single
+top-up costs roughly 0.000005–0.00001 SOL. The fee escalates only on retry under
+congestion, clamped to a hard ceiling.
+
+## Configuration
+
+| Env | Required | Meaning |
+|---|---|---|
+| `ECONOMY_MASTER_SECRET_BASE58` | yes | The master keypair (base58 of 64 raw bytes). Unset ⇒ the funding root is inert. Store `--sensitive`; keep your own copy (Vercel Sensitive vars are unreadable after save). |
+| `ECONOMY_MASTER_ADDRESS` | no | Override the expected pubkey if the master is ever rotated. Defaults to the address above. |
+| `ECONOMY_MASTER_RESERVE_SOL` / `_PER_TOPUP_MAX_SOL` / `_RUN_CAP_SOL` | no | Guard caps (see table). |
+| `CRON_SECRET` | yes | Bearer auth for the Vercel cron (shared with other crons). |
+| `SOLANA_RPC_URL` | no | Mainnet RPC (defaults to `api.mainnet-beta`). |
+
+## Verify it's working
+
+```bash
+# Balances of every registry signer (derives pubkeys, never prints secrets):
+node scripts/check-relayer-balances.mjs
+
+# Exercise the sweep against prod (real cron; safe — only funds registry wallets
+# below floor, bounded by the reserve/per-run caps). Returns the plan as JSON:
+curl -s -H "Authorization: Bearer $CRON_SECRET" https://three.ws/api/cron/treasury-topup | jq
+```
+
+The JSON response reports `configured`, `master_sol`, `funded`, `failed`,
+`skipped`, `rejected`, and `spent_sol`. A non-empty `rejected` array means an
+off-registry target reached the sweep and was blocked — investigate the caller.
+
+## Known gaps & runbook (as of 2026-07-02)
+
+The master is configured and funded, but the tree it feeds is only partly wired:
+
+- **Only two registry signers resolve in prod** — the master itself and the NFT
+ `collection-authority`. The other ten engines (launcher, buyback, treasuries,
+ club tips, a2a-payer, x402 launcher) have no secret set, so the sweep has almost
+ nothing to fund. Set each engine's secret to bring it online (see the runbook).
+- **Solana agent-to-agent settlement is down.** The `a2a-payer` signer reads
+ `A2A_PAYER_SOLANA_SECRET`; prod only has `A2A_PAYER_PRIVATE_KEY` (the EVM payer).
+ [`api/agents/a2a-call.js`](../api/agents/a2a-call.js) throws *"autonomous Solana
+ payer wallet is not configured"* on every Solana mandate. Fix: set
+ `A2A_PAYER_SOLANA_SECRET` to a base58 Solana key.
+- **The x402 spend/gas wallets are not in the registry.** `X402_FEE_PAYER_SOLANA`,
+ `X402_AGENT_SOLANA_SECRET_BASE58`, and `X402_SEED_SOLANA_SECRET_BASE58` run the
+ x402 agent-to-agent economy but are not `SOLANA_SIGNERS` entries, so the master
+ does not top them up. Whether it *should* is an operator call — x402 gas is
+ largely PayAI-sponsored (see [x402 ring economy](x402-ring-economy.md) /
+ [autonomous x402](autonomous-x402.md)), so those wallets may intentionally not
+ need funding from this master. To have the master keep them fueled, add them to
+ the registry with a floor.
+
+## Related
+
+- [`SOLANA-SIGNERS.md`](../tasks/onchain-deployment/SOLANA-SIGNERS.md) — every
+ engine signer, its encoding, and how to fund/consolidate the economy wallets.
+- [Circulation engine](circulation-engine.md) — the autonomous agent-to-agent
+ activity loop the funded engines drive.
+- [x402 ring economy](x402-ring-economy.md) — closed-loop in-house x402 settlement.
diff --git a/docs/money-map.md b/docs/money-map.md
new file mode 100644
index 000000000..922d4c6af
--- /dev/null
+++ b/docs/money-map.md
@@ -0,0 +1,165 @@
+# Money map
+
+The single source of truth for **where every dollar flows** in three.ws: which
+wallet receives each kind of payment, what share the platform keeps, and which
+treasury pays it forward. If you're adding a paid surface or auditing revenue,
+start here.
+
+Companion docs: [x402 endpoints](x402-endpoints.md) (the paid endpoint catalog),
+[x402 revenue & receipts](x402-revenue.md) (how settlements are recorded),
+[Solana signers runbook](../tasks/onchain-deployment/SOLANA-SIGNERS.md) (the
+signer/funder wallets and how to fund them).
+
+---
+
+## 1. The wallets
+
+Money-routing is deliberately **config-driven** — no receiver is hardcoded, so an
+unset receiver fails closed rather than silently routing real USDC to a baked-in
+address ([env.js:701](../api/_lib/env.js#L701)).
+
+### Receivers (inbound USDC)
+| Env var | Role | Value |
+| ------- | ---- | ----- |
+| `X402_PAY_TO_SOLANA` | Primary x402 receiver (all generic paid calls) | `wwwwwDxFWRn7grgr3Esrsg5C6NvDoDHSA4gaCffccrU` |
+| `X402_PAY_TO_BASE` | x402 receiver on Base (EVM) | `0x4022…f402` |
+| `X402_PAY_TO_BSC` | x402 receiver on BSC | (config) |
+| `X402_ASSET_MINT_SOLANA` | USDC mint accepted | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` (default constant) |
+
+### Payout treasuries (outbound — pay third parties out-of-band)
+| Env var (secret) | Pays | Network |
+| ---------------- | ---- | ------- |
+| `CLUB_SOLANA_TREASURY_SECRET_KEY_B64` | dancers (tip sweep) + vanity-bounty fallback | Solana |
+| `CLUB_EVM_TREASURY_PRIVATE_KEY` | dancers on Base | Base |
+| `COSMETIC_SPLIT_TREASURY_SECRET_KEY_B64` | cosmetic creators (their split) | Solana |
+| `VANITY_BOUNTY_PAYOUT_KEY` | vanity-bounty winners (→ club treasury fallback) | Solana |
+| `PLATFORM_TREASURY_KEYPAIR` (→ `TREASURY_KEYPAIR`) | withdrawal gas, marketplace/pump fee sink, tops up other hot wallets | Solana |
+
+### Fee sink wallets (platform's cut)
+| Env var | Fills from | Default rate |
+| ------- | ---------- | ------------ |
+| `MARKETPLACE_PLATFORM_FEE_WALLET` (→ platform treasury pubkey) | marketplace skill sales | `MARKETPLACE_PLATFORM_FEE_BPS` = **0** (off), ≤10% |
+| `PUMP_PLATFORM_FEE_WALLET` (→ platform treasury pubkey) | pump trades | `PUMP_PLATFORM_FEE_BPS` = **0** (off), ≤5% |
+
+### Signer / funder wallets
+Every engine signs from its **own** keypair; a single **funding root** tops those
+signers up with SOL when they run low, and does nothing else. Documented in full —
+encodings, minimum balances, guards, funding tool — in the
+[Solana signers runbook](../tasks/onchain-deployment/SOLANA-SIGNERS.md) and the
+[economy master](economy-master.md) subsystem doc.
+
+| Wallet | Role |
+| ------ | ---- |
+| `WwwuGbqHrwF5…T3WwW` (capital `W`) | **Economy master / funding root** (`ECONOMY_MASTER_SECRET_BASE58`) — funder-only; never trades, tips, or settles. The `treasury-topup` cron refills every engine signer from it every 30 min, allowlist-guarded (can only pay a registry pubkey). |
+| `wwwww…ccrU` | x402 **receiver** (`X402_PAY_TO_SOLANA`) + closed-loop spender |
+| `wwwqv…HGUn` | a funded **engine signer** wallet |
+| `PLATFORM_TREASURY_KEYPAIR`, `LAUNCHER_MASTER_*`, `CIRCULATION_TREASURY_*`, … | per-engine signers, each its own keypair, funded by the master |
+
+---
+
+## 2. Where each payment lands
+
+| Paid surface | Receiving wallet | Platform cut | Downstream |
+| ------------ | ---------------- | ------------ | ---------- |
+| Generic x402 endpoints | `X402_PAY_TO_SOLANA/BASE/BSC` | 100% | platform revenue (`x402_audit_log`) |
+| `skill-call` | skill author `author_payto_*` | 0% | direct to author (payTo override) |
+| `service/<slug>` | provider `payout_address` | 0% | proxied to provider API (payTo override) |
+| `asset-download`, `animation-download` | creator `creator_payto_*` | 0% | direct to creator (payTo override) |
+| `pay-by-name` | buyer-named recipient | 0% | direct SPL transfer |
+| `dance-tip` | platform receiver → dancer | 0% net | swept by `club-payouts` from `CLUB_SOLANA_TREASURY_*` |
+| `club-cover` | platform receiver (kept) | 100% | funds the club float; issues a door pass |
+| `cosmetic-purchase` | platform receiver → split | 50% | creator 50% (≤90%) from `COSMETIC_SPLIT_TREASURY_*` |
+| marketplace skill sale | agent owner `payout_address` | 0–10% fee | atomic split; fee → fee wallet |
+| labor skill (escrow) | worker + author | author 10% royalty | paid from escrow ([labor-settle.js:95](../api/_lib/labor-settle.js#L95)) |
+| pump trade | counterparty | 0–5% fee | fee appended to trader's tx |
+| `pump-launch` | `X402_PAY_TO_SOLANA/BASE` | 100% of $5 | pump.fun creator rewards accrue on-chain to nominated wallet |
+| `ring-settle` (internal) | `X402_PAY_TO_SOLANA` | 100% | recirculates (dogfood volume) |
+| vanity bounty | worker | escrow-based | from `VANITY_BOUNTY_PAYOUT_KEY` (→ club treasury fallback) |
+
+Two mechanisms above are easy to confuse — see the [split explainer](x402-endpoints.md#where-payments-land):
+a **`payTo` override** settles USDC straight to a third party (skill-call, service,
+asset/animation download, pay-by-name); a **post-settlement split** lands the USDC
+in the platform receiver first, then a separate treasury forwards a share
+(cosmetics, dance tips).
+
+---
+
+## 3. Fee & split rates
+
+| Flow | Rate | Config | Default |
+| ---- | ---- | ------ | ------- |
+| Cosmetic creator split | creator share | `cosmetics-economy.js` `DEFAULT_CREATOR_BPS` | **50%** (cap 90%) |
+| Labor skill royalty | author royalty | `LABOR_SKILL_ROYALTY_BPS` | **10%** (cap 50%) |
+| Marketplace platform fee | platform cut | `MARKETPLACE_PLATFORM_FEE_BPS` | **0%** (cap 10%) |
+| Pump trade fee | platform cut | `PUMP_PLATFORM_FEE_BPS` | **0%** (cap 5%) |
+| Club tip | dancer share | — | **100%** to dancer (platform nets 0) |
+| Club cover | platform share | — | **100%** (club float) |
+
+All defaults are a low/off demo curve; production deployments tune them to real
+unit economics.
+
+---
+
+## 4. Services catalog (what three.ws sells)
+
+- **x402 HTTP endpoints** — ~47 paid endpoints across intel/oracle, agent/reputation,
+ generation/3D, launch/naming/utility, club, avatar shop, and bazaars. Full list
+ and prices: [x402 endpoints](x402-endpoints.md).
+- **Paid MCP tools** —
+ - Main MCP ([api/mcp.js](../api/mcp.js), pricing `api/_lib/pump-pricing.js`):
+ `retexture_model` $0.10, `optimize_model` $0.05, `segment_model` $0.04,
+ `retexture_region` $0.03, `inspect_model`/`validate_model` $0.01,
+ `render_avatar` $0.005, `search_public_avatars`/`solana_agent_reputation` $0.001.
+ - 3D Studio MCP ([api/mcp-3d.js](../api/mcp-3d.js), pricing `api/_mcp3d/pricing.js`):
+ 14 priced tools — `text_to_3d`/`image_to_3d` tiered (draft/standard/high),
+ `auto_rig_model`/`capture_scene`/`retexture_model`/`retexture_region` $0.05,
+ `stylize_model`/`remesh_model`/`segment_model` $0.02,
+ `remove_background`/`pose_model`/`apply_animation`/`direct_prompt`/`generate_material` $0.01.
+- **OKX.AI ASP #2632 "three.ws 3D Studio"** — the same 3D pipeline listed on OKX.AI
+ (ERC-8004 / XLayer) as an Agent Service Provider, endpoint `https://three.ws/api/mcp-3d`,
+ serviceType `A2MCP`. The 7 registered services (fees $0.01–$0.15 USDC): Text &
+ Image-to-3D, Video-to-3D Scene Capture, Auto-Rig, Universal Animation Retarget,
+ Masked Texture Repaint, Mesh Repair/Export, Mesh Segmentation. **This list lives
+ in the on-chain ASP record, not in repo code** — update it here if the ASP
+ registration changes.
+- **Marketplace skills** — agent skill marketplace over Solana Pay
+ ([api/marketplace/](../api/marketplace/)); see [marketplace skills](ux-flows/06-marketplace-skills.md).
+- **Labor market** — bounty/escrow jobs with worker + author-royalty settlement; see
+ [labor market](labor-market.md).
+- **Other** — vanity bounties, forge REST ([api/x402/forge.js](../api/x402/forge.js)),
+ subscriptions, credit deposits.
+
+---
+
+## 5. Autonomous money movement
+
+Engines that move money on their own (cron/worker driven) draw from the signer
+wallets, not the receivers — and each signer is kept funded by the
+[economy master](economy-master.md) via the `treasury-topup` cron (every 30 min,
+allowlist-guarded, reserve/per-engine/per-run caps). Which wallet funds which
+engine and minimum balances are in the
+[Solana signers runbook](../tasks/onchain-deployment/SOLANA-SIGNERS.md). The
+recurring payout crons that forward the flows above:
+
+| Cron | Moves | From |
+| ---- | ----- | ---- |
+| `treasury-topup` | SOL refill → every low engine signer | `ECONOMY_MASTER_SECRET_BASE58` (funding root) |
+| `club-payouts` | tip sweeps → dancers | `CLUB_SOLANA_TREASURY_*` / `CLUB_EVM_TREASURY_*` |
+| `cosmetic-splits-sweep` | creator USDC payouts | `COSMETIC_SPLIT_TREASURY_*` |
+| `run-buyback` / `run-three-buyback` | coin/$THREE buybacks | `PUMP_CRON_RELAYER_*` / `THREE_BUYBACK_*` |
+| `run-distribute-payments` | coin creator/holder payouts | `PUMP_CRON_RELAYER_*` |
+| `process-withdrawals` | user withdrawals | `PLATFORM_TREASURY_KEYPAIR` + `EVM_TREASURY_PRIVATE_KEY` |
+| `x402-autonomous-loop` / `x402-seed-cron` | x402 self-spend (closed loop) | `X402_SEED_SOLANA_SECRET_BASE58` |
+
+---
+
+## Related
+
+- [x402 endpoints](x402-endpoints.md) — the paid endpoint catalog and price overrides.
+- [x402 revenue & receipts](x402-revenue.md) — where settlements are recorded.
+- [x402 ring economy](x402-ring-economy.md) — the internal recirculation loop.
+- [Pump platform fee](pump-platform-fee.md) — the pump trade fee detail.
+- [Coin-launch wallets](ux-flows/08-coin-launch-wallets.md) — launch-time wallet flow.
+- [Creator revenue splits](agent-briefs/R-3d-world-fun/phase-4/R25-creator-revenue-splits.md) — cosmetic split rationale.
+- [Agent wallet custody](internal/AGENT-WALLET-CUSTODY.md) — how custodial keys are held.
+- [Solana signers runbook](../tasks/onchain-deployment/SOLANA-SIGNERS.md) — signer/funder wallets + funding.
diff --git a/docs/x402-endpoints.md b/docs/x402-endpoints.md
index e115b9705..d83b414b5 100644
--- a/docs/x402-endpoints.md
+++ b/docs/x402-endpoints.md
@@ -62,21 +62,34 @@ endpoint logic, and issues a signed receipt.
## Where payments land
Most endpoints pay the **platform receiver** (`X402_PAY_TO_SOLANA` /
-`X402_PAY_TO_BASE`). Some deliberately override the receiver so the money reaches
-a third party instead — the platform is just the rail:
+`X402_PAY_TO_BASE` / `X402_PAY_TO_BSC`). Money reaches a third party by one of two
+distinct mechanisms — don't conflate them:
-| Endpoint | Receiver override | Who gets paid |
-| -------- | ----------------- | ------------- |
-| `/api/x402/skill-call` | per-skill `payTo` | the skill **author's** wallet ([skill-call.js:159](../api/x402/skill-call.js#L159)) |
-| `/api/x402/service` | `row.payout_address` | the **provider's** payout address for a listed service ([service.js:92](../api/x402/service.js#L92)) |
-| `/api/x402/cosmetic-purchase` | `creatorWallet` split | the cosmetic **creator** (platform keeps its cut) ([cosmetic-purchase.js:204](../api/x402/cosmetic-purchase.js#L204)) |
-| `/api/x402/dance-tip`, `/api/x402/club-cover` | platform receiver, then swept | performers, paid out by the `club-payouts` cron from `CLUB_SOLANA_TREASURY_SECRET_KEY_B64` |
+**1. `payTo` override** — the 402 challenge names a different receiver, so the
+buyer's USDC settles **directly** to that wallet and the platform never holds it:
+
+| Endpoint | Receiver | Source |
+| -------- | -------- | ------ |
+| `/api/x402/skill-call` | skill **author** | `author_payto_*` ([skill-call.js:159](../api/x402/skill-call.js#L159)) |
+| `/api/x402/service` | service **provider** | `row.payout_address` ([service.js:92](../api/x402/service.js#L92)) |
+| `/api/x402/asset-download` | 3D-asset **creator** | `creator_payto_*` ([asset-download.js:121](../api/x402/asset-download.js#L121)) |
+| `/api/x402/animation-download` | clip **creator** | `creator_payto_*` ([animation-download.js:112](../api/x402/animation-download.js#L112)) |
+| `/api/x402/pay-by-name` | **buyer-named** wallet | resolved name/`.sol`/address, direct SPL transfer ([pay-by-name.js:256](../api/x402/pay-by-name.js#L256)) |
+
+**2. Post-settlement split** — the USDC lands in the **platform receiver**, then a
+*separate* treasury forwards a share out-of-band (these are NOT `payTo` overrides):
+
+| Endpoint | Lands in | Then forwarded to | By |
+| -------- | -------- | ----------------- | -- |
+| `/api/x402/cosmetic-purchase` | platform receiver | **creator** 50% (≤90% cap) | `COSMETIC_SPLIT_TREASURY_SECRET_KEY_B64` ([cosmetics-economy.js:31](../api/_lib/cosmetics-economy.js#L31)) |
+| `/api/x402/dance-tip` | platform receiver | **dancer** (full tip) | `club-payouts` cron from `CLUB_SOLANA_TREASURY_SECRET_KEY_B64` ([club/sweep.js:19](../api/_lib/club/sweep.js#L19)) |
+| `/api/x402/club-cover` | platform receiver (kept) | — (funds the club float; issues a door pass) | — |
`/api/x402/ring-settle` is an **internal** primitive (`discoverable:false`) — it is
deliberately not advertised in the 402 challenge or the discovery catalog; it
recirculates funds back to `X402_PAY_TO_SOLANA` to keep the closed loop balanced
([ring-settle.js:18](../api/x402/ring-settle.js#L18)). The full wallet-by-wallet
-picture — every receiver, tip, split, and treasury — is in the
+picture — every receiver, tip, split, treasury, and fee rate — is in the
[money map](money-map.md).
## Intel & oracle endpoints
diff --git a/public/changelog.json b/public/changelog.json
index 191686215..37c3711ae 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-07-02T23:29:56.799Z",
+ "generated_at": "2026-07-02T23:38:29.949Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -100,6 +100,18 @@
"feature"
]
},
+ {
+ "date": "2026-07-02",
+ "type": "update",
+ "title": "Hardened the economy's funding wallet so SOL can only reach platform wallets",
+ "summary": "The platform runs a single master wallet that keeps every autonomous engine — x402 agent-to-agent payments, tips, coin launches — topped up with just enough SOL to operate. We tightened it so it can never leak funds: the funding wallet now enforces, in code, that SOL only ever moves to a wallet the platform holds the key for, never to an outside address and never to itself. There is no charity or user-payout path on it. It also always sends at the lowest available network fee, keeps a protected reserve, and caps how much can move per engine and per run. We also corrected the wallet address it was pinned to (a single-character case difference had it pointing at an empty account) and documented the whole system.",
+ "link": null,
+ "tags": [
+ "security",
+ "infra",
+ "docs"
+ ]
+ },
{
"date": "2026-07-02",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index edd6e10d0..74a741701 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -78,6 +78,14 @@
<category>feature</category>
<description>Opening a coin on Oracle used to give you a slide-over drawer, and the shareable link just bounced back into that drawer. Now every coin has a real standalone page at three.ws/oracle/coin/&lt;mint&gt; — and it resolves for any pump.fun mint, even a launch Oracle has never scored. Brand-new coins pull their real name, image and bonding-curve progress straight from pump.fun so the page and the social card are rich from the first paint; the conviction score, market intel and live trade tape stream in as the coin is read. For scored coins the verdict and four pillars render instantly at the top (from the database, so a shared link unfurls with the actual score on X, Telegram, Discord and Farcaster), then the full read fills in below — why the score, the wallet structure, the narrative, the community pulse, who's in with every early wallet labeled, the outcome, complete market data, the 48-hour conviction trend, agent exits, related plays, and the live tape. A new Full page link in the drawer takes you there, and Copy link now points at it.</description>
</item>
+ <item>
+ <title>Hardened the economy's funding wallet so SOL can only reach platform wallets</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-07-02:Hardened the economy's funding wallet so SOL can only reach platform wallets</guid>
+ <pubDate>Thu, 02 Jul 2026 12:00:00 GMT</pubDate>
+ <category>security</category>
+ <description>The platform runs a single master wallet that keeps every autonomous engine — x402 agent-to-agent payments, tips, coin launches — topped up with just enough SOL to operate. We tightened it so it can never leak funds: the funding wallet now enforces, in code, that SOL only ever moves to a wallet the platform holds the key for, never to an outside address and never to itself. There is no charity or user-payout path on it. It also always sends at the lowest available network fee, keeps a protected reserve, and caps how much can move per engine and per run. We also corrected the wallet address it was pinned to (a single-character case difference had it pointing at an empty account) and documented the whole system.</description>
+ </item>
<item>
<title>Live agent screens now reach the 3D world, and coin art loads everywhere</title>
<link>https://three.ws/play</link>
diff --git a/public/features.json b/public/features.json
index 82cd69e1a..419a09652 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-07-02T23:29:56.767Z",
+ "generated_at": "2026-07-02T23:38:29.913Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/public/oracle-coin.js b/public/oracle-coin.js
index 6a424c18a..dcfa2baf5 100644
--- a/public/oracle-coin.js
+++ b/public/oracle-coin.js
@@ -350,6 +350,92 @@
<div class="mkt-src">Live · pumpfun — full metrics populate once it lists on a DEX</div>`;
}
+ // ── price chart ────────────────────────────────────────────────────────────
+ // A TradingView-grade candlestick view via the DexScreener embed (keyed by the
+ // mint, resolves the most-liquid pair itself), plus a native SVG line chart from
+ // /api/pump/price-history for coins still on the bonding curve with no DEX pair.
+ const CHART_KEY = 'oc_chart_view';
+
+ function dexEmbedUrl(mint) {
+ const theme = document.documentElement.getAttribute('data-theme') === 'light' ? 'light' : 'dark';
+ const p = new URLSearchParams({ embed: '1', loadChartSettings: '0', theme, chartTheme: theme, chartType: 'usd', interval: '15', info: '0' });
+ return `https://dexscreener.com/solana/${encodeURIComponent(mint)}?${p}`;
+ }
+
+ function areaChartSvg(points) {
+ const w = 720, h = 240, volH = 38, priceH = h - volH, pad = { t: 12, r: 8, b: 4, l: 8 };
+ const closes = points.map((p) => p.c), vols = points.map((p) => p.v || 0);
+ const min = Math.min(...closes), max = Math.max(...closes), span = (max - min) || max || 1, maxVol = Math.max(...vols) || 1;
+ const innerW = w - pad.l - pad.r, innerH = priceH - pad.t - pad.b;
+ const x = (i) => pad.l + (i / Math.max(1, points.length - 1)) * innerW;
+ const y = (v) => pad.t + innerH - ((v - min) / span) * innerH;
+ const up = points.length > 1 && closes[closes.length - 1] >= closes[0];
+ const col = up ? 'var(--up)' : 'var(--down)';
+ const line = points.map((p, i) => `${i ? 'L' : 'M'}${x(i).toFixed(1)} ${y(p.c).toFixed(1)}`).join(' ');
+ const area = `${line} L${x(points.length - 1).toFixed(1)} ${(priceH - pad.b).toFixed(1)} L${x(0).toFixed(1)} ${(priceH - pad.b).toFixed(1)} Z`;
+ const barW = Math.max(1, (innerW / points.length) * 0.6);
+ const bars = points.map((p, i) => {
+ const bh = Math.max(1, (p.v / maxVol) * (volH - 6)), bx = x(i) - barW / 2, by = h - bh - 2;
+ return `<rect x="${bx.toFixed(1)}" y="${by.toFixed(1)}" width="${barW.toFixed(1)}" height="${bh.toFixed(1)}" rx="1" fill="${p.c >= p.o ? 'var(--up)' : 'var(--down)'}" opacity="0.45"/>`;
+ }).join('');
+ return `<svg viewBox="0 0 ${w} ${h}" preserveAspectRatio="none" class="oc-chart-svg" role="img" aria-label="Price history chart" style="color:${col}">
+ <defs><linearGradient id="ocgrad" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="currentColor" stop-opacity="0.25"/><stop offset="100%" stop-color="currentColor" stop-opacity="0"/></linearGradient></defs>
+ ${bars}
+ <line x1="${pad.l}" y1="${priceH}" x2="${w - pad.r}" y2="${priceH}" stroke="var(--line)" stroke-width="1"/>
+ <path d="${area}" fill="url(#ocgrad)" stroke="none"/>
+ <path d="${line}" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>
+ </svg>`;
+ }
+
+ async function loadNativeChart(canvas, mint) {
+ canvas.innerHTML = '<div class="oc-chart-skel"></div>';
+ const to = Math.floor(Date.now() / 1000), from = to - 36 * 3600;
+ const { ok, data } = await api(`/api/pump/price-history?mint=${encodeURIComponent(mint)}&interval=15m&from=${from}&to=${to}`, { timeout: 12000 });
+ const pts = ((data && data.data) || []).filter((p) => Number.isFinite(p.c));
+ if (!ok || pts.length < 2) { canvas.innerHTML = '<div class="state" style="padding:34px 0">Chart appears once this coin has trade history.</div>'; return; }
+ const first = pts[0].c, last = pts[pts.length - 1].c;
+ const chg = changeStr(first ? ((last - first) / first) * 100 : 0);
+ canvas.innerHTML = `<div class="oc-chart-readout"><span class="oc-chart-price">${fmtPrice(last)}</span><span class="mkt-${chg.cls}">${chg.txt} · 36h</span></div>${areaChartSvg(pts)}`;
+ }
+
+ function mountChart(container, mint) {
+ let stored = null; try { stored = localStorage.getItem(CHART_KEY); } catch {}
+ const preCurve = BOOT.pump && !BOOT.pump.complete; // no DEX pair yet → native by default
+ const view = stored || (preCurve ? 'line' : 'candles');
+ container.innerHTML = `<div class="dr-sec" style="margin-top:0">Price <span style="color:var(--faint);font-weight:400;font-size:10px">live</span></div>
+ <div class="oc-chart-controls">
+ <div class="oc-seg">
+ <button type="button" class="oc-seg-btn${view === 'candles' ? ' on' : ''}" data-view="candles">Candles</button>
+ <button type="button" class="oc-seg-btn${view === 'line' ? ' on' : ''}" data-view="line">Line</button>
+ </div>
+ <a class="dr-act" href="https://dexscreener.com/solana/${encodeURIComponent(mint)}" target="_blank" rel="noopener">DexScreener ↗</a>
+ </div>
+ <div class="oc-chart-canvas" id="ocChartCanvas"></div>`;
+ const canvas = container.querySelector('#ocChartCanvas');
+ let watchdog = 0;
+ function renderCandles() {
+ canvas.classList.remove('ready');
+ canvas.innerHTML = '<div class="oc-chart-skel"></div>';
+ const frame = document.createElement('iframe');
+ frame.className = 'oc-chart-frame';
+ frame.title = 'DexScreener live chart';
+ frame.loading = 'lazy';
+ frame.src = dexEmbedUrl(mint);
+ frame.addEventListener('load', () => { clearTimeout(watchdog); canvas.classList.add('ready'); });
+ canvas.replaceChildren(frame);
+ // Embed blocked / offline → fall back to the native line chart.
+ watchdog = setTimeout(() => { if (!canvas.classList.contains('ready')) loadNativeChart(canvas, mint); }, 9000);
+ }
+ function apply(v) {
+ try { localStorage.setItem(CHART_KEY, v); } catch {}
+ container.querySelectorAll('.oc-seg-btn').forEach((b) => b.classList.toggle('on', b.dataset.view === v));
+ clearTimeout(watchdog);
+ if (v === 'candles') renderCandles(); else loadNativeChart(canvas, mint);
+ }
+ container.querySelectorAll('.oc-seg-btn').forEach((b) => b.addEventListener('click', () => apply(b.dataset.view)));
+ if (view === 'candles') renderCandles(); else loadNativeChart(canvas, mint);
+ }
+
async function loadSentiment(mint) {
const wrap = $('#ocPulse');
if (!wrap) return;
diff --git a/src/agora/player-logic.js b/src/agora/player-logic.js
index 31eacb66b..4f17dd2e4 100644
--- a/src/agora/player-logic.js
+++ b/src/agora/player-logic.js
@@ -114,6 +114,41 @@ export function resolveBuildingCollision(nx, ny, nz, boxes, radius = PLAYER_RADI
return { x: nx, z: nz };
}
+/**
+ * Is a point clear of every building (outside all AABBs by at least `margin`)?
+ * The OSM Manhattan substrate is dense, so a naive spawn can land inside a tower.
+ */
+export function isOpenGround(x, z, boxes, margin = PLAYER_RADIUS + 0.2) {
+ for (const b of boxes || []) {
+ if (x > b.minX - margin && x < b.maxX + margin && z > b.minZ - margin && z < b.maxZ + margin) {
+ return false;
+ }
+ }
+ return true;
+}
+
+/**
+ * Find an open standing point near a desired spawn: spiral outward (golden-angle,
+ * so samples never line up with a street grid and miss every gap) until a point
+ * clear of all buildings is found. Falls back to the desired point if the whole
+ * search is walled (a degenerate map) — the player is never left unplaced.
+ * Pure: no Three.js, so it's unit-tested with plain AABBs.
+ *
+ * @returns {{x:number, z:number}}
+ */
+export function findOpenSpawn(desired, boxes, { maxRadius = 60, step = 0.7 } = {}) {
+ if (isOpenGround(desired.x, desired.z, boxes)) return { x: desired.x, z: desired.z };
+ const GOLDEN = 2.399963229728653;
+ for (let i = 1; i * step < maxRadius; i++) {
+ const r = step * Math.sqrt(i);
+ const a = i * GOLDEN;
+ const x = desired.x + Math.cos(a) * r;
+ const z = desired.z + Math.sin(a) * r;
+ if (isOpenGround(x, z, boxes)) return { x, z };
+ }
+ return { x: desired.x, z: desired.z };
+}
+
/**
* The single nearest interactable within reach — drives the "press E" prompt.
* Candidates carry {id, kind, x, z, ...} (kind: 'citizen' | 'board' | …);
diff --git a/src/agora/player-mode.js b/src/agora/player-mode.js
index 13e8796cb..10f84f30a 100644
--- a/src/agora/player-mode.js
+++ b/src/agora/player-mode.js
@@ -33,7 +33,7 @@ import { CITY_HALF } from '../city/city-map.js';
import {
JUMP_VEL, GRAVITY,
motionFor, stepMovement, easeYaw, resolveBuildingCollision,
- nearestInteractable, chooseAvatarSource, guestName,
+ nearestInteractable, chooseAvatarSource, guestName, findOpenSpawn,
} from './player-logic.js';
import { injectPlayerCss } from './player-mode.css.js';
import { log } from '../shared/log.js';
@@ -64,7 +64,7 @@ class AgoraPlayer {
this._keys = new Set();
}
- async load(avatarInput) {
+ async load(avatarInput, spawn = SPAWN) {
await loadManifest();
const url = await resolveAvatarUrl(avatarInput || '');
this._anim = newAnim();
@@ -72,7 +72,7 @@ class AgoraPlayer {
// emote library (dozens of clip downloads) — emotes lazy-load on use.
const { height, fallback } = await buildAvatar(this.rig, url, this._anim, { clips: 'locomotion' });
this.height = height;
- this.rig.position.set(SPAWN.x, 0, SPAWN.z);
+ this.rig.position.set(spawn.x, 0, spawn.z);
return { url, fallback };
}
@@ -355,7 +355,12 @@ export async function mountPlayerMode(ctx) {
setStored('agora:name', name);
const player = new AgoraPlayer(scene);
- const { url: avatarUrl } = await player.load(avatarChoice.value);
+ // Spawn on OPEN ground: the OSM Manhattan substrate is dense, so the nominal
+ // spot beside the board can sit inside a building footprint (where the player
+ // would be walled in the moment it tries to move). findOpenSpawn spirals out to
+ // the nearest clear point so the visitor always starts able to walk to citizens.
+ const spawn = findOpenSpawn(SPAWN, buildingBoxes);
+ const { url: avatarUrl } = await player.load(avatarChoice.value, spawn);
// ── Multiplayer presence (dedicated Commons room; graceful solo) ───────────
const remotes = new RemotePlayers(scene, bubbles);
diff --git a/src/shared/agent-coin.js b/src/shared/agent-coin.js
index 6c0515b81..b4d6b8e91 100644
--- a/src/shared/agent-coin.js
+++ b/src/shared/agent-coin.js
@@ -54,6 +54,9 @@ export function getCoinStatus(agent) {
mint: status.address,
symbol: status.tokenSymbol || null,
cluster,
+ // The canonical rich coin page (conviction + live market + trades) on
+ // mainnet; devnet has no such page.
+ pageUrl: cluster === 'mainnet' ? oraclePageUrl(status.address) : null,
// Prefer the pump.fun coin page on mainnet — this is a launchpad, not a
// block explorer. Fall back to the explorer only when there's no better link.
url: status.pumpfunUrl || pumpfunUrl(status.address, cluster) || status.explorerUrl,
@@ -69,6 +72,7 @@ export function getCoinStatus(agent) {
mint,
symbol: token.symbol || token.name || null,
cluster,
+ pageUrl: cluster === 'mainnet' ? oraclePageUrl(mint) : null,
url: token.pumpfun_url || pumpfunUrl(mint, cluster),
};
}
@@ -76,6 +80,11 @@ export function getCoinStatus(agent) {
return null;
}
+// The canonical three.ws rich coin page for a mint.
+function oraclePageUrl(mint) {
+ return mint ? `/oracle/coin/${mint}` : null;
+}
+
/** True when the agent already has a coin. */
export function hasCoin(agent) {
return getCoinStatus(agent) != null;
@@ -238,10 +247,17 @@ export function coinChipHTML(agent, opts = {}) {
if (coin) {
ensureCoinStyles();
const sym = coin.symbol ? `$${esc(coin.symbol)}` : 'Coin';
- const aria = `Trade ${coin.symbol ? coin.symbol + ' ' : ''}coin on pump.fun`;
const inner = `<span class="tws-coin-glyph" aria-hidden="true">◎</span><span class="tws-coin-label">${sym}</span>`;
- if (link && coin.url) {
- return `<a class="tws-coin tws-coin--live${sz}" href="${esc(coin.url)}" target="_blank" rel="noopener noreferrer" title="${esc(aria)}" aria-label="${esc(aria)}">${inner}</a>`;
+ // Prefer the internal rich coin page (conviction + market + live trades) —
+ // it links out to pump.fun to trade. Fall back to the external link (devnet).
+ const href = coin.pageUrl || coin.url;
+ const internal = Boolean(coin.pageUrl);
+ const aria = internal
+ ? `View ${coin.symbol ? coin.symbol + ' ' : ''}coin — conviction, market & live trades`
+ : `Trade ${coin.symbol ? coin.symbol + ' ' : ''}coin on pump.fun`;
+ if (link && href) {
+ const tgt = internal ? '' : ' target="_blank" rel="noopener noreferrer"';
+ return `<a class="tws-coin tws-coin--live${sz}" href="${esc(href)}"${tgt} title="${esc(aria)}" aria-label="${esc(aria)}">${inner}</a>`;
}
return `<span class="tws-coin tws-coin--live${sz}" role="img" aria-label="${esc(aria)}">${inner}</span>`;
}
diff --git a/src/shared/money-pulse.js b/src/shared/money-pulse.js
index 284f95165..66a530116 100644
--- a/src/shared/money-pulse.js
+++ b/src/shared/money-pulse.js
@@ -243,7 +243,7 @@ function rowEl(ev) {
const k = KIND_META[ev.kind] || KIND_META.trade;
const a = document.createElement('a');
a.className = `mp-row ${k.cls}`;
- a.href = ev.agent?.url || (ev.mint ? `/launches/${ev.mint}` : '#');
+ a.href = ev.agent?.url || (ev.mint ? `/oracle/coin/${ev.mint}` : '#');
a.dataset.id = ev.id;
a.setAttribute('aria-label', `${ev.agent?.name || 'Agent'} ${k.verb} — ${timeAgo(ev.ts)}`);
@@ -322,7 +322,7 @@ function tickEl(ev) {
const k = KIND_META[ev.kind] || KIND_META.trade;
const a = document.createElement('a');
a.className = `mp-tick ${k.cls}`;
- a.href = ev.agent?.url || (ev.mint ? `/launches/${ev.mint}` : '/pulse');
+ a.href = ev.agent?.url || (ev.mint ? `/oracle/coin/${ev.mint}` : '/pulse');
const amt = fmtAmount(ev);
a.innerHTML =
`<span class="mp-glyph" aria-hidden="true">${k.glyph}</span>` +
diff --git a/tasks/onchain-deployment/SOLANA-SIGNERS.md b/tasks/onchain-deployment/SOLANA-SIGNERS.md
index 7e0ef2132..011bb9a40 100644
--- a/tasks/onchain-deployment/SOLANA-SIGNERS.md
+++ b/tasks/onchain-deployment/SOLANA-SIGNERS.md
@@ -2,7 +2,9 @@
Companion to [`api/_lib/solana-signers.js`](../../api/_lib/solana-signers.js) (the machine-readable registry) and the two operator scripts below. Keep this file in sync with that registry.
-three.ws has **no single "master wallet" env var**. Every autonomous engine loads its own Solana keypair from its own env var and pays fees / rent / spend from that wallet. If a wallet runs dry, its flow stops — often silently. This doc lists every signer, what it pays for, the encoding its env var expects, and how to fund or consolidate them.
+Every autonomous engine loads its own Solana keypair from its own env var and pays fees / rent / spend from that wallet. If a wallet runs dry, its flow stops — often silently. This doc lists every signer, what it pays for, the encoding its env var expects, and how to fund or consolidate them.
+
+There **is** a single funding root: the **economy master** (`ECONOMY_MASTER_SECRET_BASE58`, `WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW` — note the capital leading `W`). It is funder-only (never trades or settles), and the [`treasury-topup`](../../api/cron/treasury-topup.js) cron auto-tops-up every engine below its floor from it every 30 min, fee-minimized and allowlist-guarded so SOL can only reach a registry wallet. Full subsystem doc: [`docs/economy-master.md`](../../docs/economy-master.md). It is inert until its secret is set, so the per-engine funding below still applies.
## The signers
@@ -10,6 +12,7 @@ Encodings: `base64` = base64 of the 64 raw secret-key bytes (`…_B64` vars); `b
| Env var | Engine / what it pays for | Enc | Min SOL | Network |
|---|---|---|---|---|
+| `ECONOMY_MASTER_SECRET_BASE58` | **Funding root** (`WwwuGbq…T3WwW`) — auto-tops-up every other signer below its floor. Funder-only; never a top-up target of itself. See [`docs/economy-master.md`](../../docs/economy-master.md) | base58 | 1.0 | mainnet |
| `LAUNCHER_MASTER_SECRET_KEY_B64` | Autonomous coin launcher — tops up the next agent's per-launch SOL (deploy + dev-buy) | base64 | 1.0 | mainnet |
| `PUMP_X402_LAUNCHER_SECRET_KEY_B64` | Fronts the ~0.022 SOL deploy cost for x402 pay-per-call pump.fun launches | base64 | 0.1 | mainnet |
| `PUMP_CRON_RELAYER_SECRET_KEY_B64` | Fees + swap gas for the buyback and distribute-payments crons | base64 | 0.1 | both |
@@ -32,7 +35,7 @@ Encodings: `base64` = base64 of the 64 raw secret-key bytes (`…_B64` vars); `b
## Two funding models
- **A — one wallet is every signer.** Put the same secret into every var above. Fast; one balance and one hot key serve everything. Blast radius: if that key leaks, all engines drain; engines compete for one balance. Use [`scripts/wire-master-wallet.mjs`](../../scripts/wire-master-wallet.mjs).
-- **B — cold master funds per-engine hot wallets.** Keep the master as a treasury source and top up each engine's own small hot wallet below a floor (the pattern `LABOR_ESCROW` and the sniper auto-funder already use via `PLATFORM_TREASURY_KEYPAIR`). Safer, but there is no universal master→engine top-up cron yet.
+- **B — cold master funds per-engine hot wallets.** Keep the master as a treasury source and top up each engine's own small hot wallet below a floor. This is now automated: the **economy master** (`ECONOMY_MASTER_SECRET_BASE58`) + the [`treasury-topup`](../../api/cron/treasury-topup.js) cron are the universal master→engine top-up loop — reserve-floor, per-engine, and per-run guarded, and allowlisted to registry wallets only. Set that secret to enable it. `LABOR_ESCROW` and the sniper auto-funder also self-fund via `PLATFORM_TREASURY_KEYPAIR`.
**Funding a wallet does not enable an engine.** Most engines also need their own flag (`CIRCULATION_ENABLED`, `THREE_BUYBACK_ENABLED`, `SOLANA_AUTODEPLOY_ENABLED`, …). EVM engines use separate keys (`EVM_TREASURY_PRIVATE_KEY`, `CIRCULATION_EVM_TREASURY_SECRET`).
@@ -48,6 +51,8 @@ Encodings: `base64` = base64 of the 64 raw secret-key bytes (`…_B64` vars); `b
`LABOR_ESCROW_SECRET_BASE58` is already **live** on its own wallet — the tool skips it unless you pass `--include-live` (rerouting strands any escrowed funds; migrate balances first). `SOLANA_AGENT_COLLECTION_AUTHORITY_KEY` is never touched.
+> **`WwwuGbq…T3WwW` plays two roles.** It is both the **economy master** funding root (`ECONOMY_MASTER_SECRET_BASE58`, `isMaster` in the registry) and, in the consolidation split above, the wallet whose key backs several payout slots (`PLATFORM_TREASURY_KEYPAIR`, `THREE_BUYBACK…`, `CLUB_SOLANA_TREASURY…`, etc.). That is consistent — the master holds those payout funds directly — but note the consequence: because those slots resolve to the master's own pubkey, the `treasury-topup` sweep will never "top them up" (a wallet cannot fund itself; the allowlist rejects it as `is_master`). They spend from the master's balance directly. If you want any of those payout flows on a *separate* hot wallet that the master keeps topped up, give it its own key rather than reusing the master's.
+
```bash
# 1. Put each wallet's secret in its own local file (base58 / base64 / JSON array).
# NEVER commit them. NEVER paste them into a chat.
diff --git a/tests/agora-player-logic.test.js b/tests/agora-player-logic.test.js
index d5dfa6579..d252fa653 100644
--- a/tests/agora-player-logic.test.js
+++ b/tests/agora-player-logic.test.js
@@ -10,6 +10,7 @@ import {
WALK_SPEED,
RUN_SPEED,
INTERACT_RADIUS,
+ PLAYER_RADIUS,
motionFor,
stepMovement,
easeYaw,
@@ -17,6 +18,8 @@ import {
nearestInteractable,
chooseAvatarSource,
guestName,
+ isOpenGround,
+ findOpenSpawn,
} from '../src/agora/player-logic.js';
describe('motion state (the wire vocabulary)', () => {
@@ -129,6 +132,45 @@ describe('interaction prompt', () => {
});
});
+describe('open-ground spawn (walk-to-NPC reachability)', () => {
+ const town = [
+ { minX: -2, maxX: 2, minZ: -2, maxZ: 2, h: 40 }, // a tower straddling the origin
+ { minX: 5, maxX: 9, minZ: 5, maxZ: 9, h: 30 },
+ ];
+
+ it('detects ground inside vs clear of buildings', () => {
+ expect(isOpenGround(0, 0, town)).toBe(false); // dead centre of the tower
+ expect(isOpenGround(1.9, 0, town)).toBe(false); // within the margin of a face
+ expect(isOpenGround(20, 20, town)).toBe(true); // open street
+ expect(isOpenGround(0, 0, [])).toBe(true); // no buildings → all open
+ });
+
+ it('nudges a walled spawn out to the nearest open point', () => {
+ const spawn = findOpenSpawn({ x: 0, z: 0 }, town);
+ expect(isOpenGround(spawn.x, spawn.z, town)).toBe(true);
+ // It stays near the desired spot, not flung across the map.
+ expect(Math.hypot(spawn.x, spawn.z)).toBeLessThan(12);
+ });
+
+ it('leaves an already-open spawn untouched', () => {
+ const spawn = findOpenSpawn({ x: 20, z: 20 }, town);
+ expect(spawn).toEqual({ x: 20, z: 20 });
+ });
+
+ it('degenerates gracefully to the desired point when nowhere is open', () => {
+ const walled = [{ minX: -1000, maxX: 1000, minZ: -1000, maxZ: 1000, h: 5 }];
+ const spawn = findOpenSpawn({ x: 3, z: 4 }, walled, { maxRadius: 20 });
+ expect(spawn).toEqual({ x: 3, z: 4 }); // never leaves the player unplaced
+ });
+
+ it('the open point clears collision push-out (player can actually stand there)', () => {
+ const spawn = findOpenSpawn({ x: 0, z: 0 }, town);
+ const resolved = resolveBuildingCollision(spawn.x, 0, spawn.z, town, PLAYER_RADIUS);
+ // A truly open point isn't pushed anywhere by the collision solver.
+ expect(Math.hypot(resolved.x - spawn.x, resolved.z - spawn.z)).toBeLessThan(1e-9);
+ });
+});
+
describe('avatar source resolution', () => {
const params = (obj) => ({ get: (k) => obj[k] ?? null });