diff --git a/learning-examples/manual_buy_geyser.py b/learning-examples/manual_buy_geyser.py index 42d07cb..a43ec99 100644 --- a/learning-examples/manual_buy_geyser.py +++ b/learning-examples/manual_buy_geyser.py @@ -344,6 +344,11 @@ async def listen_for_create_transaction_geyser(): else: continue + # Skip txs whose create ix references ALT-loaded accounts not in + # msg.account_keys (indices >= len(msg.account_keys)). + if any(idx >= len(msg.account_keys) for idx in ix.accounts): + continue + # Found a create instruction token_data = decode_create_instruction_geyser( ix.data, msg.account_keys, ix.accounts @@ -513,9 +518,9 @@ async def main(): print("New token created:") print(json.dumps(token_data, indent=2)) - # sleep_duration_sec = 15 - # print(f"Waiting for {sleep_duration_sec} seconds for things to stabilize...") - # await asyncio.sleep(sleep_duration_sec) + sleep_duration_sec = 15 + print(f"Waiting {sleep_duration_sec}s for the bonding curve account to propagate...") + await asyncio.sleep(sleep_duration_sec) mint = Pubkey.from_string(token_data["mint"]) bonding_curve = Pubkey.from_string(token_data["bondingCurve"]) diff --git a/learning-examples/pumpswap/manual_buy_pumpswap.py b/learning-examples/pumpswap/manual_buy_pumpswap.py index 85b4b70..fc3c671 100644 --- a/learning-examples/pumpswap/manual_buy_pumpswap.py +++ b/learning-examples/pumpswap/manual_buy_pumpswap.py @@ -283,6 +283,16 @@ def find_fee_config() -> Pubkey: return derived_address +def find_pool_v2(base_mint: Pubkey) -> Pubkey: + """Derive the PDA for the pool-v2 account (per-base-mint), required as the + last "pre-upgrade" account on every pump-swap buy/sell.""" + derived_address, _ = Pubkey.find_program_address( + [b"pool-v2", bytes(base_mint)], + PUMP_AMM_PROGRAM_ID, + ) + return derived_address + + # ============================================================================ # Mayhem Mode Fee Handling # ============================================================================ @@ -518,6 +528,8 @@ async def buy_pump_swap( AccountMeta(pubkey=user_volume_accumulator, is_signer=False, is_writable=True), AccountMeta(pubkey=find_fee_config(), is_signer=False, is_writable=False), AccountMeta(pubkey=PUMP_FEE_PROGRAM, is_signer=False, is_writable=False), + # pool-v2 PDA (per-base-mint) — the last "pre-upgrade" account. + AccountMeta(pubkey=find_pool_v2(base_mint), is_signer=False, is_writable=False), ] # 2 new accounts required from 2026-04-28 16:00 UTC pump-swap program upgrade, # AFTER pool-v2: breaking-upgrade fee recipient (readonly, second-to-last) and @@ -643,9 +655,9 @@ async def buy_pump_swap( async def main() -> None: """Execute the complete buy flow.""" - sol_amount_to_spend = 0.000001 # Amount of SOL to spend on the purchase + sol_amount_to_spend = 0.001 # Amount of SOL to spend on the purchase - async with AsyncClient(RPC_ENDPOINT) as client: + async with AsyncClient(RPC_ENDPOINT, timeout=120) as client: # Step 1: Find the pool address for our token market_address = await get_market_address_by_base_mint( client, TOKEN_MINT, PUMP_AMM_PROGRAM_ID diff --git a/learning-examples/pumpswap/manual_sell_pumpswap.py b/learning-examples/pumpswap/manual_sell_pumpswap.py index b9e175c..7b126da 100644 --- a/learning-examples/pumpswap/manual_sell_pumpswap.py +++ b/learning-examples/pumpswap/manual_sell_pumpswap.py @@ -236,6 +236,16 @@ def find_fee_config() -> Pubkey: return derived_address +def find_pool_v2(base_mint: Pubkey) -> Pubkey: + """Derive the PDA for the pool-v2 account (per-base-mint), required as the + last "pre-upgrade" account on every pump-swap buy/sell.""" + derived_address, _ = Pubkey.find_program_address( + [b"pool-v2", bytes(base_mint)], + PUMP_AMM_PROGRAM_ID, + ) + return derived_address + + # ============================================================================ # Mayhem Mode Fee Handling # ============================================================================ @@ -506,6 +516,8 @@ async def sell_pump_swap( ), AccountMeta(pubkey=find_fee_config(), is_signer=False, is_writable=False), AccountMeta(pubkey=PUMP_FEE_PROGRAM, is_signer=False, is_writable=False), + # pool-v2 PDA (per-base-mint) — the last "pre-upgrade" account. + AccountMeta(pubkey=find_pool_v2(base_mint), is_signer=False, is_writable=False), ] # 2 new accounts required from 2026-04-28 16:00 UTC pump-swap program upgrade, # AFTER pool-v2: breaking-upgrade fee recipient (readonly, second-to-last) and @@ -571,7 +583,7 @@ async def sell_pump_swap( async def main() -> None: """Execute the complete sell flow.""" - async with AsyncClient(RPC_ENDPOINT) as client: + async with AsyncClient(RPC_ENDPOINT, timeout=120) as client: # Step 1: Find the pool address for our token market_address = await get_market_address_by_base_mint( client, TOKEN_MINT, PUMP_AMM_PROGRAM_ID