2025-03-05 16:44:55 +00:00
|
|
|
"""
|
|
|
|
|
Configuration for the pump.fun trading bot.
|
|
|
|
|
"""
|
|
|
|
|
|
2024-09-09 09:04:23 +07:00
|
|
|
# Trading parameters
|
2025-03-14 18:25:56 +00:00
|
|
|
BUY_AMOUNT: int | float = 0.000_001 # Amount of SOL to spend when buying
|
2025-03-12 22:11:31 +00:00
|
|
|
BUY_SLIPPAGE: float = 0.4 # 40% slippage tolerance for buying
|
|
|
|
|
SELL_SLIPPAGE: float = 0.4 # 40% slippage tolerance for selling
|
|
|
|
|
|
2025-03-14 18:25:56 +00:00
|
|
|
|
2025-03-12 22:11:31 +00:00
|
|
|
# Configuration for priority fee settings
|
2025-03-14 18:25:56 +00:00
|
|
|
ENABLE_DYNAMIC_PRIORITY_FEE: bool = False # Enable dynamic priority fee calculation
|
|
|
|
|
ENABLE_FIXED_PRIORITY_FEE: bool = True # Enable fixed priority fee
|
|
|
|
|
FIXED_PRIORITY_FEE: int = 2_000 # Fixed priority fee in microlamports
|
2025-03-12 22:11:31 +00:00
|
|
|
EXTRA_PRIORITY_FEE: float = (
|
2025-03-14 18:25:56 +00:00
|
|
|
0.0 # Percentage increase applied to priority fee (0.1 = 10%)
|
2025-03-12 22:11:31 +00:00
|
|
|
)
|
2025-03-13 21:01:26 +00:00
|
|
|
HARD_CAP_PRIOR_FEE: int = (
|
|
|
|
|
200_000 # Maximum allowed priority fee in microlamports (hard cap)
|
|
|
|
|
)
|
2024-09-09 09:04:23 +07:00
|
|
|
|
2025-03-14 18:25:56 +00:00
|
|
|
|
2025-03-18 16:03:46 +00:00
|
|
|
# Listener configuration
|
|
|
|
|
LISTENER_TYPE = "block" # Options: "block" or "logs"
|
|
|
|
|
|
|
|
|
|
|
2025-03-06 13:52:40 +00:00
|
|
|
# Retries and timeouts
|
2025-03-14 18:25:56 +00:00
|
|
|
MAX_RETRIES: int = 10 # Number of retries for transaction sending
|
|
|
|
|
# TODO: waiting times will be replaced with retries to shorten delays
|
|
|
|
|
WAIT_TIME_AFTER_CREATION: int | float = (
|
|
|
|
|
15 # Time to wait after token creation (in seconds)
|
|
|
|
|
# Too short a delay may cause the RPC node to be unaware of the bonding curve account
|
|
|
|
|
)
|
|
|
|
|
WAIT_TIME_AFTER_BUY: int | float = (
|
|
|
|
|
15 # Time to wait after a buy transaction is confirmed (in seconds)
|
|
|
|
|
# Acts as a simple holding period
|
|
|
|
|
# Too short delay may cause the RPC node to be unaware of account balance
|
|
|
|
|
)
|
|
|
|
|
WAIT_TIME_BEFORE_NEW_TOKEN: int | float = (
|
|
|
|
|
5 # Time to wait after a sell transaction is confirmed (in seconds)
|
|
|
|
|
# Provides a pause between completed trades, can be set to 0
|
|
|
|
|
)
|
|
|
|
|
|
2025-03-06 22:05:51 +00:00
|
|
|
|
|
|
|
|
# Maximum age (in seconds) for a token to be considered "fresh" and eligible for processing.
|
|
|
|
|
# This threshold is checked before processing starts - tokens older than this are skipped
|
|
|
|
|
# since they likely contain outdated information from the websocket stream
|
2025-03-14 18:25:56 +00:00
|
|
|
MAX_TOKEN_AGE: int | float = 0.1
|
2024-09-09 09:04:23 +07:00
|
|
|
|
2025-03-14 18:25:56 +00:00
|
|
|
|
|
|
|
|
# Node provider configuration
|
|
|
|
|
# Tested with Chainstack nodes (https://console.chainstack.com), but you can use any node provider
|
|
|
|
|
# You can get a trader node https://docs.chainstack.com/docs/solana-trader-nodes
|
2025-03-12 22:11:31 +00:00
|
|
|
MAX_RPS: int = 25 # TODO: not implemented. Max RPS to avoid rate limit errors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_priority_fee_config() -> None:
|
|
|
|
|
"""Validate priority fee configuration values."""
|
|
|
|
|
if not isinstance(ENABLE_DYNAMIC_PRIORITY_FEE, bool):
|
|
|
|
|
raise ValueError("ENABLE_DYNAMIC_PRIORITY_FEE must be a boolean")
|
|
|
|
|
if not isinstance(ENABLE_FIXED_PRIORITY_FEE, bool):
|
|
|
|
|
raise ValueError("ENABLE_FIXED_PRIORITY_FEE must be a boolean")
|
|
|
|
|
if not isinstance(FIXED_PRIORITY_FEE, int) or FIXED_PRIORITY_FEE < 0:
|
|
|
|
|
raise ValueError("FIXED_PRIORITY_FEE must be a non-negative integer")
|
|
|
|
|
if not isinstance(EXTRA_PRIORITY_FEE, float) or EXTRA_PRIORITY_FEE < 0:
|
|
|
|
|
raise ValueError("EXTRA_PRIORITY_FEE must be a non-negative float")
|
|
|
|
|
if not isinstance(HARD_CAP_PRIOR_FEE, int) or HARD_CAP_PRIOR_FEE < 0:
|
|
|
|
|
raise ValueError("HARD_CAP_PRIOR_FEE must be a non-negative integer")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Validate config on import
|
|
|
|
|
validate_priority_fee_config()
|