Skip to content

HorseDev77/PumpFunAutoTradingPlatform

Repository files navigation

PumpFun Automated Trading Platform

A production-ready, event-driven trading platform for PumpFun tokens on Solana.

Architecture

pumpfun-trading-platform/
├── apps/
│   ├── api/          # NestJS REST API + SSE (port 3001)
│   ├── ingestor/     # Helius LaserStream gRPC → Redis Events
│   ├── engine/       # Per-campaign FSM strategy engine
│   ├── executor/     # Intent → RPC send → Solana
│   ├── db-writer/    # Events → MongoDB bulk writer
│   └── web/          # Vite + React 19 SPA (port 5173)
└── packages/
    ├── domain/       # Zod types: DomainEvent, Intent
    ├── config/       # Typed env loader
    ├── state/        # Redis client + Lua scripts
    ├── mongo/        # Mongoose models + Change Stream watcher
    ├── solana/       # PumpFun instructions, SOL distribution
    └── crypto/       # AES-256-GCM wallet key encryption

Quick Start

1. Install dependencies

npm install

2. Configure environment

cp .env.example .env
# Edit .env with your keys

3. Start infrastructure (Redis + MongoDB)

npm run docker:up

4. Build all packages

npm run build

5. Start all services

npm run dev

Campaign Workflow

  1. Create Wallet GroupPOST /api/wallets/groups
  2. Create CampaignPOST /api/campaigns (set devWalletPublicKey, buyerWalletGroupId, config)
  3. Generate WalletsPOST /api/wallets/campaign/:id/generate
  4. Distribute SOLPOST /api/wallets/campaign/:id/distribute
  5. Start CampaignPOST /api/campaigns/:id/start
  6. Monitor — SSE at GET /api/stream/campaign/:id

Trading Strategy FSM

idle → monitoring_launch → wait_time1 → gate_others_zero → buy_cycle
                                                              ↕              ↕
                                                   paused_other_buy    paused_ratio
                                                              ↓              ↓
                                                          wait_other_sell   (fourthWait → resume)
                                                              ↓
                                                          buy_cycle
  • wait_time1: Wait after token launch before checking others
  • gate_others_zero: Don't buy until no other wallets hold the token
  • buy_cycle: Sequentially buy with each wallet (balance - reserveSol), random delay between each
  • paused_other_buy: Another wallet bought → sell otherAmount × responsePercent, wait thirdWaitMs for them to sell
  • paused_ratio: othersHolding/total > limitThresholdRatio → pause; after fourthWaitMs, force-resume
  • OtherSell event: Buy otherSellAmount × responsePercent

Environment Variables

See .env.example for all required variables.

Key variables:

  • LASERSTREAM_ENDPOINT — Helius LaserStream gRPC endpoint
  • LASERSTREAM_API_KEY — LaserStream/Geyser-enabled token used by the ingestor
  • HELIUS_API_KEY — normal Helius RPC key, kept as a fallback for older configs
  • SOLANA_RPC_URL — Solana RPC endpoint
  • WALLET_ENCRYPTION_KEY — 32-byte hex key for AES-256-GCM wallet encryption
  • LOGIN_EMAILS — comma-separated email allowlist for OTP request and verify (legacy LOGIN_EMAIL still supported)
  • MONGODB_URI — MongoDB connection string (must be replica set for Change Streams)
  • REDIS_URL — Redis connection string

Production Deployment

1. Prepare production env

cp .env.example .env
# Set production values (JWT_SECRET, WALLET_ENCRYPTION_KEY, CORS_ORIGINS, RPC keys, etc.)

2. Install and build

npm ci
npm run build

3. Run services with PM2

npm run pm2:start
pm2 save
pm2 startup

Useful PM2 commands:

npm run pm2:logs
npm run pm2:restart
npm run pm2:stop

4. Serve web with Nginx (production static files)

sudo mkdir -p /var/www/apumpun/web
sudo rsync -a --delete apps/web/dist/ /var/www/apumpun/web/
sudo cp infra/nginx/apumpun-trading.conf /etc/nginx/sites-available/apumpun-trading
sudo ln -sf /etc/nginx/sites-available/apumpun-trading /etc/nginx/sites-enabled/
sudo rm -f /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl reload nginx

5. Update release flow

git pull
npm ci
npm run build
sudo rsync -a --delete apps/web/dist/ /var/www/apumpun/web/
npm run pm2:restart

Or use the one-shot deploy script:

npm run deploy:prod
# optional: npm run deploy:prod -- --skip-pull

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages