Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(economy): let a self-pay payer refill its own USDC float instead of deadlocking below both floors
nirholase5e9c897473e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 70499ec67..7406c3d2c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -31,6 +31,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **The 3D Studio API description now covers the place-it-in-your-room link too**: The published description of the free 3D Studio API at /.well-known/3d-studio-openapi.yaml now documents the augmented-reality launch endpoint behind every arUrl, not just the generation call. Anyone building on the free lane can see the full contract in one place: how to turn a prompt into a model, how to poll for it, and how the resulting link places that model in a real room on a phone. The description stays keyless and free of any payment surface, and the copy in the ChatGPT submission kit is now regenerated from the served file so the two can never drift apart. `[docs, sdk]`- **The 3D Studio connector's docs now match the connector**: The free 3D Studio connector for ChatGPT has grown to ten tools, but several places still described the older nine-tool version, and the /openai page left the newest one off its list entirely. Every count, tool table, and annotation table has been re-checked against what the live server actually returns and corrected, including the tenth tool: check_job, which collects a model that took longer than a single turn to render. Two outright wrong claims were fixed as well. The AR docs credited the free connector with an export_ar tool that only exists on the separate paid server, and the funding note claimed generations never touch the paid engine when it is in fact kept as a fallback if the free lanes are down (either way the platform pays, never you). The rate-limit and environment-variable tables were completed, and a table that had been broken in half by a stray paragraph now renders. (`/docs/mcp-studio`) `[docs, fix]`- **The 3D Studio now says exactly which quality tier you get**: Ask the free 3D Studio for a model in ChatGPT and you get the standard tier, the balanced free lane that is fast enough to stay conversational and reliably textured. Every place that describes the studio now says that plainly, including the tool description ChatGPT itself reads, so the assistant never promises you a higher tier than it delivers. The high tier is still there whenever you want it: ask for it by name and the generation runs on our own self-hosted GPU worker for denser geometry, funded by the platform, with a graceful drop back to standard if that lane is busy. Both paths were re-checked against the live site with real models before this went out. (`/docs/mcp-studio`) `[docs, improvement]`+- **The agent payment ring can refill its own spending float again after eight days stuck**: The platform's closed payment loop keeps one pool of USDC circulating between wallets it controls, and a wallet that pays its own network fees needs both USDC to spend and a little SOL to pay with. Two rules meant to stop those two needs fighting each other combined into a trap: once the payer's total balance could cover neither, it was barred from converting spare SOL into USDC and had nothing to convert the other way, so it did nothing at all. It sat that way from 29 July, holding fee money it had no way to spend, while roughly 2,900 payment attempts a day failed for want of a few cents of float. The wallet now settles on a single sensible target when it cannot afford both, keeping just enough for fees and holding the rest as spendable balance, so it recovers on its own. The revenue share the loop pays out is also taken only from genuine surplus now: because the same money laps the circuit many times a day, a cut on every lap was quietly compounding the working float away rather than sharing earnings. Wallet records for the loop were reconciled at the same time, so every role wallet is registered and there are no stale entries left. (`/economy-lab`) `[fix, infra]`- **The Agora Commons has sculptors and scribes in it again, not a square full of couriers**: Every citizen in Agora works a trade, and the trades themselves (Sculptor, Scribe, Crier, Appraiser, Namekeeper, Verifier) are carried by the founding workforce. The square was being filled with the platform's own agents first, and those all fall back to the general courier role, so once the agent directory had any size in it the specialists were cut before the world was populated and nobody in the Commons ever sculpted or wrote anything. The specialists take their seats first now and platform agents fill the rest, so there is real craft work in the labour market at any population size. A citizen can also no longer be handed a trade that has nothing behind it: a world-building or scene signal now seats a Sculptor who can actually deliver, instead of a role that would fail every job it was given. Separately, when a Verifier rejects a deliverable it now prints both fingerprints in full, so a mismatch reads as a mismatch instead of two truncated hashes that look identical. (`/agora`) `[fix, improvement]`- **The CI asset gate stops burying the warnings that matter**: The 3D asset quality gate printed every optimization suggestion the inspect API returns, including the informational ones that fire on perfectly healthy models, so the suggestions describing a real problem were lost in the noise. It now surfaces only the warning and critical ones, and still fails no build on any of them. `[improvement]`- **The creation walkthrough covers the last three screens it was missing**: The UX Flow Atlas chapter on onboarding and agent creation now documents three screens it had been routing readers into without ever describing: the guest review screen where an avatar you built signed out gets named, explored, and claimed to your account; the what-next screen that follows a successful save; and the talking-avatar video generator. Each is traced from the shipped code, including the sign-in round trip that resumes an interrupted save, the on-chain and embed follow-ups offered after a save, and the free-video limit on the video generator. `[docs]`diff --git a/api/_lib/economy-rebalance.js b/api/_lib/economy-rebalance.jsindex 4f288f90b..d20e07f5c 100644--- a/api/_lib/economy-rebalance.js+++ b/api/_lib/economy-rebalance.js@@ -80,6 +80,58 @@ export const REBALANCE = {},};+/**+ * Resolve the fee-SOL level a self-pay wallet's BOTH legs aim at, and whether the+ * usdc->sol rescue leg is armed. PURE, so the policy is unit-testable.+ *+ * A self-pay wallet has two competing needs: fee SOL (target `targetSol`, the+ * level treasury-topup refills it to) and USDC working capital (floor+ * `usdcFloorUsd`). While its total value covers both, nothing here changes: the+ * legs use `targetSol` exactly as before.+ *+ * When its total value covers NEITHER, the old resolution deadlocked the wallet.+ * planRebalance holds back `targetSol` on the sol->usdc leg, so a wallet under+ * that target can never buy USDC; and the usdc->sol leg can only sell USDC above+ * the USDC reserve, which a starved wallet does not have. Both legs skip+ * (`insufficient_sol_surplus` + `insufficient_usdc_surplus`) on every run,+ * forever. Production, 2026-07-29 to 2026-08-06: the x402 ring payer sat at 0.140+ * SOL and $0.23 USDC against a 0.18 SOL target and a $12 USDC floor, the+ * rebalancer logged ZERO swaps for eight days, and `insufficient_payer_usdc` rose+ * from 4 to ~2,900 a day while the payer held fee SOL it had no way to spend.+ *+ * The escape is to pick ONE equilibrium and hold it on every run, because two+ * legs chasing two different targets is exactly the ping-pong the 2026-07-28 fix+ * eliminated. This wallet exists to SPEND USDC; fee SOL is instrumental. So the+ * constrained equilibrium is "keep the bare fee reserve, hold the rest as USDC",+ * and BOTH legs aim at that same reserve, so they converge instead of reversing.+ *+ * The rescue leg arms off that same reserve rather than off the registry's+ * `minSol`. `minSol` is the treasury-topup floor (how much SOL the master tries to+ * keep here), not "sell working capital to buy gas": arming on it makes any wallet+ * the master is behind on sell its USDC float for SOL it does not need, which is+ * how the ring's float turned into SOL in the first place (2026-07-28: 66+ * usdc->sol swaps, $438 churned).+ *+ * @param {object} a+ * @param {number} a.sol live SOL balance+ * @param {number} a.usdc live USDC balance (whole tokens)+ * @param {number} a.solPriceUsd live SOL/USD price+ * @param {number} a.targetSol the wallet's fee-SOL refill target+ * @param {number} a.usdcFloorUsd the wallet's USDC floor+ * @param {number} [a.solReserve] bare fee/rent headroom (defaults to REBALANCE)+ * @returns {{ solFloor: number, constrained: boolean, rescueArmed: boolean }}+ */+export function resolveSelfPayFloors({ sol, usdc, solPriceUsd, targetSol, usdcFloorUsd, solReserve }) {+ const reserve = Number.isFinite(solReserve) ? solReserve : REBALANCE.solReserve;+ const totalUsd = sol * solPriceUsd + usdc;+ const bothFloorsUsd = targetSol * solPriceUsd + usdcFloorUsd;+ // No price means no comparable totals; leave the unconstrained target in place+ // and let planRebalance abort the run honestly on `no_sol_price`.+ const constrained = solPriceUsd > 0 && totalUsd < bothFloorsUsd;+ const solFloor = constrained ? Math.min(reserve, targetSol) : targetSol;+ return { solFloor, constrained, rescueArmed: sol < reserve };+}+/*** Compute the swaps that would bring each wallet's spend-asset back to its floor,* honoring reserves, per-swap and per-run caps, and the dust floor. PURE.diff --git a/api/_lib/x402/pipelines/ring-rebalance.js b/api/_lib/x402/pipelines/ring-rebalance.jsindex 88543b236..a93ad234c 100644--- a/api/_lib/x402/pipelines/ring-rebalance.js+++ b/api/_lib/x402/pipelines/ring-rebalance.js@@ -65,19 +65,48 @@ const MASTER_REVSHARE_BPS = (() => {})();// Don't bother with a dust-sized master leg (default $0.10).const MIN_REVSHARE_ATOMIC = 100_000n;+// The payer USDC level the revshare treats as working capital rather than+// revenue. Same knob the wallet monitor alerts on, so the two agree on "the+// payer is starved".+const PAYER_USDC_FLOOR_ATOMIC = BigInt(process.env.X402_RING_PAYER_USDC_FLOOR_ATOMIC || 5_000_000);/*** Pure split of a sweep amount into { payerCut, masterCut } per the revshare* bps, with the dust floor applied to the master leg.+ *+ * The cut is taken from the SURPLUS above the payer's float need, never from the+ * float itself. The distinction is the whole ballgame in a closed loop: the same+ * principal laps payer -> treasury -> payer many times a day, so a cut applied to+ * every sweep is not a share of revenue, it is a share of the working capital+ * taken again on every lap, and it compounds the float to nothing. Measured on+ * mainnet: $54 of payer float entering 2026-07-25 was skimmed 35% per lap+ * (x402_ring_ledger booked $268 of `revshare` over eight days against a float that+ * never exceeded $54) until sweeps shrank under the dust floor and the leg went+ * quiet on its own at $0.77 of float left. Netting the payer's deficit out first+ * means the master is paid only once the loop it funds can actually run.+ ** @param {bigint} sweep total atomic USDC being swept* @param {number} [bps] override for tests; defaults to the env-derived cut+ * @param {bigint} [payerDeficitAtomic] USDC the payer is short of its float floor*/-export function splitSweep(sweep, bps = MASTER_REVSHARE_BPS) {- let masterCut = (sweep * BigInt(bps)) / 10_000n;+export function splitSweep(sweep, bps = MASTER_REVSHARE_BPS, payerDeficitAtomic = 0n) {+ const deficit = payerDeficitAtomic > 0n ? payerDeficitAtomic : 0n;+ const surplus = sweep > deficit ? sweep - deficit : 0n;+ let masterCut = (surplus * BigInt(bps)) / 10_000n;if (masterCut < MIN_REVSHARE_ATOMIC) masterCut = 0n;return { payerCut: sweep - masterCut, masterCut };}+/**+ * How far the payer is below the float floor the revshare must not eat into.+ * PURE. Never negative.+ * @param {bigint} payerUsdcAtomic live payer USDC balance+ * @param {bigint} [floorAtomic]+ */+export function payerFloatDeficit(payerUsdcAtomic, floorAtomic = PAYER_USDC_FLOOR_ATOMIC) {+ return payerUsdcAtomic >= floorAtomic ? 0n : floorAtomic - payerUsdcAtomic;+}+async function confirmSignature(conn, signature, timeoutMs = 30_000) {const deadline = Date.now() + timeoutMs;for (;;) {@@ -155,14 +184,27 @@ export async function run(ctx = {}) {}}+ const payerAta = getAssociatedTokenAddressSync(mint, payerPub, false, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID);+ const payerAtaInfo = await conn.getAccountInfo(payerAta).catch(() => null);+// Split the sweep: a bounded revenue share funds the economy master (the SOL// fuel source for every engine floor), the rest recycles to the payer float.- const split = splitSweep(sweep);+ // The share comes out of the surplus ABOVE the payer's float floor only, so a+ // starved payer is made whole before the master is paid. An unreadable payer+ // balance is treated as fully starved: skipping one revshare leg costs the+ // master a few cents, while skimming a payer that turns out to be empty stalls+ // the entire ring.+ let payerUsdc = 0n;+ if (payerAtaInfo) {+ try {+ payerUsdc = (await getAccount(conn, payerAta)).amount;+ } catch {+ payerUsdc = 0n;+ }+ }+ const split = splitSweep(sweep, MASTER_REVSHARE_BPS, payerFloatDeficit(payerUsdc));let masterCut = split.masterCut;const payerCut = split.payerCut;-- const payerAta = getAssociatedTokenAddressSync(mint, payerPub, false, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID);- const payerAtaInfo = await conn.getAccountInfo(payerAta).catch(() => null);const mintInfo = await getMint(conn, mint);const { blockhash } = await conn.getLatestBlockhash('confirmed');diff --git a/api/cron/economy-rebalance.js b/api/cron/economy-rebalance.jsindex dc27a2406..da117e70a 100644--- a/api/cron/economy-rebalance.js+++ b/api/cron/economy-rebalance.js@@ -18,7 +18,7 @@ import { env } from '../_lib/env.js';import { solanaConnection } from '../_lib/solana/connection.js';import { SOLANA_SIGNERS, resolveSignerPubkey, loadSignerKeypair } from '../_lib/solana-signers.js';import { solUsdPrice } from '../_lib/avatar-wallet.js';-import { planRebalance, executeSwap, REBALANCE, USDC_WALLETS } from '../_lib/economy-rebalance.js';+import { planRebalance, executeSwap, resolveSelfPayFloors, REBALANCE, USDC_WALLETS } from '../_lib/economy-rebalance.js';import { USDC_MINT_BY_NETWORK } from '../_lib/vault-jupiter.js';import { logAudit } from '../_lib/audit.js';import { requireCron } from '../_lib/cron-auth.js';@@ -65,15 +65,25 @@ export default wrapCron(async (req, res) => {// reserve on its sol->usdc leg (see planRebalance), so the USDC floor can// never be fed by clawing back the fee runway the SOL leg just bought.const targetSol = cfg.selfPayFee ? (spec.refillTo ?? (spec.minSol ?? 0) * 3) : 0;- wallets.push({ name: cfg.role, pubkey, sol, usdc, wants: 'usdc', floorUsd, solFloor: targetSol });+ // Both legs of a self-pay wallet must aim at the SAME fee-SOL level or they+ // reverse each other. resolveSelfPayFloors keeps that level at targetSol+ // while the wallet can afford both floors, and drops it to the bare fee+ // reserve when it cannot, the state that deadlocked the ring payer for eight+ // days. It also decides when the usdc->sol rescue leg is armed.+ const floors = cfg.selfPayFee+ ? resolveSelfPayFloors({ sol, usdc, solPriceUsd, targetSol, usdcFloorUsd: floorUsd })+ : { solFloor: 0, constrained: false, rescueArmed: false };+ wallets.push({ name: cfg.role, pubkey, sol, usdc, wants: 'usdc', floorUsd, solFloor: floors.solFloor });// Self-pay fee wallets get a second row for their SOL need. Same name on// purpose: the executor resolves the signing key by name, and both legs- // are self-swaps on the same wallet. Armed only below the registry minSol- // so routine drift never triggers it, and targeting refillTo (not minSol)- // so the swap buys real runway instead of landing exactly on the floor.- if (cfg.selfPayFee && sol < (spec.minSol ?? 0)) {- wallets.push({ name: cfg.role, pubkey, sol, usdc, wants: 'sol', floorUsd: targetSol * solPriceUsd });+ // are self-swaps on the same wallet. Armed only once the wallet is under the+ // bare fee reserve -- the point where it genuinely cannot pay its own way --+ // and targeting the same resolved floor the sol->usdc leg holds back, so a+ // rescue can never overshoot into a level the other leg will claw straight+ // back.+ if (floors.rescueArmed) {+ wallets.push({ name: cfg.role, pubkey, sol, usdc, wants: 'sol', floorUsd: floors.solFloor * solPriceUsd });}}@@ -87,7 +97,9 @@ export default wrapCron(async (req, res) => {armed: false,mode: 'dry_run',solPriceUsd,- wallets: wallets.map((w) => ({ name: w.name, sol: w.sol, usdc: w.usdc, floorUsd: w.floorUsd })),+ wallets: wallets.map((w) => ({+ name: w.name, sol: w.sol, usdc: w.usdc, wants: w.wants, floorUsd: w.floorUsd, solFloor: w.solFloor,+ })),plan,skipped,note: 'ECONOMY_REBALANCE_ENABLED is not set — no swaps executed',diff --git a/data/changelog.json b/data/changelog.jsonindex 18353d149..7980c45c8 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,16 @@{"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-08-06",+ "title": "The agent payment ring can refill its own spending float again after eight days stuck",+ "summary": "The platform's closed payment loop keeps one pool of USDC circulating between wallets it controls, and a wallet that pays its own network fees needs both USDC to spend and a little SOL to pay with. Two rules meant to stop those two needs fighting each other combined into a trap: once the payer's total balance could cover neither, it was barred from converting spare SOL into USDC and had nothing to convert the other way, so it did nothing at all. It sat that way from 29 July, holding fee money it had no way to spend, while roughly 2,900 payment attempts a day failed for want of a few cents of float. The wallet now settles on a single sensible target when it cannot afford both, keeping just enough for fees and holding the rest as spendable balance, so it recovers on its own. The revenue share the loop pays out is also taken only from genuine surplus now: because the same money laps the circuit many times a day, a cut on every lap was quietly compounding the working float away rather than sharing earnings. Wallet records for the loop were reconciled at the same time, so every role wallet is registered and there are no stale entries left.",+ "tags": [+ "fix",+ "infra"+ ],+ "link": "/economy-lab"+ },{"date": "2026-08-06","title": "A paced payment rail now says \"retry shortly\" instead of reporting itself broken",diff --git a/docs/economy-master.md b/docs/economy-master.mdindex 2489f11cf..f225aaf5c 100644--- a/docs/economy-master.md+++ b/docs/economy-master.md@@ -344,7 +344,7 @@ USDC, the next sells that SOL back for USDC, forever. That ran 134 reversingswaps and churned ~$900 of notional in 2.5 hours on 2026-07-28, paying two swapfees and double slippage per round trip to end where it started.-Two invariants close it permanently, both in `planRebalance`:+Three invariants close it permanently, the first two in `planRebalance`:1. **No opposing legs in one run** — the neediest leg wins; the other defers tothe next run against fresh balances.@@ -355,9 +355,36 @@ Two invariants close it permanently, both in `planRebalance`:deliberate: `usdc->sol` may still draw USDC down to its reserve, because feeSOL is what keeps settles alive at all.-Step 3 is what makes those invariants affordable: a payer that is genuinely short+3. **One equilibrium when the wallet cannot afford both floors.** Invariants 1+ and 2 stop the churn, but on their own they stop *everything*: a wallet under+ its fee target can never buy USDC (invariant 2 holds the target back), and a+ wallet under the USDC reserve has nothing to sell, so both legs skip with+ `insufficient_sol_surplus` + `insufficient_usdc_surplus` on every run,+ forever. Mainnet 2026-07-29 to 2026-08-06: the x402 ring payer sat at 0.140+ SOL and $0.23 USDC against a 0.18 SOL target and a $12 USDC floor, the+ rebalancer executed **zero** swaps for eight days, and `insufficient_payer_usdc`+ climbed from 4 to ~2,900 a day while the payer held fee SOL it had no way to+ spend. `resolveSelfPayFloors()`+ ([`api/_lib/economy-rebalance.js`](../api/_lib/economy-rebalance.js)) breaks it:+ when a wallet's total value cannot cover its fee target **and** its USDC floor,+ BOTH legs aim at the bare `ECONOMY_REBALANCE_SOL_RESERVE` instead, so they+ converge on one equilibrium ("keep the fee reserve, hold the rest as USDC")+ rather than reversing each other. Above that total nothing changes: the legs+ use the fee target exactly as before.++ The same function also arms the `usdc->sol` rescue leg off that reserve rather+ than off the registry's `minSol`. `minSol` is the *treasury-topup* floor (how+ much SOL the master tries to keep on the wallet), not "sell working capital to+ buy gas": arming on it makes any wallet the master is behind on sell its USDC+ float for SOL it does not need, and with `SIGNER_MIN_SOL_X402_RING_PAYER` raised+ to 0.15 that leg was armed permanently. It is how the ring's float turned into+ SOL in the first place (2026-07-28: 66 `usdc->sol` swaps, $438 churned).++Step 4 is what makes those invariants affordable: a payer that is genuinely shortof both assets is now refilled from the root instead of being asked to-manufacture one asset out of the other.+manufacture one asset out of the other. **Check `ECONOMY_USDC_TOPUP_ENABLED` is+not `0` before relying on it** as the escape hatch: with the topup off and the+rebalancer deadlocked there is no path back into USDC at all.## Lowest fees@@ -387,7 +414,7 @@ congestion, clamped to a hard ceiling.| `ECONOMY_USDC_TOPUP_MASTER_KEEP` | no | USDC the topup never spends the master below, so the SOL refuel keeps its own fuel. Default 10. || `ECONOMY_USDC_TOPUP_REFILL_MULTIPLE` | no | Lift a below-floor payer to `floor ×` this (default 1.5), so a refill buys runway instead of landing on the floor. || `ECONOMY_USDC_TOPUP_COOLDOWN_S` | no | Minimum seconds between money-moving topup runs (default 90). |-| `ECONOMY_REBALANCE_SOL_RESERVE` | no | SOL the rebalancer never swaps away from any wallet (default 0.03). Raise above a self-pay wallet's fee target as a live mitigation if the two legs ever churn. |+| `ECONOMY_REBALANCE_SOL_RESERVE` | no | SOL the rebalancer never swaps away from any wallet (default 0.03). Doubles as the constrained equilibrium and the `usdc->sol` rescue arming threshold for a self-pay wallet (see invariant 3), so it is the one knob that decides how much fee runway a starved payer keeps. || `CRON_SECRET` | yes | Bearer auth for the `treasury-topup` cron (shared with every other cron; Cloud Scheduler sends it). || `SOLANA_RPC_URL` | no | Mainnet RPC (defaults to `api.mainnet-beta`). |diff --git a/docs/x402-ring-economy.md b/docs/x402-ring-economy.mdindex f3f738971..99ea0573b 100644--- a/docs/x402-ring-economy.md+++ b/docs/x402-ring-economy.md@@ -659,7 +659,8 @@ without raising real cost — cost is only the SOL fees above.### The master revenue share: how the ring fuels the rest of the economyEvery treasury sweep routes a bounded cut (`X402_RING_MASTER_REVSHARE_BPS`,-default 20%) to the **economy master wallet** instead of the payer. That cut is+default 20%) of its **surplus** to the **economy master wallet** instead of the+payer. That cut isthe funding root's only USDC inflow: `economy-fuel.js` converts it to SOL (aself-swap, per-run and per-day capped) and `treasury-topup` distributes that SOLto every engine below its floor: the circulation treasury that drives the@@ -671,6 +672,21 @@ flat-lines (July 2026 incident). Both legs of a split sweep land insame `tx_sig`) and the reconciler verifies the treasury's on-chain deltaagainst the *sum* of the legs, each recipient against its own row.+**The cut comes out of the surplus, never out of the float.** In a closed loop+the same principal laps payer to treasury to payer many times a day, so a share+taken on *every sweep* is not a share of revenue: it is a share of the working+capital, taken again on every lap, and it compounds the float to nothing.+Measured on mainnet with the cut raised to 35%: the payer's $54 float entering+2026-07-25 produced $268 of `revshare` rows over eight days and ended at $0.77,+at which point sweeps fell under the `MIN_REVSHARE_ATOMIC` dust floor and the leg+went quiet on its own. `splitSweep()` now nets the payer's shortfall against its+USDC floor (`X402_RING_PAYER_USDC_FLOOR_ATOMIC`, the same knob the wallet monitor+alerts on) out of the sweep first and shares only what is left, so the master is+paid out of genuine surplus and only once the loop it funds can actually run. A+payer already at its floor splits exactly as before. An unreadable payer balance+is treated as fully starved: skipping one revshare leg costs the master cents,+while skimming a payer that turns out to be empty stalls the whole ring.+Two scheduling guarantees keep the recirculation alive regardless of what elsethe autonomous loop is doing:diff --git a/public/changelog.json b/public/changelog.jsonindex 78b79d4c7..592045cad 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-08-06T04:24:35.226Z",+ "generated_at": "2026-08-06T04:33:48.203Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -266,6 +266,17 @@"improvement"]},+ {+ "date": "2026-08-06",+ "type": "update",+ "title": "The agent payment ring can refill its own spending float again after eight days stuck",+ "summary": "The platform's closed payment loop keeps one pool of USDC circulating between wallets it controls, and a wallet that pays its own network fees needs both USDC to spend and a little SOL to pay with. Two rules meant to stop those two needs fighting each other combined into a trap: once the payer's total balance could cover neither, it was barred from converting spare SOL into USDC and had nothing to convert the other way, so it did nothing at all. It sat that way from 29 July, holding fee money it had no way to spend, while roughly 2,900 payment attempts a day failed for want of a few cents of float. The wallet now settles on a single sensible target when it cannot afford both, keeping just enough for fees and holding the rest as spendable balance, so it recovers on its own. The revenue share the loop pays out is also taken only from genuine surplus now: because the same money laps the circuit many times a day, a cut on every lap was quietly compounding the working float away rather than sharing earnings. Wallet records for the loop were reconciled at the same time, so every role wallet is registered and there are no stale entries left.",+ "link": "/economy-lab",+ "tags": [+ "fix",+ "infra"+ ]+ },{"date": "2026-08-06","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 9cba08a6d..8e7da8837 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -206,6 +206,14 @@<category>docs</category><description>Ask the free 3D Studio for a model in ChatGPT and you get the standard tier, the balanced free lane that is fast enough to stay conversational and reliably textured. Every place that describes the studio now says that plainly, including the tool description ChatGPT itself reads, so the assistant never promises you a higher tier than it delivers. The high tier is still there whenever you want it: ask for it by name and the generation runs on our own self-hosted GPU worker for denser geometry, funded by the platform, with a graceful drop back to standard if that lane is busy. Both paths were re-checked against the live site with real models before this went out.</description></item>+ <item>+ <title>The agent payment ring can refill its own spending float again after eight days stuck</title>+ <link>https://three.ws/economy-lab</link>+ <guid isPermaLink="false">2026-08-06:The agent payment ring can refill its own spending float again after eight days stuck</guid>+ <pubDate>Thu, 06 Aug 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The platform's closed payment loop keeps one pool of USDC circulating between wallets it controls, and a wallet that pays its own network fees needs both USDC to spend and a little SOL to pay with. Two rules meant to stop those two needs fighting each other combined into a trap: once the payer's total balance could cover neither, it was barred from converting spare SOL into USDC and had nothing to convert the other way, so it did nothing at all. It sat that way from 29 July, holding fee money it had no way to spend, while roughly 2,900 payment attempts a day failed for want of a few cents of float. The wallet now settles on a single sensible target when it cannot afford both, keeping just enough for fees and holding the rest as spendable balance, so it recovers on its own. The revenue share the loop pays out is also taken only from genuine surplus now: because the same money laps the circuit many times a day, a cut on every lap was quietly compounding the working float away rather than sharing earnings. Wallet records for the loop were reconciled at the same time, so every role wallet is registered and there are no stale entries left.</description>+ </item><item><title>The Agora Commons has sculptors and scribes in it again, not a square full of couriers</title><link>https://three.ws/agora</link>diff --git a/tests/economy-rebalance.test.js b/tests/economy-rebalance.test.jsindex aa3af8a0a..f6d53247f 100644--- a/tests/economy-rebalance.test.js+++ b/tests/economy-rebalance.test.js@@ -1,7 +1,7 @@import { describe, it, expect } from 'vitest';import bs58 from 'bs58';import { Keypair } from '@solana/web3.js';-import { planRebalance } from '../api/_lib/economy-rebalance.js';+import { planRebalance, resolveSelfPayFloors } from '../api/_lib/economy-rebalance.js';import { loadSignerKeypair, SOLANA_SIGNERS } from '../api/_lib/solana-signers.js';// Fixed bounds so the test doesn't depend on env: $3/swap, $6/run, keep 0.03 SOL@@ -154,6 +154,69 @@ describe('planRebalance', () => {});});+// The 2026-08-06 deadlock: the ring payer held 0.140 SOL and $0.23 USDC against a+// 0.18 SOL fee target and a $12 USDC floor. planRebalance holds back the fee+// target on the sol->usdc leg, and the usdc->sol leg can only sell USDC above the+// $2 reserve, so BOTH legs skipped on every run. Production logged zero rebalance+// swaps for eight days while insufficient_payer_usdc climbed to ~2,900 a day.+// resolveSelfPayFloors is the escape: when a wallet cannot afford both floors,+// both legs aim at the bare fee reserve instead, so they converge on one+// equilibrium rather than reversing each other.+describe('resolveSelfPayFloors', () => {+ const P = 150; // $/SOL+ const base = { solPriceUsd: P, targetSol: 0.18, usdcFloorUsd: 12, solReserve: 0.05 };++ it('leaves the fee target alone while the wallet can afford both floors', () => {+ // 0.30 SOL ($45) + $12 = $57 against a $39 combined need.+ const r = resolveSelfPayFloors({ ...base, sol: 0.3, usdc: 12 });+ expect(r.constrained).toBe(false);+ expect(r.solFloor).toBe(0.18);+ });++ it('drops both legs to the bare fee reserve when the wallet cannot afford both', () => {+ const r = resolveSelfPayFloors({ ...base, sol: 0.140089663, usdc: 0.23205 });+ expect(r.constrained).toBe(true);+ expect(r.solFloor).toBe(0.05);+ });++ it('unblocks the deadlocked payer with a single converging swap', () => {+ const bounds2 = { solReserve: 0.05, usdcReserve: 2, perSwapUsd: 50, runCapUsd: 100, dustUsd: 0.5 };+ const rows = (sol, usdc) => {+ const f = resolveSelfPayFloors({ ...base, sol, usdc });+ const out = [{ name: 'ring', pubkey: 'R', sol, usdc, wants: 'usdc', floorUsd: 12, solFloor: f.solFloor }];+ if (f.rescueArmed) out.push({ name: 'ring', pubkey: 'R', sol, usdc, wants: 'sol', floorUsd: f.solFloor * P });+ return out;+ };+ const run1 = planRebalance({ solPriceUsd: P, bounds: bounds2, wallets: rows(0.140089663, 0.23205) });+ expect(run1.plan).toHaveLength(1);+ expect(run1.plan[0].dir).toBe('sol->usdc');+ // Run 2 against the post-swap balances: at the USDC floor, nothing reverses.+ const sol2 = 0.140089663 - run1.plan[0].inUsd / P;+ const usdc2 = 0.23205 + run1.plan[0].inUsd;+ const run2 = planRebalance({ solPriceUsd: P, bounds: bounds2, wallets: rows(sol2, usdc2) });+ expect(run2.plan).toHaveLength(0);+ expect(run2.skipped[0].reason).toBe('above_floor');+ });++ it('arms the usdc->sol rescue only under the bare fee reserve, not the topup floor', () => {+ // 0.14 SOL is under the registry minSol (0.15) that used to arm this leg, and+ // that is what made the payer sell working capital for gas it did not need.+ expect(resolveSelfPayFloors({ ...base, sol: 0.14, usdc: 0.23 }).rescueArmed).toBe(false);+ expect(resolveSelfPayFloors({ ...base, sol: 0.01, usdc: 12 }).rescueArmed).toBe(true);+ });++ it('never raises the floor above the fee target', () => {+ const r = resolveSelfPayFloors({ ...base, targetSol: 0.02, sol: 0.001, usdc: 0 });+ expect(r.solFloor).toBe(0.02);+ });++ it('keeps the unconstrained target when the SOL price is unavailable', () => {+ const r = resolveSelfPayFloors({ ...base, solPriceUsd: 0, sol: 0.14, usdc: 0.23 });+ expect(r.constrained).toBe(false);+ expect(r.solFloor).toBe(0.18);+ });+});+// Regression guard for the ring-payer refill crash: the rebalance cron once// assigned loadSignerKeypair's WRAPPER ({ configured, keypair, decodeError }) to// `keypair` and then read `keypair.publicKey`, which is undefined — so everydiff --git a/tests/x402-ring-revshare.test.js b/tests/x402-ring-revshare.test.jsindex 47d5bed08..25d378d85 100644--- a/tests/x402-ring-revshare.test.js+++ b/tests/x402-ring-revshare.test.js@@ -1,7 +1,7 @@// The treasury sweep's master revenue share: split math and the registry's// reserved maintenance slots (the two halves of the July 2026 starvation fix).import { describe, it, expect } from 'vitest';-import { splitSweep } from '../api/_lib/x402/pipelines/ring-rebalance.js';+import { splitSweep, payerFloatDeficit } from '../api/_lib/x402/pipelines/ring-rebalance.js';import { getFullRegistry } from '../api/_lib/x402/autonomous-registry.js';describe('splitSweep', () => {@@ -36,6 +36,64 @@ describe('splitSweep', () => {});});+// The float drain the revshare caused in a CLOSED loop: the same principal laps+// payer -> treasury -> payer many times a day, so a cut on every sweep is a cut on+// the working capital taken again on every lap. Mainnet 2026-07-25 to 2026-08-06:+// $54 of payer float, $268 of `revshare` booked in x402_ring_ledger, $0.77 of+// float left. The cut now comes out of the surplus above the payer's float floor.+describe('splitSweep payer-float protection', () => {+ it('pays the master nothing while the payer is short of its float floor', () => {+ // $1.00 sweep, payer $5.00 short: the whole sweep goes back to the float.+ const { payerCut, masterCut } = splitSweep(1_000_000n, 3_500, 5_000_000n);+ expect(masterCut).toBe(0n);+ expect(payerCut).toBe(1_000_000n);+ });++ it('shares only the surplus once the sweep covers the deficit', () => {+ // $10 sweep, payer $4 short: $6 is surplus, 35% of that is $2.10.+ const { payerCut, masterCut } = splitSweep(10_000_000n, 3_500, 4_000_000n);+ expect(masterCut).toBe(2_100_000n);+ expect(payerCut).toBe(7_900_000n);+ expect(payerCut + masterCut).toBe(10_000_000n);+ });++ it('behaves exactly as before once the payer is whole', () => {+ const gated = splitSweep(100_000_000n, 2_000, 0n);+ const legacy = splitSweep(100_000_000n, 2_000);+ expect(gated).toEqual(legacy);+ expect(gated.masterCut).toBe(20_000_000n);+ });++ it('cannot be driven negative by a nonsense deficit', () => {+ const { payerCut, masterCut } = splitSweep(1_000_000n, 3_500, -5n);+ expect(masterCut).toBe(350_000n);+ expect(payerCut).toBe(650_000n);+ });++ it('survives the compounding case the drain came from', () => {+ // Repeated $1 laps against a payer stuck at $0.20 of a $6 floor never skim.+ let float = 200_000n;+ for (let i = 0; i < 20; i += 1) {+ const { payerCut, masterCut } = splitSweep(1_000_000n, 3_500, payerFloatDeficit(float, 6_000_000n));+ expect(masterCut).toBe(0n);+ float += payerCut - 1_000_000n; // pays it straight back out next lap+ }+ expect(float).toBe(200_000n);+ });+});++describe('payerFloatDeficit', () => {+ it('is zero at or above the floor', () => {+ expect(payerFloatDeficit(6_000_000n, 6_000_000n)).toBe(0n);+ expect(payerFloatDeficit(9_000_000n, 6_000_000n)).toBe(0n);+ });++ it('measures the shortfall below the floor', () => {+ expect(payerFloatDeficit(232_050n, 6_000_000n)).toBe(5_767_950n);+ expect(payerFloatDeficit(0n, 6_000_000n)).toBe(6_000_000n);+ });+});+describe('autonomous registry maintenance slots', () => {it('marks every recirculation pipeline as maintenance so the loop reserves it a slot', () => {const registry = getFullRegistry();