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.

fix(economy): hold shared treasury wallets to their strictest refill floor

nirholas1c73c5b06b5a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59b293e18..0ae9487e6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-07-30
- **An underfunded trading bot now sits out instead of failing every trade** — A trading strategy whose wallet ran low could get stuck in a loop: it looked funded enough to place a shrunken buy, but not funded enough to run the safety simulation that has to pass before anything is broadcast. So it tried every candidate coin, failed at the same step every time, and filled its history with failures while never actually trading. One live strategy did this 82 times in a day without placing a single buy. Strategies now compare their balance against the amount a trade genuinely needs end to end, including the pre-trade safety checks, and quietly wait for a top-up instead. No trade behavior changes for a properly funded strategy. (`/trades`) `[fix]`
+- **Money Pulse volume restored: shared treasury wallets now refill against their strictest floor** — The autonomous economy's treasury refill sweep judged a wallet shared by two roles against the more permissive role's minimum balance, so the circulation treasury could sit nearly empty without ever qualifying for a top-up. With no measured shortfall, the USDC-to-SOL refuel lane stayed idle too, and the Money Pulse quietly dropped to free actions only. Shared wallets are now topped up once but held to the strictest floor across all their roles, so paid activity (tips, agent payments, trades, launches) self-heals instead of flatlining. `[fix, infra]`
- **Payment health now names the real cause when settlements stall** — The platform watches how many of its automated payments actually settle. When that number fell, the alert always said the same thing: payments are being rejected. That was misleading in the most common case, where nothing is rejected at all. The platform simply stops offering Solana as a payment option while its sponsor wallet is topped up, so its own agents have nothing they can pay. The health report now tells these two situations apart by name, counts how often the Solana option was unavailable, and points at the one-command self-repair instead of sending whoever is on call to the wrong system. `[infra, improvement]`
- **Payment Sessions, the developer platform, and the media APIs are now documented** — Three new developer guides: Payment Sessions (fund a capped spend envelope from prepaid credits and let an agent pay x402 services with a bearer token, no private key involved), the developer platform (API keys, usage metrics, signed webhooks, the one-call MCP connection test, and the public tool and skills catalogs), and the media and render API (avatar image renders, posed clip renders, the runtime GLB optimizer, the open model proxy, and the free vision and speech-to-text endpoints). Every endpoint ships with a runnable example. (`/docs/payment-sessions`) `[docs]`
- **Runnable examples for the x402 fetch wrapper, the MCP server, and the avatar SDK** — Three example sets you can run as-is against live three.ws services: a zero-spend x402 discovery probe plus a key-gated real paid call, curl and plain Node walkthroughs of the full MCP session lifecycle including a free tool call, and a build-free HTML page that renders a live 3D avatar straight from the CDN. `[docs, sdk]`
diff --git a/data/changelog.json b/data/changelog.json
index 15b8824f3..44473821f 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -16886,6 +16886,15 @@
"docs",
"sdk"
]
+ },
+ {
+ "date": "2026-07-30",
+ "title": "Money Pulse volume restored: shared treasury wallets now refill against their strictest floor",
+ "summary": "The autonomous economy's treasury refill sweep judged a wallet shared by two roles against the more permissive role's minimum balance, so the circulation treasury could sit nearly empty without ever qualifying for a top-up. With no measured shortfall, the USDC-to-SOL refuel lane stayed idle too, and the Money Pulse quietly dropped to free actions only. Shared wallets are now topped up once but held to the strictest floor across all their roles, so paid activity (tips, agent payments, trades, launches) self-heals instead of flatlining.",
+ "tags": [
+ "fix",
+ "infra"
+ ]
}
]
}
diff --git a/public/changelog.json b/public/changelog.json
index c30bbaad6..d5999c2dc 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-07-30T03:18:32.767Z",
+ "generated_at": "2026-07-30T03:20:42.797Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -16,6 +16,17 @@
"fix"
]
},
+ {
+ "date": "2026-07-30",
+ "type": "update",
+ "title": "Money Pulse volume restored: shared treasury wallets now refill against their strictest floor",
+ "summary": "The autonomous economy's treasury refill sweep judged a wallet shared by two roles against the more permissive role's minimum balance, so the circulation treasury could sit nearly empty without ever qualifying for a top-up. With no measured shortfall, the USDC-to-SOL refuel lane stayed idle too, and the Money Pulse quietly dropped to free actions only. Shared wallets are now topped up once but held to the strictest floor across all their roles, so paid activity (tips, agent payments, trades, launches) self-heals instead of flatlining.",
+ "link": null,
+ "tags": [
+ "fix",
+ "infra"
+ ]
+ },
{
"date": "2026-07-30",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index b0b3e1bce..8d61dc947 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -14,6 +14,14 @@
<category>fix</category>
<description>A trading strategy whose wallet ran low could get stuck in a loop: it looked funded enough to place a shrunken buy, but not funded enough to run the safety simulation that has to pass before anything is broadcast. So it tried every candidate coin, failed at the same step every time, and filled its history with failures while never actually trading. One live strategy did this 82 times in a day without placing a single buy. Strategies now compare their balance against the amount a trade genuinely needs end to end, including the pre-trade safety checks, and quietly wait for a top-up instead. No trade behavior changes for a properly funded strategy.</description>
</item>
+ <item>
+ <title>Money Pulse volume restored: shared treasury wallets now refill against their strictest floor</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-07-30:Money Pulse volume restored: shared treasury wallets now refill against their strictest floor</guid>
+ <pubDate>Thu, 30 Jul 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The autonomous economy's treasury refill sweep judged a wallet shared by two roles against the more permissive role's minimum balance, so the circulation treasury could sit nearly empty without ever qualifying for a top-up. With no measured shortfall, the USDC-to-SOL refuel lane stayed idle too, and the Money Pulse quietly dropped to free actions only. Shared wallets are now topped up once but held to the strictest floor across all their roles, so paid activity (tips, agent payments, trades, launches) self-heals instead of flatlining.</description>
+ </item>
<item>
<title>Payment health now names the real cause when settlements stall</title>
<link>https://three.ws/changelog</link>
diff --git a/public/features.json b/public/features.json
index b00397ffd..16ff553d2 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-07-30T03:18:32.760Z",
+ "generated_at": "2026-07-30T03:20:42.790Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/tests/treasury-topup-shared-wallet.test.js b/tests/treasury-topup-shared-wallet.test.js
new file mode 100644
index 000000000..a9fff1b4d
--- /dev/null
+++ b/tests/treasury-topup-shared-wallet.test.js
@@ -0,0 +1,125 @@
+// Two registry entries whose secrets resolve to the SAME wallet must be topped
+// up once, judged against the STRICTEST of their specs.
+//
+// Production hit the opposite on 2026-07-30: the circulation treasury (floor
+// 0.2 SOL, refill 0.5) shared a wallet with pump-cron-relayer (floor 0.01),
+// and the first-spec-wins dedupe kept only the relayer's trivial floor. The
+// shared wallet sat at 0.012 SOL (above 0.01, far below 0.2), so it was never
+// a refill target, the sweep's deficit read zero, the USDC→SOL fuel lane never
+// fired, and the circulation engine ran free-actions-only: the Money Pulse
+// showed reviews and trials but no tips, payments, trades, or launches.
+//
+// Exercised through the real handler in ?dry=1 mode: same signer resolution and
+// target building as a live sweep, no SOL movement, no alerts, no ledger.
+
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+const { MASTER, SHARED, LONER } = vi.hoisted(() => ({
+ MASTER: 'WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW',
+ SHARED: 'SharedSharedSharedSharedSharedSharedShared1',
+ LONER: 'EngineEngineEngineEngineEngineEngineEngine1',
+}));
+
+vi.mock('../api/_lib/solana-signers.js', () => ({
+ SOLANA_SIGNERS: [
+ { name: 'economy-master', env: 'ECONOMY_MASTER_SECRET_BASE58', isMaster: true, minSol: 0.05, network: 'mainnet' },
+ // The permissive spec resolves FIRST: the regression this test pins is
+ // its low floor shadowing the strict spec below.
+ { name: 'pump-cron-relayer', env: 'PUMP_RELAYER_SECRET', minSol: 0.01, network: 'mainnet' },
+ { name: 'circulation-treasury', env: 'CIRCULATION_TREASURY_SECRET', minSol: 0.2, refillTo: 0.5, network: 'mainnet' },
+ { name: 'a2a-payer', env: 'A2A_PAYER_SECRET', minSol: 0.02, network: 'mainnet' },
+ ],
+ resolveSignerPubkey: vi.fn(async (spec) => {
+ if (spec.name === 'a2a-payer') return { configured: true, pubkey: LONER };
+ if (spec.isMaster) return { configured: true, pubkey: MASTER };
+ // The shared-wallet condition under test: relayer and circulation
+ // treasury secrets decode to the same pubkey.
+ return { configured: true, pubkey: SHARED };
+ }),
+}));
+
+vi.mock('../api/_lib/economy-master.js', () => ({
+ ECONOMY_MASTER_ADDRESS: MASTER,
+ RESERVE_SOL: 0.05,
+ RUN_CAP_SOL: 0.5,
+ PER_TOPUP_MAX_SOL: 0.2,
+ sweepTopUps: vi.fn(async ({ targets }) => ({
+ configured: true,
+ plan: targets.map((t) => ({ name: t.name, pubkey: t.pubkey, sol: 0.1 })),
+ skipped: [],
+ rejected: [],
+ funded: [],
+ failed: [],
+ spentSol: 0,
+ masterSol: 0.02,
+ spendableSol: 0,
+ })),
+}));
+
+vi.mock('../api/_lib/economy-ledger.js', () => ({ recordSweep: vi.fn(async () => ({ wrote: 0 })) }));
+vi.mock('../api/_lib/economy-fuel.js', () => ({
+ refuelMasterFromUsdc: vi.fn(async () => ({ acted: false, reason: 'no_spare_usdc' })),
+}));
+vi.mock('../api/_lib/economy-usdc-topup.js', () => ({
+ topUpUsdcEngines: vi.fn(async () => ({ funded: [], skipped: [], failed: [] })),
+}));
+vi.mock('../api/_lib/economy-sweepback.js', () => ({
+ reclaimIdleSol: vi.fn(async () => ({ reclaimedSol: 0, moves: [], skipped: [], failed: [] })),
+ reclaimIdleAgentSol: vi.fn(async () => ({ reclaimedSol: 0, moves: [], skipped: [], failed: [] })),
+}));
+vi.mock('../api/_lib/alerts.js', () => ({ sendOpsAlert: vi.fn(async () => {}) }));
+vi.mock('../api/_lib/solana/connection.js', () => ({
+ // 0.012 SOL everywhere: above the relayer's 0.01 floor, below the
+ // circulation treasury's 0.2 and the loner's 0.02.
+ solanaConnection: () => ({ getBalance: vi.fn(async () => 12_214_000) }),
+}));
+
+import handler from '../api/cron/treasury-topup.js';
+
+function mockRes() {
+ return {
+ statusCode: 200,
+ _headers: {},
+ _body: null,
+ setHeader(k, v) { this._headers[k.toLowerCase()] = v; },
+ getHeader(k) { return this._headers[k.toLowerCase()]; },
+ end(b) { this._body = b || ''; this.writableEnded = true; },
+ writableEnded: false,
+ headersSent: false,
+ };
+}
+
+beforeEach(() => {
+ process.env.CRON_SECRET = 'test-cron-secret';
+});
+
+describe('treasury-topup shared-wallet floors', () => {
+ it('judges a shared wallet against the strictest spec and tops it up once', async () => {
+ const res = mockRes();
+ await handler(
+ {
+ method: 'GET',
+ url: '/api/cron/treasury-topup?dry=1',
+ headers: { authorization: 'Bearer test-cron-secret' },
+ socket: { remoteAddress: '127.0.0.1' },
+ },
+ res,
+ );
+
+ const body = JSON.parse(res._body);
+ expect(body.ok).toBe(true);
+ expect(body.dry_run).toBe(true);
+
+ // The shared wallet appears exactly once, under the merged name, with the
+ // strictest floor's refill target, not silently dropped by the relayer's
+ // 0.01 floor.
+ const shared = body.targets.filter((t) => t.pubkey === SHARED);
+ expect(shared).toHaveLength(1);
+ expect(shared[0].name).toBe('pump-cron-relayer+circulation-treasury');
+ expect(shared[0].refillToSol).toBe(0.5);
+ expect(shared[0].currentSol).toBeCloseTo(0.012214, 6);
+
+ // The unshared under-floor engine is still its own target.
+ expect(body.targets.some((t) => t.pubkey === LONER && t.name === 'a2a-payer')).toBe(true);
+ });
+});