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(launch-studio): drop the reward targets the launch wizard cannot actually apply

nirholasab5012addd89
diff --git a/docs/launch-usecases.md b/docs/launch-usecases.md
index b5e48bbf4..8d61e167f 100644
--- a/docs/launch-usecases.md
+++ b/docs/launch-usecases.md
@@ -54,18 +54,45 @@ The preview drawer has a **reward planner**: route a coin's creator fees to any
| **GitHub @user** | 100% to a GitHub account (pump.fun social platform 2). |
| **X @handle** | 100% to an X / Twitter account (pump.fun social platform 1). |
| **Wallet / .sol** | 100% to a fixed Solana address or name. |
-| **Cashback** | Trading fees return to holders. |
-| **Buyback** | Fees auto-buy-back & burn the coin. |
-The same generalisation powers the post-launch [fees panel](../public/studio/fees-panel.js):
-its recipient box accepts a **GitHub @user**, an **X handle** (`x:@handle`), a
-raw **Solana wallet**, or an **owner/repo** to split across contributors. All of
-it resolves through one shared resolver ([`api/_lib/github-reward.js`](../api/_lib/github-reward.js),
-`resolveSocialReward`) so GitHub and X route identically.
+Every target in that table survives the handoff to the launch wizard, which is
+the point: a target the launch flow cannot apply is a promise the product does
+not keep. (Cashback and buyback used to appear here and were exactly that.
+Cashback is a read-only pump.fun pool property with no create-time control, and
+the launch panel's buyback slider burns *agent revenue* rather than routing
+creator fees, so neither is offered.)
+
+### The `?reward=` handoff
+
+"Launch this coin" builds a deep link to `/launch` carrying the coin identity
+**and** the chosen routing:
-For reward coins, after the coin graduates you set the GitHub recipient in the
-[fees panel](../public/studio/fees-panel.js) (type a `@username` → 100%, or
-import a repo's contributors to split) — see the fee-sharing flow.
+```
+/launch?name=Deepseek+Harness&symbol=DEEPSEEKH&description=…&image=…&reward=github:deepseek-ai
+```
+
+`reward` takes one of three forms, and anything else is ignored rather than
+blocking a launch:
+
+| Value | Recipient |
+|---|---|
+| `github:<login>` | A GitHub account, resolved to its three.ws-linked payout wallet. |
+| `x:<handle>` | An X account, same resolver. |
+| `wallet:<address or name.sol>` | A fixed Solana recipient. |
+
+[`public/launch/launch.js`](../public/launch/launch.js) parses it, the launch
+panel shows the routing on the form before the mint ("Creator fees route to
+@deepseek-ai on GitHub"), and the moment the coin lands the post-launch
+[fees panel](../public/studio/fees-panel.js) mounts on the success screen with
+that recipient already filled in at 100%. It is a draft, not an automatic write:
+the creator still reviews and signs the split, and a coin that already has
+shareholders is never re-seeded.
+
+The same generalisation powers that fees panel on its own: its recipient box
+accepts a **GitHub @user**, an **X handle** (`x:@handle`), a raw **Solana
+wallet**, or an **owner/repo** to split across contributors. All of it resolves
+through one shared resolver ([`api/_lib/github-reward.js`](../api/_lib/github-reward.js),
+`resolveSocialReward`) so GitHub and X route identically.
## API
diff --git a/pages/fees.html b/pages/fees.html
index 5751e7650..9df9416ff 100644
--- a/pages/fees.html
+++ b/pages/fees.html
@@ -94,24 +94,26 @@
category, the chains they run on, and 24-hour, 7-day, and 30-day totals.
</p>
- <div class="fx-toggle" role="tablist" aria-label="Metric">
+ <!-- A segmented pair of toggle buttons, not a tablist: there is no
+ tabpanel here (the metric swaps the stats, chart and table in
+ place), and a tablist would promise arrow-key navigation this
+ control does not implement. aria-pressed is the honest role. -->
+ <div class="fx-toggle" role="group" aria-label="Metric">
<button
type="button"
class="fx-toggle-btn"
- role="tab"
id="fx-tab-fees"
data-type="fees"
- aria-selected="true"
+ aria-pressed="true"
data-i18n="fees.fees">
Fees
</button>
<button
type="button"
class="fx-toggle-btn"
- role="tab"
id="fx-tab-revenue"
data-type="revenue"
- aria-selected="false"
+ aria-pressed="false"
data-i18n="fees.revenue">
Revenue
</button>
diff --git a/pages/launch-studio.html b/pages/launch-studio.html
index 975a88da7..0946788c7 100644
--- a/pages/launch-studio.html
+++ b/pages/launch-studio.html
@@ -4,25 +4,25 @@
<script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title data-i18n="launch_studio.meta_title">Launch Studio — 50 ways to mint a coin · three.ws</title>
+ <title data-i18n="launch_studio.meta_title">Launch Studio: 50 ways to mint a coin · three.ws</title>
<meta
name="description"
- content="A catalog of 50 coin-launch use cases — from reward coins for trending GitHub repos and creators to coins riding live cultural narratives. Preview what each would mint right now, then launch on pump.fun in one click."
+ content="A catalog of 50 coin-launch use cases: reward coins for trending GitHub repos and creators, and coins riding live cultural, news, and onchain narratives. Preview what each would mint right now from live data, then launch on pump.fun in one click."
data-i18n-attr="content:launch_studio.meta_description"/>
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://three.ws/launch-studio" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="three.ws" />
- <meta property="og:title" content="Launch Studio — 50 ways to mint a coin" data-i18n-attr="content:launch_studio.meta_og_title"/>
- <meta property="og:description" content="Reward coins for trending GitHub creators, coins riding live narratives — preview live, launch in one click." data-i18n-attr="content:launch_studio.meta_og_description"/>
+ <meta property="og:title" content="Launch Studio: 50 ways to mint a coin" data-i18n-attr="content:launch_studio.meta_og_title"/>
+ <meta property="og:description" content="Reward coins for trending GitHub creators, coins riding live narratives. Preview live, launch in one click." data-i18n-attr="content:launch_studio.meta_og_description"/>
<meta property="og:url" content="https://three.ws/launch-studio" />
<meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Launch+Studio%3A+50+ways+to+mint+a+coin&amp;d=A+catalog+of+50+coin-launch+use+cases%3A+reward+coins+for+trending+GitHub+repos+and+creators%2C+and+coins+riding+live+cultural%2C+news%2C+and+onchain+narratives.&amp;p=%2Flaunch-studio" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
- <meta name="twitter:title" content="Launch Studio — 50 ways to mint a coin" data-i18n-attr="content:launch_studio.meta_twitter_title"/>
- <meta name="twitter:description" content="Reward coins for trending GitHub creators, coins riding live narratives — preview live, launch in one click." data-i18n-attr="content:launch_studio.meta_twitter_description"/>
+ <meta name="twitter:title" content="Launch Studio: 50 ways to mint a coin" data-i18n-attr="content:launch_studio.meta_twitter_title"/>
+ <meta name="twitter:description" content="Reward coins for trending GitHub creators, coins riding live narratives. Preview live, launch in one click." data-i18n-attr="content:launch_studio.meta_twitter_description"/>
<meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Launch+Studio%3A+50+ways+to+mint+a+coin&amp;d=A+catalog+of+50+coin-launch+use+cases%3A+reward+coins+for+trending+GitHub+repos+and+creators%2C+and+coins+riding+live+cultural%2C+news%2C+and+onchain+narratives.&amp;p=%2Flaunch-studio" />
<link rel="icon" href="/favicon.ico" sizes="any" />
@@ -35,23 +35,31 @@
<link rel="stylesheet" href="/mobile.css" />
<style>
+ /* Colours come from the /tokens.css ramp, so the shell flips with
+ [data-theme]. The literal whites this replaced left the hero title,
+ the hero copy and the breadcrumb invisible on the light canvas. */
.lc-page { min-height: 100vh; display: flex; flex-direction: column; }
.lc-main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.5rem 1rem 4rem; box-sizing: border-box; }
- .lc-breadcrumb { font-size: 0.78rem; color: rgba(255, 255, 255, 0.4); margin-bottom: 1.4rem; display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
- .lc-breadcrumb a { color: rgba(255, 255, 255, 0.55); text-decoration: none; }
- .lc-breadcrumb a:hover { color: #a4f0bc; }
+ .lc-breadcrumb { font-size: 0.78rem; color: var(--ink-faint, rgba(255, 255, 255, 0.4)); margin-bottom: 1.4rem; display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
+ .lc-breadcrumb a { color: var(--ink-dim, rgba(255, 255, 255, 0.55)); text-decoration: none; border-radius: 4px; transition: color 0.15s; }
+ .lc-breadcrumb a:hover { color: var(--brand-ink, #2f8f56); }
+ .lc-breadcrumb a:focus-visible { outline: 2px solid var(--brand-ink, #2f8f56); outline-offset: 2px; }
.lc-hero { text-align: center; margin-bottom: 1.8rem; }
.lc-hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); font-weight: 700; letter-spacing: -0.02em; margin: 0 0 0.6rem;
- background: linear-gradient(180deg, #fff, rgba(255, 255, 255, 0.62)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
- .lc-hero p { font-size: clamp(0.92rem, 2vw, 1.05rem); color: rgba(255, 255, 255, 0.55); line-height: 1.6; max-width: 46ch; margin: 0 auto; }
+ color: var(--ink-bright, #fff);
+ background: linear-gradient(180deg, var(--ink-bright, #fff), var(--ink-dim, rgba(255, 255, 255, 0.62))); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
+ .lc-hero p { font-size: clamp(0.92rem, 2vw, 1.05rem); color: var(--ink-dim, rgba(255, 255, 255, 0.55)); line-height: 1.6; max-width: 46ch; margin: 0 auto; }
.lc-hero .lc-pill { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
- color: #c8f0d8; background: rgba(164, 240, 188, 0.08); border: 1px solid rgba(164, 240, 188, 0.22); border-radius: 999px; padding: 0.3rem 0.7rem; margin-bottom: 1rem; }
- .lc-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: #a4f0bc; box-shadow: 0 0 6px rgba(164, 240, 188, 0.6); }
+ color: var(--brand-ink, #c8f0d8); background: rgba(164, 240, 188, 0.08); border: 1px solid rgba(164, 240, 188, 0.22); border-radius: 999px; padding: 0.3rem 0.7rem; margin-bottom: 1rem; }
+ .lc-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand-dot, #a4f0bc); box-shadow: 0 0 6px rgba(164, 240, 188, 0.6); }
+ :root { --brand-ink: #c8f0d8; --brand-dot: #a4f0bc; }
+ :root[data-theme='light'] { --brand-ink: #1a6b3c; --brand-dot: #1f8a4d; }
+ :root[data-theme='light'] .lc-hero .lc-pill { background: rgba(31, 138, 77, 0.08); border-color: rgba(31, 138, 77, 0.28); }
</style>
- <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Launch Studio","description":"A catalog of 50 coin-launch use cases — reward coins for trending GitHub repos and creators, and coins riding live cultural narratives. Preview live, launch on pump.fun.","url":"https://three.ws/launch-studio","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Launch Studio","description":"A catalog of 50 coin-launch use cases: reward coins for trending GitHub repos and creators, and coins riding live cultural, news, and onchain narratives. Preview live, launch on pump.fun.","url":"https://three.ws/launch-studio","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
<meta property="og:locale" content="en_US" />
- <meta property="og:image:alt" content="Launch Studio — three.ws" />
+ <meta property="og:image:alt" content="Launch Studio on three.ws" />
<meta name="twitter:site" content="@trythreews" />
</head>
<body class="lc-page">
@@ -70,7 +78,7 @@
<section class="lc-hero">
<span class="lc-pill" data-i18n-html="launch_studio.50_launch_recipes_live_previews"><span class="lc-pill-dot"></span> 50 launch recipes · live previews</span>
<h1 data-i18n="launch_studio.launch_studio_2">Launch Studio</h1>
- <p data-i18n="launch_studio.pick_a_recipe_reward_coins_for_trending">Pick a recipe — reward coins for trending GitHub creators, coins riding live narratives — preview exactly what it would mint right now, then launch on pump.fun in one click.</p>
+ <p data-i18n="launch_studio.pick_a_recipe_reward_coins_for_trending">Pick a recipe: reward coins for trending GitHub creators, or coins riding live narratives. Preview exactly what it would mint right now, then launch on pump.fun in one click.</p>
</section>
<div id="ls-root"></div>
diff --git a/public/launch-studio/launch-studio.js b/public/launch-studio/launch-studio.js
index 7eca1f484..44114bbbc 100644
--- a/public/launch-studio/launch-studio.js
+++ b/public/launch-studio/launch-studio.js
@@ -51,14 +51,17 @@ const CSS = `
the toast, and the coin monogram, which are coloured fills carrying their own
ink. --ls-* locals exist so the accent lightness can be re-pitched for the
light canvas in one block instead of per rule; --h is the per-category hue,
- set inline on the card / drawer root. */
-.ls{--ls-line:var(--stroke,rgba(255,255,255,.08));--ls-line2:var(--stroke-strong,rgba(255,255,255,.14));
+ set inline on the card / drawer root. The selector covers .ls-drawer and
+ .ls-toast as well as .ls because renderAll mounts all three as SIBLINGS:
+ locals declared on .ls alone would leave the drawer with no background at
+ all, which is exactly the bug the literal colours used to hide. */
+.ls,.ls-drawer,.ls-toast{--ls-line:var(--stroke,rgba(255,255,255,.08));--ls-line2:var(--stroke-strong,rgba(255,255,255,.14));
--ls-ink:var(--ink-bright,#fff);--ls-dim:var(--ink-dim,rgba(255,255,255,.5));--ls-faint:var(--ink-faint,rgba(255,255,255,.42));
--ls-s1:var(--surface-1,rgba(255,255,255,.03));--ls-s2:var(--surface-2,rgba(255,255,255,.05));--ls-s3:var(--surface-3,rgba(255,255,255,.08));
--ls-page:var(--bg-0,#0a0a0a);--ls-panel:var(--bg-1,#12151c);
--ls-al:62%;--ls-ail:74%;--ls-brand-l:74%;--ls-cta-ink:#d2f3df;
color:var(--ls-ink);--ease:cubic-bezier(.22,.61,.36,1)}
-:root[data-theme='light'] .ls{--ls-al:44%;--ls-ail:32%;--ls-brand-l:28%;--ls-cta-ink:#14532d}
+:root[data-theme='light'] :is(.ls,.ls-drawer,.ls-toast){--ls-al:44%;--ls-ail:32%;--ls-brand-l:28%;--ls-cta-ink:#14532d}
.ls *{box-sizing:border-box}
.ls-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.ls-tools{position:sticky;top:0;z-index:5;display:flex;flex-direction:column;gap:.7rem;padding:.7rem 0 .8rem;margin-bottom:.4rem;
diff --git a/public/studio/fees-panel.js b/public/studio/fees-panel.js
index 2575296aa..d5d1763cd 100644
--- a/public/studio/fees-panel.js
+++ b/public/studio/fees-panel.js
@@ -17,8 +17,13 @@
//
// Entry:
// mountFeesPanel(el, {
-// mint, network, creator, agentId, avatarId, symbol, name, getUser
+// mint, network, creator, agentId, avatarId, symbol, name, getUser,
+// prefillRecipient // { platform:'github'|'x', login } | { address }
// }) → { teardown }
+//
+// prefillRecipient seeds the split with the recipient a launch recipe promised
+// (Launch Studio hands it to /launch as ?reward=…). It applies only to a coin
+// with no shareholders yet, and only as an unsaved draft the creator signs.
// ── Pure helpers (tested) ────────────────────────────────────────────────────
@@ -258,7 +263,7 @@ function injectCss() {
export function mountFeesPanel(container, opts = {}) {
injectCss();
- const { mint, network = 'mainnet', creator, agentId, avatarId, symbol = 'TOKEN', getUser } = opts;
+ const { mint, network = 'mainnet', creator, agentId, avatarId, symbol = 'TOKEN', getUser, prefillRecipient } = opts;
const s = {
info: null, loading: true, loadError: '',
@@ -860,7 +865,22 @@ export function mountFeesPanel(container, opts = {}) {
// ── Boot ────────────────────────────────────────────────────────────────────
render();
- loadInfo();
+ // A coin launched from a reward recipe (Launch Studio's ?reward= deep link)
+ // arrives with the recipient its catalog entry promised. Seed the split with
+ // it once, and only when the coin has no shareholders yet, so re-opening this
+ // panel on a coin whose fees are already routed never quietly rewrites them.
+ // It stays a draft: the creator still reviews and signs the change.
+ async function applyPrefillRecipient() {
+ if (!prefillRecipient) return;
+ await loadInfo();
+ if (!_alive) return;
+ if ((s.info?.sharing_config?.shareholders || []).length) return;
+ if (prefillRecipient.login) await addSocialAccount(prefillRecipient.platform === 'x' ? 'x' : 'github', prefillRecipient.login);
+ else if (prefillRecipient.address) addWalletRecipient(prefillRecipient.address);
+ }
+
+ if (prefillRecipient) applyPrefillRecipient();
+ else loadInfo();
resolveAgentWallet();
tryAutoConnect();
diff --git a/public/studio/launch-panel.js b/public/studio/launch-panel.js
index a23124424..8f025850b 100644
--- a/public/studio/launch-panel.js
+++ b/public/studio/launch-panel.js
@@ -408,6 +408,16 @@ const LP_CSS = `
border-radius:8px;background:rgba(246,179,179,.07);border:1px solid rgba(246,179,179,.18)}
.lp-err-sub{font-size:.7rem;color:rgba(255,255,255,.3);margin-top:.3rem}
+/* Deep-link fee routing (?reward=…), carried in from Launch Studio. Shown on the
+ form before the mint and again as the first step after it, so the promise the
+ recipe made is visible at both ends of the handoff. */
+.lp-reward{display:flex;align-items:flex-start;gap:.5rem;font-size:.75rem;line-height:1.5;padding:.55rem .7rem;border-radius:9px;
+ color:var(--ink,rgba(255,255,255,.82));background:rgba(120,200,140,.07);border:1px solid rgba(120,200,140,.24)}
+.lp-reward-ic{flex-shrink:0;font-size:.85rem;line-height:1.35}
+.lp-reward b{font-weight:650}
+.lp-reward-sub{display:block;font-size:.68rem;color:var(--ink-dim,rgba(255,255,255,.45));margin-top:.15rem}
+.lp-ok-fees{margin-top:1rem;text-align:left}
+
/* Confirmation timeout escape hatch */
.lp-timeout{display:flex;flex-direction:column;gap:.7rem;padding:.85rem;border-radius:12px;
background:rgba(246,200,100,.05);border:1px solid rgba(246,200,100,.18)}
@@ -542,6 +552,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
imageFile: null, imagePreviewUrl: null,
imageError: '',
_symbolEdited: false,
+ // Deep-linked creator-fee routing from ?reward= ({platform,login} | {address}).
+ // Null means "creator fees stay with the launching wallet", the default.
+ rewardTarget: null,
// Which required fields the user has visited, for inline "required" hints.
_touched: { name: false, symbol: false, description: false },
@@ -1460,6 +1473,51 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
// Symbol accepts any raw value (whitespace, emoji, special chars) — only name & description require real text.
const formValid = () => s.name.trim() && s.symbol.length > 0 && s.description.trim();
+ // The launch CTA's label, action and enabled state are a pure function of the
+ // form's validity, the wallet lane and the phase. It lives here rather than
+ // inline in renderForm() so wireForm() can re-derive it on every keystroke:
+ // the name/symbol/description inputs deliberately patch the DOM instead of
+ // re-rendering (a full render would destroy the caret), and without this the
+ // button kept whatever label the first render gave it. A visitor who filled
+ // the form was left with a CTA still reading "Add name, symbol & description
+ // to launch" and still carrying data-action="focus-form", which resolves to
+ // no empty field and so did nothing at all: the primary action on /launch and
+ // /studio was unreachable once the form was actually complete.
+ function computeCta({ busy, cost }) {
+ const signedIn = !!(getUser?.());
+
+ let btnText, btnDis, btnAction = 'launch', btnTitle = '';
+ if (busy) {
+ btnText = s.phaseLabel || 'Working…'; btnDis = true;
+ } else if (!signedIn) {
+ btnText = 'Sign in to launch'; btnDis = false; btnAction = 'sign-in';
+ btnTitle = 'You need an account to launch. Click to sign in, then come right back.';
+ } else if (!formValid()) {
+ btnText = 'Add name, symbol &amp; description to launch'; btnDis = false; btnAction = 'focus-form';
+ btnTitle = 'Click to jump to the first missing field. You need a name, ticker symbol, and short description.';
+ } else if (s.walletSource === 'agent') {
+ if (s.agentWalletLoading) { btnText = 'Preparing agent wallet…'; btnDis = true; }
+ else if (!s.agentWallet) { btnText = 'Retry agent wallet'; btnDis = false; btnAction = 'agent-retry';
+ btnTitle = 'Click to retry provisioning your custodial agent wallet.'; }
+ else if ((s.agentWallet.sol ?? 0) < cost) {
+ btnText = `Fund agent wallet (~${cost.toFixed(3)} SOL needed)`; btnDis = false; btnAction = 'agent-fund';
+ btnTitle = `Your agent wallet needs ~${cost.toFixed(3)} SOL to cover mint fees and your initial buy. Click to see the deposit address & QR code.`;
+ }
+ else { btnText = `Launch $${esc(s.symbol.trim() || 'TOKEN')} from agent wallet`; btnDis = false;
+ btnTitle = 'Signs and submits the transaction from your custodial agent wallet.'; }
+ } else {
+ if (!s.walletAddr) { btnText = 'Connect wallet to launch'; btnDis = false; btnAction = 'connect';
+ btnTitle = 'Opens Phantom or Backpack to connect your Solana wallet. No funds move until you sign the launch.'; }
+ else if (s.walletLinkChecking) { btnText = 'Checking wallet link…'; btnDis = true; }
+ else if (s.walletLinked === false) { btnText = 'Link wallet to launch'; btnDis = false; btnAction = 'link';
+ btnTitle = 'Signs a free message proving you own this wallet. Required so tokens get attributed to your account.'; }
+ else { btnText = `Launch $${esc(s.symbol.trim() || 'TOKEN')}`; btnDis = false;
+ btnTitle = 'Signs and submits the launch transaction from your connected wallet.'; }
+ }
+ return { btnText, btnDis, btnAction, btnTitle };
+ }
+
+
// ── Render ─────────────────────────────────────────────────────────────
function render() {
@@ -1602,6 +1660,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
avatarId: av?.id || null,
symbol: m.symbol || '',
name: m.name || '',
+ prefillRecipient: s.rewardTarget,
getUser,
});
}
@@ -1867,36 +1926,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
walletHtml = renderConnectedWalletBar(cost) + renderLinkRow();
}
- const signedIn = !!(getUser?.());
-
- let btnText, btnDis, btnAction = 'launch', btnTitle = '';
- if (busy) {
- btnText = s.phaseLabel || 'Working…'; btnDis = true;
- } else if (!signedIn) {
- btnText = 'Sign in to launch'; btnDis = false; btnAction = 'sign-in';
- btnTitle = 'You need an account to launch — click to sign in, then come right back.';
- } else if (!formValid()) {
- btnText = 'Add name, symbol &amp; description to launch'; btnDis = false; btnAction = 'focus-form';
- btnTitle = 'Click to jump to the first missing field. You need a name, ticker symbol, and short description.';
- } else if (s.walletSource === 'agent') {
- if (s.agentWalletLoading) { btnText = 'Preparing agent wallet…'; btnDis = true; }
- else if (!s.agentWallet) { btnText = 'Retry agent wallet'; btnDis = false; btnAction = 'agent-retry';
- btnTitle = 'Click to retry provisioning your custodial agent wallet.'; }
- else if ((s.agentWallet.sol ?? 0) < cost) {
- btnText = `Fund agent wallet (~${cost.toFixed(3)} SOL needed)`; btnDis = false; btnAction = 'agent-fund';
- btnTitle = `Your agent wallet needs ~${cost.toFixed(3)} SOL to cover mint fees and your initial buy. Click to see the deposit address & QR code.`;
- }
- else { btnText = `Launch $${esc(s.symbol.trim() || 'TOKEN')} from agent wallet`; btnDis = false;
- btnTitle = 'Signs and submits the transaction from your custodial agent wallet.'; }
- } else {
- if (!s.walletAddr) { btnText = 'Connect wallet to launch'; btnDis = false; btnAction = 'connect';
- btnTitle = 'Opens Phantom or Backpack to connect your Solana wallet. No funds move until you sign the launch.'; }
- else if (s.walletLinkChecking) { btnText = 'Checking wallet link…'; btnDis = true; }
- else if (s.walletLinked === false) { btnText = 'Link wallet to launch'; btnDis = false; btnAction = 'link';
- btnTitle = 'Signs a free message proving you own this wallet. Required so tokens get attributed to your account.'; }
- else { btnText = `Launch $${esc(s.symbol.trim() || 'TOKEN')}`; btnDis = false;
- btnTitle = 'Signs and submits the launch transaction from your connected wallet.'; }
- }
+ const { btnText, btnDis, btnAction, btnTitle } = computeCta({ busy, cost });
const imgSrc = s.imagePreviewUrl || av?.thumbnail_url;
@@ -1985,6 +2015,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
})()}
${sourceToggleHtml}
${walletHtml}
+ ${rewardNoteHtml()}
${s.phase === 'error' ? `<div class="lp-err" role="alert"><b>Launch failed.</b> ${esc(s.errorMsg)}<div class="lp-err-sub">Nothing was minted. Fix the issue, then press the launch button to retry.</div></div>` : ''}
<button class="lp-launch${busy ? ' busy' : ''}" id="lp-go" data-action="${btnAction}"${btnTitle ? ` title="${esc(btnTitle)}"` : ''} ${btnDis ? 'disabled' : ''}>${btnText}</button>
${busy ? launchStepsHtml() : ''}
@@ -1995,6 +2026,23 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
wireForm();
}
+ /** Human label for the deep-linked fee recipient, e.g. "@vercel on GitHub". */
+ function rewardLabel(t) {
+ if (!t) return '';
+ if (t.login) return `@${t.login} on ${t.platform === 'x' ? 'X' : 'GitHub'}`;
+ const a = String(t.address || '');
+ return a.length > 16 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a;
+ }
+
+ /** The routing promise, shown on the form so it is visible before the mint. */
+ function rewardNoteHtml() {
+ if (!s.rewardTarget) return '';
+ return `<div class="lp-reward"><span class="lp-reward-ic" aria-hidden="true">🎁</span><div>
+ Creator fees route to <b>${esc(rewardLabel(s.rewardTarget))}</b>.
+ <span class="lp-reward-sub">The fee split opens pre-filled right after the mint, where you confirm and sign it.</span>
+ </div></div>`;
+ }
+
/** Render a mint with the leading 3ws mark visually emphasized. */
function stampedMintMarkup(mint) {
if (!mint) return '';
@@ -2040,6 +2088,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
</div>
<button class="lp-share" id="lp-share">📋 Copy launch announcement</button>
<button class="lp-again" id="lp-again">Launch another token</button>
+ ${s.rewardTarget ? `<div class="lp-ok-fees" id="lp-ok-fees"></div>` : ''}
</div></div>`;
const copyBtn = (id, text) => {
@@ -2052,6 +2101,11 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
};
copyBtn('#lp-copy-mint', mint);
copyBtn('#lp-share', shareText);
+
+ // A coin launched from a reward recipe promised its fees to somebody. Mount
+ // the real fee-split panel here, seeded with that recipient, so the creator
+ // finishes the routing in the same flow instead of having to find it later.
+ if (s.rewardTarget && mint) mountSuccessFees(mint);
container.querySelector('#lp-again')?.addEventListener('click', () => {
s.phase = 'idle'; s.mint = null; s.errorMsg = ''; s.launchSig = null;
s.imageFile = null; s.imagePreviewUrl = null; s.imageError = '';
@@ -2061,6 +2115,35 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
});
}
+ // The on-chain creator (agent_authority) decides whether a fee-split save is
+ // server-signed by the agent wallet or signed by the user's wallet, and it is
+ // only known once the mint is indexed, so read it back before mounting.
+ async function mountSuccessFees(mint) {
+ const host = container.querySelector('#lp-ok-fees');
+ if (!host) return;
+ let creator = null;
+ try {
+ const param = s.resolvedAgentId
+ ? `agent_id=${encodeURIComponent(s.resolvedAgentId)}`
+ : `avatar_id=${encodeURIComponent(av?.id || '')}`;
+ const r = await fetch(`/api/pump/by-agent?${param}`, { credentials: 'include' });
+ if (r.ok) creator = (await r.json())?.data?.agent_authority || null;
+ } catch { /* the panel still works: it falls back to the connected wallet */ }
+ if (!container.contains(host)) return;
+ _feesPanel?.teardown?.();
+ _feesPanel = mountFeesPanel(host, {
+ mint,
+ network: 'mainnet',
+ creator,
+ agentId: s.resolvedAgentId || av?.agent_id || null,
+ avatarId: av?.id || null,
+ symbol: s.symbol.trim() || 'TOKEN',
+ name: s.name.trim() || '',
+ prefillRecipient: s.rewardTarget,
+ getUser,
+ });
+ }
+
function wireForm() {
const q = (sel) => container.querySelector(sel);
@@ -2075,6 +2158,30 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
el.classList.toggle('warn', n >= max * 0.9);
};
+ // Keep the launch CTA truthful while the visitor types. Same DOM-patch
+ // reason as the counters and hints: a full render on each keystroke would
+ // drop the caret, so the button's label, action, tooltip and enabled
+ // state are re-derived and written straight onto the node instead.
+ const syncCta = () => {
+ const go = q('#lp-go');
+ if (!go) return;
+ const busy = s.phase !== 'idle' && s.phase !== 'error';
+ const { btnText, btnDis, btnAction, btnTitle } = computeCta({ busy, cost: estimatedCost() });
+ // btnText is render-time HTML (it carries entities such as &amp;), so
+ // it goes in as HTML here too, exactly as the template writes it.
+ if (go.innerHTML !== btnText) go.innerHTML = btnText;
+ go.dataset.action = btnAction;
+ go.disabled = btnDis;
+ if (btnTitle) go.title = btnTitle;
+ else go.removeAttribute('title');
+ go.classList.toggle('busy', busy);
+ };
+
+ // Every wired required field, so the CTA's "jump to the first gap" action
+ // can mark them visited and show their reasons instead of moving the caret
+ // with no explanation.
+ const requiredFields = [];
+
// Inline "required" hints: appear once a field is visited and left empty,
// clear live as soon as the user types. DOM-patched, never a full render.
const wireRequired = (key, inputSel, msgSel, isEmpty) => {
@@ -2085,7 +2192,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
const m = q(msgSel); if (m) m.hidden = !bad;
};
el.addEventListener('blur', () => { s._touched[key] = true; apply(); });
- el.addEventListener('input', apply);
+ el.addEventListener('input', () => { apply(); syncCta(); });
+ requiredFields.push({ key, apply, isEmpty, el });
};
q('#lp-name')?.addEventListener('input', (e) => {
@@ -2113,6 +2221,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
q('#lp-desc')?.addEventListener('input', (e) => {
s.description = e.target.value;
setCount('#lp-desc-count', s.description.length, 500);
+ syncCta();
});
wireRequired('name', '#lp-name', '#lp-name-msg', () => !s.name.trim());
@@ -2180,12 +2289,24 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
location.href = `/login?next=${encodeURIComponent(location.pathname + location.search)}`;
return;
case 'focus-form': {
- const target = !s.name.trim() ? '#lp-name'
- : !s.symbol.trim() ? '#lp-sym'
- : !s.description.trim() ? '#lp-desc'
- : null;
- const el = target && container.querySelector(target);
- if (el) { el.focus(); el.scrollIntoView({ behavior: 'smooth', block: 'center' }); }
+ // Pressing the CTA is the visitor asking what is missing, so
+ // treat every empty required field as visited: that flips its
+ // inline "… is required." hint and aria-invalid on. Focusing
+ // the first gap without this moved the caret into a textarea
+ // and explained nothing, because the hints only ever appeared
+ // after a field had been blurred.
+ let first = null;
+ for (const f of requiredFields) {
+ if (!f.isEmpty()) continue;
+ s._touched[f.key] = true;
+ f.apply();
+ if (!first) first = f.el;
+ }
+ // Nothing is missing after all: the CTA raced a keystroke.
+ // Re-derive it and let the visitor press the real action.
+ if (!first) { syncCta(); return; }
+ first.focus();
+ first.scrollIntoView({ behavior: 'smooth', block: 'center' });
return;
}
case 'connect': connectWallet(); return;
@@ -2237,6 +2358,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
if (prefill.description) s.description = String(prefill.description).slice(0, 500);
const buy = Number(prefill.initialBuy);
if (isFinite(buy) && buy > 0) s.initialBuy = String(buy);
+ if (prefill.reward && (prefill.reward.login || prefill.reward.address)) s.rewardTarget = prefill.reward;
}
// Pull a prefilled token image (a hosted URL from the launchpad config) into a
diff --git a/src/fees.css b/src/fees.css
index 191f1d65d..c17c9e73a 100644
--- a/src/fees.css
+++ b/src/fees.css
@@ -45,11 +45,14 @@
.fx-toggle-btn:hover {
color: var(--cv-text);
}
-.fx-toggle-btn[aria-selected='true'] {
+.fx-toggle-btn[aria-pressed='true'] {
background: var(--cv-surface);
color: var(--cv-text);
box-shadow: 0 1px 2px rgb(0 0 0 / 0.15);
}
+.fx-toggle-btn:active {
+ transform: translateY(1px);
+}
.fx-toggle-btn:focus-visible {
outline: none;
box-shadow: 0 0 0 3px color-mix(in srgb, var(--cv-accent) 30%, transparent);
@@ -99,10 +102,21 @@
background: color-mix(in srgb, var(--cv-accent) 12%, var(--cv-surface-3));
outline: none;
}
+/* Hover and keyboard focus shared one treatment, which left a keyboard user
+ with nothing louder than the tint a mouse already produces. Focus gets the
+ same ring every other control on the page uses. */
+.fx-chip:focus-visible {
+ outline: 2px solid var(--cv-accent);
+ outline-offset: 2px;
+}
+.fx-chip:active {
+ transform: translateY(1px);
+}
.fx-more {
color: var(--cv-text-3);
font-size: 0.75rem;
font-variant-numeric: tabular-nums;
+ cursor: help;
}
/* ── Protocol name link ────────────────────────────────────────────────────── */
@@ -147,3 +161,11 @@
.fx-retry:hover {
color: var(--cv-accent-hover);
}
+.fx-retry:active {
+ opacity: 0.75;
+}
+.fx-retry:focus-visible {
+ outline: 2px solid var(--cv-accent);
+ outline-offset: 2px;
+ border-radius: var(--cv-radius-sm);
+}
diff --git a/src/fees.js b/src/fees.js
index c7d251323..fb1065646 100644
--- a/src/fees.js
+++ b/src/fees.js
@@ -16,6 +16,9 @@ import { upstreamLogoURL, swapFailedLogos } from './shared/upstream-logo.js';
const $ = (id) => document.getElementById(id);
+// /api/defi/fees labels a last-good copy it served after an upstream failure
+// with `x-three-stale: 1`. The footer line says so rather than passing a cached
+// figure off as live, matching /defi and /stablecoins.
async function getJson(url) {
const res = await fetch(url, { headers: { accept: 'application/json' } });
if (!res.ok) {
@@ -23,7 +26,35 @@ async function getJson(url) {
err.status = res.status;
throw err;
}
- return res.json();
+ return { data: await res.json(), stale: res.headers.get('x-three-stale') === '1' };
+}
+
+/*
+ * The page ships its copy as static HTML annotated with data-i18n, and the
+ * catalog pass lands AFTER an async locale fetch. Anything this script writes
+ * into an annotated node before then is silently reverted: on ?type=revenue the
+ * table heading and the document title snapped back to the Fees copy while the
+ * Revenue metric was selected and the revenue numbers were on screen.
+ * `data-i18n-owned="1"` is this codebase's documented opt-out (src/i18n.js):
+ * claim a node while the script owns its text, hand it back when it returns to
+ * its declared copy so a later locale switch still translates it.
+ */
+function i18nText(key, fallback) {
+ const v = window.threewsI18n?.t?.(key);
+ return typeof v === 'string' && v && v !== key ? v : fallback;
+}
+
+function claimI18n(el, text) {
+ if (!el) return;
+ el.setAttribute('data-i18n-owned', '1');
+ el.textContent = text;
+}
+
+function releaseI18n(el, text) {
+ if (!el) return;
+ el.textContent = text;
+ el.removeAttribute('data-i18n-owned');
+ window.threewsI18n?.apply?.(el); // the catalog may have landed while owned
}
// ── State ───────────────────────────────────────────────────────────────────
@@ -37,6 +68,7 @@ const state = {
chart: [],
protocols: [],
updated_at: 0,
+ stale: false,
sortKey: 'total24h',
sortDir: 'desc',
loading: true,
@@ -272,8 +304,10 @@ function chainsCell(chains) {
`<a class="fx-chip" href="/chain/${encodeURIComponent(c)}">${esc(c)}</a>`,
)
.join('');
- const extra =
- chains.length > 3 ? `<span class="fx-more">+${chains.length - 3}</span>` : '';
+ const rest = chains.slice(3);
+ const extra = rest.length
+ ? `<span class="fx-more" title="${esc(rest.join(', '))}">+${rest.length}</span>`
+ : '';
return `<td class="left hide-lg"><span class="fx-chips">${shown}${extra}</span></td>`;
}
@@ -339,7 +373,11 @@ function renderTable() {
const head = COLUMNS.map((col) => {
const active = col.key === state.sortKey;
const arrow = active ? (state.sortDir === 'asc' ? '↑' : '↓') : '↕';
- return `<th scope="col" tabindex="0" data-key="${col.key}" class="${col.left ? 'left' : ''} ${col.hide || ''}"${active ? ` aria-sort="${state.sortDir === 'asc' ? 'ascending' : 'descending'}"` : ''}>${esc(col.label)}<span class="arrow" aria-hidden="true">${arrow}</span></th>`;
+ // Every column here is sortable, so every header carries aria-sort: the
+ // inactive ones get "none" (which is what makes a screen reader announce
+ // them as sortable at all) and only the active one names a direction.
+ const sort = active ? (state.sortDir === 'asc' ? 'ascending' : 'descending') : 'none';
+ return `<th scope="col" tabindex="0" data-key="${col.key}" aria-sort="${sort}" class="${col.left ? 'left' : ''} ${col.hide || ''}">${esc(col.label)}<span class="arrow" aria-hidden="true">${arrow}</span></th>`;
}).join('');
const body = sortedProtocols()
@@ -394,13 +432,33 @@ function renderTable() {
// ── Toggle + URL sync ───────────────────────────────────────────────────────
+const FEES_TITLE = 'Protocol Fees & Revenue · three.ws';
+const REVENUE_TITLE = 'Protocol Revenue & Fees · three.ws';
+
function syncToggle() {
for (const type of ['fees', 'revenue']) {
const btn = $(`fx-tab-${type}`);
- if (btn) btn.setAttribute('aria-selected', String(type === state.type));
+ if (btn) btn.setAttribute('aria-pressed', String(type === state.type));
+ }
+
+ const heading = $('fx-table-heading');
+ const titleEl = document.querySelector('title');
+ if (state.type === 'revenue') {
+ claimI18n(heading, LABELS.revenue.heading);
+ claimI18n(titleEl, REVENUE_TITLE);
+ } else {
+ // Back on the declared metric: hand both nodes back to the catalog so a
+ // visitor reading in another language keeps the translated copy.
+ releaseI18n(heading, i18nText('fees.top_protocols_by_fees', LABELS.fees.heading));
+ releaseI18n(titleEl, i18nText('fees.meta_title', FEES_TITLE));
}
- $('fx-table-heading').textContent = LABELS[state.type].heading;
- document.title = `${LABELS[state.type].noun === 'Fees' ? 'Protocol Fees & Revenue' : 'Protocol Revenue & Fees'} · three.ws`;
+
+ // The three hydrated regions are labelled for the metric on screen, so a
+ // screen reader on the Revenue tab is not told it is reading fees.
+ const metric = LABELS[state.type].metric;
+ $('fx-stats')?.setAttribute('aria-label', `24h, 7d and 30d ${metric} totals`);
+ $('fx-chart')?.setAttribute('aria-label', `Aggregate daily ${metric} over time`);
+ $('fx-table')?.setAttribute('aria-label', `Top protocols by ${metric}`);
}
function wireToggle() {
@@ -418,16 +476,24 @@ function wireToggle() {
// ── Boot ────────────────────────────────────────────────────────────────────
+// Toggling Fees/Revenue faster than the network answers used to let an earlier
+// response land on top of a later one, painting one metric's numbers under the
+// other metric's heading. Only the newest request may write to the state.
+let requestSeq = 0;
+
async function load(type) {
+ const seq = ++requestSeq;
state.type = type === 'revenue' ? 'revenue' : 'fees';
state.loading = true;
state.error = false;
+ state.stale = false;
syncToggle();
statsSkeleton();
renderChart();
renderTable();
try {
- const data = await getJson(`/api/defi/fees?type=${state.type}`);
+ const { data, stale } = await getJson(`/api/defi/fees?type=${state.type}`);
+ if (seq !== requestSeq) return;
state.total24h = data.total24h ?? null;
state.total7d = data.total7d ?? null;
state.total30d = data.total30d ?? null;
@@ -435,14 +501,27 @@ async function load(type) {
state.chart = Array.isArray(data.chart) ? data.chart : [];
state.protocols = Array.isArray(data.protocols) ? data.protocols : [];
state.updated_at = data.updated_at || Date.now();
+ state.stale = stale;
state.loading = false;
state.error = false;
- renderStats();
renderChart();
renderTable();
- $('fx-updated').textContent =
- `Top ${state.protocols.length} protocols by ${LABELS[state.type].metric} · Data: DeFiLlama · updated ${new Date(state.updated_at).toLocaleTimeString('en-US')}`;
+ // An empty payload has no totals worth showing: three "no value" cards and
+ // a "Top 0 protocols" line read as a claim that DeFi earned nothing today
+ // rather than as missing data. The table's empty state carries the message.
+ if (state.protocols.length) {
+ renderStats();
+ const when = new Date(state.updated_at).toLocaleTimeString('en-US');
+ const lead = `Top ${state.protocols.length} protocols by ${LABELS[state.type].metric} · Data: DeFiLlama`;
+ $('fx-updated').textContent = state.stale
+ ? `${lead} · cached copy from ${when}, the live feed is unreachable`
+ : `${lead} · updated ${when}`;
+ } else {
+ $('fx-stats').innerHTML = '';
+ $('fx-updated').textContent = 'Data: DeFiLlama';
+ }
} catch {
+ if (seq !== requestSeq) return;
state.loading = false;
state.error = true;
$('fx-stats').innerHTML = '';
@@ -457,4 +536,7 @@ function initialType() {
}
wireToggle();
+// A late catalog or a language switch re-translates the annotated copy; the
+// heading and title this script owns have to follow it.
+window.addEventListener('i18n:change', syncToggle);
load(initialType());