@b402ai/trader
v0.2.1
Published
Turn one wallet into an agent fleet. Spawn capitalized AI trading agents with private treasuries on Hyperliquid.
Readme
b402-trader
Turn one wallet into a self-improving trading desk on Hyperliquid. Private. Gasless. Autonomous.
USDC flows through a Railgun ZK privacy pool, emerges in untraceable wallets, bridges to Arbitrum, and deposits to Hyperliquid through gasless permits. Each agent gets its own anonymous identity. Nobody can link them to you.
Zero gas. Zero setup. Zero trace. Wallet auto-generated on first run. All gas paid by protocol infrastructure.
Install
claude mcp add b402-trader -- npx @b402ai/traderOn first run, a wallet is auto-generated at ~/.b402/wallet.json (chmod 600). No private keys to manage. If you already have a ~/.b402/wallet.json from the b402-sdk, it uses the same wallet.
Optional env vars (create ~/.b402/.env):
OPENROUTER_API_KEY=sk-... # For LLM-confirmed entries (recommended)
BASE_RPC_URL=https://... # Custom Base RPC (default: public)Quick Start
"check balance" → shows your fund address + privacy pool
"shield 50 USDC" → move USDC into privacy pool
"spawn 5 agents with different strategies"
"fund each agent with 10 USDC" → ZK unshield → bridge → HL deposit
"start all agents live" → agents trading independently
"status" → live P&L, positions, equity
"analytics phantom" → Sharpe, win rate, profit factor, per-asset P&L
"darwinian" → fleet rankings, who gets more capitalStrategies
Each agent has its own config at ~/.b402/agents/{name}.json. Five presets:
| Preset | Style | Positions | Leverage | LLM | Risk | |--------|-------|-----------|----------|-----|------| | momentum | ride directional moves | 2 max | 3x | confirms | SL -0.5% TP 1.5% | | scalping | fast in/out, tight stops | 3 max | 5x | confirms | SL -0.4% TP 0.8% | | trend | patient, wide stops | 1 max | 3x | confirms | SL -0.8% TP 2.0% | | mean_reversion | fade extremes | 2 max | 3x | confirms | SL -0.5% TP 0.8% | | breakout | volume spikes | 2 max | 4x | off | SL -0.6% TP 1.5% |
All params editable in the JSON. Changes take effect on next start_agent.
Self-Improving Agents
Agents evolve autonomously — no human intervention needed.
Every 5 trades (when no positions open):
- Measures Sharpe ratio before and after last config change
- If improved → KEEP. If degraded → REVERT to previous config.
- Proposes next change based on trade analytics (LLM analyzes full history)
- Applies change, tests for 5 more trades
Prompt evolution — agents rewrite their own strategy description based on which assets and patterns work for them. Example: spectre evolved from "aggressive" to "focus on BTC, TAO, HYPE. avoid XPL, LIT, ENA, DOGE."
Fleet intelligence:
- Contrarian block: if 2+ agents already entered the same trade, others are blocked
- Cross-agent learning: discoveries propagate (one agent learns → all benefit)
- Market regime detection: trending, ranging, volatile, low volume
- Darwinian weights: top performers get amplified, bottom get decayed
How It Works
Auto-generated Wallet (Base)
→ shield USDC into Railgun privacy pool (ZK proof, gasless)
→ unshield to anonymous smart wallet (zero on-chain link)
→ Across bridge to Arbitrum (~2s fill)
→ permit deposit to Hyperliquid (gasless, hosted relayer)
→ agent trades on HL order book through anonymous identityTrading Pipeline
SCAN → TA + ML → LLM CONFIRM → EXECUTE → MANAGE → EVOLVE- SCAN — RSI, MACD, BB, OBV, ATR across top 20 assets by volume
- ML — logistic regression (3 bucketed models: majors, liquid_alts, high_beta) predicts 15-min direction
- LLM — sees TA score, ML score, RSI, price action, portfolio, session P&L. Knows when TA+ML agree or disagree.
- EXECUTE — market order, position sized at 30% of available equity
- MANAGE — mechanical exits every 15s: stop loss, take profit, trailing stop, TA flip, stagnation
- EVOLVE — every 5 trades: measure Sharpe, propose change, test, keep or revert
Dashboard
npx tsx src/dashboard-server.ts
# → http://localhost:3502Three-panel live view: agent list (left), detail panel (center), self-improvement timeline (right). P&L leaderboard, live ticker, streaming logs.
MCP Tools
| Tool | Description |
|------|-------------|
| check_balance | Fund address, privacy pool, agent wallets |
| shield | Move USDC into Railgun privacy pool |
| spawn_agent | Create anonymous wallet + strategy config |
| fund_agent | Privacy pool → bridge → HL deposit (gasless) |
| start_agent | Start trading (paper or live, pick strategy) |
| stop_agent | Stop + close positions + show P&L |
| list_agents | All agents with status |
| status | Positions, equity, trades for any/all agents |
| market_data | Price, order book, funding for any asset |
| analytics | Sharpe, win rate, profit factor, per-asset P&L, exit reasons |
| improve | Propose a self-improvement change for an agent |
| darwinian | Fleet rankings with Darwinian weights |
