mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-08-09 13:30:57 +00:00
40ad32b8d0
* feat(core): add RPC rate limiting, retry logic, and 429 handling Addresses #44 — users on free-tier RPC endpoints hit HTTP 429 errors during buy transactions due to no rate limiting or retry handling. - Add TokenBucketRateLimiter (new file: src/core/rpc_rate_limiter.py) - Gate all RPC methods through rate limiter (both post_rpc and solana-py calls) - Rewrite post_rpc() with retry loop, exponential backoff, jitter, and specific 429 detection with Retry-After header support - Replace per-call aiohttp session with shared persistent session - Wire node.max_rps from YAML bot config through to SolanaClient - Fix cleanup manager and learning example to use SolanaClient abstraction instead of bypassing it via get_client() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(core): address CodeRabbitAI review feedback on rate limiting PR Validate max_rps > 0 in TokenBucketRateLimiter to prevent ZeroDivisionError and infinite loops with fractional values. Add asyncio.Lock to _get_session to fix race condition, handle non-numeric Retry-After headers gracefully, replace dead json.JSONDecodeError with aiohttp.ContentTypeError, and combine burn+close into a single transaction in cleanup example. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: document RPC rate limiting feature in README - Add section on built-in RPC rate limiting with token bucket algorithm - Document configurable max RPS and automatic retry logic - Update roadmap to mark "Configurable RPS" as completed - Clarify benefits of rate limiting for provider compliance Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: use math.ceil for burst_size to handle fractional max_rps - Replace int(max_rps) with math.ceil(max_rps) in burst_size calculation - Prevents infinite loop when max_rps < 1.0 (e.g., 0.5 RPS would result in burst_size=0) - Ensures burst_size is always at least 1 for valid fractional rates - Addresses CodeRabbit feedback on rpc_rate_limiter.py:27 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix(core): validate burst_size and fix table pipe consistency Address remaining CodeRabbitAI review feedback: add burst_size validation guard, fix TRY003 lint (use msg variable for ValueError), break long line under 88 chars, and fix MD055 table pipe style in README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(core): separate 429 retry budget from error retries in post_rpc 429 responses no longer count against max_retries — they use a dedicated max_429_retries counter (default 10) so free-tier users hitting rate limits won't exhaust retries prematurely. Also refresh the aiohttp session inside the retry loop to avoid stale references after network failures, and fix cleanup log message accuracy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Anton Sauchyk <antonsauchyk@gmail.com>
96 lines
4.4 KiB
YAML
96 lines
4.4 KiB
YAML
# This file defines comprehensive parameters and settings for the trading bot.
|
|
# Carefully review and adjust values to match your trading strategy and risk tolerance.
|
|
|
|
# Bot identification and connection settings
|
|
name: "bot-sniper-pumpportal"
|
|
env_file: ".env"
|
|
rpc_endpoint: "${SOLANA_NODE_RPC_ENDPOINT}"
|
|
wss_endpoint: "${SOLANA_NODE_WSS_ENDPOINT}"
|
|
private_key: "${SOLANA_PRIVATE_KEY}"
|
|
|
|
enabled: false # You can turn off the bot w/o removing its config
|
|
separate_process: true
|
|
|
|
# Options: "pump_fun" (default), "lets_bonk"
|
|
platform: "lets_bonk"
|
|
|
|
# PumpPortal configuration (optional - uses default URL if not specified)
|
|
pumpportal:
|
|
url: "wss://pumpportal.fun/api/data" # Default PumpPortal WebSocket URL
|
|
|
|
# Trading parameters
|
|
# Control trade execution: amount of SOL per trade and acceptable price deviation
|
|
trade:
|
|
buy_amount: 0.0001 # Amount of SOL to spend when buying (in SOL)
|
|
buy_slippage: 0.3 # Maximum acceptable price deviation (0.3 = 30%)
|
|
sell_slippage: 0.3
|
|
|
|
# Exit strategy configuration
|
|
exit_strategy: "time_based" # Options: "time_based", "tp_sl", "manual"
|
|
take_profit_percentage: 0.1 # Take profit at 10% gain (0.1 = 10%)
|
|
stop_loss_percentage: 0.1 # Stop loss at 10% loss (0.1 = 10%)
|
|
max_hold_time: 15 # Maximum hold time in seconds for TP/SL strategy, for time_based - see wait_after_buy
|
|
price_check_interval: 2 # Check price every 2 seconds
|
|
|
|
# EXTREME FAST mode configuration
|
|
# When enabled, skips waiting for the bonding curve to stabilize and RPC price check.
|
|
# The bot buys the specified number of tokens directly, making the process faster but less precise.
|
|
extreme_fast_mode: true
|
|
extreme_fast_token_amount: 20 # Amount of tokens to buy
|
|
|
|
# Priority fee configuration
|
|
# Manage transaction speed and cost on the Solana network.
|
|
# Note: dynamic mode requires an additional RPC call, which slows down the buying process.
|
|
priority_fees:
|
|
enable_dynamic: false # Use latest transactions to estimate required fee (getRecentPrioritizationFees)
|
|
enable_fixed: true # Use fixed amount below
|
|
fixed_amount: 200_000 # Base fee in microlamports
|
|
extra_percentage: 0.0 # Percentage increase on riority fee regardless of the calculation method (0.1 = 10%)
|
|
hard_cap: 200_000 # Maximum allowable fee in microlamports to prevent excessive spending
|
|
|
|
# Compute unit limits for transaction processing
|
|
# Operation-specific defaults are used if not specified: buy=100K, sell=60K
|
|
compute_units:
|
|
# Override default CU limits for this platform
|
|
# buy: 100_000 # Buy operations (ATA creation + trading)
|
|
# sell: 60_000 # Sell operations (just trading)
|
|
|
|
# Account data size optimization (reduces CU cost and improves tx priority)
|
|
# Reduces CU cost from 16k to ~128 CU by limiting loaded account data.
|
|
# Default is 64MB (16k CU). Setting to 512KB significantly reduces overhead.
|
|
# Note: Savings don't show in "consumed CU" but improve tx priority/cost.
|
|
# Note (Nov 23, 2025): with data size set to 512KB, transactions fail - increasing to 12.5MB resolves the issue.
|
|
# Reference: https://www.anza.xyz/blog/cu-optimization-with-setloadedaccountsdatasizelimit
|
|
account_data_size: 12_500_000
|
|
|
|
# Filters for token selection
|
|
filters:
|
|
match_string: null # Only process tokens with this string in name/symbol
|
|
bro_address: null # Only trade tokens created by this user address
|
|
listener_type: "pumpportal" # Method for detecting new tokens: "logs", "blocks", "geyser", or "pumpportal"
|
|
max_token_age: 0.001 # Maximum token age in seconds for processing
|
|
marry_mode: false # Only buy tokens, skip selling
|
|
yolo_mode: false # Continuously trade tokens
|
|
|
|
# Retry and timeout settings
|
|
retries:
|
|
max_attempts: 1 # Number of attempts for transaction submission
|
|
wait_after_creation: 15 # Seconds to wait after token creation (only if EXTREME FAST is disabled)
|
|
wait_after_buy: 15 # Holding period after buy transaction
|
|
wait_before_new_token: 15 # Pause between token trades
|
|
|
|
# Token and account management
|
|
cleanup:
|
|
# Cleanup mode determines when to manage token accounts. Options:
|
|
# "disabled": no cleanup will occur.
|
|
# "on_fail": only clean up if a buy transaction fails.
|
|
# "after_sell": clean up after selling.
|
|
# "post_session": clean up all empty accounts after a trading session ends.
|
|
mode: "post_session"
|
|
force_close_with_burn: false # Force burning remaining tokens before closing account
|
|
with_priority_fee: false # Use priority fees for cleanup transactions
|
|
|
|
# Node provider configuration
|
|
node:
|
|
max_rps: 25 # Maximum requests per second
|