Advanced automated trading bot for Solana tokens using PumpPortal WebSocket feeds
Features β’ Installation β’ Configuration β’ Usage β’ API β’ Contributing
- Real-time Token Detection: Monitors PumpPortal WebSocket for new token launches
- Automated Trading: Executes buy/sell orders based on market conditions
- Risk Management: Built-in stop-loss and take-profit mechanisms
- Position Tracking: Monitors active positions and PnL in real-time
- Multi-token Support: Handles multiple concurrent token positions
- Slippage Protection: Configurable slippage tolerance for trades
- Liquidity Checks: Validates minimum liquidity before trading
- Error Handling: Comprehensive error handling and recovery
- Rate Limiting: Built-in rate limiting to prevent API abuse
- Real-time Logging: Detailed logging with configurable levels
- Telegram Notifications: Get notified of trades, errors, and status updates
- Portfolio Tracking: Track total PnL and trade statistics
- Performance Metrics: Monitor success rates and profitability
- TypeScript: Fully typed for better development experience
- Modular Architecture: Clean, maintainable code structure
- WebSocket Reconnection: Automatic reconnection with exponential backoff
- Transaction Optimization: Optimized for Solana's transaction model
- Node.js (v18 or higher)
- npm or yarn
- Solana Wallet with SOL for trading
- Telegram Bot (optional, for notifications)
-
Clone the repository
git clone https://github.com/radioman/Auto-solana-trading-bot.git cd Auto-solana-trading-bot
-
Install dependencies
npm install # or yarn install
-
Set up environment variables
cp env.example .env
-
Configure your environment Edit
.env
file with your settings:# Required PRIVATE_KEY=your_base58_private_key_here # Optional RPC_ENDPOINT=https://api.mainnet-beta.solana.com BUY_AMOUNT_SOL=0.01 MAX_CONCURRENT_TRADES=5 TELEGRAM_BOT_TOKEN=your_telegram_bot_token TELEGRAM_CHAT_ID=your_telegram_chat_id
-
Build and run
# Development npm run dev # Production npm run build npm start
Variable | Description | Default | Required |
---|---|---|---|
PRIVATE_KEY |
Base58 encoded Solana private key | - | β |
RPC_ENDPOINT |
Solana RPC endpoint | https://api.mainnet-beta.solana.com |
β |
COMMITMENT_LEVEL |
Transaction commitment level | confirmed |
β |
BUY_AMOUNT_SOL |
SOL amount per trade | 0.01 |
β |
MAX_CONCURRENT_TRADES |
Maximum concurrent positions | 5 |
β |
STOP_LOSS_PERCENTAGE |
Stop loss percentage | 20 |
β |
TAKE_PROFIT_PERCENTAGE |
Take profit percentage | 50 |
β |
TELEGRAM_BOT_TOKEN |
Telegram bot token | - | β |
TELEGRAM_CHAT_ID |
Telegram chat ID | - | β |
SOLANA_VIBE_STATION_API_KEY |
API key for token metadata | - | β |
You can modify trading parameters in src/constants/index.ts
:
export const BUY_AMOUNT_SOL = 0.01; // SOL per trade
export const MAX_CONCURRENT_TRADES = 5; // Max positions
export const STOP_LOSS_PERCENTAGE = 20; // Stop loss %
export const TAKE_PROFIT_PERCENTAGE = 50; // Take profit %
# Start the bot
npm run dev
# Or build and run
npm run build
npm start
import { SolanaTradingBot } from './src/index';
const bot = new SolanaTradingBot();
// Start trading
await bot.start();
// Get current status
const status = bot.getStatus();
console.log(status);
// Stop trading
await bot.stop();
The bot provides real-time monitoring through:
- Console Logs: Detailed logging with timestamps
- Telegram Notifications: Real-time alerts and updates
- Status Endpoint: Programmatic status checking
start()
: Start the trading botstop()
: Stop the trading botgetState()
: Get current bot stategetConfig()
: Get current configurationupdateConfig(config)
: Update trading configuration
interface BotState {
isRunning: boolean;
activeTrades: Map<string, TokenPosition>;
totalPnl: number;
totalTrades: number;
successfulTrades: number;
failedTrades: number;
}
connect()
: Connect to PumpPortal WebSocketdisconnect()
: Disconnect from WebSocketisWebSocketConnected()
: Check connection status
trade
: Emitted when a new trade is detectederror
: Emitted when an error occurs
src/
βββ constants/ # Configuration constants
βββ services/ # External service integrations
β βββ pumpportal.ts # PumpPortal WebSocket client
β βββ telegram.ts # Telegram notification service
β βββ tokenService.ts # Token metadata service
βββ trading/ # Core trading logic
β βββ tradingBot.ts # Main trading bot class
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
β βββ helpers.ts # Helper functions
β βββ logger.ts # Logging utility
βββ index.ts # Main entry point
# Build TypeScript
npm run build
# Watch mode
npm run watch
# Clean build
npm run clean
# Run tests (when implemented)
npm test
# Run with coverage
npm run test:coverage
- Never commit private keys to version control
- Use environment variables for sensitive data
- Consider using a hardware wallet for large amounts
- Regularly rotate keys and monitor transactions
- Start with small amounts to test the bot
- Monitor performance regularly
- Set appropriate stop-losses to limit downside
- Understand the risks of automated trading
- Test on devnet before mainnet
- Monitor logs for errors and anomalies
- Keep the bot updated with latest changes
- Backup your configuration regularly
- Use a fast RPC endpoint for better performance
- Monitor memory usage for long-running instances
- Adjust trade frequency based on market conditions
- Use appropriate slippage settings for your strategy
- Set up alerts for critical errors
- Monitor PnL regularly
- Check transaction success rates
- Review trade logs for patterns
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests (if applicable)
- Submit a pull request
# Fork and clone
git clone https://github.com/radioman/Auto-solana-trading-bot.git
cd Auto-solana-trading-bot
# Install dependencies
npm install
# Create feature branch
git checkout -b feature/your-feature-name
# Make changes and test
npm run dev
# Submit PR
git push origin feature/your-feature-name
This project is licensed under the MIT License - see the LICENSE file for details.
This software is for educational purposes only. Trading cryptocurrencies involves substantial risk of loss and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade cryptocurrencies, you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with cryptocurrency trading and seek advice from an independent financial advisor if you have any doubts.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
- Connection Issues: Check your RPC endpoint and internet connection
- Transaction Failures: Verify wallet balance and gas settings
- WebSocket Disconnections: Check network stability and reconnection settings
Made with β€οΈ for the Solana community
β Star this repo β’ π Report Bug β’ π‘ Request Feature