mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-07-27 15:27:44 +00:00
4.3 KiB
4.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Development Commands
Environment Setup
# Create virtual environment and install dependencies
uv sync --extra dev
# Activate virtual environment
source .venv/bin/activate # Unix/macOS
.venv\Scripts\activate # Windows
Running the Bot
# Run bot with all configurations in bots/ directory
pump_bot
# Run bot directly
uv run src/bot_runner.py
Development Tools
# Run linting
uv run ruff check src/
# Run formatting
uv run ruff format src/
Testing
# Run individual test files
uv run tests/test_block_listener.py
uv run tests/test_geyser_listener.py
uv run tests/test_logs_listener.py
Architecture Overview
This is a Solana-based trading bot for pump.fun tokens with a modular architecture:
Core Components
src/bot_runner.py: Main entry point that loads configurations and starts trading botssrc/config_loader.py: Handles YAML configuration loading, validation, and environment variable resolutionsrc/trading/trader.py:PumpTraderclass - main trading coordinator that orchestrates token detection, buying, and sellingsrc/core/client.py:SolanaClient- abstraction for Solana RPC operations with background blockhash cachingsrc/core/wallet.py: Wallet management for signing transactionssrc/core/curve.py: Bonding curve calculations for pump.fun tokens
Trading System
src/trading/buyer.py:TokenBuyer- handles token purchase logic with slippage and retry supportsrc/trading/seller.py:TokenSeller- handles token sale logicsrc/trading/position.py:Position- tracks positions with take-profit/stop-loss functionalitysrc/trading/base.py: Common trading data structures (TokenInfo,TradeResult)
Token Detection (Monitoring)
Multiple listener implementations for detecting new tokens:
src/monitoring/logs_listener.py: UseslogsSubscribeWebSocket methodsrc/monitoring/block_listener.py: UsesblockSubscribeWebSocket methodsrc/monitoring/geyser_listener.py: Uses Geyser gRPC streaming (fastest)src/monitoring/pumpportal_listener.py: Uses PumpPortal WebSocket APIsrc/monitoring/base_listener.py: Abstract base class for all listeners
Priority Fees
src/core/priority_fee/manager.py: Manages priority fee calculationsrc/core/priority_fee/dynamic_fee.py: Dynamic fee calculation based on network conditionssrc/core/priority_fee/fixed_fee.py: Fixed fee implementation
Configuration System
Bot configurations are stored in bots/*.yaml files. Each bot can run independently with its own settings for:
- Connection endpoints (RPC, WSS, Geyser)
- Trading parameters (buy amount, slippage, exit strategy)
- Priority fees (dynamic vs fixed)
- Token filters (match string, creator address)
- Cleanup modes for token accounts
Key Features
- Multiple Listener Types: Supports logs, blocks, Geyser, and PumpPortal for token detection
- Exit Strategies: Time-based, take-profit/stop-loss, or manual
- Extreme Fast Mode: Skips stabilization wait and price checks for faster execution
- Priority Fee Management: Dynamic or fixed fee calculation
- Account Cleanup: Automatic cleanup of empty token accounts
- Multi-bot Support: Run multiple bots with different configurations simultaneously
Trading Modes
- Single Token Mode (
yolo_mode: false): Process one token and exit - Continuous Mode (
yolo_mode: true): Continuously process tokens - Marry Mode (
marry_mode: true): Only buy tokens, skip selling
Environment Configuration
Create .env file with:
SOLANA_NODE_RPC_ENDPOINT=your_rpc_endpoint
SOLANA_NODE_WSS_ENDPOINT=your_wss_endpoint
SOLANA_PRIVATE_KEY=your_private_key
GEYSER_ENDPOINT=your_geyser_endpoint
GEYSER_API_TOKEN=your_geyser_token
Important Notes
- This is educational/learning code - not for production use
- The bot trades on pump.fun bonding curves and handles migrations to PumpSwap
- Geyser listener provides fastest token detection
- All configurations support environment variable substitution with
${VAR}syntax - Bot logs are stored in
logs/directory with timestamps - Trade logs are written to
trades/trades.log