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(three-token): stop reporting deploy burns the platform never makes and point supply claims at the revenue buyback
Nicholasb2bf595a02a6
diff --git a/api/three-token/[action].js b/api/three-token/[action].jsindex f942bffbf..72cb5bb7d 100644--- a/api/three-token/[action].js+++ b/api/three-token/[action].js@@ -3,16 +3,16 @@* -------------------------* GET /api/three-token/stats — protocol-level metrics (public)* GET /api/three-token/revenue-share — authenticated user's revenue share position- * GET /api/three-token/burns — deploy-to-burn ledger (per-deploy burns)+ * GET /api/three-token/burns — platform burn ledger (always empty: no platform burns)* GET /api/three-token/activity — protocol activity feed* GET /api/three-token/leaderboard — ranked $THREE holders (public, paginated)** Market data (price, market cap, supply, holders) comes from the shared market* module — Birdeye → DexScreener → GeckoTerminal failover with a stale cache —* so a Birdeye 429 transparently falls over to the keyless sources instead of- * blanking the price panel. Protocol data (agents, revenue, deploy burns) is- * derived from the application database; deploy burns = deployed agents ×- * AGENT_DEPLOY_BURN.+ * blanking the price panel. Protocol data (agents, revenue) is derived from the+ * application database. The platform never burns $THREE (api/_lib/token/config.js);+ * its supply commitment is the revenue buyback reported under `buyback`.*/import { sql } from '../_lib/db.js';@@ -32,9 +32,7 @@ function shortWallet(addr) {}// Protocol tokenomics (fixed parameters of the $THREE protocol).-// AGENT_DEPLOY_BURN: $THREE permanently burned each time an agent is deployed.// REVENUE_SHARE_POOL_PCT: share of platform revenue distributed to holders.-const AGENT_DEPLOY_BURN = 1000;const REVENUE_SHARE_POOL_PCT = 10;// Degrade a failed panel query without hiding WHY it failed. A silent@@ -68,28 +66,6 @@ async function fetchPlatformMetrics() {};}-// Deploy-to-burn ledger: each agent deployment burns AGENT_DEPLOY_BURN $THREE.-// We surface the most recent deployments as burn events and the lifetime total-// so the burn figures are derived from real on-chain deployment records rather-// than hardcoded or conflated with revenue.-// `name` is the agent's label everywhere in api/ (agent-task.js,-// autopilot/activity.js); agent_identities has no display column.-async function fetchBurnEvents() {- const [recent, totalRow] = await Promise.all([- sql`- SELECT id, name, created_at- FROM agent_identities- WHERE deleted_at IS NULL- ORDER BY created_at DESC- LIMIT 20- `.catch(degrade('burn_events', [])),- sql`SELECT count(*)::int AS total FROM agent_identities WHERE deleted_at IS NULL`.catch(- degrade('burn_total', [{ total: 0 }]),- ),- ]);- return { recent, totalAgents: totalRow[0]?.total ?? 0 };-}-async function fetchRecentActivity() {const rows = await sql`SELECT@@ -162,7 +138,6 @@ export default wrap(async (req, res) => {total_revenue_usd: platform.total_revenue_gross / 1_000_000,total_payments: platform.total_payments,revenue_share_pool_pct: REVENUE_SHARE_POOL_PCT,- agent_deploy_burn: AGENT_DEPLOY_BURN,},// Revenue converted to onchain buy pressure — programmatic, no burn.// Commitment fields mirror buybackStats() so the page renders the@@ -228,18 +203,22 @@ export default wrap(async (req, res) => {}if (action === 'burns') {- const { recent, totalAgents } = await fetchBurnEvents();- return json(res, 200, {- burns: recent.map((a) => ({- id: a.id,- agent_name: a.name || 'Agent',- amount: AGENT_DEPLOY_BURN,- reason: 'agent_deploy',- created_at: a.created_at,- })),- total_burned: totalAgents * AGENT_DEPLOY_BURN,- burn_per_deploy: AGENT_DEPLOY_BURN,- });+ // The platform never burns $THREE, so there is no burn ledger to report.+ // This endpoint once derived "burns" from the agent count with no on-chain+ // transaction behind them; it now answers with the policy and an empty+ // ledger, and points callers at the buyback figures that are real.+ return json(+ res,+ 200,+ {+ policy: 'no_platform_burns',+ burns: [],+ total_burned: 0,+ burn_per_deploy: 0,+ see: '/api/three-token/stats#buyback',+ },+ { 'cache-control': 'public, s-maxage=3600' },+ );}if (action === 'activity') {diff --git a/pages/three-live.html b/pages/three-live.htmlindex 485167ebd..2364f1f0a 100644--- a/pages/three-live.html+++ b/pages/three-live.html@@ -304,7 +304,7 @@<div class="cell"><div class="label">Holders</div><div class="value" id="pl-holders">—</div></div><div class="cell"><div class="label">Liquidity</div><div class="value" id="pl-liq">—</div></div><div class="cell"><div class="label">Agents deployed</div><div class="value" id="pl-agents">—</div></div>- <div class="cell"><div class="label">$THREE burned</div><div class="value r" id="pl-burned">—</div></div>+ <div class="cell"><div class="label">$THREE bought back</div><div class="value" id="pl-bought">—</div></div></section><!-- Flow counters -->@@ -711,8 +711,8 @@setTextById('pl-holders', tk.holders != null ? fmtNum(tk.holders) : '—');setTextById('pl-liq', fmtUsd(tk.liquidity));setTextById('pl-agents', pr.total_agents != null ? fmtNum(pr.total_agents) : '—');- const burned = (pr.total_agents || 0) * (pr.agent_deploy_burn || 0);- setTextById('pl-burned', burned ? fmtNum(burned) : '—');+ const bb = d.buyback || {};+ setTextById('pl-bought', bb.three_bought != null ? fmtNum(bb.three_bought) : '—');// market cap gently scales the coreif (tk.market_cap) {const mc = Math.min(1, Math.log10(Number(tk.market_cap) + 1) / Math.log10(50_000_000));diff --git a/public/legal/tos.html b/public/legal/tos.htmlindex ae3a30980..2c3a76551 100644--- a/public/legal/tos.html+++ b/public/legal/tos.html@@ -104,6 +104,7 @@<li data-i18n-html="legal_tos.total_loss_is_possible_digital_assets_are"><strong>Total loss is possible.</strong> Digital assets are volatile and speculative; any amount you commit can be lost entirely, quickly, and permanently. Blockchain transactions are irreversible.</li><li data-i18n-html="legal_tos.nothing_on_the_service_is_financial_investme"><strong>Nothing on the Service is financial, investment, legal, accounting, or tax advice</strong>, or a recommendation to buy, sell, or hold any asset. We are not your broker, adviser, or fiduciary, and no fiduciary duty is created by your use of the Service.</li><li data-i18n-html="legal_tos.autonomous_features_act_on_your_instructions"><strong>Autonomous features act on your instructions.</strong> Features you enable (autopilot, strategies, agent delegation) can transact on your behalf without asking again. You are responsible for what you enable and for monitoring it.</li>+ <li><strong>Platform fees are shown before you sign.</strong> Some Real-Funds Features carry a three.ws fee on top of network and third-party fees, for example a percentage of the dev buy when you launch a coin through three.ws. The fee is shown in the interface before you approve, travels in the same transaction you sign, and is non-refundable once that transaction confirms.</li><li data-i18n-html="legal_tos.taxes_are_yours_you_are_solely_responsible"><strong>Taxes are yours.</strong> You are solely responsible for determining and paying any taxes that apply to your transactions.</li></ul>diff --git a/src/dashboard-next/pages/three-token.js b/src/dashboard-next/pages/three-token.jsindex eb45635fe..ece68bb8f 100644--- a/src/dashboard-next/pages/three-token.js+++ b/src/dashboard-next/pages/three-token.js@@ -2,7 +2,7 @@//// The command center for the $THREE protocol economy. Shows real token// data from Birdeye/Pump.fun, platform revenue metrics, and the four-// utility pillars: agent-to-agent payments, revenue share, deploy burns,+// utility pillars: agent-to-agent payments, revenue share, revenue buyback,// and index token exposure.//// Real endpoints:@@ -80,7 +80,7 @@ function pctColor(n) {const host = main.querySelector('[data-slot="content"]');// Single source of truth for all $THREE data — price, protocol metrics,- // revenue share, activity, burns, and the signed-in holder's live position.+ // revenue share, activity, buyback, and the signed-in holder's live position.// The store wraps the same /api/three-token/* endpoints this page used to// fetch inline; centralising them keeps every section (and the position// widget) reading one consistent snapshot. It polls protocol + activity and@@ -120,7 +120,7 @@ function pctColor(n) {return;}- const stats = { token: snap.protocol.token, protocol: snap.protocol.protocol };+ const stats = { token: snap.protocol.token, protocol: snap.protocol.protocol, buyback: snap.protocol.buyback };// pump.fun verification badge beside the page title. Same live flag and// same badge the public /three-token page renders.@@ -144,7 +144,7 @@ function pctColor(n) {host.appendChild(renderUtilityPillars(stats));host.appendChild(renderLiveConverter(tokenConfig));host.appendChild(renderRevenueShare(stats, revenueShare));- host.appendChild(renderDeployBurn(stats));+ host.appendChild(renderBuyback(stats));host.appendChild(renderActivityFeed(activity));host.appendChild(renderTokenInfo());@@ -635,11 +635,11 @@ function renderUtilityPillars(stats) {color: '#60a5fa',},{- icon: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="width:28px;height:28px"><path d="M12 22C6.5 22 2 17.5 2 12S6.5 2 12 2s10 4.5 10 10"/><path d="M18 16l4 4m0-4l-4 4"/></svg>`,- title: 'Deploy-to-Burn',- desc: `Every agent deployed on three.ws burns ${fmtCompact(p.agent_deploy_burn || 1000)} $THREE permanently. More agents = less supply.`,- metric: fmtCompact(p.total_agents || 0),- metricLabel: 'agents deployed',+ icon: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="width:28px;height:28px"><path d="M3 17l6-6 4 4 8-8"/><path d="M14 7h7v7"/></svg>`,+ title: 'Revenue Buyback',+ desc: `${stats?.buyback?.commit_pct ?? 50}% of platform revenue is committed to buying $THREE on the open market. The platform never sells and never burns.`,+ metric: fmtCompact(stats?.buyback?.three_bought || 0),+ metricLabel: '$THREE bought back',color: '#f97316',},{@@ -991,65 +991,41 @@ function calcResultCards(amount, perToken, tokenPrice, revenuePool, totalSupply)`;}-// ── Deploy burn section ───────────────────────────────────────────────────────+// ── Buyback section ───────────────────────────────────────────────────────────-function renderDeployBurn(stats) {- const p = stats?.protocol || {};- const burnPerAgent = p.agent_deploy_burn || 1000;- const totalAgents = p.total_agents || 0;- const totalBurned = totalAgents * burnPerAgent;- const totalSupply = stats?.token?.supply || 1_000_000_000;- const burnPct = totalSupply > 0 ? (totalBurned / totalSupply) * 100 : 0;+// The platform never burns $THREE. What it commits to is buying $THREE with a+// fixed share of revenue, so this panel reports that ledger exactly as+// /api/three-token/stats returns it, including when the engine is switched off.+function renderBuyback(stats) {+ const bb = stats?.buyback || {};+ const enabled = bb.enabled === true;+ const lastRun = bb.last_run?.created_at || bb.last_run?.at || null;const section = document.createElement('div');section.className = 'dn-panel';section.style.cssText = 'position:relative;overflow:hidden;';+ const cell = (label, value, sub) => `+ <div style="padding:16px;background:rgba(255,255,255,0.02);border:1px solid var(--nxt-stroke);border-radius:var(--nxt-radius-sm)">+ <div style="font-size:11.5px;color:var(--nxt-ink-dim);margin-bottom:4px">${label}</div>+ <div style="font-size:22px;font-weight:700;font-family:${MONO}">${value}</div>+ <div style="font-size:11.5px;color:var(--nxt-ink-fade);margin-top:2px">${sub}</div>+ </div>`;+section.innerHTML = `- <div style="position:absolute;top:0;left:0;right:0;height:3px;background:linear-gradient(90deg,#f97316,#ef4444);opacity:0.6;border-radius:2px 2px 0 0"></div><div style="display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex-wrap:wrap;margin-top:4px;margin-bottom:20px"><div>- <h2 style="font-size:18px;font-weight:700;margin:0 0 4px">Deploy-to-Burn Mechanism</h2>- <p style="font-size:13px;color:var(--nxt-ink-dim);margin:0">Every agent deployed permanently removes $THREE from circulation</p>- </div>- </div>-- <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:14px;margin-bottom:20px">- <div style="padding:16px;background:rgba(249,115,22,0.06);border:1px solid rgba(249,115,22,0.12);border-radius:var(--nxt-radius-sm)">- <div style="font-size:11.5px;color:var(--nxt-ink-dim);margin-bottom:4px">Burn Per Deploy</div>- <div style="font-size:22px;font-weight:700;font-family:${MONO};color:#f97316">${fmtCompact(burnPerAgent)}</div>- <div style="font-size:11.5px;color:var(--nxt-ink-fade);margin-top:2px">$THREE burned permanently</div>- </div>- <div style="padding:16px;background:rgba(255,255,255,0.02);border:1px solid var(--nxt-stroke);border-radius:var(--nxt-radius-sm)">- <div style="font-size:11.5px;color:var(--nxt-ink-dim);margin-bottom:4px">Agents Deployed</div>- <div style="font-size:22px;font-weight:700;font-family:${MONO}">${fmtCompact(totalAgents)}</div>- <div style="font-size:11.5px;color:var(--nxt-ink-fade);margin-top:2px">on three.ws</div>- </div>- <div style="padding:16px;background:rgba(255,255,255,0.02);border:1px solid var(--nxt-stroke);border-radius:var(--nxt-radius-sm)">- <div style="font-size:11.5px;color:var(--nxt-ink-dim);margin-bottom:4px">Total Burned</div>- <div style="font-size:22px;font-weight:700;font-family:${MONO};color:#ef4444">${fmtCompact(totalBurned)}</div>- <div style="font-size:11.5px;color:var(--nxt-ink-fade);margin-top:2px">${burnPct.toFixed(4)}% of supply</div>+ <h2 style="font-size:18px;font-weight:700;margin:0 0 4px">Revenue Buyback</h2>+ <p style="font-size:13px;color:var(--nxt-ink-dim);margin:0">${bb.commit_pct ?? 50}% of platform revenue is committed to buying $THREE on the open market. No burn: supply is never destroyed.</p></div>+ <span style="font-size:11.5px;padding:4px 10px;border-radius:999px;border:1px solid var(--nxt-stroke);color:${enabled ? 'var(--nxt-success)' : 'var(--nxt-ink-dim)'}">${enabled ? 'Engine on' : 'Engine off'}</span></div>-- <div style="margin-bottom:8px">- <div style="display:flex;justify-content:space-between;font-size:12.5px;margin-bottom:6px">- <span style="color:var(--nxt-ink-dim)">Supply burned</span>- <span style="font-family:${MONO}">${burnPct.toFixed(4)}%</span>- </div>- <div style="height:8px;border-radius:4px;background:var(--nxt-stroke);overflow:hidden;position:relative">- <div style="height:100%;width:${Math.min(100, burnPct).toFixed(4)}%;background:linear-gradient(90deg,#f97316,#ef4444);transition:width 600ms ease;min-width:${burnPct > 0 ? '2px' : '0'}"></div>- </div>- <div style="display:flex;justify-content:space-between;font-size:11px;color:var(--nxt-ink-fade);margin-top:4px">- <span>0%</span>- <span>Circulating supply: ${fmtCompact(totalSupply - totalBurned)}</span>- <span>100%</span>- </div>- </div>-- <div style="margin-top:16px;padding:12px 16px;background:rgba(249,115,22,0.04);border:1px solid rgba(249,115,22,0.08);border-radius:8px;font-size:12.5px;color:var(--nxt-ink-dim);line-height:1.55">- Every time a creator deploys a new agent on three.ws, <strong style="color:var(--nxt-ink)">${fmtCompact(burnPerAgent)} $THREE</strong> are burned — permanently removed from circulation. This creates a deflationary flywheel: as the platform grows and more agents are deployed, the total supply of $THREE shrinks, concentrating value among remaining holders.+ <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px">+ ${cell('Committed', fmtUsd(bb.committed_usd || 0), `of ${fmtUsd(bb.revenue_usd || 0)} revenue`)}+ ${cell('Deployed', fmtUsd(bb.deployed_usd || 0), `${Number(bb.commitment_progress_pct || 0).toFixed(1)}% of commitment`)}+ ${cell('$THREE bought', fmtCompact(bb.three_bought || 0), `${fmtCompact(bb.runs || 0)} run${bb.runs === 1 ? '' : 's'}${lastRun ? `, last ${new Date(lastRun).toLocaleDateString()}` : ''}`)}</div>+ ${enabled ? '' : '<div style="margin-top:16px;padding:12px 16px;border:1px solid var(--nxt-stroke);border-radius:8px;font-size:12.5px;color:var(--nxt-ink-dim);line-height:1.55">The buyback engine is not running yet, so nothing has been bought. These figures update from the live ledger the moment it starts.</div>'}`;return section;diff --git a/src/pump/three-token-data.js b/src/pump/three-token-data.jsindex 122d21ac0..0d1772e15 100644--- a/src/pump/three-token-data.js+++ b/src/pump/three-token-data.js@@ -12,7 +12,7 @@// GET /api/three-token/stats (public, edge-cached) → protocol + token market// GET /api/three-token/revenue-share (authed; 401 = guest) → pro-rata pool math// GET /api/three-token/activity → recent revenue events-// GET /api/three-token/burns → deploy-burn ledger+// GET /api/three-token/burns → platform burn ledger (empty: the platform never burns)// POST /api/wallet/balances {chain:'solana',address} → the holder's position//// Design: a plain subscribable store (this codebase is vanilla JS modules, not@@ -43,7 +43,7 @@ function errInfo(err) {function freshState() {return {- protocol: { status: 'loading', token: null, protocol: null, source: null, updatedAt: null, error: null },+ protocol: { status: 'loading', token: null, protocol: null, buyback: null, source: null, updatedAt: null, error: null },revenueShare: { status: 'loading', unauthenticated: false, error: null },activity: { status: 'loading', events: [], error: null },burns: { status: 'loading', burns: [], total_burned: null, burn_per_deploy: null, error: null },@@ -110,6 +110,7 @@ export function createThreeTokenData(opts = {}) {status: 'ok',token: data?.token ?? null,protocol: data?.protocol ?? null,+ buyback: data?.buyback ?? null,source: data?.token?.source ?? null,updatedAt: Date.now(),error: null,diff --git a/src/pump/three-token-data.test.js b/src/pump/three-token-data.test.jsindex 06d32ccc8..bdd94e39e 100644--- a/src/pump/three-token-data.test.js+++ b/src/pump/three-token-data.test.js@@ -30,7 +30,8 @@ const WALLET = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; // 44-char base58function statsOk() {return {token: { mint: THREE_MINT, symbol: '$THREE', price_usd: 2, supply: 1000, decimals: 6, source: 'birdeye' },- protocol: { total_agents: 5, revenue_share_pool_pct: 10, agent_deploy_burn: 1000 },+ protocol: { total_agents: 5, revenue_share_pool_pct: 10 },+ buyback: { enabled: false, commit_pct: 50, three_bought: 0, runs: 0 },};}@@ -38,7 +39,7 @@ function statsOk() {function routeGet(path) {if (path === '/api/three-token/stats') return Promise.resolve(statsOk());if (path === '/api/three-token/activity') return Promise.resolve({ events: [{ id: 'e1', type: 'payment' }] });- if (path === '/api/three-token/burns') return Promise.resolve({ burns: [], total_burned: 5000, burn_per_deploy: 1000 });+ if (path === '/api/three-token/burns') return Promise.resolve({ policy: 'no_platform_burns', burns: [], total_burned: 0, burn_per_deploy: 0 });if (path === '/api/three-token/revenue-share') return Promise.resolve({ user_id: 'u1', revenue_share_pool_usd: 50 });return Promise.reject(new Error(`unexpected GET ${path}`));}@@ -62,7 +63,8 @@ describe('createThreeTokenData — protocol/activity/burns', () => {expect(s.activity.status).toBe('ok');expect(s.activity.events).toHaveLength(1);expect(s.burns.status).toBe('ok');- expect(s.burns.total_burned).toBe(5000);+ expect(s.burns.total_burned).toBe(0);+ expect(s.protocol.buyback.commit_pct).toBe(50);store.destroy();});diff --git a/tests/api/three-token-actions.test.js b/tests/api/three-token-actions.test.jsindex b38efc6d6..33816a739 100644--- a/tests/api/three-token-actions.test.js+++ b/tests/api/three-token-actions.test.js@@ -177,43 +177,19 @@ function routeSql(handlers) {describe('GET /api/three-token/burns', () => {beforeEach(() => { vi.clearAllMocks(); });- afterEach(() => { vi.restoreAllMocks(); });- it('renders the deploy-burn ledger from real agent rows', async () => {- routeSql([- ['ORDER BY created_at DESC', () => Promise.resolve([- { id: 'a1', name: 'Green Galunga', created_at: '2026-08-16T04:58:12.852Z' },- { id: 'a2', name: null, created_at: '2026-08-15T21:17:07.046Z' },- ])],- ['count(*)', () => Promise.resolve([{ total: 3167 }])],- ]);+ it('reports the no-burn policy with an empty ledger and never touches the database', async () => {const res = makeRes();await handler(makeReq('/api/three-token/burns'), res);expect(res.statusCode).toBe(200);const body = getJson(res);- expect(body.burn_per_deploy).toBe(1000);- expect(body.total_burned).toBe(3167 * 1000);- expect(body.burns).toHaveLength(2);- expect(body.burns[0]).toMatchObject({ id: 'a1', agent_name: 'Green Galunga', amount: 1000, reason: 'agent_deploy' });- // A nameless agent still gets a label rather than an empty cell.- expect(body.burns[1].agent_name).toBe('Agent');- });-- it('degrades to an empty ledger on a query failure, and logs why', async () => {- const logged = vi.spyOn(console, 'error').mockImplementation(() => {});- routeSql([- ['ORDER BY created_at DESC', () => Promise.reject(new Error('column "nope" does not exist'))],- ['count(*)', () => Promise.resolve([{ total: 7 }])],- ]);- const res = makeRes();- await handler(makeReq('/api/three-token/burns'), res);-- expect(res.statusCode).toBe(200);- expect(getJson(res).burns).toEqual([]);- // The silent swallow is what hid the original bug: the reason must reach the logs.- expect(logged).toHaveBeenCalled();- expect(logged.mock.calls.flat().join(' ')).toContain('does not exist');+ expect(body.policy).toBe('no_platform_burns');+ expect(body.burns).toEqual([]);+ expect(body.total_burned).toBe(0);+ expect(body.burn_per_deploy).toBe(0);+ // Burns were once derived from the agent count. Nothing here may read it.+ expect(sql).not.toHaveBeenCalled();});});