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.

Sniper: painted-stairstep defense (real two-sided market gate)

nirholas7818e7309a9a
diff --git a/api/_lib/migrations/20260721130000_sniper_two_sided_market.sql b/api/_lib/migrations/20260721130000_sniper_two_sided_market.sql
new file mode 100644
index 000000000..e1bacae06
--- /dev/null
+++ b/api/_lib/migrations/20260721130000_sniper_two_sided_market.sql
@@ -0,0 +1,18 @@
+-- Sniper market-realness gates (the painted-stairstep defense).
+--
+-- A big opening candle that then stairsteps up on a handful of wallets with no
+-- sellers is a chart PAINTED to trap momentum bots. In the platform's own labeled
+-- outcomes (~62k coins), a genuine two-sided market (>=20 unique buyers AND >=5
+-- unique sellers over the observation window) wins ~52% vs a ~12% base rate, while
+-- a one-sided painted rise barely beats a coin flip. These two optional per-strategy
+-- gates let an arm demand a real market before it buys. Read by the worker's
+-- scoreIntel (api/../scorer.js) via assessMarketRealness. Off by default (NULL/false)
+-- so existing arms are unchanged.
+--
+-- require_two_sided_market — hard-require the proven two-sided bar.
+-- min_unique_sellers — require a floor of real sellers (no painted one-sided rise).
+--
+-- Additive and idempotent, safe to re-run.
+ALTER TABLE agent_sniper_strategies
+ ADD COLUMN IF NOT EXISTS require_two_sided_market BOOLEAN NOT NULL DEFAULT false,
+ ADD COLUMN IF NOT EXISTS min_unique_sellers INTEGER;
diff --git a/tests/market-realness.test.js b/tests/market-realness.test.js
new file mode 100644
index 000000000..af304177b
--- /dev/null
+++ b/tests/market-realness.test.js
@@ -0,0 +1,37 @@
+// market-realness: the painted-stairstep detector, calibrated to the platform's
+// own labeled outcomes (two-sided markets win ~52% vs a ~12% base).
+
+import { describe, it, expect } from 'vitest';
+import { assessMarketRealness } from '../api/_lib/market-realness.js';
+
+describe('assessMarketRealness', () => {
+ it('flags a painted one-sided rise (the honeypot stairstep)', () => {
+ const m = assessMarketRealness({ unique_buyers: 4, unique_sellers: 0, buy_count: 11, sell_count: 0, concentration_top5: 0.94, timing_entropy: 0.3 });
+ expect(m.painted).toBe(true);
+ expect(m.twoSided).toBe(false);
+ expect(m.realness).toBeLessThan(0.3);
+ expect(m.flags).toContain('one_sided_no_sellers');
+ expect(m.flags).toContain('whale_concentrated');
+ });
+
+ it('rewards a genuine two-sided market', () => {
+ const m = assessMarketRealness({ unique_buyers: 31, unique_sellers: 8, buy_count: 60, sell_count: 22, concentration_top5: 0.42, timing_entropy: 0.8 });
+ expect(m.twoSided).toBe(true);
+ expect(m.painted).toBe(false);
+ expect(m.realness).toBeGreaterThan(0.8);
+ });
+
+ it('stays neutral when there is not enough trading to read', () => {
+ const m = assessMarketRealness({ unique_buyers: 1, buy_count: 1, sell_count: 0 });
+ expect(m.painted).toBe(false);
+ expect(m.twoSided).toBe(false);
+ expect(m.realness).toBe(0.5);
+ expect(m.flags).toContain('insufficient_trades');
+ });
+
+ it('does not convict on thin-crowd alone (needs two structural tells)', () => {
+ // few buyers but real sellers and not whale-held → not painted
+ const m = assessMarketRealness({ unique_buyers: 8, unique_sellers: 4, buy_count: 12, sell_count: 6, concentration_top5: 0.5, timing_entropy: 0.9 });
+ expect(m.painted).toBe(false);
+ });
+});
diff --git a/workers/agent-sniper/index.js b/workers/agent-sniper/index.js
index 47a43c769..6e9ca5b6b 100644
--- a/workers/agent-sniper/index.js
+++ b/workers/agent-sniper/index.js
@@ -220,6 +220,38 @@ async function main() {
const trigger = strat.trigger || 'new_mint';
if (strat.network !== cfg.network) continue;
+ // LLM arms on the intel trigger judge the coin AFTER observation, so the
+ // model sees the market SHAPE (buyer/seller diversity, concentration,
+ // timing) — the painted-stairstep tell a human reads off the chart and a
+ // blind new_mint LLM buy never gets. Safety rails still gate at executeBuy.
+ if (trigger === 'intel_confirmed' && (strat.decision_mode || 'rules') === 'llm') {
+ smartReady.then(() => {
+ const judgeMint = {
+ mint: rec.mint, symbol: rec.symbol, name: rec.name, description: rec.description,
+ twitter: rec.twitter, telegram: rec.telegram, website: rec.website,
+ market_cap_usd: rec.market_cap_usd, initial_buy_sol: rec.dev_buy_sol,
+ creator_launches: rec.creator_launches, creator_graduated: rec.creator_graduated,
+ signals: rec.signals,
+ };
+ judgeLaunch(judgeMint, strat).then((verdict) => {
+ if (!verdict) return;
+ const minConf = Number(strat.llm_min_confidence ?? 0.6);
+ if (!verdict.buy || verdict.confidence < minConf) {
+ log.info('llm judge pass', { agent: strat.agent_id, mint: rec.mint, model: verdict.model, buy: verdict.buy, confidence: verdict.confidence });
+ return;
+ }
+ log.info('llm judge buy', { agent: strat.agent_id, mint: rec.mint, model: verdict.model, confidence: verdict.confidence, thesis: verdict.thesis });
+ queue.push(async () => {
+ await executeBuy({
+ cfg, strat, throttle,
+ mint: { mint: rec.mint, symbol: rec.symbol, name: rec.name, market_cap_usd: rec.market_cap_usd, entry_trigger: 'llm_intel', trigger_ref: verdict.model, score: verdict.confidence, llm: verdict },
+ });
+ });
+ }).catch((err) => log.error('llm intel judge failed', { mint: rec.mint, err: err?.message }));
+ });
+ continue;
+ }
+
if (trigger === 'intel_confirmed') {
Promise.all([getLearnedWeights(cfg.network), smartReady])
.then(([weights]) => {