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
feat(launchpad): /three-launchpad, the public page for the $THREE-quoted curve, with buy and sell from the visitor's wallet
ni3ad137c4fb0df9
diff --git a/data/pages.json b/data/pages.jsonindex 5e34ae0fc..e1d82978c 100644--- a/data/pages.json+++ b/data/pages.json@@ -1479,6 +1479,14 @@"changefreq": "weekly","added": "2026-06-30"},+ {+ "path": "/three-launchpad",+ "title": "$THREE Launchpad",+ "description": "A bonding-curve launchpad priced in $THREE: every coin launched for a 3D agent is bought with $THREE, creators earn their fees in $THREE, and each graduation locks the $THREE it raised in a pool nobody can withdraw. Launch a coin or trade the live curves.",+ "priority": 0.9,+ "changefreq": "daily",+ "added": "2026-09-20"+ },{"path": "/launches","title": "Agent Launches",diff --git a/pages/three-launchpad.html b/pages/three-launchpad.htmlnew file mode 100644index 000000000..d6d5e5471--- /dev/null+++ b/pages/three-launchpad.html@@ -0,0 +1,60 @@+<!doctype html>+<html lang="en">+ <head>+ <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>$THREE Launchpad: Every Coin Is Bought With $THREE · three.ws</title>+ <meta+ name="description"+ content="Launch a coin for your 3D AI agent on a bonding curve priced in $THREE. Every buy is a $THREE buy, creators earn fees in $THREE, and each graduation locks the $THREE it raised in a pool nobody can withdraw."+ />+ <meta name="robots" content="index, follow, max-image-preview:large" />+ <link rel="canonical" href="https://three.ws/three-launchpad" />++ <meta property="og:type" content="website" />+ <meta property="og:site_name" content="three.ws" />+ <meta property="og:title" content="The $THREE Launchpad" />+ <meta property="og:description" content="Every coin here is bought with $THREE. Launch one for your agent, or trade the curve." />+ <meta property="og:url" content="https://three.ws/three-launchpad" />+ <meta property="og:image" content="https://three.ws/api/page-og?s=crypto&t=%24THREE+Launchpad&d=Every+coin+here+is+bought+with+%24THREE.+Launch+one+for+your+3D+agent%2C+or+trade+the+curve.&p=%2Fthree-launchpad" />+ <meta property="og:image:width" content="1200" />+ <meta property="og:image:height" content="630" />+ <meta property="og:image:alt" content="The $THREE Launchpad on three.ws" />+ <meta property="og:locale" content="en_US" />+ <meta name="twitter:card" content="summary_large_image" />+ <meta name="twitter:site" content="@trythreews" />+ <meta name="twitter:title" content="The $THREE Launchpad" />+ <meta name="twitter:description" content="Every coin here is bought with $THREE. Launch one for your agent, or trade the curve." />+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&t=%24THREE+Launchpad&d=Every+coin+here+is+bought+with+%24THREE.+Launch+one+for+your+3D+agent%2C+or+trade+the+curve.&p=%2Fthree-launchpad" />++ <link rel="icon" href="/favicon.ico" sizes="any" />+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />+ <link rel="manifest" href="/manifest.webmanifest" />+ <link rel="stylesheet" href="/style.css" />+ <link rel="stylesheet" href="/nav.css" />+ <link rel="stylesheet" href="/fonts/fonts.css" />+ <link rel="stylesheet" href="/mobile.css" />++ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"$THREE Launchpad","description":"Launch a coin for your 3D AI agent on a bonding curve priced in $THREE. Every buy is a $THREE buy, creators earn fees in $THREE, and each graduation locks the $THREE it raised in a pool nobody can withdraw.","url":"https://three.ws/three-launchpad","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>+ </head>+ <body>+ <header><div id="nav-container"></div></header>+ <script src="/nav.js"></script>++ <main class="tl" id="main-content">+ <div id="three-launchpad-app">+ <p class="tl-boot" role="status">Loading the launchpad…</p>+ </div>+ </main>++ <div id="footer-container"></div>+ <script src="/footer.js"></script>+ <script type="module" src="/src/three-launchpad/page.js"></script>+ <script src="/brand.js" defer></script>+ <script type="module" src="/i18n.js"></script>+ </body>+</html>diff --git a/public/studio/launch-panel.js b/public/studio/launch-panel.jsindex cd202bd4a..afd3ac647 100644--- a/public/studio/launch-panel.js+++ b/public/studio/launch-panel.js@@ -567,7 +567,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView// native lane has no curve config deployed on this network the toggle is// hidden entirely and every launch stays on pump.lane: 'pump',- laneInfo: null, // { trade_fee_bps, fee_split, graduation_sol_approx, … } | null+ laneInfo: null, // { trade_fee_bps, fee_split, graduation_three_approx, … } | nulllaneAvailable: false,// wallet source: 'connected' (Phantom/Backpack) or 'agent' (custodial agent wallet)@@ -1327,8 +1327,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViewconst isNative = s.lane === 'native';const isUsdc = !isNative && s.coinType === 'usdc';const buyIn = Math.max(0, parseFloat(s.initialBuy) || 0);- // The native lane runs three.ws's own bonding curve: SOL-quoted, no coin- // variants, no on-chain buyback binding — so it takes the base fields only.+ // The native lane runs three.ws's own bonding curve: quoted in $THREE, no coin+ // variants, no on-chain buyback binding, so it takes the base fields only and+ // its first buy is an amount of $THREE.const prepUrl = isNative ? '/api/native-launch/launch-prep' : '/api/pump/launch-prep';const prepBody = isNative? {@@ -1336,7 +1337,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViewwallet_address: payer,name: nameTrim, symbol: symTrim, uri: s._metaUrl,mint_address: ground.publicKey,- sol_buy_in: buyIn,+ three_buy_in: buyIn,network: 'mainnet',}: {@@ -1470,7 +1471,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView// rent/fee applies — the buy itself is debited from the wallet's USDC ATA.const estimatedCost = () => {const buy = Math.max(0, parseFloat(s.initialBuy) || 0);- return PUMP_BASE_COST + (s.coinType === 'usdc' ? 0 : buy);+ // Only a SOL-quoted buy adds to the SOL cost: USDC and $THREE buys are debited+ // from the wallet's token accounts.+ return PUMP_BASE_COST + (s.coinType === 'usdc' || s.lane === 'native' ? 0 : buy);};// 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();@@ -1867,9 +1870,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViewconst laneNoteHtml = isNative && s.laneInfo? `<div class="lp-lane-note">Launches on three.ws's own bonding curve. ${(s.laneInfo.trade_fee_bps / 100).toFixed(s.laneInfo.trade_fee_bps % 100 ? 2 : 0)- }% trading fee, ${s.laneInfo.fee_split.creator_percent}% of it to you. Graduates at ~${- s.laneInfo.graduation_sol_approx- } SOL raised into a locked liquidity pool you keep earning fees from.</div>`+ }% trading fee, ${s.laneInfo.fee_split.creator_percent}% of it to you, paid in $THREE. Every buy of your coin is made with $THREE. Graduates at about ${+ Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1 }).format(s.laneInfo.graduation_three_approx)+ } $THREE raised into a locked $THREE pool you keep earning fees from. <a href="/three-launchpad">See the launchpad</a>.</div>`: '';// The native lane has no server-signed path, so its signer is always the@@ -1991,11 +1994,14 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView${coinNoteHtml}${(() => {const isUsdcCoin = ct === 'usdc';- const unit = isUsdcCoin ? 'USDC' : 'SOL';- // pump.fun launch caps: 50 SOL or 1,000,000 USDC (matches server schema).- const maxBuy = isUsdcCoin ? 1_000_000 : 50;- const stepBuy = isUsdcCoin ? 1 : 0.001;- const buyTitle = isUsdcCoin+ const unit = isNative ? '$THREE' : isUsdcCoin ? 'USDC' : 'SOL';+ // Launch caps match the server schemas: 10,000,000 $THREE on the native+ // lane, and pump.fun's 50 SOL or 1,000,000 USDC.+ const maxBuy = isNative ? 10_000_000 : isUsdcCoin ? 1_000_000 : 50;+ const stepBuy = isNative || isUsdcCoin ? 1 : 0.001;+ const buyTitle = isNative+ ? 'Optional $THREE spent on your own curve at launch. The signing wallet must hold it. Leave at 0 for a launch-only mint.'+ : isUsdcCoin? 'Optional USDC spent on the bonding curve at launch. Requires a USDC ATA on the signing wallet.': 'Optional SOL spent on the bonding curve at launch. You receive the resulting coins. Leave at 0 for a launch-only mint.';const buybackUnit = isUsdcCoin ? 'USDC' : 'SOL';diff --git a/src/launch/launch-wallet.js b/src/launch/launch-wallet.jsindex dbb360784..eabec971a 100644--- a/src/launch/launch-wallet.js+++ b/src/launch/launch-wallet.js@@ -142,6 +142,37 @@ export async function restoreLaunchWallet() {}}+/**+ * Connect without linking the wallet to an account. Trading on a curve needs only a+ * signature, so a visitor with no three.ws session can still buy and sell.+ * @param {{ silent?: boolean }} [o] silent: reconnect only if the site is already trusted+ * @returns {Promise<{ address: string, name: string } | null>}+ */+export async function connectTradingWallet({ silent = false } = {}) {+ const provider = injectedProvider();+ if (!provider?.connect) {+ if (silent) return null;+ throw Object.assign(new Error('No Solana wallet found.'), { code: 'NO_PROVIDER' });+ }+ try {+ const resp = await provider.connect(silent ? { onlyIfTrusted: true } : undefined);+ const address = (resp?.publicKey || provider.publicKey)?.toString();+ if (!address) return null;+ const name = provider.isPhantom ? 'Phantom' : provider.isBackpack ? 'Backpack' : provider.isSolflare ? 'Solflare' : 'Wallet';+ return { address, name };+ } catch (e) {+ if (silent) return null;+ throw rejected(e);+ }+}++/** Whole-unit balance of `mint` held by `address`, across every token account and either token program. */+export async function tokenBalance(address, mint) {+ const { PublicKey } = await import('@solana/web3.js');+ const { value } = await rpc().getParsedTokenAccountsByOwner(new PublicKey(address), { mint: new PublicKey(mint) }, 'confirmed');+ return value.reduce((sum, a) => sum + (a.account.data.parsed?.info?.tokenAmount?.uiAmount || 0), 0);+}+export async function solBalance(address) {const { PublicKey } = await import('@solana/web3.js');return (await rpc().getBalance(new PublicKey(address), 'confirmed')) / 1e9;diff --git a/src/three-launchpad/page.css b/src/three-launchpad/page.cssnew file mode 100644index 000000000..25175ec46--- /dev/null+++ b/src/three-launchpad/page.css@@ -0,0 +1,534 @@+/* $THREE launchpad. Scoped to .tl; colours and spacing come from the shared tokens. */+.tl {+ --tl-accent: #86efac;+ --tl-accent-ink: #052e16;+ --tl-accent-soft: rgba(134, 239, 172, 0.1);+ --tl-accent-stroke: rgba(134, 239, 172, 0.34);+ --tl-sell: #fca5a5;+ max-width: 1180px;+ margin: 0 auto;+ padding: 96px 20px 80px;+ color: var(--ink);+ font-family: var(--font-body);+}+[data-theme='light'] .tl {+ --tl-accent: #15803d;+ --tl-accent-ink: #ffffff;+ --tl-accent-soft: rgba(21, 128, 61, 0.08);+ --tl-accent-stroke: rgba(21, 128, 61, 0.35);+ --tl-sell: #b91c1c;+}+.tl *,+.tl *::before,+.tl *::after {+ box-sizing: border-box;+}+.tl-boot {+ color: var(--ink-dim);+ padding: 80px 0;+ text-align: center;+}++/* Head */+.tl-eyebrow {+ display: inline-flex;+ align-items: center;+ gap: 8px;+ margin: 0 0 14px;+ font: 600 11px/1 var(--font-mono);+ letter-spacing: 0.08em;+ text-transform: uppercase;+ color: var(--ink-dim);+}+.tl-dot {+ width: 7px;+ height: 7px;+ border-radius: 50%;+ background: var(--tl-accent);+ box-shadow: 0 0 10px var(--tl-accent);+}+.tl-dot[data-state='pending'] {+ background: #fbbf24;+ box-shadow: 0 0 10px #fbbf24;+}+.tl h1 {+ margin: 0;+ font-size: clamp(30px, 5vw, 52px);+ line-height: 1.04;+ letter-spacing: -0.03em;+ max-width: 17ch;+}+.tl h1 em {+ font-style: normal;+ color: var(--tl-accent);+}+.tl-sub {+ margin: 16px 0 0;+ max-width: 62ch;+ color: var(--ink-dim);+ font-size: 16px;+ line-height: 1.55;+}+.tl-cta {+ display: flex;+ flex-wrap: wrap;+ gap: 10px;+ margin-top: 26px;+}++/* Buttons */+.tl-btn {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ gap: 8px;+ min-height: 42px;+ padding: 0 18px;+ border-radius: var(--radius-control, 10px);+ border: 1px solid var(--stroke-strong, var(--stroke));+ background: var(--surface-3);+ color: var(--ink);+ font: 600 14px/1 var(--font-body);+ text-decoration: none;+ cursor: pointer;+ transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;+}+.tl-btn:hover:not(:disabled) {+ border-color: var(--tl-accent-stroke);+ transform: translateY(-1px);+}+.tl-btn:active:not(:disabled) {+ transform: translateY(0);+}+.tl-btn:focus-visible,+.tl-card:focus-visible,+.tl-field input:focus-visible,+.tl-field select:focus-visible,+.tl-field textarea:focus-visible,+.tl-seg button:focus-visible,+.tl-chip:focus-visible {+ outline: 2px solid var(--tl-accent);+ outline-offset: 2px;+}+.tl-btn:disabled {+ opacity: 0.5;+ cursor: not-allowed;+}+.tl-btn--primary {+ background: var(--tl-accent);+ border-color: transparent;+ color: var(--tl-accent-ink);+}+.tl-btn--sell {+ background: var(--tl-sell);+ border-color: transparent;+ color: #1f0a0a;+}+.tl-btn--block {+ width: 100%;+}++/* Lane facts */+.tl-facts {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));+ gap: 1px;+ margin: 44px 0 0;+ border: 1px solid var(--stroke);+ border-radius: var(--radius-card, 16px);+ background: var(--stroke);+ overflow: hidden;+}+.tl-fact {+ padding: 18px 20px;+ background: var(--surface-1, var(--bg));+}+.tl-fact dt {+ font: 600 11px/1.2 var(--font-mono);+ letter-spacing: 0.06em;+ text-transform: uppercase;+ color: var(--ink-dim);+}+.tl-fact dd {+ margin: 8px 0 0;+ font-size: 19px;+ font-weight: 650;+ letter-spacing: -0.01em;+}+.tl-fact dd small {+ display: block;+ margin-top: 4px;+ font-size: 12px;+ font-weight: 400;+ color: var(--ink-dim);+}++/* The loop */+.tl-loop {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));+ gap: 14px;+ margin-top: 18px;+ padding: 0;+ list-style: none;+ counter-reset: loop;+}+.tl-loop li {+ counter-increment: loop;+ padding: 20px;+ border: 1px solid var(--stroke);+ border-radius: var(--radius-card, 16px);+ background: var(--surface-glass, var(--surface-2));+}+.tl-loop li::before {+ content: counter(loop, decimal-leading-zero);+ font: 600 11px/1 var(--font-mono);+ color: var(--tl-accent);+}+.tl-loop h3 {+ margin: 10px 0 6px;+ font-size: 15px;+}+.tl-loop p {+ margin: 0;+ color: var(--ink-dim);+ font-size: 14px;+ line-height: 1.5;+}++/* Sections */+.tl-section {+ margin-top: 64px;+}+.tl-section-head {+ display: flex;+ flex-wrap: wrap;+ align-items: baseline;+ justify-content: space-between;+ gap: 8px 16px;+ margin-bottom: 18px;+}+.tl-section h2 {+ margin: 0;+ font-size: 22px;+ letter-spacing: -0.02em;+}+.tl-section-note {+ margin: 0;+ color: var(--ink-dim);+ font-size: 13px;+}++/* Notice (lane not open, errors) */+.tl-notice {+ display: flex;+ gap: 12px;+ padding: 16px 18px;+ border: 1px solid var(--stroke);+ border-left: 3px solid #fbbf24;+ border-radius: 12px;+ background: var(--surface-2);+ font-size: 14px;+ line-height: 1.5;+}+.tl-notice[data-tone='error'] {+ border-left-color: var(--danger, #f87171);+}+.tl-notice strong {+ display: block;+ margin-bottom: 2px;+}+.tl-notice p {+ margin: 0;+ color: var(--ink-dim);+}++/* Coin grid */+.tl-grid {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));+ gap: 14px;+}+.tl-card {+ display: flex;+ flex-direction: column;+ gap: 12px;+ padding: 16px;+ text-align: left;+ border: 1px solid var(--stroke);+ border-radius: var(--radius-card, 16px);+ background: var(--surface-glass, var(--surface-2));+ color: inherit;+ font: inherit;+ cursor: pointer;+ transition: transform 0.15s ease, border-color 0.15s ease;+}+.tl-card:hover,+.tl-card[aria-pressed='true'] {+ border-color: var(--tl-accent-stroke);+ transform: translateY(-2px);+}+.tl-card-top {+ display: flex;+ align-items: center;+ gap: 12px;+ min-width: 0;+}+.tl-card-img {+ flex: none;+ width: 44px;+ height: 44px;+ border-radius: 12px;+ object-fit: cover;+ background: var(--surface-3);+}+.tl-card-img--blank {+ display: grid;+ place-items: center;+ font: 700 15px/1 var(--font-mono);+ color: var(--ink-dim);+}+.tl-card-name {+ min-width: 0;+}+.tl-card-name b,+.tl-card-name span {+ display: block;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}+.tl-card-name span {+ margin-top: 3px;+ color: var(--ink-dim);+ font-size: 12px;+}+.tl-bar {+ height: 6px;+ border-radius: 99px;+ background: var(--surface-3);+ overflow: hidden;+}+.tl-bar > i {+ display: block;+ height: 100%;+ border-radius: inherit;+ background: var(--tl-accent);+ transition: width 0.5s ease;+}+.tl-card-meta {+ display: flex;+ justify-content: space-between;+ gap: 8px;+ font: 500 12px/1.2 var(--font-mono);+ color: var(--ink-dim);+}+.tl-card-meta b {+ color: var(--ink);+ font-weight: 600;+}+.tl-skel {+ height: 132px;+ border-radius: var(--radius-card, 16px);+ background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);+ background-size: 200% 100%;+ animation: tl-shimmer 1.3s linear infinite;+}+@keyframes tl-shimmer {+ to {+ background-position: -200% 0;+ }+}+.tl-empty {+ padding: 40px 24px;+ border: 1px dashed var(--stroke);+ border-radius: var(--radius-card, 16px);+ text-align: center;+ color: var(--ink-dim);+}+.tl-empty b {+ display: block;+ margin-bottom: 6px;+ color: var(--ink);+ font-size: 16px;+}+.tl-more {+ display: flex;+ justify-content: center;+ margin-top: 18px;+}++/* Panels: trade + launch */+.tl-panel {+ padding: 22px;+ border: 1px solid var(--stroke);+ border-radius: var(--radius-card, 16px);+ background: var(--surface-glass, var(--surface-2));+}+.tl-trade {+ display: grid;+ grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);+ gap: 22px;+ margin-top: 16px;+ animation: tl-in 0.25s ease;+}+@keyframes tl-in {+ from {+ opacity: 0;+ transform: translateY(6px);+ }+}+.tl-trade h3 {+ margin: 0;+ font-size: 20px;+}+.tl-trade-sub {+ margin: 6px 0 16px;+ color: var(--ink-dim);+ font-size: 13px;+ word-break: break-all;+}+.tl-kv {+ display: grid;+ grid-template-columns: auto 1fr;+ gap: 8px 16px;+ margin: 16px 0 0;+ font-size: 13px;+}+.tl-kv dt {+ color: var(--ink-dim);+}+.tl-kv dd {+ margin: 0;+ text-align: right;+ font-family: var(--font-mono);+}+.tl-seg {+ display: grid;+ grid-template-columns: 1fr 1fr;+ gap: 4px;+ padding: 4px;+ border-radius: 12px;+ background: var(--surface-3);+}+.tl-seg button {+ min-height: 36px;+ border: 0;+ border-radius: 9px;+ background: transparent;+ color: var(--ink-dim);+ font: 600 13px/1 var(--font-body);+ cursor: pointer;+ transition: background 0.15s ease, color 0.15s ease;+}+.tl-seg button[aria-selected='true'] {+ background: var(--surface-1, var(--bg));+ color: var(--ink);+}+.tl-field {+ display: block;+ margin-top: 14px;+}+.tl-field > span {+ display: flex;+ justify-content: space-between;+ gap: 8px;+ margin-bottom: 6px;+ font-size: 12px;+ color: var(--ink-dim);+}+.tl-field input,+.tl-field select,+.tl-field textarea {+ width: 100%;+ min-height: 44px;+ padding: 10px 12px;+ border: 1px solid var(--stroke);+ border-radius: 10px;+ background: var(--surface-1, var(--bg));+ color: var(--ink);+ font: 500 15px/1.3 var(--font-body);+ transition: border-color 0.15s ease;+}+.tl-field textarea {+ min-height: 84px;+ resize: vertical;+}+.tl-field input:hover,+.tl-field select:hover,+.tl-field textarea:hover {+ border-color: var(--stroke-strong, var(--stroke));+}+.tl-chips {+ display: flex;+ flex-wrap: wrap;+ gap: 6px;+ margin-top: 8px;+}+.tl-chip {+ padding: 6px 10px;+ border: 1px solid var(--stroke);+ border-radius: 99px;+ background: transparent;+ color: var(--ink-dim);+ font: 600 12px/1 var(--font-mono);+ cursor: pointer;+ transition: border-color 0.15s ease, color 0.15s ease;+}+.tl-chip:hover {+ border-color: var(--tl-accent-stroke);+ color: var(--ink);+}+.tl-quote {+ min-height: 40px;+ margin: 14px 0;+ font-size: 13px;+ color: var(--ink-dim);+}+.tl-quote b {+ color: var(--ink);+}+.tl-status {+ min-height: 20px;+ margin: 12px 0 0;+ font-size: 13px;+ line-height: 1.45;+ color: var(--ink-dim);+}+.tl-status[data-tone='error'] {+ color: var(--danger, #f87171);+}+.tl-status[data-tone='ok'] {+ color: var(--tl-accent);+}+.tl-status a {+ color: inherit;+}+.tl-form {+ display: grid;+ grid-template-columns: repeat(2, minmax(0, 1fr));+ gap: 0 18px;+}+.tl-form .tl-span {+ grid-column: 1 / -1;+}++@media (max-width: 820px) {+ .tl {+ padding-top: 84px;+ }+ .tl-trade,+ .tl-form {+ grid-template-columns: 1fr;+ }+}+@media (prefers-reduced-motion: reduce) {+ .tl *,+ .tl *::before {+ animation: none !important;+ transition: none !important;+ }+}+.tl-notice a {+ color: var(--tl-accent);+}diff --git a/src/three-launchpad/page.js b/src/three-launchpad/page.jsnew file mode 100644index 000000000..1f03d99e2--- /dev/null+++ b/src/three-launchpad/page.js@@ -0,0 +1,573 @@+// /three-launchpad: the $THREE-quoted bonding-curve lane.+//+// Everything on this page is live data from /api/native-launch/*:+// GET config lane economics, quote mint, whether the on-chain config is pinned+// GET launches coins launched on the lane, newest first+// GET pool one curve's progress and the $THREE it holds+// GET quote a buy (three_in) or sell (tokens_in) quote off the live curve+// POST swap-prep unsigned buy/sell transaction for the visitor's own wallet+// POST launch-prep unsigned create-pool transaction (signed in, wallet linked)+// POST launch-confirm+// Metadata is pinned through /api/pump/build-metadata, which the pump.fun lane shares.++import './page.css';+import { Keypair, VersionedTransaction } from '@solana/web3.js';+import {+ walletInstalled,+ connectTradingWallet,+ connectLaunchWallet,+ tokenBalance,+ signAndBroadcast,+ waitForConfirmation,+} from '../launch/launch-wallet.js';++const params = new URLSearchParams(location.search);+const NETWORK = params.get('network') === 'devnet' ? 'devnet' : 'mainnet';+const PAGE_SIZE = 24;+const QUOTE_DEBOUNCE_MS = 300;++const state = {+ lane: null,+ launches: null, // null while loading+ launchesError: '',+ hasMore: false,+ pools: new Map(), // mint -> pool state, or { error }+ selected: params.get('mint'),+ side: 'buy',+ amount: '',+ quote: null,+ wallet: null,+ balances: { three: null, coin: null },+ user: undefined, // undefined while loading, null when signed out+ avatars: [],+ busy: false,+};++const root = document.getElementById('three-launchpad-app');+const $ = (sel, el = root) => el.querySelector(sel);+const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);+const fmt = (n, digits = 0) => (Number.isFinite(n) ? n.toLocaleString('en-US', { maximumFractionDigits: digits }) : '');+const compact = (n) => (Number.isFinite(n) ? Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 2 }).format(n) : '');+const short = (a) => (a && a.length > 10 ? `${a.slice(0, 4)}…${a.slice(-4)}` : a || '');+const explorerTx = (sig) => `https://solscan.io/tx/${sig}${NETWORK === 'devnet' ? '?cluster=devnet' : ''}`;+const withNetwork = (path) => `${path}${path.includes('?') ? '&' : '?'}network=${NETWORK}`;++async function api(path, { method = 'GET', body } = {}) {+ const res = await fetch(path, {+ method,+ credentials: 'include',+ headers: body ? { 'content-type': 'application/json' } : undefined,+ body: body ? JSON.stringify(body) : undefined,+ });+ const data = await res.json().catch(() => ({}));+ if (!res.ok) {+ throw Object.assign(new Error(data?.error_description || data?.error || `Request failed (${res.status})`), {+ code: data?.error,+ status: res.status,+ });+ }+ return data;+}++const selectedCoin = () => state.launches?.find((c) => c.mint === state.selected) || null;++// ── Shell ──────────────────────────────────────────────────────────────────++function renderShell() {+ const lane = state.lane;+ const open = Boolean(lane?.available);+ root.innerHTML = `+ <p class="tl-eyebrow"><span class="tl-dot" data-state="${open ? 'live' : 'pending'}" aria-hidden="true"></span>${open ? '$THREE launchpad · live' : '$THREE launchpad · opening soon'}</p>+ <h1>Every coin here is bought with <em>$THREE</em>.</h1>+ <p class="tl-sub">Launch a coin for your 3D agent on a bonding curve priced in $THREE. There is no SOL pair to route around it: to buy any coin on this lane you hold $THREE first, creators are paid their fees in $THREE, and when a coin graduates, the $THREE it raised is locked in its pool for good.</p>+ <div class="tl-cta">+ <a class="tl-btn tl-btn--primary" href="#tl-launch">Launch a coin</a>+ <a class="tl-btn" href="#tl-coins">Trade the curve</a>+ <a class="tl-btn" href="/three-token">Get $THREE</a>+ </div>++ <dl class="tl-facts" aria-label="Lane economics">+ <div class="tl-fact"><dt>Priced in</dt><dd>$THREE<small>${esc(short(lane?.quote_mint))}</small></dd></div>+ <div class="tl-fact"><dt>Starts at</dt><dd>${compact(lane?.initial_market_cap_three)} $THREE<small>market cap</small></dd></div>+ <div class="tl-fact"><dt>Graduates at</dt><dd>${compact(lane?.migration_market_cap_three)} $THREE<small>about ${compact(lane?.graduation_three_approx)} $THREE raised</small></dd></div>+ <div class="tl-fact"><dt>Trading fee</dt><dd>${(lane?.trade_fee_bps ?? 0) / 100}%<small>${lane?.fee_split?.creator_percent}% to the creator, in $THREE</small></dd></div>+ <div class="tl-fact"><dt>At graduation</dt><dd>${lane?.lp_locked_percent}% locked<small>liquidity can never be pulled</small></dd></div>+ </dl>++ <ol class="tl-loop" aria-label="How the loop works">+ <li><h3>Buying a coin is buying $THREE</h3><p>The curve only accepts $THREE. Every new buyer of every coin on this lane is a $THREE buyer first.</p></li>+ <li><h3>Creators get paid in $THREE</h3><p>${lane?.fee_split?.creator_percent}% of every trade's fee goes to the agent's creator, in $THREE, for as long as the coin trades.</p></li>+ <li><h3>Graduation locks $THREE away</h3><p>A coin that fills its curve moves to a Meteora pool against $THREE with all of its liquidity locked. Roughly ${compact(lane?.graduation_three_approx)} $THREE per graduate, out of circulation.</p></li>+ </ol>++ <section class="tl-section" id="tl-coins" aria-labelledby="tl-coins-h">+ <div class="tl-section-head"><h2 id="tl-coins-h">Coins on the curve</h2><p class="tl-section-note" id="tl-coins-note"></p></div>+ <div id="tl-coins-body"></div>+ <div id="tl-trade-slot"></div>+ </section>++ <section class="tl-section" id="tl-launch" aria-labelledby="tl-launch-h">+ <div class="tl-section-head"><h2 id="tl-launch-h">Launch a coin</h2><p class="tl-section-note">Supply 1B · metadata can never be changed · mint address carries the 3ws mark</p></div>+ <div id="tl-launch-body"></div>+ </section>+ `;+ renderCoins();+ renderLaunch();+}++function laneClosedNotice() {+ return `<div class="tl-notice" role="status"><div><strong>Opening soon.</strong><p>The $THREE curve is built and has been verified against Solana mainnet. Launching and trading open here as soon as its curve settings are published on-chain. Until then, the best preparation is simple: <a href="/three-token">hold $THREE</a> and have an agent ready.</p></div></div>`;+}++// ── Coins ──────────────────────────────────────────────────────────────────++function coinImage(c) {+ const url = c.agent?.avatar_thumbnail_url;+ return url+ ? `<img class="tl-card-img" src="${esc(url)}" alt="" loading="lazy" />`+ : `<span class="tl-card-img tl-card-img--blank" aria-hidden="true">${esc((c.symbol || '?').slice(0, 2).toUpperCase())}</span>`;+}++function renderCoins() {+ const body = $('#tl-coins-body');+ const note = $('#tl-coins-note');+ if (!body) return;+ if (state.launchesError) {+ note.textContent = '';+ body.innerHTML = `<div class="tl-notice" data-tone="error" role="alert"><div><strong>Could not load the coins.</strong><p>${esc(state.launchesError)}</p></div></div><div class="tl-more"><button type="button" class="tl-btn" id="tl-retry">Try again</button></div>`;+ $('#tl-retry').addEventListener('click', () => loadLaunches({ reset: true }));+ return;+ }+ if (state.launches === null) {+ note.textContent = '';+ body.innerHTML = `<div class="tl-grid" aria-busy="true" aria-label="Loading coins">${'<div class="tl-skel"></div>'.repeat(6)}</div>`;+ return;+ }+ if (state.launches.length === 0) {+ note.textContent = '';+ body.innerHTML = state.lane?.available+ ? `<div class="tl-empty"><b>No coins yet. The first one is yours.</b>Launch a coin for one of your agents below and it will show up here with its live curve.</div>`+ : `<div class="tl-empty"><b>No coins yet.</b>The first coins appear here, with their live curves, the moment the lane opens.</div>`;+ return;+ }++ const onCurve = state.launches.filter((c) => c.status !== 'migrated').length;+ const held = [...state.pools.values()].reduce((sum, p) => sum + (p?.migrated ? 0 : p?.quote_reserve_three || 0), 0);+ note.textContent = `${state.launches.length} launched · ${onCurve} on the curve${held > 0 ? ` · ${compact(held)} $THREE held in curves` : ''}`;++ body.innerHTML = `<div class="tl-grid">${state.launches+ .map((c) => {+ const pool = state.pools.get(c.mint);+ const pct = pool?.migrated ? 100 : Math.round((pool?.curve_progress || 0) * 100);+ const raised = pool?.error ? 'unavailable' : pool ? `${compact(pool.quote_reserve_three)} $THREE` : 'reading…';+ return `<button type="button" class="tl-card" data-mint="${esc(c.mint)}" aria-pressed="${c.mint === state.selected}">+ <span class="tl-card-top">${coinImage(c)}<span class="tl-card-name"><b>${esc(c.name || 'Unnamed')}</b><span>$${esc(c.symbol || '')}${c.agent?.name ? ` · ${esc(c.agent.name)}` : ''}</span></span></span>+ <span class="tl-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${pct}" aria-label="Curve progress"><i style="width:${pct}%"></i></span>+ <span class="tl-card-meta"><span>${pool?.migrated ? 'Graduated' : `${pct}% to graduation`}</span><b>${esc(raised)}</b></span>+ </button>`;+ })+ .join('')}</div>${state.hasMore ? '<div class="tl-more"><button type="button" class="tl-btn" id="tl-more">Show more</button></div>' : ''}`;++ body.querySelectorAll('.tl-card').forEach((el) => el.addEventListener('click', () => selectCoin(el.dataset.mint)));+ $('#tl-more')?.addEventListener('click', () => loadLaunches());+}++async function loadLaunches({ reset = false } = {}) {+ if (reset) {+ state.launches = null;+ state.launchesError = '';+ renderCoins();+ }+ try {+ const offset = reset || !state.launches ? 0 : state.launches.length;+ const { data } = await api(withNetwork(`/api/native-launch/launches?limit=${PAGE_SIZE}&offset=${offset}`));+ state.launches = [...(offset ? state.launches : []), ...data.launches];+ state.hasMore = data.has_more;+ renderCoins();+ await Promise.all(data.launches.map((c) => loadPool(c.mint)));+ renderCoins();+ if (state.selected && selectedCoin()) renderTrade();+ } catch (err) {+ state.launchesError = /failed to fetch/i.test(err.message) ? 'three.ws could not be reached. Check your connection.' : err.message;+ if (!state.launches) state.launches = [];+ renderCoins();+ }+}++async function loadPool(mint) {+ try {+ state.pools.set(mint, await api(withNetwork(`/api/native-launch/pool?mint=${mint}`)));+ } catch (err) {+ state.pools.set(mint, { error: err.message });+ }+}++// ── Trade ──────────────────────────────────────────────────────────────────++function selectCoin(mint) {+ state.selected = state.selected === mint ? null : mint;+ state.amount = '';+ state.quote = null;+ const url = new URL(location.href);+ if (state.selected) url.searchParams.set('mint', state.selected);+ else url.searchParams.delete('mint');+ history.replaceState(null, '', url);+ renderCoins();+ renderTrade();+ if (state.selected) {+ refreshBalances();+ $('#tl-trade-slot').scrollIntoView({ behavior: 'smooth', block: 'nearest' });+ }+}++function renderTrade() {+ const slot = $('#tl-trade-slot');+ const coin = selectedCoin();+ if (!slot) return;+ if (!coin) {+ slot.innerHTML = '';+ return;+ }+ const pool = state.pools.get(coin.mint);+ const graduated = Boolean(pool?.migrated);+ const buying = state.side === 'buy';+ const chips = buying+ ? [10_000, 50_000, 250_000, 1_000_000].map((v) => `<button type="button" class="tl-chip" data-amount="${v}">${compact(v)}</button>`).join('')+ : [25, 50, 100].map((v) => `<button type="button" class="tl-chip" data-percent="${v}">${v}%</button>`).join('');+ const balance = buying ? state.balances.three : state.balances.coin;++ slot.innerHTML = `<div class="tl-trade">+ <div class="tl-panel">+ <h3>${esc(coin.name || 'Unnamed')} <span style="color:var(--ink-dim);font-weight:500">$${esc(coin.symbol || '')}</span></h3>+ <p class="tl-trade-sub">${esc(coin.mint)}</p>+ <span class="tl-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${Math.round((pool?.curve_progress || 0) * 100)}" aria-label="Curve progress"><i style="width:${graduated ? 100 : Math.round((pool?.curve_progress || 0) * 100)}%"></i></span>+ <dl class="tl-kv">+ <dt>$THREE in the curve</dt><dd>${pool?.error ? 'unavailable' : pool ? fmt(pool.quote_reserve_three) : 'reading…'}</dd>+ <dt>Graduates at</dt><dd>${pool?.migration_quote_threshold_three ? `${fmt(pool.migration_quote_threshold_three)} $THREE` : ''}</dd>+ <dt>Creator</dt><dd>${esc(short(pool?.creator))}</dd>+ ${coin.agent ? `<dt>Agent</dt><dd><a href="${esc(coin.agent.url)}">${esc(coin.agent.name || 'View agent')}</a></dd>` : ''}+ </dl>+ </div>+ <div class="tl-panel">+ ${+ graduated+ ? `<div class="tl-notice" role="status"><div><strong>This coin graduated.</strong><p>Its curve is closed and its $THREE is locked in a Meteora pool. It now trades against $THREE on any Solana DEX aggregator.</p></div></div>`+ : `<div class="tl-seg" role="tablist" aria-label="Trade side">+ <button type="button" role="tab" data-side="buy" aria-selected="${buying}">Buy</button>+ <button type="button" role="tab" data-side="sell" aria-selected="${!buying}">Sell</button>+ </div>+ <label class="tl-field"><span><span>${buying ? 'You pay ($THREE)' : `You sell ($${esc(coin.symbol || 'tokens')})`}</span><span id="tl-balance">${balance == null ? '' : `Balance ${fmt(balance, 2)}`}</span></span>+ <input id="tl-amount" inputmode="decimal" autocomplete="off" placeholder="0" value="${esc(state.amount)}" aria-describedby="tl-quote" /></label>+ <div class="tl-chips">${chips}</div>+ <p class="tl-quote" id="tl-quote" aria-live="polite"></p>+ <button type="button" class="tl-btn tl-btn--block ${buying ? 'tl-btn--primary' : 'tl-btn--sell'}" id="tl-swap"></button>+ <p class="tl-status" id="tl-trade-status" aria-live="polite"></p>`+ }+ </div>+ </div>`;+ if (graduated) return;++ slot.querySelectorAll('[data-side]').forEach((b) =>+ b.addEventListener('click', () => {+ state.side = b.dataset.side;+ state.amount = '';+ state.quote = null;+ renderTrade();+ }),+ );+ const input = $('#tl-amount');+ input.addEventListener('input', () => {+ state.amount = input.value.replace(/[^0-9.]/g, '');+ scheduleQuote();+ });+ slot.querySelectorAll('[data-amount]').forEach((b) => b.addEventListener('click', () => setAmount(Number(b.dataset.amount))));+ slot.querySelectorAll('[data-percent]').forEach((b) =>+ b.addEventListener('click', () => setAmount(Math.floor(((state.balances.coin || 0) * Number(b.dataset.percent)) / 100))),+ );+ $('#tl-swap').addEventListener('click', onSwapClick);+ renderQuote();+}++function setAmount(value) {+ state.amount = value > 0 ? String(value) : '';+ const input = $('#tl-amount');+ if (input) input.value = state.amount;+ scheduleQuote();+}++let quoteTimer = null;+let quoteSeq = 0;+function scheduleQuote() {+ clearTimeout(quoteTimer);+ state.quote = null;+ renderQuote();+ const amount = Number(state.amount);+ if (!(amount > 0)) return;+ quoteTimer = setTimeout(async () => {+ const seq = ++quoteSeq;+ const key = state.side === 'buy' ? 'three_in' : 'tokens_in';+ try {+ const quote = await api(withNetwork(`/api/native-launch/quote?mint=${state.selected}&${key}=${amount}`));+ if (seq === quoteSeq) state.quote = quote;+ } catch (err) {+ if (seq === quoteSeq) state.quote = { error: err.message };+ }+ if (seq === quoteSeq) renderQuote();+ }, QUOTE_DEBOUNCE_MS);+}++function renderQuote() {+ const el = $('#tl-quote');+ const btn = $('#tl-swap');+ if (!el || !btn) return;+ const coin = selectedCoin();+ const amount = Number(state.amount);+ const buying = state.side === 'buy';+ const q = state.quote;++ if (!(amount > 0)) el.textContent = buying ? 'Enter how much $THREE to spend.' : 'Enter how many tokens to sell.';+ else if (!q) el.textContent = 'Reading the curve…';+ else if (q.error) el.textContent = `No quote: ${q.error}`;+ else if (buying) el.innerHTML = `You receive about <b>${fmt(q.tokens_out, 2)} $${esc(coin.symbol || '')}</b>, at least ${fmt(q.min_tokens_out, 2)} after ${q.slippage_bps / 100}% slippage. Fee ${fmt(q.trading_fee_three, 2)} $THREE.`;+ else el.innerHTML = `You receive about <b>${fmt(q.three_out, 2)} $THREE</b>, at least ${fmt(q.min_three_out, 2)} after ${q.slippage_bps / 100}% slippage. Fee ${fmt(q.trading_fee_three, 2)} $THREE.`;++ const balance = buying ? state.balances.three : state.balances.coin;+ const short_ = state.wallet && balance != null && amount > balance;+ btn.disabled = state.busy || (state.wallet && (!(amount > 0) || !q || Boolean(q.error) || short_));+ if (!walletInstalled()) btn.textContent = 'Install a Solana wallet';+ else if (!state.wallet) btn.textContent = 'Connect wallet';+ else if (state.busy) btn.textContent = 'Working…';+ else if (short_) btn.textContent = buying ? 'Not enough $THREE' : 'Not enough tokens';+ else btn.textContent = buying ? 'Buy with $THREE' : 'Sell for $THREE';++ const status = $('#tl-trade-status');+ if (status && short_ && buying && !state.busy) {+ status.dataset.tone = '';+ status.innerHTML = `This wallet holds ${fmt(balance, 2)} $THREE. <a href="/three-token">Get $THREE</a>, then come back.`;+ }+}++function setStatus(id, html, tone = '') {+ const el = $(id);+ if (!el) return;+ el.dataset.tone = tone;+ el.innerHTML = html;+}++async function refreshBalances() {+ if (!state.wallet || !state.lane?.quote_mint) return;+ const mint = state.selected;+ try {+ const [three, coin] = await Promise.all([+ tokenBalance(state.wallet.address, state.lane.quote_mint),+ mint ? tokenBalance(state.wallet.address, mint) : Promise.resolve(null),+ ]);+ if (mint !== state.selected) return;+ state.balances = { three, coin };+ } catch {+ state.balances = { three: null, coin: null };+ }+ const el = $('#tl-balance');+ const balance = state.side === 'buy' ? state.balances.three : state.balances.coin;+ if (el) el.textContent = balance == null ? '' : `Balance ${fmt(balance, 2)}`;+ renderQuote();+}++async function onSwapClick() {+ if (!walletInstalled()) {+ window.open('https://phantom.com/download', '_blank', 'noopener');+ return;+ }+ if (!state.wallet) {+ try {+ state.wallet = await connectTradingWallet();+ await refreshBalances();+ } catch (err) {+ setStatus('#tl-trade-status', esc(err.message), 'error');+ }+ renderQuote();+ return;+ }+ const mint = state.selected;+ const side = state.side;+ state.busy = true;+ renderQuote();+ setStatus('#tl-trade-status', 'Building the transaction…');+ try {+ const prep = await api('/api/native-launch/swap-prep', {+ method: 'POST',+ body: { mint, wallet_address: state.wallet.address, side, amount: Number(state.amount), network: NETWORK },+ });+ setStatus('#tl-trade-status', 'Approve it in your wallet…');+ const signature = await signAndBroadcast({ txBase64: prep.tx_base64, version: 0, address: state.wallet.address });+ setStatus('#tl-trade-status', `Sent. Waiting for confirmation… <a href="${explorerTx(signature)}" target="_blank" rel="noopener">view</a>`);+ const confirmed = await waitForConfirmation(signature);+ setStatus(+ '#tl-trade-status',+ `${confirmed ? (side === 'buy' ? 'Bought.' : 'Sold.') : 'Sent, still confirming.'} <a href="${explorerTx(signature)}" target="_blank" rel="noopener">View transaction</a>`,+ confirmed ? 'ok' : '',+ );+ state.amount = '';+ state.quote = null;+ const input = $('#tl-amount');+ if (input) input.value = '';+ await Promise.all([loadPool(mint), refreshBalances()]);+ renderCoins();+ } catch (err) {+ setStatus('#tl-trade-status', esc(err.code === 'USER_REJECTED' ? 'You cancelled the signature. Nothing was sent.' : err.message), 'error');+ } finally {+ state.busy = false;+ renderQuote();+ }+}++// ── Launch ─────────────────────────────────────────────────────────────────++function renderLaunch() {+ const body = $('#tl-launch-body');+ if (!body) return;+ if (!state.lane?.available) {+ body.innerHTML = laneClosedNotice();+ return;+ }+ if (state.user === undefined) {+ body.innerHTML = '<div class="tl-skel" aria-busy="true"></div>';+ return;+ }+ const next = encodeURIComponent(`${location.pathname}${location.search}#tl-launch`);+ if (!state.user) {+ body.innerHTML = `<div class="tl-empty"><b>Sign in to launch.</b>Every coin on three.ws belongs to a 3D agent, so launching starts from your account.<div class="tl-cta" style="justify-content:center"><a class="tl-btn tl-btn--primary" href="/login?next=${next}">Sign in</a><a class="tl-btn" href="/create-agent">Create an agent</a></div></div>`;+ return;+ }+ if (state.avatars.length === 0) {+ body.innerHTML = `<div class="tl-empty"><b>You need an agent first.</b>A coin here is tied to one of your 3D agents. Creating one takes about a minute.<div class="tl-cta" style="justify-content:center"><a class="tl-btn tl-btn--primary" href="/create-agent">Create an agent</a></div></div>`;+ return;+ }+ body.innerHTML = `<form class="tl-panel tl-form" id="tl-form" novalidate>+ <label class="tl-field tl-span"><span><span>Agent</span></span><select name="avatar" required>${state.avatars.map((a) => `<option value="${esc(a.id)}">${esc(a.name || a.slug || 'Untitled agent')}</option>`).join('')}</select></label>+ <label class="tl-field"><span><span>Coin name</span><span>max 32</span></span><input name="name" maxlength="32" required autocomplete="off" placeholder="Nova" /></label>+ <label class="tl-field"><span><span>Ticker</span><span>max 10</span></span><input name="symbol" maxlength="10" required autocomplete="off" placeholder="NOVA" /></label>+ <label class="tl-field tl-span"><span><span>Description</span><span>optional</span></span><textarea name="description" maxlength="500" placeholder="What this agent does and why its coin exists."></textarea></label>+ <label class="tl-field tl-span"><span><span>Your first buy, in $THREE</span><span>optional, fills the start of your own curve</span></span><input name="buy" inputmode="decimal" autocomplete="off" placeholder="0" /></label>+ <div class="tl-span" style="margin-top:18px"><button type="submit" class="tl-btn tl-btn--primary tl-btn--block" id="tl-launch-btn">Launch on the $THREE curve</button><p class="tl-status" id="tl-launch-status" aria-live="polite"></p></div>+ </form>`;+ const form = $('#tl-form');+ form.symbol.addEventListener('input', () => (form.symbol.value = form.symbol.value.toUpperCase().replace(/[^A-Z0-9]/g, '')));+ form.buy.addEventListener('input', () => (form.buy.value = form.buy.value.replace(/[^0-9.]/g, '')));+ form.addEventListener('submit', onLaunchSubmit);+}++function fromBase64(b64) {+ return Uint8Array.from(atob(b64), (ch) => ch.charCodeAt(0));+}+function toBase64(bytes) {+ let bin = '';+ for (const b of bytes) bin += String.fromCharCode(b);+ return btoa(bin);+}++async function onLaunchSubmit(event) {+ event.preventDefault();+ const form = event.currentTarget;+ const name = form.name.value.trim();+ const symbol = form.symbol.value.trim();+ if (!name || !symbol) {+ setStatus('#tl-launch-status', 'Give the coin a name and a ticker.', 'error');+ (name ? form.symbol : form.name).focus();+ return;+ }+ const avatar = state.avatars.find((a) => a.id === form.avatar.value);+ const threeBuyIn = Number(form.buy.value) || 0;+ const btn = $('#tl-launch-btn');+ btn.disabled = true;+ const say = (text, tone) => setStatus('#tl-launch-status', text, tone);+ try {+ say('Connecting your wallet…');+ const wallet = await connectLaunchWallet();+ state.wallet = { address: wallet.address, name: wallet.name };+ if (threeBuyIn > 0) {+ const held = await tokenBalance(wallet.address, state.lane.quote_mint);+ if (held < threeBuyIn) {+ say(`This wallet holds ${fmt(held, 2)} $THREE, less than your ${fmt(threeBuyIn)} $THREE first buy. <a href="/three-token">Get $THREE</a> or lower the first buy.`, 'error');+ return;+ }+ }+ say('Pinning the coin metadata…');+ const meta = await api('/api/pump/build-metadata', {+ method: 'POST',+ body: {+ name,+ symbol,+ description: form.description.value.trim(),+ avatar_id: avatar.id,+ ...(avatar.agent_id ? { agent_id: avatar.agent_id } : {}),+ },+ });+ say('Building the launch transaction…');+ const prep = await api('/api/native-launch/launch-prep', {+ method: 'POST',+ body: {+ avatar_id: avatar.id,+ ...(avatar.agent_id ? { agent_id: avatar.agent_id } : {}),+ wallet_address: wallet.address,+ name,+ symbol,+ uri: meta.metadata_url,+ network: NETWORK,+ three_buy_in: threeBuyIn,+ },+ });+ // The new mint has to sign its own creation. The server ground its address and+ // handed back the key for exactly this; the wallet signs after it.+ const tx = VersionedTransaction.deserialize(fromBase64(prep.tx_base64));+ tx.sign([Keypair.fromSecretKey(fromBase64(prep.mint_secret_key_b64))]);+ say('Approve the launch in your wallet…');+ const signature = await signAndBroadcast({ txBase64: toBase64(tx.serialize()), version: 0, address: wallet.address });+ say(`Sent. Waiting for confirmation… <a href="${explorerTx(signature)}" target="_blank" rel="noopener">view</a>`);+ await waitForConfirmation(signature);+ await api('/api/native-launch/launch-confirm', { method: 'POST', body: { prep_id: prep.prep_id, tx_signature: signature } });+ say(`Launched. <a href="${explorerTx(signature)}" target="_blank" rel="noopener">View transaction</a>`, 'ok');+ form.reset();+ state.selected = prep.mint;+ await loadLaunches({ reset: true });+ renderTrade();+ $('#tl-coins').scrollIntoView({ behavior: 'smooth' });+ } catch (err) {+ say(esc(err.code === 'USER_REJECTED' ? 'You cancelled the signature. Nothing was launched.' : err.message), 'error');+ } finally {+ btn.disabled = false;+ }+}++async function loadIdentity() {+ try {+ const me = await fetch('/api/auth/me', { credentials: 'include' });+ state.user = me.ok ? (await me.json()).user || null : null;+ if (state.user) state.avatars = (await api('/api/avatars?limit=100')).avatars || [];+ } catch {+ state.user = null;+ }+ renderLaunch();+}++// ── Boot ───────────────────────────────────────────────────────────────────++async function boot() {+ try {+ state.lane = await api(withNetwork('/api/native-launch/config'));+ } catch (err) {+ root.innerHTML = `<div class="tl-notice" data-tone="error" role="alert"><div><strong>The launchpad could not load.</strong><p>${esc(err.message)}</p></div></div><div class="tl-more"><button type="button" class="tl-btn" id="tl-reload">Try again</button></div>`;+ $('#tl-reload').addEventListener('click', boot);+ return;+ }+ renderShell();+ loadLaunches({ reset: true });+ loadIdentity();+ connectTradingWallet({ silent: true }).then((wallet) => {+ if (!wallet) return;+ state.wallet = wallet;+ refreshBalances();+ });+}++boot();diff --git a/vercel.json b/vercel.jsonindex b7f7579d0..f6dacf2a7 100644--- a/vercel.json+++ b/vercel.json@@ -1010,6 +1010,10 @@"src": "/launches/?","dest": "/launches.html"},+ {+ "src": "/three-launchpad/?",+ "dest": "/three-launchpad.html"+ },{"src": "/drops/?$","dest": "/drops.html"diff --git a/vite.config.js b/vite.config.jsindex c483ecce3..f641baaa4 100644--- a/vite.config.js+++ b/vite.config.js@@ -781,6 +781,7 @@ const appConfig = {wallet: resolve(__dirname, 'pages/wallet.html'),guardian: resolve(__dirname, 'pages/guardian.html'),launches: resolve(__dirname, 'pages/launches.html'),+ 'three-launchpad': resolve(__dirname, 'pages/three-launchpad.html'),minted: resolve(__dirname, 'pages/minted.html'),creations: resolve(__dirname, 'pages/creations.html'),mine: resolve(__dirname, 'pages/mine.html'),@@ -1585,6 +1586,8 @@ const appConfig = {'/bounties/': resolve(root, 'pages/bounties.html'),'/launches': resolve(root, 'pages/launches.html'),'/launches/': resolve(root, 'pages/launches.html'),+ '/three-launchpad': resolve(root, 'pages/three-launchpad.html'),+ '/three-launchpad/': resolve(root, 'pages/three-launchpad.html'),'/wardrobe': resolve(root, 'pages/wardrobe.html'),'/wardrobe/': resolve(root, 'pages/wardrobe.html'),'/minted': resolve(root, 'pages/minted.html'),