bitman09
pumpfun-sniper-bot
TypeScript

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.

Last updated Jun 25, 2026
84
Stars
1
Forks
1
Issues
0
Stars/day
Attention Score
75
Language breakdown
No language data available.
โ–ธ Files click to expand
README

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

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 transactionSubscribe stream 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.
Detection latency is logged in milliseconds (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:
- HTTP RPC + WebSocket RPC for reads, confirms, and quotes - Atlas Geyser WebSocket for transactionSubscribe (see Helius Geyser docs)
  • Optional paid infra for competitive inclusion:
- NextBlock API key (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, and GEYSERRPC with your provider API keys.
  • Keep SIMULATION_MODE=true until filters and sizing look correct in logs.
  • Set NEXTBLOCKMODE=true and NEXTBLOCK_API if you use NextBlock (default in .env.example).
Run in simulation (recommended first):
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 / JITOFEE appear in .env.example but are not wired in src/constants/constants.ts (commented out). Jito helper code exists under src/executor/jito.ts but 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_ADDRESS
  • TICKERMODE, TOKENTICKER
  • POSITIONCONTROL, POSITIONNUMBER (position limit in index.ts is partially present but env wiring is commented out)
Do not rely on them until added to 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 .env or share PRIVATE_KEY.
  • Use a dedicated hot wallet with only the SOL you are willing to lose.
  • Start with SIMULATIONMODE=true and small BUYAMOUNT.
  • 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).

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท bitman09/pumpfun-sniper-bot ยท Updated daily from GitHub