mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-08-17 17:28:05 +00:00
Merge pull request #79 from chainstacklabs/feat/extreme-fast-mode
Add EXTREME FAST mode for token buying (without waiting for bonding curve)
This commit is contained in:
@@ -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
|
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
|
# Priority fee configuration
|
||||||
# Manage transaction speed and cost on the Solana network
|
# Manage transaction speed and cost on the Solana network
|
||||||
ENABLE_DYNAMIC_PRIORITY_FEE: bool = False # Adaptive fee calculation
|
ENABLE_DYNAMIC_PRIORITY_FEE: bool = False # Adaptive fee calculation
|
||||||
|
|||||||
+16
-6
@@ -40,6 +40,8 @@ class TokenBuyer(Trader):
|
|||||||
amount: float,
|
amount: float,
|
||||||
slippage: float = 0.01,
|
slippage: float = 0.01,
|
||||||
max_retries: int = 5,
|
max_retries: int = 5,
|
||||||
|
extreme_fast_token_amount: int = 0,
|
||||||
|
extreme_fast_mode: bool = False,
|
||||||
):
|
):
|
||||||
"""Initialize token buyer.
|
"""Initialize token buyer.
|
||||||
|
|
||||||
@@ -50,6 +52,8 @@ class TokenBuyer(Trader):
|
|||||||
amount: Amount of SOL to spend
|
amount: Amount of SOL to spend
|
||||||
slippage: Slippage tolerance (0.01 = 1%)
|
slippage: Slippage tolerance (0.01 = 1%)
|
||||||
max_retries: Maximum number of retry attempts
|
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.client = client
|
||||||
self.wallet = wallet
|
self.wallet = wallet
|
||||||
@@ -58,6 +62,8 @@ class TokenBuyer(Trader):
|
|||||||
self.amount = amount
|
self.amount = amount
|
||||||
self.slippage = slippage
|
self.slippage = slippage
|
||||||
self.max_retries = max_retries
|
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:
|
async def execute(self, token_info: TokenInfo, *args, **kwargs) -> TradeResult:
|
||||||
"""Execute buy operation.
|
"""Execute buy operation.
|
||||||
@@ -72,12 +78,16 @@ class TokenBuyer(Trader):
|
|||||||
# Convert amount to lamports
|
# Convert amount to lamports
|
||||||
amount_lamports = int(self.amount * LAMPORTS_PER_SOL)
|
amount_lamports = int(self.amount * LAMPORTS_PER_SOL)
|
||||||
|
|
||||||
# Fetch token price
|
if self.extreme_fast_mode:
|
||||||
curve_state = await self.curve_manager.get_curve_state(
|
# Skip the wait and directly calculate the amount
|
||||||
token_info.bonding_curve
|
token_amount = self.extreme_fast_token_amount
|
||||||
)
|
token_price_sol = self.amount / token_amount
|
||||||
token_price_sol = curve_state.calculate_price()
|
logger.info(f"EXTREME FAST Mode: Buying {token_amount} tokens.")
|
||||||
token_amount = self.amount / token_price_sol
|
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
|
# Calculate maximum SOL to spend with slippage
|
||||||
max_amount_lamports = int(amount_lamports * (1 + self.slippage))
|
max_amount_lamports = int(amount_lamports * (1 + self.slippage))
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ class PumpTrader:
|
|||||||
buy_amount,
|
buy_amount,
|
||||||
buy_slippage,
|
buy_slippage,
|
||||||
max_retries,
|
max_retries,
|
||||||
|
config.EXTREME_FAST_TOKEN_AMOUNT,
|
||||||
|
config.EXTREME_FAST_MODE
|
||||||
)
|
)
|
||||||
|
|
||||||
self.seller = TokenSeller(
|
self.seller = TokenSeller(
|
||||||
@@ -212,10 +214,11 @@ class PumpTrader:
|
|||||||
try:
|
try:
|
||||||
await self._save_token_info(token_info)
|
await self._save_token_info(token_info)
|
||||||
|
|
||||||
logger.info(
|
if not config.EXTREME_FAST_MODE:
|
||||||
f"Waiting for {config.WAIT_TIME_AFTER_CREATION} seconds for the bonding curve to stabilize..."
|
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)
|
)
|
||||||
|
await asyncio.sleep(config.WAIT_TIME_AFTER_CREATION)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Buying {self.buy_amount:.6f} SOL worth of {token_info.symbol}..."
|
f"Buying {self.buy_amount:.6f} SOL worth of {token_info.symbol}..."
|
||||||
|
|||||||
@@ -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: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: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-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"}
|
||||||
|
|||||||
Reference in New Issue
Block a user