diff --git a/learning-examples/manual_buy.py b/learning-examples/manual_buy.py index 05cbeff..9a2c889 100644 --- a/learning-examples/manual_buy.py +++ b/learning-examples/manual_buy.py @@ -159,6 +159,14 @@ def _find_fee_config() -> Pubkey: return derived_address +def _find_bonding_curve_v2(mint: Pubkey) -> Pubkey: + derived_address, _ = Pubkey.find_program_address( + [b"bonding-curve-v2", bytes(mint)], + PUMP_PROGRAM, + ) + return derived_address + + async def get_fee_recipient( client: AsyncClient, curve_state: BondingCurveState ) -> Pubkey: @@ -253,9 +261,7 @@ async def buy_token( ), AccountMeta(pubkey=payer.pubkey(), is_signer=True, is_writable=True), AccountMeta(pubkey=SYSTEM_PROGRAM, is_signer=False, is_writable=False), - AccountMeta( - pubkey=token_program, is_signer=False, is_writable=False - ), + AccountMeta(pubkey=token_program, is_signer=False, is_writable=False), AccountMeta(pubkey=creator_vault, is_signer=False, is_writable=True), AccountMeta( pubkey=PUMP_EVENT_AUTHORITY, is_signer=False, is_writable=False @@ -283,6 +289,12 @@ async def buy_token( is_signer=False, is_writable=False, ), + # Remaining account: bonding_curve_v2 (readonly, required for all coins) + AccountMeta( + pubkey=_find_bonding_curve_v2(mint), + is_signer=False, + is_writable=False, + ), ] discriminator = struct.pack(" Pubkey: return derived_address +def _find_bonding_curve_v2(mint: Pubkey) -> Pubkey: + derived_address, _ = Pubkey.find_program_address( + [b"bonding-curve-v2", bytes(mint)], + PUMP_PROGRAM, + ) + return derived_address + + async def get_fee_recipient( client: AsyncClient, curve_state: BondingCurveState ) -> Pubkey: @@ -291,9 +299,7 @@ async def buy_token( ), AccountMeta(pubkey=payer.pubkey(), is_signer=True, is_writable=True), AccountMeta(pubkey=SYSTEM_PROGRAM, is_signer=False, is_writable=False), - AccountMeta( - pubkey=token_program, is_signer=False, is_writable=False - ), + AccountMeta(pubkey=token_program, is_signer=False, is_writable=False), AccountMeta(pubkey=creator_vault, is_signer=False, is_writable=True), AccountMeta( pubkey=PUMP_EVENT_AUTHORITY, is_signer=False, is_writable=False @@ -321,6 +327,12 @@ async def buy_token( is_signer=False, is_writable=False, ), + # Remaining account: bonding_curve_v2 (readonly, required for all coins) + AccountMeta( + pubkey=_find_bonding_curve_v2(mint), + is_signer=False, + is_writable=False, + ), ] discriminator = struct.pack(" Pubkey: return derived_address +def _find_bonding_curve_v2(mint: Pubkey) -> Pubkey: + derived_address, _ = Pubkey.find_program_address( + [b"bonding-curve-v2", bytes(mint)], + PUMP_PROGRAM, + ) + return derived_address + + async def get_fee_recipient( client: AsyncClient, curve_state: BondingCurveState ) -> Pubkey: @@ -328,7 +336,7 @@ async def listen_for_create_transaction_geyser(): # Add token program info to decoded args token_data["token_program"] = str(token_program) - token_data["is_token_2022"] = (token_program == SYSTEM_TOKEN_2022_PROGRAM) + token_data["is_token_2022"] = token_program == SYSTEM_TOKEN_2022_PROGRAM signature = base58.b58encode( bytes(update.transaction.transaction.signature) @@ -391,9 +399,7 @@ async def buy_token( ), AccountMeta(pubkey=payer.pubkey(), is_signer=True, is_writable=True), AccountMeta(pubkey=SYSTEM_PROGRAM, is_signer=False, is_writable=False), - AccountMeta( - pubkey=token_program, is_signer=False, is_writable=False - ), + AccountMeta(pubkey=token_program, is_signer=False, is_writable=False), AccountMeta(pubkey=creator_vault, is_signer=False, is_writable=True), AccountMeta( pubkey=PUMP_EVENT_AUTHORITY, is_signer=False, is_writable=False @@ -421,6 +427,12 @@ async def buy_token( is_signer=False, is_writable=False, ), + # Remaining account: bonding_curve_v2 (readonly, required for all coins) + AccountMeta( + pubkey=_find_bonding_curve_v2(mint), + is_signer=False, + is_writable=False, + ), ] discriminator = struct.pack(" Pubkey: return derived_address +def _find_bonding_curve_v2(mint: Pubkey) -> Pubkey: + derived_address, _ = Pubkey.find_program_address( + [b"bonding-curve-v2", bytes(mint)], + PUMP_PROGRAM, + ) + return derived_address + + async def get_fee_recipient( client: AsyncClient, curve_state: BondingCurveState ) -> Pubkey: @@ -312,6 +320,12 @@ async def sell_token( is_signer=False, is_writable=False, ), + # Remaining account: bonding_curve_v2 (readonly, required for all coins) + AccountMeta( + pubkey=_find_bonding_curve_v2(mint), + is_signer=False, + is_writable=False, + ), ] discriminator = struct.pack(" Pubkey: return derived_address +def _find_bonding_curve_v2(mint: Pubkey) -> Pubkey: + derived_address, _ = Pubkey.find_program_address( + [b"bonding-curve-v2", bytes(mint)], + PUMP_PROGRAM, + ) + return derived_address + + def create_pump_create_instruction( mint: Pubkey, mint_authority: Pubkey, @@ -263,6 +271,12 @@ def create_buy_instruction( is_signer=False, is_writable=False, ), + # Remaining account: bonding_curve_v2 (readonly, required for all coins) + AccountMeta( + pubkey=_find_bonding_curve_v2(mint), + is_signer=False, + is_writable=False, + ), ] # Encode OptionBool for track_volume diff --git a/learning-examples/mint_and_buy_v2.py b/learning-examples/mint_and_buy_v2.py index e41d2b9..ffbefe8 100644 --- a/learning-examples/mint_and_buy_v2.py +++ b/learning-examples/mint_and_buy_v2.py @@ -159,6 +159,14 @@ def _find_fee_config() -> Pubkey: return derived_address +def _find_bonding_curve_v2(mint: Pubkey) -> Pubkey: + derived_address, _ = Pubkey.find_program_address( + [b"bonding-curve-v2", bytes(mint)], + PUMP_PROGRAM, + ) + return derived_address + + def create_pump_create_v2_instruction( mint: Pubkey, mint_authority: Pubkey, @@ -307,6 +315,12 @@ def create_buy_instruction( is_signer=False, is_writable=False, ), + # Remaining account: bonding_curve_v2 (readonly, required for all coins) + AccountMeta( + pubkey=_find_bonding_curve_v2(mint), + is_signer=False, + is_writable=False, + ), ] # Encode OptionBool for track_volume