mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-08-17 09:18:05 +00:00
feat(examples): update bonding curve buy instructions
This commit is contained in:
@@ -104,6 +104,27 @@ def _find_creator_vault(creator: Pubkey) -> Pubkey:
|
|||||||
return derived_address
|
return derived_address
|
||||||
|
|
||||||
|
|
||||||
|
def _find_global_volume_accumulator() -> Pubkey:
|
||||||
|
derived_address, _ = Pubkey.find_program_address(
|
||||||
|
[
|
||||||
|
b"global_volume_accumulator"
|
||||||
|
],
|
||||||
|
PUMP_PROGRAM,
|
||||||
|
)
|
||||||
|
return derived_address
|
||||||
|
|
||||||
|
|
||||||
|
def _find_user_volume_accumulator(user: Pubkey) -> Pubkey:
|
||||||
|
derived_address, _ = Pubkey.find_program_address(
|
||||||
|
[
|
||||||
|
b"user_volume_accumulator",
|
||||||
|
bytes(user)
|
||||||
|
],
|
||||||
|
PUMP_PROGRAM,
|
||||||
|
)
|
||||||
|
return derived_address
|
||||||
|
|
||||||
|
|
||||||
async def buy_token(
|
async def buy_token(
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
bonding_curve: Pubkey,
|
bonding_curve: Pubkey,
|
||||||
@@ -153,6 +174,8 @@ async def buy_token(
|
|||||||
pubkey=PUMP_EVENT_AUTHORITY, is_signer=False, is_writable=False
|
pubkey=PUMP_EVENT_AUTHORITY, is_signer=False, is_writable=False
|
||||||
),
|
),
|
||||||
AccountMeta(pubkey=PUMP_PROGRAM, is_signer=False, is_writable=False),
|
AccountMeta(pubkey=PUMP_PROGRAM, is_signer=False, is_writable=False),
|
||||||
|
AccountMeta(pubkey=_find_global_volume_accumulator(), is_signer=False, is_writable=True),
|
||||||
|
AccountMeta(pubkey=_find_user_volume_accumulator(payer.pubkey()), is_signer=False, is_writable=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
discriminator = struct.pack("<Q", 16927863322537952870)
|
discriminator = struct.pack("<Q", 16927863322537952870)
|
||||||
|
|||||||
@@ -101,6 +101,27 @@ def find_creator_vault(creator: Pubkey) -> Pubkey:
|
|||||||
return derived_address
|
return derived_address
|
||||||
|
|
||||||
|
|
||||||
|
def _find_global_volume_accumulator() -> Pubkey:
|
||||||
|
derived_address, _ = Pubkey.find_program_address(
|
||||||
|
[
|
||||||
|
b"global_volume_accumulator"
|
||||||
|
],
|
||||||
|
PUMP_PROGRAM,
|
||||||
|
)
|
||||||
|
return derived_address
|
||||||
|
|
||||||
|
|
||||||
|
def _find_user_volume_accumulator(user: Pubkey) -> Pubkey:
|
||||||
|
derived_address, _ = Pubkey.find_program_address(
|
||||||
|
[
|
||||||
|
b"user_volume_accumulator",
|
||||||
|
bytes(user)
|
||||||
|
],
|
||||||
|
PUMP_PROGRAM,
|
||||||
|
)
|
||||||
|
return derived_address
|
||||||
|
|
||||||
|
|
||||||
def create_pump_create_instruction(
|
def create_pump_create_instruction(
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
mint_authority: Pubkey,
|
mint_authority: Pubkey,
|
||||||
@@ -177,6 +198,8 @@ def create_buy_instruction(
|
|||||||
AccountMeta(pubkey=creator_vault, is_signer=False, is_writable=True),
|
AccountMeta(pubkey=creator_vault, is_signer=False, is_writable=True),
|
||||||
AccountMeta(pubkey=PUMP_EVENT_AUTHORITY, is_signer=False, is_writable=False),
|
AccountMeta(pubkey=PUMP_EVENT_AUTHORITY, is_signer=False, is_writable=False),
|
||||||
AccountMeta(pubkey=PUMP_PROGRAM, is_signer=False, is_writable=False),
|
AccountMeta(pubkey=PUMP_PROGRAM, is_signer=False, is_writable=False),
|
||||||
|
AccountMeta(pubkey=_find_global_volume_accumulator(), is_signer=False, is_writable=True),
|
||||||
|
AccountMeta(pubkey=_find_user_volume_accumulator(user), is_signer=False, is_writable=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
|
|||||||
Reference in New Issue
Block a user