mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-08-05 19:47:45 +00:00
Add mayhem mode support and Token2022 integration (#149)
* feat: mayhem update in idl * feat(examples): update bonding curve scripts * feat(example): update listen_blocksubscribe * feat(examples): update geyser listener * feat(examples): update all new token listeners * feat(examples): add comments, fix printing, formatting * feat(examples): pumpswap buy and sell update with mayhem mode * fix(examples): sell pump amm fee recipient * feat(examples): update decode scripts * feat(examples): update fetch price * feat(examples): buy and sell bonding curve scripts * feat(examples): add mint with mayhem mode enabled * feat(examples): improve listening to wallet txs * feat(examples): migration listener improvements * feat(examples): global vol accumulator is not writable * feat(examples): support token/token2022 programs in buy instructions * feat(examples): token/token2022 for pumpswap buy * feat(examples): token/token2022 supprot for sell instructions * feat(bot): support create_v2 with token2022, mayhem mode, other fixes * fix(bot): support only token2022 in logs and pumportal listeners * feat(bot): token2022 support in cleanup flow * fix(bot): update token program handling and improve price validation in trading logic * feat(bot): enhance token program handling for LetsBonk integration
This commit is contained in:
@@ -11,18 +11,7 @@ EXPECTED_DISCRIMINATOR = struct.pack("<Q", 6966180631402821399)
|
||||
|
||||
|
||||
class BondingCurveState:
|
||||
_STRUCT_1 = Struct(
|
||||
"virtual_token_reserves" / Int64ul,
|
||||
"virtual_sol_reserves" / Int64ul,
|
||||
"real_token_reserves" / Int64ul,
|
||||
"real_sol_reserves" / Int64ul,
|
||||
"token_total_supply" / Int64ul,
|
||||
"complete" / Flag,
|
||||
)
|
||||
|
||||
# Struct after creator fee update has been introduced
|
||||
# https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_CREATOR_FEE_README.md
|
||||
_STRUCT_2 = Struct(
|
||||
_STRUCT = Struct(
|
||||
"virtual_token_reserves" / Int64ul,
|
||||
"virtual_sol_reserves" / Int64ul,
|
||||
"real_token_reserves" / Int64ul,
|
||||
@@ -30,23 +19,43 @@ class BondingCurveState:
|
||||
"token_total_supply" / Int64ul,
|
||||
"complete" / Flag,
|
||||
"creator" / Bytes(32), # Added new creator field - 32 bytes for Pubkey
|
||||
"is_mayhem_mode" / Flag, # Added mayhem mode flag - 1 byte
|
||||
)
|
||||
|
||||
def __init__(self, data: bytes) -> None:
|
||||
"""Parse bonding curve data."""
|
||||
"""Parse bonding curve data - supports all versions."""
|
||||
if data[:8] != EXPECTED_DISCRIMINATOR:
|
||||
raise ValueError("Invalid curve state discriminator")
|
||||
|
||||
if len(data) < 150:
|
||||
parsed = self._STRUCT_1.parse(data[8:])
|
||||
self.__dict__.update(parsed)
|
||||
# Required fields (always present)
|
||||
offset = 8
|
||||
self.virtual_token_reserves = int.from_bytes(
|
||||
data[offset : offset + 8], "little"
|
||||
)
|
||||
offset += 8
|
||||
self.virtual_sol_reserves = int.from_bytes(data[offset : offset + 8], "little")
|
||||
offset += 8
|
||||
self.real_token_reserves = int.from_bytes(data[offset : offset + 8], "little")
|
||||
offset += 8
|
||||
self.real_sol_reserves = int.from_bytes(data[offset : offset + 8], "little")
|
||||
offset += 8
|
||||
self.token_total_supply = int.from_bytes(data[offset : offset + 8], "little")
|
||||
offset += 8
|
||||
self.complete = bool(data[offset])
|
||||
offset += 1
|
||||
|
||||
# Optional fields (may not be present in older versions)
|
||||
if len(data) >= offset + 32:
|
||||
self.creator = Pubkey.from_bytes(data[offset : offset + 32])
|
||||
offset += 32
|
||||
|
||||
if len(data) > offset:
|
||||
self.is_mayhem_mode = bool(data[offset])
|
||||
else:
|
||||
self.is_mayhem_mode = None
|
||||
|
||||
else:
|
||||
parsed = self._STRUCT_2.parse(data[8:])
|
||||
self.__dict__.update(parsed)
|
||||
# Convert raw bytes to Pubkey for creator field
|
||||
if hasattr(self, "creator") and isinstance(self.creator, bytes):
|
||||
self.creator = Pubkey.from_bytes(self.creator)
|
||||
self.creator = None
|
||||
|
||||
|
||||
def calculate_bonding_curve_price(curve_state: BondingCurveState) -> float:
|
||||
|
||||
Reference in New Issue
Block a user