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.

docs(structure): map the $THREE micro-buy loop to its endpoint, cron and ledger

nirholas0eb413a8f645
diff --git a/STRUCTURE.md b/STRUCTURE.md
index 19aaf3269..de1f55558 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -210,6 +210,7 @@ bottom.
| 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` |
| 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) |
| Ring payer pool (many distinct payers) | [api/_lib/x402/pool.js](api/_lib/x402/pool.js), [api/_lib/x402/pipelines/ring-pool-fund.js](api/_lib/x402/pipelines/ring-pool-fund.js), [scripts/x402-ring-pool-setup.mjs](scripts/x402-ring-pool-setup.mjs), migration [api/_lib/migrations/2026-07-17-x402-ring-pool.sql](api/_lib/migrations/2026-07-17-x402-ring-pool.sql) | In-repo (off by default) | Reused rotating payer wallets (500–1,000) the ring tick cycles through so the closed loop shows many distinct, attributed payers at 1 tx/settle. Keys secret-box-encrypted in `x402_ring_pool`; pubkeys mirrored into `x402_ring_wallets(role='pool')` so they join the controlled set automatically; NOT in solana-signers.js so sweepback never touches them. LRU rotation (`claimNextPayer`), batched threshold funding (`ring-pool-fund`). Env: `X402_RING_POOL_ENABLED`, `X402_RING_POOL_SIZE`. See [docs/x402-ring-economy.md](docs/x402-ring-economy.md#payer-pool--many-distinct-payers-one-reused-set-of-wallets) |
+| $THREE micro-buy loop (x402 buy pressure) | Endpoint [api/x402/three-buy.js](api/x402/three-buy.js) `→ /api/x402/three-buy`, driver [api/cron/three-buy-loop.js](api/cron/three-buy-loop.js), engine [api/_lib/token/microbuy.js](api/_lib/token/microbuy.js), shared Jupiter client [api/_lib/token/jupiter.js](api/_lib/token/jupiter.js), ledger [migration 20260717233000_three_microbuy.sql](api/_lib/migrations/20260717233000_three_microbuy.sql) | In-repo (off by default) | Many tiny, real USDC→$THREE market buys per minute (target ~60/min), each triggered by (and paid through) a settled x402 call: the x402 toll routes to the ring treasury like every other endpoint, and the paid good is one on-chain buy on Jupiter. BUY-ONLY, never sells; accrued $THREE swept to the treasury. High-frequency sibling of the daily buyback ([api/_lib/token/buyback.js](api/_lib/token/buyback.js)). Real spend hard-bounded by a UTC-daily USD ceiling enforced atomically (Redis reserve-before-buy). `autobuy:false` in [ring-catalog.js](api/_lib/x402/ring-catalog.js) so the generic ring never fires it. Env: `THREE_MICROBUY_ENABLED`, `THREE_MICROBUY_SECRET_KEY_B64` (or reuses the buyback wallet), `THREE_MICROBUY_PER_TICK`, `THREE_MICROBUY_DAILY_CAP_USD`. See [docs/three-microbuy.md](docs/three-microbuy.md). |
| Money flow map | [pages/flow.html](pages/flow.html) `→ /flow`, pure graph math + force layout [src/flow-map-core.js](src/flow-map-core.js), canvas/DOM layer [src/flow-map.js](src/flow-map.js), styles [src/flow-map.css](src/flow-map.css), backend view [api/pulse.js](api/pulse.js) `→ GET /api/pulse?view=graph` | Live | The TOPOLOGY of the agent economy, which every other economy surface here misses because a leaderboard cannot show shape. A force-directed canvas map of who paid whom, for which skill, and how much, built from two already-public on-chain sources: agent-to-agent x402 skill payments (`meta.to` payee wallet + `meta.service`) and tips (`meta.from` payer wallet). Every edge is a settled transfer with an explorer-verifiable signature; no inferred or estimated edges exist. Nodes are classified `source` / `hub` / `relay` / `sink` / `quiet` from flow asymmetry, which makes capital dispersion (value entering agent wallets and never circulating out) visible at a glance and puts a number on it as "stuck capital". Counterparty privacy matches the live feed: a wallet is NAMED only when it resolves to a public, non-opted-out agent, otherwise it stays an address-only dashed node. Keyboard and screen-reader parity is structural, not a bolt-on: the table below the canvas renders from the same filtered data and selecting a row selects the node. Docs: [docs/money-flow-map.md](docs/money-flow-map.md). Tests: [tests/flow-map-core.test.js](tests/flow-map-core.test.js) |
| 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) + the signer registry [api/_lib/solana-signers.js](api/_lib/solana-signers.js) |
| Economy master audit ledger + breach monitor | ledger [api/_lib/economy-ledger.js](api/_lib/economy-ledger.js) ([schema](api/_lib/migrations/20260702010000_economy_master_ledger.sql)), reconcile cron [api/cron/economy-reconcile.js](api/cron/economy-reconcile.js), export [scripts/economy-ledger-export.mjs](scripts/economy-ledger-export.mjs) | In-repo | Tamper-evident (SHA-256 hash-chained) accounting book of every SOL movement from the master, with running balance + USD-at-transfer-time. The reconcile cron checks it every 30 min for tamper, unrecorded on-chain outbound (breach/key-compromise), and on-chain integrity; findings land in `payment_reconciliation`. Accounting CSV/JSON export. See [docs/economy-master.md](docs/economy-master.md#audit-accounting--breach-monitoring) |