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
docs(money): reconcile the money-path docs with current floors, ledgers, and endpoints
nirholas9963f943dd43
diff --git a/docs/economy-master.md b/docs/economy-master.mdindex bcf0185e9..c50b9a6f5 100644--- a/docs/economy-master.md+++ b/docs/economy-master.md@@ -1,10 +1,13 @@# 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.+engine on the platform** and does nothing else. It never launches, tips, snipes,+or settles a payment. Its on-chain actions are all funding moves: a native SOL+transfer that tops up an engine signer when that signer drops below its floor,+plus the two bounded self-refill legs described under "Fuel" below (swapping its+own idle USDC revenue into SOL, and direct USDC top-ups to the two USDC payers).+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@@ -48,7 +51,7 @@ belongs in an engine signer the master funds — not in the master.| 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. |+| Reserve floor | `ECONOMY_MASTER_RESERVE_SOL` | `0.02` | Never spend the master below this: its own rent-exemption plus fee headroom. An on-chain read, so it holds even with no database. When the master is also the x402 sponsor fee wallet (`X402_FEE_PAYER_SOLANA` points at it), the sweep floor rises to the sponsor settle floor (0.02 SOL) plus `ECONOMY_MASTER_SPONSOR_HEADROOM_SOL` (default `0.03`), so topping up engines can never starve settlement (`sweepFloorSol()`). || 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. |@@ -108,7 +111,7 @@ the return.## Agent-wallet reclaim: the other half of the fleet's SOLSweepback and `reclaimIdleSol` both walk the **`SOLANA_SIGNERS` registry** — the-eight engine wallets. That is not where most of the platform's SOL lives.+fourteen engine wallets. That is not where most of the platform's SOL lives.`fundAgentForLaunch` ([`api/_lib/launcher-funding.js`](../api/_lib/launcher-funding.js))moves SOL master → **agent custody wallet** one way, and nothing ever moved itback: snipes recycle ~97 % of their capital, but the proceeds settle into the@@ -371,6 +374,7 @@ congestion, clamped to a hard ceiling.| `ECONOMY_MASTER_SECRET_BASE58` | yes | The master keypair (base58 of 64 raw bytes). Unset ⇒ the funding root is inert. Store it as a secret on the Cloud Run service (or your host's secret store), never plaintext; keep your own offline copy since secret values are unreadable after they are written. || `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). |+| `ECONOMY_MASTER_SPONSOR_HEADROOM_SOL` | no | Working headroom the sweep keeps on top of the x402 sponsor settle floor when the master doubles as the sponsor fee wallet. Default 0.03. || `ECONOMY_FUEL_ENABLED` | no | `0` disables the USDC→SOL auto-refuel (default on). || `ECONOMY_MASTER_OPERATING_SOL` | no | Working headroom above the reserve the master keeps for sponsor co-sign fees; its shortfall below reserve + this counts toward the self-heal deficit. Default 0.15. || `ECONOMY_FUEL_PER_RUN_USDC` / `_DAILY_USDC` | no | Fuel caps: max USDC per swap (default 25) and per UTC day (default 100). |@@ -502,27 +506,27 @@ day) so it does not contribute to storage pressure. The chain head may be anchoron-chain (same mechanism as [`ledger-anchor.js`](../api/_lib/ledger-anchor.js)) fora third-party-verifiable timestamp of the books.-## 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.+## Registry coverage & runbook (updated 2026-08-05)++The 2026-07-02 wiring gaps this section used to track are closed. Current state+of the tree the master feeds:++- **The registry defines the master plus fourteen engine signers** (relayers,+ launcher master, treasuries, marketplace payer, a2a payer, ring sponsor/payer,+ circulation treasury, NFT collection authority). An engine whose secret env is+ unset simply never resolves and is skipped by the sweep; set each engine's+ secret to bring it online, and override floors per signer with+ `SIGNER_MIN_SOL_<NAME>` / `SIGNER_REFILL_TO_SOL_<NAME>`.+- **The a2a payer accepts a fallback env.** The `a2a-payer` signer reads+ `A2A_PAYER_SOLANA_SECRET` and falls back to `A2A_PAYER_SOLANA_PRIVATE_KEY`, so+ either name brings Solana mandate settlement online.+- **The x402 ring wallets are registry entries.** `x402-ring-sponsor`+ (`X402_FEE_PAYER_SECRET_BASE58`, floor 0.03 SOL, kept a hair above the 0.02+ sponsor settle floor) and `x402-ring-payer` (`X402_SEED_SOLANA_SECRET_BASE58`,+ fallback `X402_AGENT_SOLANA_SECRET_BASE58`, floor 0.03 SOL, `holdsTokens` so+ sweepback leaves its USDC float alone) are topped up by this master like every+ other engine (see [x402 ring economy](x402-ring-economy.md) /+ [autonomous x402](autonomous-x402.md)).## Relateddiff --git a/docs/financial-controls.md b/docs/financial-controls.mdindex cf84b115e..54af70830 100644--- a/docs/financial-controls.md+++ b/docs/financial-controls.md@@ -12,10 +12,11 @@ It is a companion to the [money map](money-map.md) (who receives what) and thewallets). Keep it in sync with the code — every row cites its source.> **Status of this register:** the platform's logging is strong for a few flows-> (credit deposits, marketplace sales, labor settlement) and has material gaps in-> others (unlogged treasury transfers, fire-and-forget revenue writes, Redis-only-> payout ledgers). The [gap register](#gap-register) tracks each with a severity-> and a fix. Do not treat any flow as audit-complete until its gaps are closed.+> (credit deposits, marketplace sales, labor settlement, the hash-chained+> economy-master ledger) and has material gaps in others (fire-and-forget+> revenue writes, Redis-only payout ledgers). The [gap register](#gap-register)+> tracks each with a severity and a fix. Do not treat any flow as+> audit-complete until its gaps are closed.---@@ -27,7 +28,7 @@ and whether it is reconciled against the chain.| Flow | Ledger table (key columns) | tx sig? | Append-only | Idempotency | Chain-reconciled || ---- | -------------------------- | ------- | ----------- | ----------- | ---------------- |-| x402 settlements (main revenue) | `x402_audit_log` (`event_type, payer, network, amount_atomics, asset, tx_hash, settlement_status, …`) | ✅ | by convention* | Redis proof-hash slot (app-layer) | ❌ **no** |+| x402 settlements (main revenue) | `x402_audit_log` (`event_type, payer, network, amount_atomics, asset, tx_hash, settlement_status, …`) | ✅ | by convention* | Redis proof-hash slot + durable `x402_spent_payments` row ([`spent-payments.js`](../api/_lib/x402/spent-payments.js), replay guard beyond the cache TTL; fails open) | ❌ **no** || Signed receipts | `x402_receipts` (`payer, resource_url, receipt jsonb, transaction`) | ⚠️ often NULL (`includeTxHash` default false) | by convention | ❌ none | n/a (EIP-712 verifiable) || Club tips → dancer payouts | `club_tips` (`ticket_id UNIQUE, dancer, amount_atomics, paid_tx`) → `club_payouts` (`tx, swept_tip_count`) | ✅ | payouts ✅; tips mutable | `ticket_id UNIQUE` + claim-before-send | ❌ || Club cover charges | **none** (only `x402_audit_log`) | — | — | — | ❌ |@@ -37,7 +38,7 @@ and whether it is reconciled against the chain.| $THREE buyback | `three_buyback_runs` (`usdc_spent_atomics, three_bought_atomics, buy_signature, sweep_signature`) | ✅ | ✅ (one row/run) | ❌ **no unique key** | ❌ || Coin buyback / distribute | `pump_buyback_runs`, `pump_distribute_runs` (`tx_signature, status`) | ✅ | mutable status | ❌ **no unique key** | ❌ || Withdrawals | `agent_withdrawals` (`amount, currency_mint, chain, to_address, tx_signature, status`) | ✅ | mutable status | ⚠️ claim-CAS only; **no on-chain-send idempotency** | ❌ |-| Treasury top-up / economy master | **NONE** — only an ops-alert string + ephemeral cron response | ⚠️ in alert text only | ❌ not persisted | ❌ | ❌ |+| Treasury top-up / economy master | `economy_master_ledger` (`event, target_pubkey, lamports, signature, resulting balance, sol_usd, usd_value, prev_hash, entry_hash`): every transfer/failed/blocked plus a per-sweep heartbeat row | ✅ | ✅ SHA-256 hash-chained (tamper-evident) | ❌ no unique key on sig | ✅ **yes** (`economy-reconcile`) || Autonomous x402 loop | `x402_autonomous_log` (`tx_signature, amount_atomic, success`) | ✅ | ✅ | ❌ no unique on sig | ✅ **yes** || Inbound agent payments | `agent_payment_intents` (`amount, currency_mint, tx_signature, status`) | ✅ | mutable status | tx-unique index | ✅ **yes** || a2a mandate settlements | **no durable ledger** — mandate is an unstored JWS; cap in Redis (`INCRBY`) with per-replica memory fallback | ❌ | ❌ | Redis atomic (bypassable w/o Upstash) | ❌ |@@ -85,7 +86,7 @@ Books automatically verified against the chain:**NOT reconciled against the chain:** `x402_audit_log` (the main revenue ledger),`club_payouts`, `cosmetic_sales`, `agent_jobs`, `agent_withdrawals`,-`three_buyback_runs`, treasury top-ups, and vanity payouts.+`three_buyback_runs`, and vanity payouts.Two blind spots default a record to `reconciled=true` without verifying it:**EVM/Base** settlements (`skipped_non_solana`) and **RPC failures** (`unknown`).@@ -105,18 +106,30 @@ SELECT * FROM payment_reconciliation WHERE reconciled = false ORDER BY checked_a## 3. Monitoring & breach controls-**Alerting** — [`sendOpsAlert`](../api/_lib/alerts.js) is **Telegram-only**-(`TELEGRAM_BOT_TOKEN` + `TELEGRAM_ALERTS_CHAT_ID`); a no-op if unset, swallows-delivery failures, and **self-throttles at 20 alerts/hour**. There is no+**Alerting**: [`sendOpsAlert`](../api/_lib/alerts.js) has two sinks. The+**DB sink is always on**: every alert is upserted into `ops_alerts` keyed by a+stable signature (a recurring condition is one row with a growing count), read+via `GET /api/admin/ops-alerts` and the `/admin/ops` dashboard. **Telegram is an+optional push** (`TELEGRAM_BOT_TOKEN` + `TELEGRAM_ALERTS_CHAT_ID`; absent means+dashboard-only), swallows delivery failures, dedups one push per signature per+hour, and **self-throttles at 20 pushes/hour**. There is still noemail/Slack/PagerDuty fallback and no alert-on-alerting-down.**Balance watchdogs** — `relayer-balance-check` (6h) alerts on any signer's SOLbelow its `minSol` floor; `treasury-topup` (30 min) auto-refills from the economymaster and alerts when the master can't cover or an off-registry target is-rejected. **Both read native SOL only — no USDC balance watchdog exists.**+rejected. Both read native SOL only. USDC coverage now exists for the x402+wallets: the autonomous loop's `wallet-balance-monitor`+([`api/_lib/x402/wallet-balance-monitor.js`](../api/_lib/x402/wallet-balance-monitor.js))+samples the seed/ring wallets' USDC + SOL, alerts below floor+(`X402_RING_PAYER_USDC_FLOOR_ATOMIC`, default $5), and the economy master's+direct USDC top-up ([`economy-usdc-topup.js`](../api/_lib/economy-usdc-topup.js))+auto-refills the ring/a2a payers below their floors. **Other treasuries still+have no USDC balance watchdog.****Spend controls** — x402 buyer caps (`X402_MAX_PER_CALL/HOUR/DAY_ATOMIC`, Redis-reserve-first), autonomous-loop daily cap (default $5), pumpfun spend-policy+reserve-first), autonomous-loop daily cap (`X402_AUTONOMOUS_DAILY_CAP_ATOMIC`,+default $15), pumpfun spend-policy(`daily_sol_cap` default 5), agent-wallet bridge caps, a2a mandate budget, laborescrow. **Cross-path USD caps (`agent-trade-guards.js` `daily_usd`/`per_tx_usd`)default to `null` = uncapped** — an agent whose owner never set limits has no USD@@ -130,7 +143,8 @@ kills (`SNIPER_/ORACLE_/MM_/ORDERS_GLOBAL_KILL` — **env flags, need a redeploy**Breach detection** — `wallet-anomaly.js` scores outbound transfers (size,velocity, first-time destination) and **auto-freezes** the wallet, but notifiesonly the **wallet owner, never platform ops** (`sendOpsAlert` is not called), and-**does not cover the treasury / economy-master / coin-creator custodial signers**.+**does not cover the treasury / economy-master / coin-creator custodial signers**+(those are covered by the on-chain leak scan, `wallets-leak-scan.js`, instead).There is no detection of a signer key used from an unexpected host/IP.**Tamper-evidence** — `custody-attest` (6h) Merkle-anchors custodial wallet@@ -144,9 +158,9 @@ or anchor**.| Table(s) | Deleted by | Window | Financial-record risk || -------- | ---------- | ------ | --------------------- || `x402_audit_log`, `x402_receipts`, `club_tips/payouts`, `cosmetic_sales`, `agent_*`, `credit_ledger`, payout/run tables | **nothing** | ∞ | none (safe) |-| `audit_log` (generic action log) | `audit-log-cleanup` (daily) | **365 days, hardcoded** | ⚠️ likely below statutory (5–7 yr) retention; no archive before delete |+| `audit_log` (generic action log) | `audit-log-cleanup` (daily) | **365 days, hardcoded** (legal-acceptance rows `tos-accept` / `risk-ack-accept` exempt, kept forever) | ⚠️ likely below statutory (5 to 7 yr) retention; no archive before delete || `siwx_payments` (access grants) | `siwx-gc` (daily) | 7 days post-expiry | low (money record survives elsewhere; entitlement history lost) |-| pump-intel firehose | `db-retention` (15 min) | `PUMP_INTEL_RETENTION_DAYS` (14, floor 3) | none — valve never touches money tables |+| pump-intel firehose | `db-retention` (15 min) | `PUMP_INTEL_RETENTION_DAYS` (14, floor 2) | none: valve never touches money tables |**Storage fragility:** financial tables share one **512 MB Neon branch** with a~60 MB/day intel firehose. The pressure valve protects money data *by omission@@ -162,8 +176,9 @@ There is **no consolidated, admin-authenticated, all-flows ledger export** and ncost side, so **a full P&L / cash-flow cannot be produced today**. What exists:- `api/x402-revenue.js?view=export` → CSV, **x402 settlements only**.-- `api/x402/analytics.js?report=revenue` → JSON, x402 only, **net is an estimate**- (gross − count × avg gas), not actual per-tx fees.+- `POST api/x402/analytics` body `{"report":"revenue"}` (a paid x402 endpoint) →+ JSON, x402 only; **net is derived** (gross − count × measured avg per-tx+ settlement cost over the window), not actual per-tx fees.- `api/billing/invoices.js?format=csv` → per-user metered usage, owner-scoped only.- `api/x402/my-receipts.js` → a buyer's own signed receipts.@@ -177,16 +192,11 @@ withdrawals have **no unified export**.Ranked by accounting/regulatory risk. Each is a tracked remediation item.### P0 — must fix (unlogged or double-pay risk)-1. **Treasury top-up / economy-master transfers are unlogged.** Real SOL moves with- no durable record — only an ops-alert string. *Fix: append-only- `treasury_transfers` table (from, to, lamports, signature, run_id, ts) written in- `economy-master.js` `sendSol`.* ⚠️ `economy-master.js` is under active- development by another workstream — coordinate before editing.-2. **x402 revenue writes are fire-and-forget and drop under DB load.** On-chain+1. **x402 revenue writes are fire-and-forget and drop under DB load.** On-chainsettled USDC can be absent from `x402_audit_log`, under-reporting revenue. *Fix:make the settle-path audit write awaited/durable with a dead-letter, and add a`UNIQUE(tx_hash)` idempotency constraint.*-3. **Withdrawals lack on-chain-send idempotency.** Broadcast-then-throw marks+2. **Withdrawals lack on-chain-send idempotency.** Broadcast-then-throw marks`failed` while funds may have left → double-pay on retry. *Fix: persist anidempotency key / pre-send intent and check chain before re-issuing.*@@ -222,13 +232,23 @@ Ranked by accounting/regulatory risk. Each is a tracked remediation item.12. **`audit_log` hard-deleted at 365 days** — make the window configurable andarchive to cold storage before delete.13. **Reconciliation blind spots** (EVM/RPC-miss default to reconciled); **no USDC- balance watchdog**; **alerting is single-channel + self-throttling**; **global- kill switches need a redeploy** (add a runtime halt flag).+ balance watchdog on the non-x402 treasuries** (the ring/seed wallets are+ covered, see §3); **no external alert channel beyond Telegram, and the push+ lane self-throttles**; **global kill switches need a redeploy** (add a+ runtime halt flag).14. **Financial data shares the storage-capped Neon branch** — isolate money/audittables onto their own branch/DB so an intel-firehose cap can't drop financialwrites.### Done+- ✅ **Treasury top-up / economy-master transfers are logged and reconciled.**+ Every sweep appends hash-chained rows (transfer/failed/blocked plus a heartbeat)+ to `economy_master_ledger` via [`economy-ledger.js`](../api/_lib/economy-ledger.js),+ with the tx signature, running balance, and at-transfer USD value;+ [`economy-reconcile.js`](../api/cron/economy-reconcile.js) (every 30 min)+ verifies the chain, flags unrecorded outbound debits, and confirms every+ recorded signature on-chain. Closes the former P0 "unlogged treasury transfers"+ gap.- ✅ **All controlled wallets are on-chain leak-scanned** (`wallets-leak-scan.js`,every 15 min) — not just the ring. Any SOL/token debit leaving a`SOLANA_SIGNERS` wallet to an address outside the controlled set pages ops anddiff --git a/docs/money-map.md b/docs/money-map.mdindex abbc5d6d1..544f57e6d 100644--- a/docs/money-map.md+++ b/docs/money-map.md@@ -16,7 +16,7 @@ signer/funder wallets and how to fund them).Money-routing is deliberately **config-driven** — no receiver is hardcoded, so anunset receiver fails closed rather than silently routing real USDC to a baked-in-address ([env.js:786](../api/_lib/env.js#L786)).+address ([env.js:808](../api/_lib/env.js#L808)).### Receivers (inbound USDC)| Env var | Role | Value |@@ -109,9 +109,10 @@ unit economics.[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.+ `mint_3d_asset` $0.25, `retexture_model` $0.10, `optimize_model` $0.05,+ `segment_model` $0.04, `retexture_region` $0.03, `apply_animation` $0.02,+ `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`):15 priced tools: `text_to_3d`/`image_to_3d` tiered (draft/standard/high),`auto_rig_model`/`capture_scene`/`retexture_model`/`retexture_region`/`anchor_provenance` $0.05,diff --git a/docs/risk-acknowledgment.md b/docs/risk-acknowledgment.mdindex acea75499..80d3fa427 100644--- a/docs/risk-acknowledgment.md+++ b/docs/risk-acknowledgment.md@@ -25,9 +25,10 @@ simply doesn't run; everything else on the platform keeps working.`POST /api/legal/risk-ack` ([`api/legal/risk-ack.js`](../api/legal/risk-ack.js)),which writes a `risk-ack-accept` row into `audit_log` — user id when signedin (null otherwise), disclosure version, the feature context, path, IP, and- user agent. `audit_log` is not retention-pruned, so acceptance records- persist. The write is fire-and-forget: a failed network call never blocks the- user's accepted state.+ user agent. The `audit-log-cleanup` cron prunes `audit_log` at 365 days but+ exempts `risk-ack-accept` (and `tos-accept`) rows, so acceptance records+ persist indefinitely. The write is fire-and-forget: a failed network call+ never blocks the user's accepted state.- **Devnet stays friction-free.** Surfaces that know their network only gatewhen it isn't `devnet`. Simulation modes (e.g. Oracle arm's simulate mode)are never gated.@@ -98,6 +99,12 @@ is a thin wrapper for bundled code. Pure logic (`parseAckRecord`,If you add a surface, add its row here and its gate call in the code — both inthe same change.+Known gap: the master-wallet page ([/wallet](https://three.ws/wallet),+`src/master-wallet.js`) moves real funds through its send and fund-agent flows+but does not call `ensureRiskAck()` yet; it relies on its own simulate-then-+confirm step instead. Wiring it through the gate is an open task, per the rule+above.+## Related- [Risk Disclosure](https://three.ws/legal/risk) — the full legal text users acceptdiff --git a/docs/user-wallet.md b/docs/user-wallet.mdindex 39c25664e..9f835d9cb 100644--- a/docs/user-wallet.md+++ b/docs/user-wallet.md@@ -10,14 +10,15 @@ Code: `api/user/wallet/index.js`, `send.js`, `fund-agent.js`, `history.js`.## The page: [three.ws/wallet](https://three.ws/wallet)-If you just want to use your wallet rather than script it, **[/wallet](https://three.ws/wallet)** is the whole feature in a browser. Sign in and it shows your balances across Solana and Base, your two addresses with copy buttons and explorer links, and three actions: send, fund an agent, and history. If you have never provisioned a wallet, the page offers to create one and explains exactly what gets generated first.+If you just want to use your wallet rather than script it, **[/wallet](https://three.ws/wallet)** is the whole feature in a browser. Sign in and it shows your balances across Solana and Base, your two addresses with copy buttons and explorer links, and four actions: add funds (deposit), send, fund an agent, and history. If you have never provisioned a wallet, the page offers to create one and explains exactly what gets generated first.-Two things about that page are worth knowing before you use it:+Three things about that page are worth knowing before you use it:-- **Sending is two-step by design.** When you submit the send form, the page does not sign anything. It calls `POST /api/user/wallet/send` with `simulate: true`, which runs the real balance, rent, and fee checks on the server and returns what the transfer would actually cost. Only after you read back the amount, recipient, asset, and network, and press **Confirm and send**, does anything get signed and broadcast. A transfer cannot be reversed, so nothing leaves your wallet without you seeing the final numbers.+- **Depositing is scan-to-fund.** The **Add funds** sheet (`src/wallet-deposit.js`) renders a payment-request QR, not a bare address: a Solana Pay URI (`solana:<addr>?amount=&spl-token=`) or, for Base USDC, an EIP-681 transfer link, so a scanning wallet opens with the recipient, token, and amount pre-filled. While the sheet is open, a watcher re-reads the wallet's real balances against a baseline and announces the exact on-chain delta the moment the deposit lands; it backs off over time, suspends while the tab is hidden, and gives up rather than polling forever.+- **Moving money out is two-step by design.** When you submit the send form or the fund-agent form, the page does not sign anything. It calls the route with `simulate: true`, which runs the real balance, rent, and fee checks on the server and returns what the transfer would actually cost. Only after you read back the amount, recipient, asset, and network, and press **Confirm and send**, does anything get signed and broadcast. A transfer cannot be reversed, so nothing leaves your wallet without you seeing the final numbers.- **It is the same API documented below.** The page has no privileged path: it is a session-authenticated client over these four endpoints, so anything it can do, the `curl` examples on this page can do too.-Page code: `pages/wallet.html`, `src/master-wallet.js` (controller), `src/wallet-api.js` (the client), `public/master-wallet.css`. Not to be confused with `src/wallet.js`, which connects an **external** wallet such as Phantom and has nothing to do with the custodial master wallet.+Page code: `pages/wallet.html`, `src/master-wallet.js` (controller), `src/wallet-api.js` (the client), `src/wallet-deposit.js` (the deposit sheet), `public/master-wallet.css`. Not to be confused with `src/wallet.js`, which connects an **external** wallet such as Phantom and has nothing to do with the custodial master wallet.## Master wallet vs agent wallet@@ -40,7 +41,7 @@ Funds flow one way through the platform's plumbing: master wallet to agent walle- Every route requires a signed-in **session cookie**. Without one: `401 unauthorized`. There is no bearer or API-key path on these four routes, unlike most of the API.- Every write (`POST`) additionally requires a one-time CSRF token in `X-CSRF-Token`, obtained from `GET /api/csrf-token`. The token is bound to your user id, single-use, and expires after an hour. Missing: `403 csrf_missing`. Stale or wrong: `403 csrf_invalid`. Fetch a fresh token per write.-- Reads are rate limited at 60 per minute per user. Writes that move funds are limited to **5 per day per user**, and that limiter is critical: if its backend is unreachable in production the write is refused rather than uncapped. Wallet creation is additionally limited per IP.+- Reads are rate limited at 60 per minute per user. Writes that move funds are limited to **5 per day per user**, and that limiter is critical: if its backend is unreachable in production the write is refused rather than uncapped. A `simulate: true` preview does **not** draw on that daily budget; previews have their own ceiling of 30 per minute per user, so pricing a transfer a few times can never lock you out of sending. Both money-moving routes are additionally limited per IP, as is wallet creation.See [authentication.md](authentication.md) for how sessions and CSRF tokens work in general.@@ -181,9 +182,12 @@ Error shapes worth handling: `404 not_found` (no master wallet yet), `400 invali| `agent_id` | required. Must be your agent and not deleted, otherwise `403 forbidden`. || `asset` | `"USDC"` (default) or `"SOL"`. || `amount` | positive number, or `"max"`. |+| `simulate` | `true` to preview. Runs the identical ownership, balance, rent, and fee path and returns the resolved numbers without decrypting the key or signing anything. |The destination address is resolved from the agent record, never from the request body, so there is no address to mistype. An agent that has not been provisioned a Solana wallet yet returns `400 no_agent_wallet`.+A simulation response reports `asset`, `agent_id`, `agent_wallet`, `human_amount`, `usd_value`, plus `creates_token_account` and `token_account_rent_sol` when the agent has no USDC account yet, so the rent your wallet would pay surfaces before you commit rather than appearing as a surprise SOL debit.+```bashcurl -sX POST https://three.ws/api/user/wallet/fund-agent \-b cookies.txt -H "X-CSRF-Token: $CSRF" -H 'content-type: application/json' \@@ -206,7 +210,7 @@ curl -sX POST https://three.ws/api/user/wallet/fund-agent \}```-Same reserve logic as `send`, and mainnet only: a `"max"` SOL top-up leaves rent and fee headroom, and if the agent has no USDC account yet the transaction opens one and your master wallet pays the rent (refused with `insufficient_sol_for_fees` if your SOL cannot cover it). Note there is **no `simulate` option on this route**: a well-formed call executes immediately.+Same reserve logic as `send`, and mainnet only: a `"max"` SOL top-up leaves rent and fee headroom, and if the agent has no USDC account yet the transaction opens one and your master wallet pays the rent (refused with `insufficient_sol_for_fees` if your SOL cannot cover it). Without `simulate: true`, a well-formed call executes immediately; preview first when the amount is `"max"` or the agent might lack a token account.Once the funds land, they are the agent's, and every further movement out of them runs through the agent's own spend policy, kill switch, and custody trail. Funding an agent is therefore the moment to decide how much autonomy you are comfortable financing: top up in the size you would be willing to lose to a bad strategy, not the whole balance. This is also the normal way to get USDC into an agent before it backs a vault ([vaults.md](vaults.md)) and the easiest way to send a vault the small SOL balance it needs for swap fees, by sending to the vault address with `send`.@@ -253,7 +257,7 @@ Two routes move real funds, irreversibly, the moment they return success:| `POST /api/user/wallet/send` | SOL or any SPL token, to **any address you name**. No allowlist. || `POST /api/user/wallet/fund-agent` | USDC or SOL, to **an agent you own**. |-As coded, the server-side protections are: a signed-in session (no API key can reach these), a single-use CSRF token per call, a hard ceiling of 5 outbound transactions per user per day, on-curve destination validation, and rent and fee reserves that prevent a sweep from bricking the account. That is the entire list. **There is no per-transaction cap, no daily USD cap, no destination allowlist, no freeze switch, no approval step, and no undo.** `simulate: true` on `send` is a preview, not a confirmation gate: a plain call skips it entirely, and `fund-agent` has no preview at all.+As coded, the server-side protections are: a signed-in session (no API key can reach these), a single-use CSRF token per call, a hard ceiling of 5 outbound transactions per user per day, on-curve destination validation, and rent and fee reserves that prevent a sweep from bricking the account. That is the entire list. **There is no per-transaction cap, no daily USD cap, no destination allowlist, no freeze switch, no approval step, and no undo.** `simulate: true` on `send` and `fund-agent` is a preview, not a confirmation gate: a plain call skips it entirely.So the confirmation has to come from your client, before the call: