The Solana Pump.fun SOL/USDC pair sniper trading bot is an advanced automated tool designed for seamless #buy-#sell execution, optimizing real-time #trading efficiency and profitability on the #Pumpfun platform.
Pump.fun Sniper
A low-latency Solana Pumpfun Sniper bot that watches Pump.fun token launches in real time over a Geyser WebSocket feed, applies configurable filters, buys on the bonding curve, and exits automatically via take-profit, stop-loss, or timeout.
Built with TypeScript, Anchor, and the official Pump.fun program IDL. Supports Token-2022 mints (including transfer-fee harvest on cleanup).
Table of contents
- How it works
- Features
- Requirements
- Quick start
- Configuration
- Exit logic
- Transaction submission
- Scripts
- Project structure
- Security
- Troubleshooting
- Disclaimer
How it works
sequenceDiagram
participant Geyser as Geyser WebSocket
participant Bot as index.ts
participant RPC as Solana RPC
participant PF as Pump.fun program
Geyser->>Bot: New tx on Pump.fun program Bot->>Bot: Detect InitializeMint2 log Bot->>Bot: Parse dev buy (SOL + tokens) Bot->>Bot: Optional filters (social, dev buy, mcap) alt SIMULATION_MODE=true Bot->>Bot: Log only, no tx else Live trading Bot->>PF: Buy on bonding curve loop Every 500ms Bot->>RPC: Quote sell output (SOL) Bot->>Bot: TP / SL / timeout? end Bot->>PF: Sell full position end
- Subscribe โ Opens a Geyser
transactionSubscribestream filtered to the Pump.fun program (6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P). - Detect โ When logs contain
Instruction: InitializeMint2, the bot treats the transaction as a new launch and extracts mint, bonding curve, and dev wallet from account keys. - Parse โ Reads the creatorโs initial buy from inner instructions (
parseDevBuyFromInnerInstructions) and resolves the token program (legacy SPL vs Token-2022). - Filter โ Optional checks: social links (X / Telegram / website), dev buy size band, minimum market cap wait.
- Trade โ If
SIMULATION_MODE=false, submits a buy then monitors unrealized SOL value until take-profit, stop-loss, or timeout triggers a sell.
Date.now() - firstTime at buy time).
Features
| Area | Capability | |------|------------| | Speed | Geyser processed commitment โ reacts before typical polling RPC | | Safety | SIMULATION_MODE โ full pipeline without sending transactions | | Filters | Dev buy min/max, market cap gate, X / Telegram / website validation | | Risk | Take-profit %, stop-loss %, position timeout (seconds) | | Execution | NextBlock, bloXroute, or standard RPC + compute budget priority fee | | Tokens | Token-2022 + legacy SPL; bonding curve PDA / creator vault from on-chain layout | | Cleanup | npm run burn โ burn leftover balances and close ATAs (reclaim rent) |
Requirements
- Node.js 18+ (22 recommended per
devDependencies) - A funded Solana wallet (base58-encoded secret key)
- Helius (or compatible) endpoints:
transactionSubscribe (see Helius Geyser docs)
- Optional paid infra for competitive inclusion:
NEXTBLOCK_API)
- bloXroute auth header
You need enough SOL for buys, priority / tip fees, and rent for new ATAs.
Quick start
git clone <your-repo-url>
cd pumpfun-sniper
npm install
cp .env.example .env
Edit .env:
- Set
PRIVATE_KEY(base58 secret key โ never commit this). - Set
RPCENDPOINT,RPCWEBSOCKETENDPOINT, andGEYSERRPCwith your provider API keys. - Keep
SIMULATION_MODE=trueuntil filters and sizing look correct in logs. - Set
NEXTBLOCKMODE=trueandNEXTBLOCK_APIif you use NextBlock (default in.env.example).
npm run dev
When ready for live trades:
# In .env
SIMULATION_MODE=false
npm start
Configuration
Copy .env.example to .env. All variables below are read at startup; missing required values exit the process.
Wallet & RPC
| Variable | Required | Description | |----------|----------|-------------| | PRIVATE_KEY | Yes | Base58-encoded wallet secret key | | RPC_ENDPOINT | Yes | HTTP RPC URL (e.g. Helius mainnet) | | RPCWEBSOCKETENDPOINT | Yes | WebSocket RPC URL | | GEYSER_RPC | Yes | Geyser WebSocket URL (e.g. wss://atlas-mainnet.helius-rpc.com/?api-key=...) |
Trading
| Variable | Default (example) | Description | |----------|-------------------|-------------| | SIMULATION_MODE | true | true = detect and log only; false = send buy/sell | | BUY_AMOUNT | 0.005 | SOL spent per snipe | | SLIPPAGE | 100 | Slippage in percent (100 = 100%) applied to max SOL on buy | | TAKEPROFIT | 20 | Exit when sell quote โฅ BUYAMOUNT ร (100 + TAKE_PROFIT) / 100 SOL | | STOPLOSS | 10 | Exit when sell quote โค BUYAMOUNT ร (100 - STOP_LOSS) / 100 SOL | | TIME_OUT | 60 | Max seconds to wait (market cap monitor or sell monitor) | | CHECKMARKETCAP | false | Wait until bonding-curve market cap โฅ MARKET_CAP before buying | | MARKETCAP | 30 | Target market cap in SOL when CHECKMARKET_CAP=true |
Dev buy filter
| Variable | Description | |----------|-------------| | CHECKDEVBUY | true to enforce min/max on creatorโs initial buy | | MINDEVBUY_AMOUNT | Minimum dev buy in SOL; empty / unset = 0 | | MAXDEVBUY_AMOUNT | Maximum dev buy in SOL; empty / none / unset = no cap |
Social filters
When enabled, metadata is fetched via Metaplex (with retries). The token is skipped if links fail validation.
| Variable | Validation | |----------|------------| | CHECK_X | twitter must contain https://x.com | | CHECK_TG | telegram must contain https://t.me | | CHECK_WEBSITE | website must be non-empty |
Transaction fees & routing
| Variable | Description | |----------|-------------| | NEXTBLOCK_MODE | true โ submit via NextBlock (fra.nextblock.io) + tip transfer | | NEXTBLOCKAPI | NextBlock authorization header / API key | | NEXTBLOCKFEE | SOL tip to NextBlock address on each tx | | BLOXROUTE_MODE | true โ submit via bloXroute trader API | | BLOXROUTE_FEE | bloXroute tip amount | | BLOXROUTEAUTHHEADER | bloXroute Authorization value | | PRIORITY_FEE | SOL used to derive compute-unit price on buy/sell (see ComputeBudgetProgram.setComputeUnitPrice) |
Routing priority: If NEXTBLOCKMODE=true, NextBlock is used. Else if BLOXROUTEMODE=true, bloXroute is used. Otherwise the bot uses connection.sendRawTransaction with the configured priority fee.
Note:JITOMODE/JITOFEEappear in.env.examplebut are not wired insrc/constants/constants.ts(commented out). Jito helper code exists undersrc/executor/jito.tsbut is not used by the main sniper loop.
Not yet implemented
These keys exist in .env.example but are not read by the application today:
DEVMODE,DEVWALLET_ADDRESSTICKERMODE,TOKENTICKERPOSITIONCONTROL,POSITIONNUMBER(position limit inindex.tsis partially present but env wiring is commented out)
src/constants/constants.ts and src/index.ts.
Exit logic
After a successful buy, monitorSellPosition polls every 500 ms:
- Loads your token balance (retries with backoff).
- Quotes SOL out via bonding curve (
getSellPrice). - Compares quote to thresholds (computed at startup from
BUY_AMOUNT):
Take-profit threshold (TP) = BUYAMOUNT ร (100 + TAKEPROFIT) / 100
Stop-loss threshold (LS) = BUYAMOUNT ร (100 - STOPLOSS) / 100
- Sells when:
outAmount >= TP โ take profit
- outAmount <= LS โ stop loss
- Elapsed time โฅ TIME_OUT โ timeout exit
- Balance is zero โ stop monitoring
Example: BUYAMOUNT=0.005, TAKEPROFIT=20, STOP_LOSS=10 โ TP at 0.006 SOL quoted out, SL at 0.0045 SOL quoted out.
Transaction submission
Buy / Sell transaction
โโโ Compute budget (250k units + priority fee from PRIORITY_FEE)
โโโ Create ATA idempotently if needed
โโโ Anchor Pump.fun buy/sell instruction
โโโ Submit via:
โโโ NextBlock API (NEXTBLOCK_MODE) + tip
โโโ bloXroute (BLOXROUTE_MODE) + tip
โโโ RPC sendRawTransaction + confirm
Buy and sell share the same routing flags. Ensure only one โfast pathโ mode matches your infrastructure setup.
Scripts
| Command | Description | |---------|-------------| | npm run dev | Run sniper with ts-node | | npm start | Same as dev | | npm run build | Compile TypeScript to dist/ | | npm run burn | Burn all token balances and close empty ATAs (rent reclaim) | | npm run encrypt | Obfuscate compiled dist/ โ dist-encrypt/ (optional release build) |
Burn utility
src/burn.ts scans SPL and Token-2022 accounts, burns non-zero balances, harvests withheld fees on Token-2022 mints, and closes accounts. Useful after many snipes to recover rent.
npm run burn
Requires only PRIVATEKEY and RPCENDPOINT in .env.
Project structure
src/
โโโ index.ts # Geyser listener, filters, buy/sell orchestration
โโโ burn.ts # Token burn + ATA cleanup
โโโ constants/
โ โโโ constants.ts # Env โ exported config
โโโ executor/
โ โโโ bloXroute.ts # bloXroute submission
โ โโโ jito.ts # Jito bundle helper (not active in main flow)
โ โโโ legacy.ts
โโโ pumputils/
โ โโโ idl/ # Pump.fun Anchor IDL
โ โโโ utils/ # buyToken, sellToken, pricing, bonding curve
โ โโโ bloxutils/ # bloXroute quote helpers
โโโ utils/
โโโ parseDevBuy.ts # Dev buy extraction from Geyser payload
โโโ utils.ts # Env helpers, JSON debug helpers
Pump.fun program ID (subscribe filter): 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P
Security
- Never commit
.envor sharePRIVATE_KEY. - Use a dedicated hot wallet with only the SOL you are willing to lose.
- Start with
SIMULATIONMODE=trueand smallBUYAMOUNT. - Verify RPC and Geyser URLs point to mainnet (or devnet) intentionally.
- Review third-party tip endpoints (NextBlock / bloXroute) on their official docs.
- This software does not encrypt keys at rest; OS-level disk encryption and access control are your responsibility.
Troubleshooting
| Symptom | Things to check | |---------|------------------| | Process exits immediately | Required env var missing โ console prints X is not set | | No detections | Geyser URL valid? API key has Geyser access? Firewall allows WSS | | WebSocket is open but nothing else | Pump.fun activity; filter logs for InitializeMint2 | | Buys always skipped | CHECK_* filters too strict; dev buy outside min/max; mcap timeout | | Transaction failed | Low slippage vs volatile curve; insufficient SOL; bonding curve complete | | Sell never fires | TIMEOUT too high; TP/SL thresholds unrealistic for BUYAMOUNT | | Token-2022 errors on burn | Run npm run burn โ includes harvest-before-close for fee mints | | High latency | Use Geyser + NextBlock/bloXroute; colocate RPC region with validator geography |
Enable debug by inspecting Solscan links printed for each detection (signature, mint).
Disclaimer
This project is for educational and research purposes. Trading memecoins on Pump.fun is extremely risky: rugs, honeypots, failed transactions, and total loss of funds are common. The authors provide no financial advice and no guarantee of profitability or correctness. You are solely responsible for compliance with local laws, taxes, and platform terms of service.
Use at your own risk.
License
ISC (see package.json).