Fix/update letsbonk fun instructions in the bot (#142)

* feat(core): support multiple initialize instruction variants in LetsBonkEventParser

* feat(core): add creator and platform fee vault derivation methods and update account handling in buy/sell instructions

* feat(letsbonk): add global_config and platform_config to TokenInfo and update address provider logic
This commit is contained in:
Anton
2025-10-26 16:21:58 +01:00
committed by GitHub
parent 7377e1757e
commit 68cac87aad
5 changed files with 211 additions and 28 deletions
+54 -5
View File
@@ -112,9 +112,8 @@ class LetsBonkInstructionBuilder(InstructionBuilder):
instructions.append(initialize_wsol_ix)
# 4. Build buy_exact_in instruction with correct account ordering
# Based on the IDL and manual examples, the account order should be:
buy_accounts = [
AccountMeta(pubkey=user, is_signer=True, is_writable=True), # payer
AccountMeta(pubkey=user, is_signer=True, is_writable=False), # payer
AccountMeta(
pubkey=accounts_info["authority"], is_signer=False, is_writable=False
), # authority
@@ -167,6 +166,31 @@ class LetsBonkInstructionBuilder(InstructionBuilder):
), # program
]
# Add remaining accounts (required by the program for fee collection)
# These are not explicitly listed in IDL but required by the program
buy_accounts.append(
AccountMeta(
pubkey=accounts_info["system_program"],
is_signer=False,
is_writable=False,
)
) # #16: System Program
buy_accounts.append(
AccountMeta(
pubkey=accounts_info["platform_fee_vault"],
is_signer=False,
is_writable=True,
)
) # #17: Platform fee vault
if "creator_fee_vault" in accounts_info:
buy_accounts.append(
AccountMeta(
pubkey=accounts_info["creator_fee_vault"],
is_signer=False,
is_writable=True,
)
) # #18: Creator fee vault
# Build instruction data: discriminator + amount_in + minimum_amount_out + share_fee_rate
SHARE_FEE_RATE = 0 # No sharing fee
instruction_data = (
@@ -244,7 +268,7 @@ class LetsBonkInstructionBuilder(InstructionBuilder):
# 3. Build sell_exact_in instruction with correct account ordering
sell_accounts = [
AccountMeta(pubkey=user, is_signer=True, is_writable=True), # payer
AccountMeta(pubkey=user, is_signer=True, is_writable=False), # payer
AccountMeta(
pubkey=accounts_info["authority"], is_signer=False, is_writable=False
), # authority
@@ -297,6 +321,31 @@ class LetsBonkInstructionBuilder(InstructionBuilder):
), # program
]
# Add remaining accounts (required by the program for fee collection)
# These are not explicitly listed in IDL but required by the program
sell_accounts.append(
AccountMeta(
pubkey=accounts_info["system_program"],
is_signer=False,
is_writable=False,
)
) # #16: System Program
sell_accounts.append(
AccountMeta(
pubkey=accounts_info["platform_fee_vault"],
is_signer=False,
is_writable=True,
)
) # #17: Platform fee vault
if "creator_fee_vault" in accounts_info:
sell_accounts.append(
AccountMeta(
pubkey=accounts_info["creator_fee_vault"],
is_signer=False,
is_writable=True,
)
) # #18: Creator fee vault
# Build instruction data: discriminator + amount_in + minimum_amount_out + share_fee_rate
SHARE_FEE_RATE = 0 # No sharing fee
instruction_data = (
@@ -473,7 +522,7 @@ class LetsBonkInstructionBuilder(InstructionBuilder):
if config_override is not None:
return config_override
# Buy operations: ATA creation + WSOL creation/init/close + buy instruction
return 100_000
return 150_000
def get_sell_compute_unit_limit(self, config_override: int | None = None) -> int:
"""Get the recommended compute unit limit for LetsBonk sell operations.
@@ -487,4 +536,4 @@ class LetsBonkInstructionBuilder(InstructionBuilder):
if config_override is not None:
return config_override
# Sell operations: WSOL creation/init/close + sell instruction
return 60_000
return 150_000