feat: add EXTREME FAST mode for token buying

This commit is contained in:
smypmsa
2025-04-03 21:57:36 +00:00
parent d662b126b9
commit 4eacc5a4f7
4 changed files with 35 additions and 10 deletions
+8
View File
@@ -12,6 +12,14 @@ BUY_SLIPPAGE: float = 0.4 # Maximum acceptable price deviation (0.4 = 40%)
SELL_SLIPPAGE: float = 0.4 # Consistent slippage tolerance to maintain trading strategy
# 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: bool = False
# Amount of tokens to buy in EXTREME FAST mode. No price calculation is done; the bot buys exactly this amount.
EXTREME_FAST_TOKEN_AMOUNT: int = 30
# Priority fee configuration
# Manage transaction speed and cost on the Solana network
ENABLE_DYNAMIC_PRIORITY_FEE: bool = False # Adaptive fee calculation
+16 -6
View File
@@ -40,6 +40,8 @@ class TokenBuyer(Trader):
amount: float,
slippage: float = 0.01,
max_retries: int = 5,
extreme_fast_token_amount: int = 0,
extreme_fast_mode: bool = False,
):
"""Initialize token buyer.
@@ -50,6 +52,8 @@ class TokenBuyer(Trader):
amount: Amount of SOL to spend
slippage: Slippage tolerance (0.01 = 1%)
max_retries: Maximum number of retry attempts
extreme_fast_token_amount: Amount of token to buy if extreme fast mode is enabled
extreme_fast_mode: If enabled, avoid fetching associated bonding curve state
"""
self.client = client
self.wallet = wallet
@@ -58,6 +62,8 @@ class TokenBuyer(Trader):
self.amount = amount
self.slippage = slippage
self.max_retries = max_retries
self.extreme_fast_mode = extreme_fast_mode
self.extreme_fast_token_amount = extreme_fast_token_amount
async def execute(self, token_info: TokenInfo, *args, **kwargs) -> TradeResult:
"""Execute buy operation.
@@ -72,12 +78,16 @@ class TokenBuyer(Trader):
# Convert amount to lamports
amount_lamports = int(self.amount * LAMPORTS_PER_SOL)
# Fetch token price
curve_state = await self.curve_manager.get_curve_state(
token_info.bonding_curve
)
token_price_sol = curve_state.calculate_price()
token_amount = self.amount / token_price_sol
if self.extreme_fast_mode:
# Skip the wait and directly calculate the amount
token_amount = self.extreme_fast_token_amount
token_price_sol = self.amount / token_amount
logger.info(f"EXTREME FAST Mode: Buying {token_amount} tokens.")
else:
# Regular behavior with RPC call
curve_state = await self.curve_manager.get_curve_state(token_info.bonding_curve)
token_price_sol = curve_state.calculate_price()
token_amount = self.amount / token_price_sol
# Calculate maximum SOL to spend with slippage
max_amount_lamports = int(amount_lamports * (1 + self.slippage))
+7 -4
View File
@@ -78,6 +78,8 @@ class PumpTrader:
buy_amount,
buy_slippage,
max_retries,
config.EXTREME_FAST_TOKEN_AMOUNT,
config.EXTREME_FAST_MODE
)
self.seller = TokenSeller(
@@ -212,10 +214,11 @@ class PumpTrader:
try:
await self._save_token_info(token_info)
logger.info(
f"Waiting for {config.WAIT_TIME_AFTER_CREATION} seconds for the bonding curve to stabilize..."
)
await asyncio.sleep(config.WAIT_TIME_AFTER_CREATION)
if not config.EXTREME_FAST_MODE:
logger.info(
f"Waiting for {config.WAIT_TIME_AFTER_CREATION} seconds for the bonding curve to stabilize..."
)
await asyncio.sleep(config.WAIT_TIME_AFTER_CREATION)
logger.info(
f"Buying {self.buy_amount:.6f} SOL worth of {token_info.symbol}..."
+4
View File
@@ -6,3 +6,7 @@
{"timestamp": "2025-03-06T22:04:48.843998", "action": "sell", "token_address": "5jch2xH14RBWZgKwmxEUJwC4howFNBCBqbnZ5uguGujj", "symbol": "$MOONWEN", "price": 2.8056120698010214e-08, "amount": 35.033737, "tx_hash": "RLx8hFVd5DVZdUg5vN41Fs8Yz66yTEUEvegasuHwYQ7DTJhPcCdggoNBtipb93VPVdtQLZydxc9ZKRZ1uzK6KzH"}
{"timestamp": "2025-03-06T22:05:11.444317", "action": "buy", "token_address": "C9GrXnLPkD4fdj83ua7TFndtxvCVxdYyZzqrMBBZpump", "symbol": "CRYPTO ", "price": 3.383038210726932e-08, "amount": 29.559228649242023, "tx_hash": "3E4RT5kvRezWJmQKJ9wmcAiDcYZefohxFVNdEZPweE9vhq215rSmqBn4Dv4ypH5KUUuNJzKdhjyrGU2b47woWr9e"}
{"timestamp": "2025-03-06T22:05:25.789876", "action": "sell", "token_address": "C9GrXnLPkD4fdj83ua7TFndtxvCVxdYyZzqrMBBZpump", "symbol": "CRYPTO ", "price": 3.3830384158620706e-08, "amount": 29.559228, "tx_hash": "3oyJVzsRvnQV5qBsEp4hSk97eFWzUjzfWWa16GMUXtMd7JBmbQkTkmvs7N8nagYcJvqfFhzhCKZEG6onxjYYQbwX"}
{"timestamp": "2025-04-03T21:55:46.849123", "action": "buy", "token_address": "4rHSLfYLkFmHTcyCF8thnUmyuX4MBrHdjdftZXM7pump", "symbol": "GCT", "price": 3.3333333333333334e-08, "amount": 30, "tx_hash": "35UncvxypdvuKC4gD3jXnmmtwfBfEhFc2Y2JLfszzvHqsZumcjp2CMkXH4HD7iexgkPEpG1je73bwnFWbNQjxNUS"}
{"timestamp": "2025-04-03T21:56:05.816803", "action": "sell", "token_address": "4rHSLfYLkFmHTcyCF8thnUmyuX4MBrHdjdftZXM7pump", "symbol": "GCT", "price": 3.1716731316027684e-08, "amount": 30.0, "tx_hash": "2NoMsScE5tJu3gzvrSn1uarnVZ4DcgXVLsc7BEwJ1ndU7T69xPbgyk53YW4MVCEfrSvdoaCup6VyM9pnf6YR6pGc"}
{"timestamp": "2025-04-03T21:56:49.686823", "action": "buy", "token_address": "Hx4wR3Z7tEjfVip8jHFFsF3d4LwNmXgjBRkNR9qSUarF", "symbol": "Pablo", "price": 5.067234074416521e-08, "amount": 19.734632055953472, "tx_hash": "52hQYXPjtP1Rr945UW5peef6qbxThUubyBbEbcnGCCJ146nxx6bZXj3mCpWtpqpmMe82oNkEFwMms26JqhAaJMXL"}
{"timestamp": "2025-04-03T21:57:09.656288", "action": "sell", "token_address": "Hx4wR3Z7tEjfVip8jHFFsF3d4LwNmXgjBRkNR9qSUarF", "symbol": "Pablo", "price": 2.8113188162567704e-08, "amount": 19.734632, "tx_hash": "xzpCFN8PgtPvXyRfQjkhHkPQcdzTNb6JXtCsQixtsMQabiBt9yNMSb7JLxRCT295rbVZuuocRNxYe6AqAiRnE91"}