mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-07-27 23:37: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:
@@ -27,6 +27,7 @@ print(json.dumps(tx_data, indent=2))
|
||||
|
||||
|
||||
def decode_create_instruction(data):
|
||||
"""Decode legacy Create instruction (Metaplex tokens)."""
|
||||
# The Create instruction has 3 string arguments: name, symbol, uri
|
||||
offset = 8 # Skip the 8-byte discriminator
|
||||
results = []
|
||||
@@ -36,7 +37,42 @@ def decode_create_instruction(data):
|
||||
string_data = data[offset : offset + length].decode("utf-8")
|
||||
results.append(string_data)
|
||||
offset += length
|
||||
return {"name": results[0], "symbol": results[1], "uri": results[2]}
|
||||
return {
|
||||
"name": results[0],
|
||||
"symbol": results[1],
|
||||
"uri": results[2],
|
||||
"token_standard": "legacy",
|
||||
"is_mayhem_mode": False,
|
||||
}
|
||||
|
||||
|
||||
def decode_create_v2_instruction(data):
|
||||
"""Decode CreateV2 instruction (Token2022 tokens)."""
|
||||
# The CreateV2 instruction has 3 string arguments: name, symbol, uri + is_mayhem_mode
|
||||
offset = 8 # Skip the 8-byte discriminator
|
||||
results = []
|
||||
for _ in range(3):
|
||||
length = struct.unpack_from("<I", data, offset)[0]
|
||||
offset += 4
|
||||
string_data = data[offset : offset + length].decode("utf-8")
|
||||
results.append(string_data)
|
||||
offset += length
|
||||
|
||||
# Skip creator pubkey (32 bytes)
|
||||
offset += 32
|
||||
|
||||
# Parse is_mayhem_mode (OptionBool at the end)
|
||||
is_mayhem_mode = False
|
||||
if offset < len(data):
|
||||
is_mayhem_mode = bool(data[offset])
|
||||
|
||||
return {
|
||||
"name": results[0],
|
||||
"symbol": results[1],
|
||||
"uri": results[2],
|
||||
"token_standard": "token2022",
|
||||
"is_mayhem_mode": is_mayhem_mode,
|
||||
}
|
||||
|
||||
|
||||
def decode_buy_instruction(data):
|
||||
@@ -48,6 +84,8 @@ def decode_buy_instruction(data):
|
||||
def decode_instruction_data(instruction, accounts, data):
|
||||
if instruction["name"] == "create":
|
||||
return decode_create_instruction(data)
|
||||
elif instruction["name"] == "createV2":
|
||||
return decode_create_v2_instruction(data)
|
||||
elif instruction["name"] == "buy":
|
||||
return decode_buy_instruction(data)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user