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
Sniper fleet: boost-ride arm trades the pump.fun BOOST window
nirholasf15f0ba3d227
diff --git a/api/_lib/migrations/20260721200000_sniper_graduation_ride.sql b/api/_lib/migrations/20260721200000_sniper_graduation_ride.sqlnew file mode 100644index 000000000..d1beecbea--- /dev/null+++ b/api/_lib/migrations/20260721200000_sniper_graduation_ride.sql@@ -0,0 +1,32 @@+-- graduation_ride trigger (the BOOST-window arm) + entry_trigger CHECK repair.+-- Apply: psql "$DATABASE_URL" -f api/_lib/migrations/20260721200000_sniper_graduation_ride.sql+-- Idempotent (drop + re-add of named constraints).+--+-- 1. New trigger value `graduation_ride`: buy a coin's pump AMM pool the moment+-- it migrates off the bonding curve and sell into pump.fun's BOOST window+-- (live 2026-07-21: ~17.6 SOL of buyback+burn TWAP'd over the 5 minutes after+-- every non-Mayhem migration). Entry: workers/agent-sniper/graduation-ride.js.+-- Exits reuse the unchanged exit engine (max_hold_seconds is the window sell).+--+-- 2. REPAIR: the positions entry_trigger CHECK still listed only the original 4+-- values, but the worker has been writing 'llm_judge', 'llm_intel',+-- 'alpha_hunt' and 'swarm_consensus' since those paths shipped — every such+-- buy died at the position-claim INSERT with a constraint violation. Widen+-- the CHECK to every value the code actually writes.++begin;++alter table agent_sniper_strategies drop constraint if exists agent_sniper_strategies_trigger_check;+alter table agent_sniper_strategies+ add constraint agent_sniper_strategies_trigger_check+ check (trigger in ('new_mint', 'first_claim', 'intel_confirmed', 'prelaunch_radar',+ 'alpha_hunt', 'graduation_ride'));++alter table agent_sniper_positions drop constraint if exists agent_sniper_positions_entry_trigger_check;+alter table agent_sniper_positions+ add constraint agent_sniper_positions_entry_trigger_check+ check (entry_trigger in ('new_mint', 'first_claim', 'intel_confirmed', 'prelaunch_radar',+ 'alpha_hunt', 'llm_judge', 'llm_intel', 'swarm_consensus',+ 'graduation_ride'));++commit;diff --git a/api/sniper/strategy.js b/api/sniper/strategy.jsindex c4478d900..abff210d8 100644--- a/api/sniper/strategy.js+++ b/api/sniper/strategy.js@@ -56,9 +56,11 @@ const STRATEGY_SCHEMA = z.object({enabled: z.boolean().optional(),kill_switch: z.boolean().optional(),// trigger: what arms this strategy.- // new_mint — snipe new pump.fun launches off the PumpPortal feed (default).- // first_claim — snipe a creator's coin the first time they EVER claim rewards.- trigger: z.enum(['new_mint', 'first_claim', 'intel_confirmed', 'prelaunch_radar', 'alpha_hunt']).optional(),+ // new_mint — snipe new pump.fun launches off the PumpPortal feed (default).+ // first_claim — snipe a creator's coin the first time they EVER claim rewards.+ // graduation_ride — buy the AMM pool at migration and sell into pump.fun's+ // 5-minute BOOST buyback window (workers/agent-sniper/graduation-ride.js).+ trigger: z.enum(['new_mint', 'first_claim', 'intel_confirmed', 'prelaunch_radar', 'alpha_hunt', 'graduation_ride']).optional(),buy_delay_ms: z.union([z.string(), z.number()]).optional(),// prelaunch_radar gates (null clears)min_creator_graduated_radar: optInt,diff --git a/docs/agent-sniper.md b/docs/agent-sniper.mdindex fe27fe8a5..70b7996e7 100644--- a/docs/agent-sniper.md+++ b/docs/agent-sniper.md@@ -86,7 +86,7 @@ The strategy row (`agent_sniper_strategies`, armed via `POST /api/sniper/strateg| Field | What it does ||---|---|-| `trigger` | `new_mint`, `first_claim`, `intel_confirmed`, alpha/radar variants |+| `trigger` | `new_mint`, `first_claim`, `intel_confirmed`, `graduation_ride` (buy at migration, sell into pump.fun's 5-minute BOOST buyback window), alpha/radar variants || `per_trade_lamports` / `daily_budget_lamports` | Position size and the hard daily spend ceiling || `max_concurrent_positions` | Open-position cap || `min_market_cap_usd` / `max_market_cap_usd` | Entry band; tightened by the fleet-wide safety band |diff --git a/scripts/seed-sniper-experiments.mjs b/scripts/seed-sniper-experiments.mjsindex ce852cd8d..1dda7b75d 100644--- a/scripts/seed-sniper-experiments.mjs+++ b/scripts/seed-sniper-experiments.mjs@@ -13,6 +13,15 @@// oracle group: conviction-gated entries (bite after score maturity)// llm group: no rule shields; a model judges each launch (grok / claude /// openrouter auto-router), safety rails still enforced+// boost group: event-driven — buy the pump AMM at migration and sell into+// pump.fun's 5-minute BOOST buyback window (live 2026-07-21)+//+// The boost-ride arm is PROVISIONED here too (agent identity + custodial wallet+// + strategy row) because unlike the first ten arms it has no pre-existing+// strategy to reshape. Provisioning is idempotent (keyed by agent name + owner).+// NOTE the wallet secret is encrypted with the process env's WALLET_ENCRYPTION_KEY+// (JWT_SECRET fallback) — run this with the SAME key material the agent-sniper+// service decrypts with, or the worker will load a wallet it cannot open.import { execSync } from 'node:child_process';import { createRequire } from 'node:module';@@ -21,6 +30,11 @@ const require = createRequire(import.meta.url);const { Pool } = require('@neondatabase/serverless');const APPLY = process.argv.includes('--apply');+// --only <label>: touch a single arm (and skip the rest entirely). Use this for+// late-added arms so a re-run can never clobber params the live optimizer has+// evolved on the original fleet since the first seeding.+const _onlyIdx = process.argv.indexOf('--only');+const ONLY = _onlyIdx >= 0 ? process.argv[_onlyIdx + 1] : null;const NETWORK = 'mainnet';// agent_id (unique per arm) → the experiment definition. `set` contains only@@ -121,6 +135,89 @@ const ARMS = [},];+// ── boost-ride: the 11th arm (provisioned, not reshaped) ─────────────────────+// pump.fun BOOST mode injects ~17.6 SOL of buyback+burn TWAP over the 5 minutes+// after every non-Mayhem migration. The arm buys the fresh AMM pool at the+// migration event and exits INSIDE that window:+// max_hold_seconds 240 — the timed sell into the TWAP (the play itself)+// trailing_stop 8% — locks the pop if it front-runs the window+// take_profit 20% — ceiling; a bigger pop than BOOST alone explains+// stop_loss 15% — hard cap; migration dumps overwhelm the TWAP+// Owner is the same user that owns the core arms; sizing matches the fleet.+const BOOST_ARM = {+ label: 'boost-ride',+ group: 'boost',+ agentName: 'Sniper Arm: Boost Ride',+ note: 'buy the AMM at migration, sell into the 5-min BOOST buyback window',+ ownerUser: 'a6a6aed1-9ecc-40cd-889b-340895ee4d8c',+ strategy: {+ enabled: true,+ kill_switch: false,+ trigger: 'graduation_ride',+ decision_mode: 'rules',+ require_socials: false,+ require_sol_quote: true,+ min_market_cap_usd: null,+ max_market_cap_usd: null,+ min_oracle_score: null,+ per_trade_lamports: '10000000',+ daily_budget_lamports: '50000000',+ max_concurrent_positions: 1,+ slippage_bps: 500,+ max_price_impact_pct: 10,+ stop_loss_pct: 15,+ trailing_stop_pct: 8,+ take_profit_pct: 20,+ max_hold_seconds: 240,+ initials_out_multiple: null, // ladder off — a 4-minute ride full-exits+ auto_fund_enabled: true,+ },+};++async function provisionBoostArm(pool) {+ const arm = BOOST_ARM;+ // 1. find-or-create the agent identity (idempotent on name + owner).+ const { rows: agents } = await pool.query(+ 'select id from agent_identities where user_id = $1 and name = $2 and deleted_at is null',+ [arm.ownerUser, arm.agentName],+ );+ let agentId = agents[0]?.id;+ console.log(`${APPLY ? 'APPLY' : 'PLAN '} ${arm.label.padEnd(16)} ${agentId ? `agent ${agentId.slice(0, 8)} exists` : 'create agent + wallet'}: ${arm.note}`);+ for (const [k, v] of Object.entries(arm.strategy)) console.log(` ${k} = ${JSON.stringify(v)}`);+ if (!APPLY) return;++ if (!agentId) {+ const { rows: created } = await pool.query(+ `insert into agent_identities (user_id, name, description, is_public)+ values ($1, $2, $3, false) returning id`,+ [arm.ownerUser, arm.agentName,+ 'Autonomous sniper experiment arm: buys the pump AMM at migration and sells into the BOOST buyback window.'],+ );+ agentId = created[0].id;+ console.log(` created agent ${agentId}`);+ }++ // 2. custodial Solana wallet (idempotent — ensureAgentWallet no-ops when the+ // agent already holds a valid address + encrypted secret).+ const { ensureAgentWallet } = await import('../api/_lib/agent-wallet.js');+ const wallet = await ensureAgentWallet(agentId, arm.ownerUser, { reason: 'sniper_experiment_seed' });+ console.log(` wallet ${wallet.address}${wallet.created ? ' (new — auto-funder will top it up)' : ''}`);++ // 3. strategy upsert (same shape as the arm API's upsert).+ const s = { ...arm.strategy, agent_id: agentId, user_id: arm.ownerUser, network: NETWORK, label: arm.label, experiment_group: arm.group };+ const cols = Object.keys(s);+ const placeholders = cols.map((_, i) => `$${i + 1}`).join(', ');+ const updates = cols.filter((c) => !['agent_id', 'network'].includes(c)).map((c) => `${c} = excluded.${c}`).join(', ');+ const { rows: [row] } = await pool.query(+ `insert into agent_sniper_strategies (${cols.join(', ')}, updated_at)+ values (${placeholders}, now())+ on conflict (agent_id, network) do update set ${updates}, updated_at = now()+ returning id, enabled`,+ cols.map((c) => s[c]),+ );+ console.log(` strategy ${row.id} armed (enabled=${row.enabled})`);+}+function resolveDatabaseUrl() {if (process.env.DATABASE_URL) return process.env.DATABASE_URL;const svc = JSON.parse(execSync(@@ -143,6 +240,7 @@ const byAgent = new Map(existing.map((r) => [r.agent_id, r]));let updated = 0;for (const arm of ARMS) {+ if (ONLY && arm.label !== ONLY) continue;const cur = byAgent.get(arm.agent);if (!cur) {console.log(`SKIP ${arm.label}: no ${NETWORK} strategy exists for agent ${arm.agent} (arms only reshape existing strategies)`);@@ -169,6 +267,8 @@ for (const arm of ARMS) {updated++;}+if (!ONLY || ONLY === BOOST_ARM.label) await provisionBoostArm(pool);+if (APPLY) console.log(`\nDone: ${updated} strategies updated.`);else console.log('\nDry-run only. Re-run with --apply to write.');await pool.end();diff --git a/tests/agent-sniper-graduation-ride.test.js b/tests/agent-sniper-graduation-ride.test.jsnew file mode 100644index 000000000..cbc2461bc--- /dev/null+++ b/tests/agent-sniper-graduation-ride.test.js@@ -0,0 +1,58 @@+import { describe, it, expect } from 'vitest';+import { graduationRideGate, BOOST_WINDOW_MS } from '../workers/agent-sniper/graduation-ride.js';++// The pure per-strategy gate that decides whether a PumpPortal migration event+// arms a graduation_ride (BOOST-window) buy. The impure half (pool wait ++// executeBuy) rides the same chokepoint the whole fleet uses and is covered by+// the executor/amm-exit suites.++const NOW = 1_790_000_000_000; // fixed epoch ms+const strat = (over = {}) => ({ trigger: 'graduation_ride', agent_id: 'a', ...over });+const ev = (over = {}) => ({+ mint: 'MintPubkey1111111111111111111111111111111111',+ quote_symbol: 'SOL',+ timestamp: Math.floor(NOW / 1000),+ ...over,+});++describe('graduationRideGate', () => {+ it('passes a fresh SOL-paired migration for a graduation_ride strategy', () => {+ expect(graduationRideGate(ev(), strat(), NOW)).toEqual({ pass: true });+ });++ it('rejects every other trigger (and the new_mint default)', () => {+ expect(graduationRideGate(ev(), strat({ trigger: 'new_mint' }), NOW).reason).toBe('not_graduation_ride');+ expect(graduationRideGate(ev(), strat({ trigger: 'intel_confirmed' }), NOW).reason).toBe('not_graduation_ride');+ expect(graduationRideGate(ev(), strat({ trigger: undefined }), NOW).reason).toBe('not_graduation_ride');+ });++ it('rejects an event with no mint', () => {+ expect(graduationRideGate(ev({ mint: null }), strat(), NOW).reason).toBe('no_mint');+ expect(graduationRideGate(null, strat(), NOW).reason).toBe('no_mint');+ });++ it('rejects non-SOL quoted pools (USDC/OTHER BOOST pairs are not lamports-priceable)', () => {+ expect(graduationRideGate(ev({ quote_symbol: 'USDC' }), strat(), NOW).reason).toBe('quote_not_sol');+ expect(graduationRideGate(ev({ quote_symbol: 'OTHER' }), strat(), NOW).reason).toBe('quote_not_sol');+ });++ it('treats a missing quote classification as SOL (live WS events always carry one)', () => {+ expect(graduationRideGate(ev({ quote_symbol: undefined }), strat(), NOW).pass).toBe(true);+ });++ it('rejects a stale event — too little of the 5-minute BOOST window left to ride', () => {+ // 2 minutes old: window has 3 minutes left, the minimum — boundary passes.+ const twoMinOld = ev({ timestamp: Math.floor((NOW - 2 * 60_000) / 1000) });+ expect(graduationRideGate(twoMinOld, strat(), NOW).pass).toBe(true);+ // Past the boundary: reject.+ const stale = ev({ timestamp: Math.floor((NOW - 2 * 60_000 - 5_000) / 1000) });+ expect(graduationRideGate(stale, strat(), NOW).reason).toBe('boost_window_stale');+ // Way past the whole window: reject.+ const dead = ev({ timestamp: Math.floor((NOW - BOOST_WINDOW_MS - 1_000) / 1000) });+ expect(graduationRideGate(dead, strat(), NOW).reason).toBe('boost_window_stale');+ });++ it('treats a missing timestamp as fresh (stamped at receipt on the live path)', () => {+ expect(graduationRideGate(ev({ timestamp: undefined }), strat(), NOW).pass).toBe(true);+ });+});diff --git a/workers/agent-sniper/README.md b/workers/agent-sniper/README.mdindex 8b742991e..585155ac2 100644--- a/workers/agent-sniper/README.md+++ b/workers/agent-sniper/README.md@@ -10,6 +10,12 @@ take-profit / trailing-stop / timeout exit. Two triggers arm a strategy:a creator pulls their accrued creator/delegated rewards for the **first timeever** — an irreversible "the creator is live and taking real fees" signal.Buys the creator's coin after an owner-set delay.+- **`graduation_ride`** — listens for PumpPortal migration events and buys the+ coin's fresh pump AMM pool the moment it leaves the bonding curve, to sell+ into pump.fun's BOOST window (live 2026-07-21: ~17.6 SOL of buyback+burn+ TWAP'd over the 5 minutes after every non-Mayhem migration). The exit is the+ unchanged exit engine: `max_hold_seconds` set inside the window (e.g. 240 s)+ is the timed sell, stop-loss/trailing-stop stay the rails.It is deliberately **not** a scheduled cron: periodic ticks can't snipe a launch.@@ -27,6 +33,7 @@ It is deliberately **not** a scheduled cron: periodic ticks can't snipe a launch| `trade-client.js` | Wraps `PumpTradeClient`; `signAndSend` assembles a v0 tx, signs with the agent keypair, broadcasts, confirms. || `executor.js` | `executeBuy` / `executeSell` — every guardrail, the idempotency lock, the only place that signs. Routes graduated coins through the AMM. || `positions.js` | `runPositionSweep` — re-quotes open positions (curve OR AMM) and triggers exits. |+| `graduation-ride.js` | `graduationRideGate` (pure, tested) + `executeBoostRideBuy` — the BOOST-window entry: gate the migration event, wait for the new AMM pool, buy via `executeBuy` with `venue:'amm'`. || `amm-exit.js` | `quoteAmmSell` / `buildAmmSellInstructions` / `isGraduated` — post-graduation AMM pricing + sell build (shared with the user-driven path's pool resolution). |State lives in two tables (migrations `…20260615020000_agent_sniper.sql` +@@ -106,6 +113,11 @@ Every strategy row carries a `decision_mode`:firewall round-trip, budgets, concurrency, headroom, spend policy) still applyto both modes at the `executeBuy` chokepoint.+The fleet's experiment groups: **rules** (shield-based entries at different+strictness), **oracle** (conviction-gated), **llm** (model-judged), and+**boost** (event-driven — the `graduation_ride` arm above, which trades the+post-migration BOOST buyback window instead of new launches).+Strategies also carry a human `label` + `experiment_group` so deliberatelydifferent rule sets can trade side by side and be compared honestly:`scripts/seed-sniper-experiments.mjs` shapes the fleet (dry-run by default,diff --git a/workers/agent-sniper/executor.js b/workers/agent-sniper/executor.jsindex df5acaff7..a711fdc6b 100644--- a/workers/agent-sniper/executor.js+++ b/workers/agent-sniper/executor.js@@ -21,7 +21,7 @@ import {checkDailyLoss, recordCustodyEvent,SOL_FEE_HEADROOM_LAMPORTS,} from '../../api/_lib/agent-trade-guards.js';-import { buildAmmSellInstructions } from './amm-exit.js';+import { buildAmmSellInstructions, quoteAmmBuy, buildAmmBuyInstructions } from './amm-exit.js';import { getWalletBaseBalance, reconcileVanishedBag } from './reconcile.js';import { assessTradeSafety, recordFirewallDecision, criticalFirewallReason } from '../../api/_lib/trade-firewall.js';import { recordDecision } from '../../api/_lib/reasoning-ledger.js';@@ -350,10 +350,24 @@ export async function executeBuy({ cfg, strat, mint, throttle }) {const mintPk = new ctx.web3.PublicKey(mint.mint);const slippagePct = strat.slippage_bps / 100;+ // Venue: an 'amm' entry (graduation_ride) trades the post-migration pump+ // AMM pool; everything else prices the bonding curve. The AMM path+ // enforces a wSOL quote itself (amm_quote_not_sol), so the explicit+ // require_sol_quote check below only guards the curve branch.+ const ammEntry = mint.venue === 'amm';+// 6. quote + price-impact circuit breaker- const quote = await ctx.client.quoteForBuy({ mint: mintPk, quoteAmount: bn(ctx, perTrade), slippagePct });- if (strat.require_sol_quote && !quote.quoteMint.equals(ctx.web3.PublicKey.default) && quote.quoteMint.toBase58() !== 'So11111111111111111111111111111111111111112') {- return await fail(posId, tag, 'quote_not_sol');+ let quote;+ if (ammEntry) {+ const ammQuote = await quoteAmmBuy({+ network: cfg.network, mint: mint.mint, quoteAmount: bn(ctx, perTrade), slippagePct,+ });+ quote = { priceImpactPct: ammQuote.priceImpactPct };+ } else {+ quote = await ctx.client.quoteForBuy({ mint: mintPk, quoteAmount: bn(ctx, perTrade), slippagePct });+ if (strat.require_sol_quote && !quote.quoteMint.equals(ctx.web3.PublicKey.default) && quote.quoteMint.toBase58() !== 'So11111111111111111111111111111111111111112') {+ return await fail(posId, tag, 'quote_not_sol');+ }}const impact = checkPriceImpact(Number(quote.priceImpactPct), Number(strat.max_price_impact_pct));if (impact) return await fail(posId, tag, impact.reason);@@ -426,9 +440,18 @@ export async function executeBuy({ cfg, strat, mint, throttle }) {}// 7. build + (live) broadcast- const built = await ctx.client.buildBuyInstructions({- mint: mintPk, user: keypair.publicKey, quoteAmount: bn(ctx, perTrade), slippagePct,- });+ let built;+ if (ammEntry) {+ const ammBuilt = await buildAmmBuyInstructions({+ network: cfg.network, mint: mint.mint, user: keypair.publicKey,+ quoteAmount: bn(ctx, perTrade), slippagePct,+ });+ built = { instructions: ammBuilt.instructions, expectedBaseTokens: ammBuilt.expectedBaseOut };+ } else {+ built = await ctx.client.buildBuyInstructions({+ mint: mintPk, user: keypair.publicKey, quoteAmount: bn(ctx, perTrade), slippagePct,+ });+ }const baseAmount = BigInt(built.expectedBaseTokens.toString());if (baseAmount <= 0n) return await fail(posId, tag, 'zero_tokens');@@ -460,9 +483,13 @@ export async function executeBuy({ cfg, strat, mint, throttle }) {}const pricePerToken = Number(perTrade) / Number(baseAmount);+ // An AMM entry is born graduated: flag it exactly like a curve position+ // that graduated mid-hold, so the sweep re-quotes it off the AMM and+ // executeSell routes the exit there instead of the dead curve.await sql`UPDATE agent_sniper_positions SETstatus = 'open', buy_sig = ${sig},+ error = ${ammEntry ? 'graduated:amm_entry' : null},entry_quote_lamports = ${perTrade.toString()},base_amount = ${baseAmount.toString()},entry_price_lamports_per_token = ${pricePerToken},diff --git a/workers/agent-sniper/graduation-ride.js b/workers/agent-sniper/graduation-ride.jsnew file mode 100644index 000000000..87120ff1d--- /dev/null+++ b/workers/agent-sniper/graduation-ride.js@@ -0,0 +1,94 @@+// agent-sniper — graduation_ride entry (the BOOST-window arm).+//+// pump.fun BOOST mode (live 2026-07-21): every non-Mayhem coin that migrates+// gets ~17.6 SOL of dead-liquidity buybacks TWAP'd over the 5 minutes after+// migration, with the bought tokens burned. That is a guaranteed, publicly-known+// buyer for exactly 5 minutes. This trigger trades it: buy on the pump AMM the+// moment the migration lands, ride the TWAP, and let the strategy's timed exit+// (max_hold_seconds, set inside the window) sell into that buy pressure.+//+// Entry flow (driven by the PumpPortal migration event in index.js):+// 1. gate the event per-strategy (SOL pair only, freshness cap) — pure, tested+// 2. wait for the new AMM pool to be readable (migration tx just landed)+// 3. executeBuy with venue:'amm' — every chokepoint guard still applies+// (Mayhem gate, firewall, budgets, concurrency, headroom, spend policy).+// Mayhem coins never get BOOST, so the existing exclusion is also the+// strategy-correct filter here.+//+// Exits are DELIBERATELY not special-cased: the pure exit engine already covers+// the play. max_hold_seconds (e.g. 240s) IS the BOOST-window sell; stop-loss /+// trailing-stop stay the protective rails. Zero drift risk with the backtester.++import { log } from './log.js';+import { executeBuy } from './executor.js';+import { isGraduated } from './amm-exit.js';++// The BOOST TWAP runs 5 minutes from migration. Past this age the edge is gone —+// never chase a stale event (feed reconnect replays, enrichment lag).+export const BOOST_WINDOW_MS = 5 * 60_000;+// Entering with less than this much window left cannot complete the ride+// (buy lands ~seconds in, the timed exit needs room before the TWAP ends).+const MIN_WINDOW_LEFT_MS = 3 * 60_000;++/**+ * Pure per-strategy gate for a migration event. Returns { pass, reason }.+ *+ * @param {object} ev normalized graduation event ({ mint, quote_symbol, timestamp } at minimum)+ * @param {object} strat strategy row+ * @param {number} [now] epoch ms (injectable for tests)+ */+export function graduationRideGate(ev, strat, now = Date.now()) {+ if ((strat.trigger || 'new_mint') !== 'graduation_ride') return { pass: false, reason: 'not_graduation_ride' };+ if (!ev?.mint) return { pass: false, reason: 'no_mint' };+ // The AMM entry/exit math is lamports-denominated; USDC/OTHER-quoted pools+ // are refused downstream (amm_quote_not_sol) — skip them before spending a+ // buy-queue slot. A missing quote classification on a SOL-era event defaults+ // to SOL upstream, so this only rejects explicit non-SOL pairs.+ if (ev.quote_symbol && ev.quote_symbol !== 'SOL') return { pass: false, reason: 'quote_not_sol' };+ // Freshness: the event timestamp is seconds. No timestamp → treat as fresh+ // (the live WS path stamps it at receipt).+ const evMs = Number.isFinite(ev.timestamp) ? ev.timestamp * 1000 : now;+ const age = Math.max(0, now - evMs);+ if (age > BOOST_WINDOW_MS - MIN_WINDOW_LEFT_MS) return { pass: false, reason: 'boost_window_stale' };+ return { pass: true };+}++// Wait until the just-created AMM pool is readable. The migration tx creates the+// pool, but the RPC the worker reads from may lag the PumpPortal event by a few+// slots. Bounded, short: the whole point of the arm is entering early in the+// window. Returns true when the pool resolved, false when it never appeared.+async function waitForPool(network, mint, { attempts = 5, delayMs = 2_000 } = {}) {+ for (let i = 0; i < attempts; i++) {+ try {+ if (await isGraduated({ network, mint })) return true;+ } catch (err) {+ // Transient RPC failure — retry on the same schedule.+ log.warn('boost-ride pool probe failed', { mint, attempt: i + 1, err: err?.message });+ }+ if (i < attempts - 1) await new Promise((r) => setTimeout(r, delayMs));+ }+ return false;+}++/**+ * Execute one graduation_ride entry: wait for the pool, then buy on the AMM via+ * the shared chokepoint. Intended to run inside the worker's bounded buy queue.+ *+ * @param {object} p { cfg, strat, ev, throttle }+ */+export async function executeBoostRideBuy({ cfg, strat, ev, throttle }) {+ const ready = await waitForPool(cfg.network, ev.mint);+ if (!ready) {+ log.warn('boost-ride skip — amm pool never resolved', { agent: strat.agent_id, mint: ev.mint });+ return { status: 'skipped', reason: 'pool_not_ready' };+ }+ return executeBuy({+ cfg, strat, throttle,+ mint: {+ mint: ev.mint, symbol: ev.symbol || null, name: ev.name || null,+ market_cap_usd: ev.market_cap_usd ?? null,+ entry_trigger: 'graduation_ride', trigger_ref: ev.signature || ev.tx_signature || null,+ venue: 'amm',+ },+ });+}diff --git a/workers/agent-sniper/index.js b/workers/agent-sniper/index.jsindex 6e9ca5b6b..fa29d5fad 100644--- a/workers/agent-sniper/index.js+++ b/workers/agent-sniper/index.js@@ -36,6 +36,7 @@ import {import { screenPush } from './screen-push.js';import { scoreAlpha } from './alpha-hunt.js';import { startAutoClaimerWatch } from './auto-claimer.js';+import { graduationRideGate, executeBoostRideBuy } from './graduation-ride.js';import { startAutoFunderWatch } from './auto-funder.js';import { startLauncherWatch } from './launcher.js';import { startMarketMakerWatch } from './market-maker.js';@@ -130,7 +131,31 @@ async function main() {const onEvent = ({ kind, data }) => {lastEventAt = Date.now();feedConnected = true; // an event is proof the subscription is live- if (kind !== 'mint' || draining || cfg.globalKill) return;+ if (draining || cfg.globalKill) return;++ // Migration events drive graduation_ride (BOOST-window) strategies: the+ // coin just left the curve, pump.fun's 5-minute buyback+burn TWAP is+ // starting, and the arm buys the new AMM pool to sell into that window.+ // executeBoostRideBuy waits for the pool then flows through the same+ // executeBuy chokepoint (Mayhem gate, firewall, budgets) as every path.+ if (kind === 'graduation') {+ const gsym = (data.symbol || data.mint?.slice(0, 6) || '?').toUpperCase();+ for (const strat of cachedStrategies()) {+ const gate = graduationRideGate(data, strat);+ if (!gate.pass) {+ if (gate.reason !== 'not_graduation_ride') log.info('boost-ride gate skip', { agent: strat.agent_id, mint: data.mint, reason: gate.reason });+ continue;+ }+ log.info('boost-ride candidate', { agent: strat.agent_id, mint: data.mint, symbol: data.symbol });+ screenPush(`$${gsym} migrated — riding the BOOST window`, 'trade');+ queue.push(async () => {+ await executeBoostRideBuy({ cfg, strat, ev: data, throttle });+ });+ }+ return;+ }++ if (kind !== 'mint') return;const sym = (data.symbol || data.mint.slice(0, 6)).toUpperCase();screenPush(`New token: $${sym} — scoring`, 'analysis');const strategies = cachedStrategies();@@ -191,7 +216,9 @@ async function main() {};const abort = new AbortController();- let stopFeed = connectPumpFunFeed({ kind: 'mint', signal: abort.signal, onEvent });+ // kind 'all' = new mints + migrations (no per-mint trade subs without tracked+ // mints). Migrations feed the graduation_ride (BOOST-window) strategies.+ let stopFeed = connectPumpFunFeed({ kind: 'all', signal: abort.signal, onEvent });feedConnected = true;log.info('feed connected', {});@@ -410,7 +437,7 @@ async function main() {lastEventAt = Date.now();const a2 = new AbortController();abort.signal.addEventListener('abort', () => a2.abort());- stopFeed = connectPumpFunFeed({ kind: 'mint', signal: a2.signal, onEvent });+ stopFeed = connectPumpFunFeed({ kind: 'all', signal: a2.signal, onEvent });}}, Math.min(cfg.feedWatchdogMs, 60_000));