@three-ws/agent-sniper

A lightweight, embeddable pump.fun sniper engine for 3D AI agents. One trade
loop — feed a stream of new launches, score each against a per-agent strategy,
run the pre-trade guards, buy, then sweep open positions on an interval and exit
on stop-loss / take-profit / trailing-stop / timeout / sentiment-flip. It is
multi-agent and multi-user by construction (one wallet per agentId), and every
external dependency — wallet custody, persistence, RPC/venue, launch feed — is a
pluggable adapter, so the same engine runs locally with in-memory state or
hosted across thousands of tenants. The package ships with four faces over that
one engine: a library, a CLI, an MCP server, and an x402 paid HTTP
API.
Why — the adapter architecture
The engine is pure orchestration. It owns the decision pipeline; it owns nothing
about where the money, the data, or the chain live. Five adapter interfaces
(src/types.js) are the seams, and a default implementation ships for each:
┌──────────────────────────── engine ────────────────────────────┐
Feed ──{mint|intel|claim}─▶ score ──▶ guards ──▶ executeBuy ──▶ claimPosition │
(PumpPortal) (scorer) (concurrency, (quote + (atomic slot) │
budget, SOL build + sign │
headroom, + broadcast) │
price impact) │
position sweep (every pollMs) │
──▶ decideExit ──▶ executeSell │
└────────────────────────────────────────────────────────────────────┘
adapters: Feed Solana Wallet Executor Store
(launch (quote/build (resolve a (sign + (strategies,
stream) pump.fun ix) Keypair per broadcast) positions,
agentId) spend ledger)
Swap any one without touching the loop: a custodial KMS wallet instead of local
keys, a Postgres store instead of memory, a different launch feed, a different
venue. Implement the shape, pass it to createSniper(), done.
| Adapter | Responsibility |
|---|
Feed | Push { kind: 'mint'|'intel'|'claim', data: Candidate } events into the engine. |
Solana | Quote + build pump.fun buy/sell instructions; expose a web3 Connection. |
Wallet | Resolve a signing Keypair for an agentId (or null if unprovisioned). |
Executor | The one place that signs and broadcasts; returns landing telemetry. |
Store | Persist strategies, positions, and the daily spend ledger; atomic claimPosition. |
Optional Hooks (firewall assessSafety, oracleGate, onScreen, onBuy,
onSell, recordDecision) are best-effort cross-cutting callbacks — a throw is
swallowed and never aborts a trade, except onTip, which is a deliberate veto.
Install
npm i @three-ws/agent-sniper
Optional peers, installed only if you use the face that needs them:
npm i better-sqlite3 # durable Store (src/adapters/store/sqlite.js)
npm i express # the x402 HTTP API face
Requires Node >= 20.
Quickstart (library)
The presets.local wiring is the zero-to-running path: in-memory store +
self-custody wallet + pump.fun client + web3 executor + PumpPortal feed. Run it
in simulate mode on devnet first — the engine scores, guards, and logs
every decision but never broadcasts.
A strategy must carry a stop_loss_pct — the engine refuses to arm a
strategy without one. SOL amounts on a strategy are expressed in lamports
(1 SOL = 1,000,000,000 lamports), as a string, number, or bigint.