mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-08-17 09:18:05 +00:00
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:
@@ -23,11 +23,22 @@ class LetsBonkAddresses:
|
||||
PROGRAM: Final[Pubkey] = Pubkey.from_string(
|
||||
"LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"
|
||||
)
|
||||
# NOTE: GLOBAL_CONFIG is NOT constant across all pools!
|
||||
# Each pool can be initialized with different global_config values. Different global_configs
|
||||
# may define different program-wide settings, versions, or operational parameters.
|
||||
# The correct global_config for each pool is extracted during pool initialization
|
||||
# and stored in TokenInfo.global_config. This value below is a default, used as a fallback.
|
||||
GLOBAL_CONFIG: Final[Pubkey] = Pubkey.from_string(
|
||||
"6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX"
|
||||
)
|
||||
# NOTE: PLATFORM_CONFIG is NOT constant across all pools!
|
||||
# Each pool is initialized with a specific platform_config that defines its fee structure,
|
||||
# launch restrictions, and other settings. Different pools may use different platform_configs
|
||||
# (e.g., standard launches vs partner launches). The correct platform_config for each pool
|
||||
# is extracted during pool initialization and stored in TokenInfo.platform_config.
|
||||
# This value below is the default/most common platform_config, used as a fallback.
|
||||
PLATFORM_CONFIG: Final[Pubkey] = Pubkey.from_string(
|
||||
"FfYek5vEz23cMkWsdJwG2oa6EphsvXSHrGpdALN4g6W1"
|
||||
"5thqcDwKp5QQ8US4XRMoseGeGbmLKMmoKZmS6zHrQAsA"
|
||||
)
|
||||
|
||||
|
||||
@@ -212,6 +223,53 @@ class LetsBonkAddressProvider(AddressProvider):
|
||||
)
|
||||
return event_authority_pda
|
||||
|
||||
def derive_creator_fee_vault(
|
||||
self, creator: Pubkey, quote_mint: Pubkey | None = None
|
||||
) -> Pubkey:
|
||||
"""Derive the creator fee vault PDA.
|
||||
|
||||
This vault accumulates creator fees from trades.
|
||||
|
||||
Args:
|
||||
creator: The pool creator's pubkey
|
||||
quote_mint: The quote token mint (defaults to WSOL)
|
||||
|
||||
Returns:
|
||||
Creator fee vault address
|
||||
"""
|
||||
if quote_mint is None:
|
||||
quote_mint = SystemAddresses.SOL_MINT
|
||||
|
||||
creator_fee_vault, _ = Pubkey.find_program_address(
|
||||
[bytes(creator), bytes(quote_mint)], LetsBonkAddresses.PROGRAM
|
||||
)
|
||||
return creator_fee_vault
|
||||
|
||||
def derive_platform_fee_vault(
|
||||
self, platform_config: Pubkey | None = None, quote_mint: Pubkey | None = None
|
||||
) -> Pubkey:
|
||||
"""Derive the platform fee vault PDA.
|
||||
|
||||
This vault accumulates platform fees from trades.
|
||||
|
||||
Args:
|
||||
platform_config: The platform config account (defaults to LetsBonk config)
|
||||
quote_mint: The quote token mint (defaults to WSOL)
|
||||
|
||||
Returns:
|
||||
Platform fee vault address
|
||||
"""
|
||||
if platform_config is None:
|
||||
platform_config = LetsBonkAddresses.PLATFORM_CONFIG
|
||||
|
||||
if quote_mint is None:
|
||||
quote_mint = SystemAddresses.SOL_MINT
|
||||
|
||||
platform_fee_vault, _ = Pubkey.find_program_address(
|
||||
[bytes(platform_config), bytes(quote_mint)], LetsBonkAddresses.PROGRAM
|
||||
)
|
||||
return platform_fee_vault
|
||||
|
||||
def create_wsol_account_with_seed(self, payer: Pubkey, seed: str) -> Pubkey:
|
||||
"""Create a WSOL account address using createAccountWithSeed pattern.
|
||||
|
||||
@@ -238,11 +296,25 @@ class LetsBonkAddressProvider(AddressProvider):
|
||||
"""
|
||||
additional_accounts = self.get_additional_accounts(token_info)
|
||||
|
||||
return {
|
||||
# Use global_config from TokenInfo if available, otherwise use default
|
||||
global_config = (
|
||||
token_info.global_config
|
||||
if token_info.global_config
|
||||
else LetsBonkAddresses.GLOBAL_CONFIG
|
||||
)
|
||||
|
||||
# Use platform_config from TokenInfo if available, otherwise use default
|
||||
platform_config = (
|
||||
token_info.platform_config
|
||||
if token_info.platform_config
|
||||
else LetsBonkAddresses.PLATFORM_CONFIG
|
||||
)
|
||||
|
||||
accounts = {
|
||||
"payer": user,
|
||||
"authority": additional_accounts["authority"],
|
||||
"global_config": LetsBonkAddresses.GLOBAL_CONFIG,
|
||||
"platform_config": LetsBonkAddresses.PLATFORM_CONFIG,
|
||||
"global_config": global_config,
|
||||
"platform_config": platform_config,
|
||||
"pool_state": additional_accounts["pool_state"],
|
||||
"user_base_token": self.derive_user_token_account(user, token_info.mint),
|
||||
"base_vault": additional_accounts["base_vault"],
|
||||
@@ -253,8 +325,18 @@ class LetsBonkAddressProvider(AddressProvider):
|
||||
"quote_token_program": SystemAddresses.TOKEN_PROGRAM,
|
||||
"event_authority": additional_accounts["event_authority"],
|
||||
"program": LetsBonkAddresses.PROGRAM,
|
||||
"system_program": SystemAddresses.SYSTEM_PROGRAM,
|
||||
"platform_fee_vault": self.derive_platform_fee_vault(platform_config),
|
||||
}
|
||||
|
||||
# Add creator fee vault if creator is known
|
||||
if token_info.creator:
|
||||
accounts["creator_fee_vault"] = self.derive_creator_fee_vault(
|
||||
token_info.creator
|
||||
)
|
||||
|
||||
return accounts
|
||||
|
||||
def get_sell_instruction_accounts(
|
||||
self, token_info: TokenInfo, user: Pubkey
|
||||
) -> dict[str, Pubkey]:
|
||||
@@ -269,11 +351,25 @@ class LetsBonkAddressProvider(AddressProvider):
|
||||
"""
|
||||
additional_accounts = self.get_additional_accounts(token_info)
|
||||
|
||||
return {
|
||||
# Use global_config from TokenInfo if available, otherwise use default
|
||||
global_config = (
|
||||
token_info.global_config
|
||||
if token_info.global_config
|
||||
else LetsBonkAddresses.GLOBAL_CONFIG
|
||||
)
|
||||
|
||||
# Use platform_config from TokenInfo if available, otherwise use default
|
||||
platform_config = (
|
||||
token_info.platform_config
|
||||
if token_info.platform_config
|
||||
else LetsBonkAddresses.PLATFORM_CONFIG
|
||||
)
|
||||
|
||||
accounts = {
|
||||
"payer": user,
|
||||
"authority": additional_accounts["authority"],
|
||||
"global_config": LetsBonkAddresses.GLOBAL_CONFIG,
|
||||
"platform_config": LetsBonkAddresses.PLATFORM_CONFIG,
|
||||
"global_config": global_config,
|
||||
"platform_config": platform_config,
|
||||
"pool_state": additional_accounts["pool_state"],
|
||||
"user_base_token": self.derive_user_token_account(user, token_info.mint),
|
||||
"base_vault": additional_accounts["base_vault"],
|
||||
@@ -284,8 +380,18 @@ class LetsBonkAddressProvider(AddressProvider):
|
||||
"quote_token_program": SystemAddresses.TOKEN_PROGRAM,
|
||||
"event_authority": additional_accounts["event_authority"],
|
||||
"program": LetsBonkAddresses.PROGRAM,
|
||||
"system_program": SystemAddresses.SYSTEM_PROGRAM,
|
||||
"platform_fee_vault": self.derive_platform_fee_vault(platform_config),
|
||||
}
|
||||
|
||||
# Add creator fee vault if creator is known
|
||||
if token_info.creator:
|
||||
accounts["creator_fee_vault"] = self.derive_creator_fee_vault(
|
||||
token_info.creator
|
||||
)
|
||||
|
||||
return accounts
|
||||
|
||||
def get_wsol_account_creation_accounts(
|
||||
self, user: Pubkey, wsol_account: Pubkey
|
||||
) -> dict[str, Pubkey]:
|
||||
|
||||
Reference in New Issue
Block a user