Skip to content

TopTrenDev/raydium-cpmm-trading-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raydium CPMM Trading Bot

Automated Solana trading bot that monitors new Raydium CPMM pools and executes buy/sell trades with configurable filters.

Telegram Twitter Discord

Features

  • Real-time pool monitoring via Solana account subscriptions
  • Smart filtering (LP value, pool age, token safety checks)
  • Automated buy/sell execution with Bloxroute fast submission
  • Auto WSOL wrapping/unwrapping
  • Priority fee management

Quick Start

npm install && npm run build

Create .env:

RPC_ENDPOINT=https://api.mainnet-beta.solana.com
RPC_WEBSOCKET_ENDPOINT=wss://api.mainnet-beta.solana.com
PRIVATE_KEY=your_private_key_base58_or_json
BLOXROUTE_API_KEY=your_api_key
BLOXROUTE_API_URL=https://ny.solana.dex.blxrbdn.com
BUY_AMOUNT_SOL=0.0001
HOLD_TIME_SECONDS=30
MIN_LP_VALUE=30000
MAX_AGE_SECONDS=5

Run: npm start or npm run dev (with auto-reload)

Configuration

Variable Description Default
RPC_ENDPOINT Solana RPC HTTP endpoint Required
RPC_WEBSOCKET_ENDPOINT WebSocket endpoint (optional) -
PRIVATE_KEY Wallet private key (base58 or JSON array) Required
BLOXROUTE_API_KEY Bloxroute API key (paid required) Required
BLOXROUTE_API_URL Bloxroute API URL https://ny.solana.dex.blxrbdn.com
BUY_AMOUNT_SOL SOL amount per buy 0.0001
HOLD_TIME_SECONDS Hold time before sell 30
MIN_LP_VALUE Minimum LP value (USD) 30000
MAX_AGE_SECONDS Max pool age to consider "new" 5

Testing

npm run test                    # Mock data test
npm run test real <pool>         # Test with real pool
npm run test monitor            # Live monitoring test
npm run test buy-sell <pool>    # Full buy/sell test

How It Works

  1. Detection: Subscribes to Raydium CPMM program account changes
  2. Filtering: Validates pool age, LP value, and token safety (no mint/freeze authority)
  3. Trading: Buys → waits → sells, with automatic WSOL handling and Bloxroute submission

Project Structure

src/
├── bot/tradingBot.ts          # Main bot logic
├── config/env.ts              # Environment config
├── filters/newTokenFilter.ts  # Pool filtering
├── raydium-cpmm/             # Raydium integration
│   ├── idl/                  # IDL files
│   ├── index.ts              # CPMM functions
│   └── pda.ts                # PDA helpers
└── utils/bloxrouteSwap.ts    # Transaction submission

Important Notes

Bloxroute: Paid API required. Bot sets minimum priority fee (1M microlamports = 0.001 SOL/1M CU). Ensure wallet has SOL for: buy amount + fees + priority (~0.001 SOL) + rent.

Token Safety: Automatically skips tokens with mint/freeze authority to prevent rug pulls.

Networks: Supports Mainnet, Devnet, Testnet (configure RPC endpoints accordingly).

Troubleshooting

Error Solution
RPC_ENDPOINT is not set Check .env exists
insufficient tips Verify Bloxroute API key is valid (bot sets min fee automatically)
Pool does not contain SOL/WSOL Bot only trades SOL/WSOL pairs - verify pool tokens
Transaction failures Check wallet balance, pool validity, RPC responsiveness, API key

Development

npm run build    # Compile TypeScript
npm run clean    # Remove build artifacts

License

MIT

Disclaimer: Educational purposes only. Trading involves significant risk. Use at your own risk.

About

Automated Solana trading bot that monitors new Raydium CPMM pools and executes buy/sell trades with configurable filters.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors