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.

Add oracle conviction badges to watchlist via batch endpoint

nirholas694af7e0f325
diff --git a/api/oracle/batch.js b/api/oracle/batch.js
new file mode 100644
index 000000000..501b135ac
--- /dev/null
+++ b/api/oracle/batch.js
@@ -0,0 +1,72 @@
+/**
+ * Oracle — batch conviction scores for multiple mints.
+ *
+ * GET /api/oracle/batch?mints=<m1>,<m2>,...&network=mainnet
+ *
+ * Accepts up to 20 base58 mints (comma-separated). Returns a map of
+ * { mint → { score, tier, pillars: { pedigree, structure, narrative, momentum } } }
+ * for every mint that exists in the oracle_conviction cache. Mints with no
+ * cached score are omitted (not an error — means unscored).
+ *
+ * Used by the watchlist page and any surface that needs conviction badges for
+ * a known set of coins without issuing N individual /api/oracle/coin requests.
+ *
+ * Public, IP rate-limited, 30-second CDN cache.
+ */
+
+import { cors, json, method, wrap, error, rateLimited } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { sql } from '../_lib/db.js';
+
+const NETWORKS = new Set(['mainnet', 'devnet']);
+const MINT_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
+const MAX_MINTS = 20;
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const rl = await limits.publicIp(clientIp(req));
+ if (!rl.success) return rateLimited(res, rl);
+
+ const params = new URL(req.url, `http://${req.headers.host || 'x'}`).searchParams;
+ const network = NETWORKS.has(params.get('network')) ? params.get('network') : 'mainnet';
+ const raw = (params.get('mints') || '').trim();
+
+ if (!raw) return error(res, 400, 'validation_error', '`mints` query param is required');
+
+ const mints = [...new Set(
+ raw.split(',')
+ .map((m) => m.trim())
+ .filter((m) => MINT_RE.test(m))
+ )].slice(0, MAX_MINTS);
+
+ if (mints.length === 0) return error(res, 400, 'validation_error', 'no valid base58 mints provided');
+
+ const rows = await sql`
+ select mint, score, tier, pedigree, structure, narrative, momentum
+ from oracle_conviction
+ where network = ${network}
+ and mint = any(${mints})
+ `.catch((e) => {
+ throw new Error(`batch query failed: ${e.message}`);
+ });
+
+ const results = {};
+ for (const r of rows) {
+ results[r.mint] = {
+ score: r.score != null ? Number(r.score) : null,
+ tier: r.tier || null,
+ pillars: {
+ pedigree: r.pedigree != null ? Number(r.pedigree) : null,
+ structure: r.structure != null ? Number(r.structure) : null,
+ narrative: r.narrative != null ? Number(r.narrative) : null,
+ momentum: r.momentum != null ? Number(r.momentum) : null,
+ },
+ };
+ }
+
+ return json(res, 200, { network, results, queried: mints.length, found: rows.length }, {
+ 'cache-control': 'public, max-age=30, s-maxage=60, stale-while-revalidate=120',
+ });
+});
diff --git a/src/watchlist.css b/src/watchlist.css
index 71c21bff2..d0986ab4f 100644
--- a/src/watchlist.css
+++ b/src/watchlist.css
@@ -203,3 +203,44 @@ body {
.wl-btn-primary { background: var(--accent); color: var(--bg-0); border-color: var(--accent); }
.wl-btn-primary:hover { color: var(--bg-0); filter: brightness(1.08); }
.wl-btn-ghost { background: transparent; }
+
+/* ── Oracle conviction badge ─────────────────────────────────────────────── */
+
+.wl-oracle-badge {
+ position: absolute;
+ bottom: var(--space-sm, 10px);
+ right: var(--space-sm, 10px);
+ z-index: 3;
+ pointer-events: none;
+}
+.wl-ob-link {
+ pointer-events: all;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ background: rgba(0,0,0,0.55);
+ border: 1px solid rgba(255,255,255,0.10);
+ border-radius: 8px;
+ padding: 5px 9px 4px;
+ text-decoration: none;
+ line-height: 1;
+ backdrop-filter: blur(6px);
+ transition: background 0.14s, border-color 0.14s, transform 0.14s;
+}
+.wl-ob-link:hover { background: rgba(0,0,0,0.75); border-color: rgba(255,255,255,0.22); transform: scale(1.05); }
+.wl-ob-score {
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 17px;
+ font-weight: 800;
+ font-variant-numeric: tabular-nums;
+ letter-spacing: -0.01em;
+}
+.wl-ob-tier {
+ font-family: var(--font-mono, ui-monospace, monospace);
+ font-size: 8.5px;
+ font-weight: 700;
+ letter-spacing: 0.07em;
+ text-transform: uppercase;
+ opacity: 0.85;
+ margin-top: 2px;
+}
diff --git a/src/watchlist.js b/src/watchlist.js
index 54827de88..8406a6ca1 100644
--- a/src/watchlist.js
+++ b/src/watchlist.js
@@ -11,7 +11,8 @@
import { mountCoinStatus } from './pump/coin-status-card.js';
-const WATCH_KEY = 'ld_watchlist'; // shared with src/launch-detail.js
+const WATCH_KEY = 'ld_watchlist'; // shared with src/launch-detail.js
+const TIER_COLOR = { prime: '#c084fc', strong: '#34d399', lean: '#fbbf24', watch: '#94a3b8', avoid: '#f87171' };
const MINT_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
const REDUCED_MOTION = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -163,7 +164,8 @@ function watchCard(mint, index) {
remove(mint);
},
});
- const card = el('article', { class: 'wl-card' }, [link, removeBtn, market]);
+ const oracleBadge = el('div', { class: 'wl-oracle-badge', 'data-oracle': mint });
+ const card = el('article', { class: 'wl-card', 'data-mint': mint }, [link, oracleBadge, removeBtn, market]);
if (!REDUCED_MOTION) {
card.style.animationDelay = `${Math.min(index, 12) * 40}ms`;
card.classList.add('wl-in');
@@ -206,6 +208,47 @@ function render() {
list.forEach((mint, i) => feedEl.appendChild(watchCard(mint, i)));
feedEl.setAttribute('aria-busy', 'false');
+
+ enrichWithOracleConviction(list);
+}
+
+// Batch-fetch Oracle conviction for all watched mints and paint badges on cards.
+async function enrichWithOracleConviction(mints) {
+ if (!mints.length) return;
+ // Chunk into ≤20 per request (API limit).
+ const chunks = [];
+ for (let i = 0; i < mints.length; i += 20) chunks.push(mints.slice(i, i + 20));
+ let results = {};
+ try {
+ const responses = await Promise.all(
+ chunks.map((chunk) =>
+ fetch(`/api/oracle/batch?mints=${chunk.map(encodeURIComponent).join(',')}&network=mainnet`)
+ .then((r) => r.ok ? r.json() : null)
+ .catch(() => null),
+ ),
+ );
+ for (const resp of responses) {
+ if (resp?.results) Object.assign(results, resp.results);
+ }
+ } catch { return; }
+
+ // Paint each card whose article has a data-mint attribute.
+ for (const article of feedEl.querySelectorAll('article[data-mint]')) {
+ const mint = article.dataset.mint;
+ const data = results[mint];
+ if (!data || data.score == null) continue;
+ let badge = article.querySelector('.wl-oracle-badge');
+ if (!badge) {
+ badge = document.createElement('div');
+ badge.className = 'wl-oracle-badge';
+ article.appendChild(badge);
+ }
+ const color = TIER_COLOR[data.tier] || '#94a3b8';
+ badge.innerHTML = `<a class="wl-ob-link" href="/oracle?mint=${encodeURIComponent(mint)}" aria-label="Oracle conviction: ${data.score} ${data.tier || ''}">
+ <span class="wl-ob-score" style="color:${color}">${data.score}</span>
+ <span class="wl-ob-tier" style="color:${color}">${data.tier || ''}</span>
+ </a>`;
+ }
}
// ── ambient field (shared visual language) ──────────────────────────────────
diff --git a/vercel.json b/vercel.json
index 809aa5025..24299221e 100644
--- a/vercel.json
+++ b/vercel.json
@@ -191,6 +191,10 @@
"includeFiles": "{examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json}",
"maxDuration": 30
},
+ "api/oracle/batch.js": {
+ "includeFiles": "{examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json}",
+ "maxDuration": 15
+ },
"api/copy/executions.js": {
"includeFiles": "{examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json}",
"maxDuration": 30
@@ -1865,6 +1869,10 @@
"src": "/api/oracle/activity",
"dest": "/api/oracle/activity.js"
},
+ {
+ "src": "/api/oracle/batch",
+ "dest": "/api/oracle/batch.js"
+ },
{
"src": "/api/copy/executions",
"dest": "/api/copy/executions.js"