@@ -23,11 +23,22 @@ class LetsBonkAddresses:
2323 PROGRAM : Final [Pubkey ] = Pubkey .from_string (
2424 "LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"
2525 )
26+ # NOTE: GLOBAL_CONFIG is NOT constant across all pools!
27+ # Each pool can be initialized with different global_config values. Different global_configs
28+ # may define different program-wide settings, versions, or operational parameters.
29+ # The correct global_config for each pool is extracted during pool initialization
30+ # and stored in TokenInfo.global_config. This value below is a default, used as a fallback.
2631 GLOBAL_CONFIG : Final [Pubkey ] = Pubkey .from_string (
2732 "6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX"
2833 )
34+ # NOTE: PLATFORM_CONFIG is NOT constant across all pools!
35+ # Each pool is initialized with a specific platform_config that defines its fee structure,
36+ # launch restrictions, and other settings. Different pools may use different platform_configs
37+ # (e.g., standard launches vs partner launches). The correct platform_config for each pool
38+ # is extracted during pool initialization and stored in TokenInfo.platform_config.
39+ # This value below is the default/most common platform_config, used as a fallback.
2940 PLATFORM_CONFIG : Final [Pubkey ] = Pubkey .from_string (
30- "FfYek5vEz23cMkWsdJwG2oa6EphsvXSHrGpdALN4g6W1 "
41+ "5thqcDwKp5QQ8US4XRMoseGeGbmLKMmoKZmS6zHrQAsA "
3142 )
3243
3344
@@ -212,6 +223,53 @@ def derive_event_authority_pda(self) -> Pubkey:
212223 )
213224 return event_authority_pda
214225
226+ def derive_creator_fee_vault (
227+ self , creator : Pubkey , quote_mint : Pubkey | None = None
228+ ) -> Pubkey :
229+ """Derive the creator fee vault PDA.
230+
231+ This vault accumulates creator fees from trades.
232+
233+ Args:
234+ creator: The pool creator's pubkey
235+ quote_mint: The quote token mint (defaults to WSOL)
236+
237+ Returns:
238+ Creator fee vault address
239+ """
240+ if quote_mint is None :
241+ quote_mint = SystemAddresses .SOL_MINT
242+
243+ creator_fee_vault , _ = Pubkey .find_program_address (
244+ [bytes (creator ), bytes (quote_mint )], LetsBonkAddresses .PROGRAM
245+ )
246+ return creator_fee_vault
247+
248+ def derive_platform_fee_vault (
249+ self , platform_config : Pubkey | None = None , quote_mint : Pubkey | None = None
250+ ) -> Pubkey :
251+ """Derive the platform fee vault PDA.
252+
253+ This vault accumulates platform fees from trades.
254+
255+ Args:
256+ platform_config: The platform config account (defaults to LetsBonk config)
257+ quote_mint: The quote token mint (defaults to WSOL)
258+
259+ Returns:
260+ Platform fee vault address
261+ """
262+ if platform_config is None :
263+ platform_config = LetsBonkAddresses .PLATFORM_CONFIG
264+
265+ if quote_mint is None :
266+ quote_mint = SystemAddresses .SOL_MINT
267+
268+ platform_fee_vault , _ = Pubkey .find_program_address (
269+ [bytes (platform_config ), bytes (quote_mint )], LetsBonkAddresses .PROGRAM
270+ )
271+ return platform_fee_vault
272+
215273 def create_wsol_account_with_seed (self , payer : Pubkey , seed : str ) -> Pubkey :
216274 """Create a WSOL account address using createAccountWithSeed pattern.
217275
@@ -238,11 +296,25 @@ def get_buy_instruction_accounts(
238296 """
239297 additional_accounts = self .get_additional_accounts (token_info )
240298
241- return {
299+ # Use global_config from TokenInfo if available, otherwise use default
300+ global_config = (
301+ token_info .global_config
302+ if token_info .global_config
303+ else LetsBonkAddresses .GLOBAL_CONFIG
304+ )
305+
306+ # Use platform_config from TokenInfo if available, otherwise use default
307+ platform_config = (
308+ token_info .platform_config
309+ if token_info .platform_config
310+ else LetsBonkAddresses .PLATFORM_CONFIG
311+ )
312+
313+ accounts = {
242314 "payer" : user ,
243315 "authority" : additional_accounts ["authority" ],
244- "global_config" : LetsBonkAddresses . GLOBAL_CONFIG ,
245- "platform_config" : LetsBonkAddresses . PLATFORM_CONFIG ,
316+ "global_config" : global_config ,
317+ "platform_config" : platform_config ,
246318 "pool_state" : additional_accounts ["pool_state" ],
247319 "user_base_token" : self .derive_user_token_account (user , token_info .mint ),
248320 "base_vault" : additional_accounts ["base_vault" ],
@@ -253,8 +325,18 @@ def get_buy_instruction_accounts(
253325 "quote_token_program" : SystemAddresses .TOKEN_PROGRAM ,
254326 "event_authority" : additional_accounts ["event_authority" ],
255327 "program" : LetsBonkAddresses .PROGRAM ,
328+ "system_program" : SystemAddresses .SYSTEM_PROGRAM ,
329+ "platform_fee_vault" : self .derive_platform_fee_vault (platform_config ),
256330 }
257331
332+ # Add creator fee vault if creator is known
333+ if token_info .creator :
334+ accounts ["creator_fee_vault" ] = self .derive_creator_fee_vault (
335+ token_info .creator
336+ )
337+
338+ return accounts
339+
258340 def get_sell_instruction_accounts (
259341 self , token_info : TokenInfo , user : Pubkey
260342 ) -> dict [str , Pubkey ]:
@@ -269,11 +351,25 @@ def get_sell_instruction_accounts(
269351 """
270352 additional_accounts = self .get_additional_accounts (token_info )
271353
272- return {
354+ # Use global_config from TokenInfo if available, otherwise use default
355+ global_config = (
356+ token_info .global_config
357+ if token_info .global_config
358+ else LetsBonkAddresses .GLOBAL_CONFIG
359+ )
360+
361+ # Use platform_config from TokenInfo if available, otherwise use default
362+ platform_config = (
363+ token_info .platform_config
364+ if token_info .platform_config
365+ else LetsBonkAddresses .PLATFORM_CONFIG
366+ )
367+
368+ accounts = {
273369 "payer" : user ,
274370 "authority" : additional_accounts ["authority" ],
275- "global_config" : LetsBonkAddresses . GLOBAL_CONFIG ,
276- "platform_config" : LetsBonkAddresses . PLATFORM_CONFIG ,
371+ "global_config" : global_config ,
372+ "platform_config" : platform_config ,
277373 "pool_state" : additional_accounts ["pool_state" ],
278374 "user_base_token" : self .derive_user_token_account (user , token_info .mint ),
279375 "base_vault" : additional_accounts ["base_vault" ],
@@ -284,8 +380,18 @@ def get_sell_instruction_accounts(
284380 "quote_token_program" : SystemAddresses .TOKEN_PROGRAM ,
285381 "event_authority" : additional_accounts ["event_authority" ],
286382 "program" : LetsBonkAddresses .PROGRAM ,
383+ "system_program" : SystemAddresses .SYSTEM_PROGRAM ,
384+ "platform_fee_vault" : self .derive_platform_fee_vault (platform_config ),
287385 }
288386
387+ # Add creator fee vault if creator is known
388+ if token_info .creator :
389+ accounts ["creator_fee_vault" ] = self .derive_creator_fee_vault (
390+ token_info .creator
391+ )
392+
393+ return accounts
394+
289395 def get_wsol_account_creation_accounts (
290396 self , user : Pubkey , wsol_account : Pubkey
291397 ) -> dict [str , Pubkey ]:
0 commit comments