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
Add Oracle conviction gate to copy trading subscriptions
nirholas5daab724f4e1
diff --git a/api/_lib/copy-engine.js b/api/_lib/copy-engine.jsindex 65b0e68f2..94e68fc45 100644--- a/api/_lib/copy-engine.js+++ b/api/_lib/copy-engine.js@@ -46,6 +46,11 @@ export function normalizeSubscriptionInput(raw = {}) {return { ok: false, error: 'mcap_floor_usd cannot exceed mcap_ceiling_usd' };}+ const minOracleScore = raw.min_oracle_score == null || raw.min_oracle_score === '' ? null : Math.round(n(raw.min_oracle_score));+ if (minOracleScore != null && (minOracleScore < 0 || minOracleScore > 100)) {+ return { ok: false, error: 'min_oracle_score must be between 0 and 100' };+ }+return {ok: true,value: {@@ -61,6 +66,7 @@ export function normalizeSubscriptionInput(raw = {}) {mcap_ceiling_usd: mcapCeil,copy_sells: raw.copy_sells !== false,require_safety_pass: raw.require_safety_pass === true,+ min_oracle_score: minOracleScore,perf_fee_bps: perfBps,},};@@ -150,6 +156,14 @@ export function evaluateSafety(sub, coin) {if (coin.liquidity_usd != null && coin.liquidity_usd > 0 && coin.liquidity_usd < 1000) {return { ok: false, reason: 'low_liquidity', detail: `Liquidity $${fmt(coin.liquidity_usd)} is too thin to copy safely.` };}++ // Oracle conviction gate: skip if the score is known and below the threshold.+ if (sub.min_oracle_score != null && coin.oracle_score != null) {+ if (n(coin.oracle_score) < n(sub.min_oracle_score)) {+ return { ok: false, reason: 'below_oracle_threshold', detail: `Oracle conviction ${n(coin.oracle_score)} is below your minimum ${n(sub.min_oracle_score)}.` };+ }+ }+return { ok: true };}diff --git a/api/_lib/migrations/20260616150000_copy_oracle_gate.sql b/api/_lib/migrations/20260616150000_copy_oracle_gate.sqlnew file mode 100644index 000000000..28bad0ac2--- /dev/null+++ b/api/_lib/migrations/20260616150000_copy_oracle_gate.sql@@ -0,0 +1,6 @@+-- Copy trading: Oracle conviction gate.+-- Adds min_oracle_score to copy_subscriptions so copiers can require a+-- minimum conviction score before a copy intent is generated.+alter table copy_subscriptions+ add column if not exists min_oracle_score smallint+ check (min_oracle_score >= 0 and min_oracle_score <= 100);diff --git a/api/copy/subscriptions.js b/api/copy/subscriptions.jsindex e7e0336c2..1bf4f2a50 100644--- a/api/copy/subscriptions.js+++ b/api/copy/subscriptions.js@@ -121,12 +121,12 @@ export default wrap(async (req, res) => {copier_user_id, copier_wallet, leader_agent_id, leader_wallet, network, status,sizing_rule, fixed_sol, multiplier, pct_balance,per_trade_cap_sol, min_order_sol, daily_budget_sol, max_open_copies,- mcap_floor_usd, mcap_ceiling_usd, copy_sells, require_safety_pass, perf_fee_bps+ mcap_floor_usd, mcap_ceiling_usd, copy_sells, require_safety_pass, min_oracle_score, perf_fee_bps) values (${userId}, ${wallet}, ${leaderId}, ${leaderWallet}, ${network}, 'active',${v.sizing_rule}, ${v.fixed_sol}, ${v.multiplier}, ${v.pct_balance},${v.per_trade_cap_sol}, ${v.min_order_sol}, ${v.daily_budget_sol}, ${v.max_open_copies},- ${v.mcap_floor_usd}, ${v.mcap_ceiling_usd}, ${v.copy_sells}, ${v.require_safety_pass}, ${v.perf_fee_bps}+ ${v.mcap_floor_usd}, ${v.mcap_ceiling_usd}, ${v.copy_sells}, ${v.require_safety_pass}, ${v.min_oracle_score}, ${v.perf_fee_bps})on conflict (copier_user_id, leader_agent_id, network) do update setcopier_wallet = excluded.copier_wallet,@@ -144,6 +144,7 @@ export default wrap(async (req, res) => {mcap_ceiling_usd = excluded.mcap_ceiling_usd,copy_sells = excluded.copy_sells,require_safety_pass = excluded.require_safety_pass,+ min_oracle_score = excluded.min_oracle_score,perf_fee_bps = excluded.perf_fee_bps,updated_at = now()returning *diff --git a/api/cron/copy-fanout.js b/api/cron/copy-fanout.jsindex 9cce7fbce..284c21060 100644--- a/api/cron/copy-fanout.js+++ b/api/cron/copy-fanout.js@@ -39,10 +39,14 @@ function requireCron(req, res) {// Best-effort coin context for the safety gate. pump.fun's public coin endpoint// gives a live USD market cap; richer signals (dev holding, liquidity, honeypot)-// are left null and the engine treats them as "unknown".+// are left null and the engine treats them as "unknown". Oracle score is merged+// in separately so subscriptions with min_oracle_score can filter on it.const _coinCache = new Map();-async function coinContext(mint) {- if (_coinCache.has(mint)) return _coinCache.get(mint);+async function coinContext(mint, oracleScore) {+ if (_coinCache.has(mint)) {+ const cached = _coinCache.get(mint);+ return oracleScore != null ? { ...cached, oracle_score: oracleScore } : cached;+ }let ctx = null;try {const r = await fetch(`https://frontend-api-v3.pump.fun/coins/${mint}`, {@@ -54,7 +58,25 @@ async function coinContext(mint) {}} catch { /* leave null — engine handles missing context */ }_coinCache.set(mint, ctx);- return ctx;+ return oracleScore != null ? { ...(ctx || {}), oracle_score: oracleScore } : ctx;+}++// Fetch the latest Oracle conviction score for a mint from the DB. Returns null+// if unscored. Called in the sniper fanout path (Oracle fanout has the score inline).+const _oracleScoreCache = new Map();+async function oracleScore(mint, network) {+ const key = `${network}:${mint}`;+ if (_oracleScoreCache.has(key)) return _oracleScoreCache.get(key);+ try {+ const [row] = await sql`+ select score from oracle_conviction+ where mint = ${mint} and network = ${network}+ limit 1+ `;+ const score = row?.score != null ? Number(row.score) : null;+ _oracleScoreCache.set(key, score);+ return score;+ } catch { return null; }}async function fanoutBuys(network, stats) {@@ -94,7 +116,8 @@ async function fanoutBuys(network, stats) {where leader_agent_id = ${pos.agent_id} and network = ${network} and status = 'active'`;if (!subs.length) continue;- const coin = await coinContext(pos.mint);+ const score = await oracleScore(pos.mint, network);+ const coin = await coinContext(pos.mint, score);const entrySol = lamToSol(pos.entry_quote_lamports);for (const sub of subs) {@@ -216,7 +239,8 @@ async function fanoutOracleBuys(network, stats) {where leader_agent_id = ${action.agent_id} and network = ${network} and status = 'active'`;if (!subs.length) continue;- const coin = await coinContext(action.mint);+ // Oracle action has conviction inline — no DB lookup needed.+ const coin = await coinContext(action.mint, action.conviction != null ? Number(action.conviction) : null);const entrySol = Number(action.size_sol) || 0;for (const sub of subs) {diff --git a/src/copy-panel.js b/src/copy-panel.jsindex 18672ed3f..5e89aa56e 100644--- a/src/copy-panel.js+++ b/src/copy-panel.js@@ -151,6 +151,13 @@ function renderForm(el, { leaderAgentId, leaderName, network, prefill }) {<input class="cp-input" id="cp-mcc" type="number" step="1000" min="0" placeholder="any" value="${p.mcap_ceiling_usd ?? ''}" /></label></div>+ <div class="cp-row">+ <label class="cp-field">+ <span class="cp-label">Min Oracle conviction (0–100)</span>+ <input class="cp-input" id="cp-oracle" type="number" step="1" min="0" max="100" placeholder="any" value="${p.min_oracle_score ?? ''}" />+ <span class="cp-hint">Skip copies if Oracle score is below this. Leave blank to copy regardless of conviction.</span>+ </label>+ </div><label class="cp-check"><input type="checkbox" id="cp-sells" ${p.copy_sells === false ? '' : 'checked'} /> <span>Mirror their exits too</span></label><label class="cp-check"><input type="checkbox" id="cp-safe" ${p.require_safety_pass ? 'checked' : ''} /> <span>Only copy when coin safety is confirmed</span></label></details>@@ -191,6 +198,7 @@ function renderForm(el, { leaderAgentId, leaderName, network, prefill }) {daily_budget_sol: num('cp-daily'),mcap_floor_usd: $('#cp-mcf', el).value === '' ? null : num('cp-mcf'),mcap_ceiling_usd: $('#cp-mcc', el).value === '' ? null : num('cp-mcc'),+ min_oracle_score: $('#cp-oracle', el).value === '' ? null : Math.round(num('cp-oracle')),copy_sells: $('#cp-sells', el).checked,require_safety_pass: $('#cp-safe', el).checked,};diff --git a/src/dashboard-next/pages/copy.js b/src/dashboard-next/pages/copy.jsindex ac703db8d..7a877e15a 100644--- a/src/dashboard-next/pages/copy.js+++ b/src/dashboard-next/pages/copy.js@@ -17,6 +17,7 @@ const SKIP_LABEL = {low_liquidity: 'Liquidity too thin',honeypot: 'Flagged as a honeypot',safety_unknown: 'Coin safety unconfirmed',+ below_oracle_threshold: 'Oracle conviction too low',below_min_order: 'Sized below your minimum',daily_budget_spent: 'Daily budget used up',max_open_copies: 'Open-copies cap reached',@@ -113,7 +114,7 @@ function subRow(s) {<a href="${traderHref(s.leader_agent_id)}" style="color:inherit;text-decoration:none">${esc(s.leader_name || 'trader')}</a><span class="cp-tag ${paused ? 'paused' : 'on'}">${paused ? 'Paused' : '● Active'}</span></div>- <div class="cp-sub">${esc(sizingLabel(s))} · cap ${Number(s.per_trade_cap_sol)} ◎ · ${Number(s.daily_budget_sol)} ◎/day · ${Number(s.pending_count) || 0} pending</div>+ <div class="cp-sub">${esc(sizingLabel(s))} · cap ${Number(s.per_trade_cap_sol)} ◎ · ${Number(s.daily_budget_sol)} ◎/day · ${Number(s.pending_count) || 0} pending${s.min_oracle_score != null ? ` · Oracle ≥${s.min_oracle_score}` : ''}</div></div><div class="cp-side"><button class="cp-btn" data-sub-act="${paused ? 'active' : 'paused'}">${paused ? 'Resume' : 'Pause'}</button>diff --git a/src/trader.css b/src/trader.cssindex ccb1aea78..961778f10 100644--- a/src/trader.css+++ b/src/trader.css@@ -219,6 +219,7 @@.cp-check { display: flex; align-items: center; gap: var(--space-2xs); font-size: var(--text-xs); color: var(--ink-dim); margin-top: var(--space-2xs); cursor: pointer; }.cp-err { color: var(--danger); font-size: var(--text-xs); margin: 0; }.cp-fine { color: var(--ink-faint); font-size: var(--text-2xs); margin: 0; }+.cp-hint { display: block; font-size: var(--text-2xs); color: var(--ink-faint); margin-top: 4px; line-height: 1.4; }/* ---- States / skeleton ---- */.tp-skel { border: 1px solid var(--stroke); border-radius: var(--radius-card); background: var(--surface-1); padding: var(--space-lg); }