From bda9099275d4ae5f87460a13d9e28a8fc5b95b23 Mon Sep 17 00:00:00 2001 From: Anton Sauchyk Date: Mon, 27 Apr 2026 19:52:41 +0200 Subject: [PATCH] chore(examples): accept argv override and bump RPC timeouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three small ergonomic fixes uncovered while running every learning example end-to-end: copytrading/listen_wallet_transactions.py Was hardcoded to WALLET_TO_TRACK = "...". Now accepts argv[1] so you can run it without editing the file. pumpswap/get_pumpswap_pools.py Same pattern (TOKEN_MINT placeholder) and the underlying getProgramAccounts call would also time out at the default 30s on busy mainnet RPCs — bumped both AsyncClient timeouts to 120s. bonding-curve-progress/get_graduating_tokens.py Bumped RPC timeout 120s → 240s for the same reason. The threshold scan over all pump.fun bonding curves still occasionally exceeds even that on overloaded RPCs (it's a known-heavy query); a smaller threshold or memcmp-narrowed filter is the proper long-term fix. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../bonding-curve-progress/get_graduating_tokens.py | 2 +- .../copytrading/listen_wallet_transactions.py | 2 +- learning-examples/pumpswap/get_pumpswap_pools.py | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/learning-examples/bonding-curve-progress/get_graduating_tokens.py b/learning-examples/bonding-curve-progress/get_graduating_tokens.py index f97f708..56fb4f3 100644 --- a/learning-examples/bonding-curve-progress/get_graduating_tokens.py +++ b/learning-examples/bonding-curve-progress/get_graduating_tokens.py @@ -141,7 +141,7 @@ def get_mint_address(data: bytes) -> str: async def main() -> None: """Main entry point for querying and processing bonding curves.""" - async with AsyncClient(RPC_ENDPOINT, commitment="processed", timeout=120) as client: + async with AsyncClient(RPC_ENDPOINT, commitment="processed", timeout=240) as client: await client.is_connected() bonding_curves = await get_bonding_curves_by_reserves(client) diff --git a/learning-examples/copytrading/listen_wallet_transactions.py b/learning-examples/copytrading/listen_wallet_transactions.py index 777e966..7c2bad2 100644 --- a/learning-examples/copytrading/listen_wallet_transactions.py +++ b/learning-examples/copytrading/listen_wallet_transactions.py @@ -21,7 +21,7 @@ load_dotenv() # Configuration WSS_ENDPOINT = os.environ.get("SOLANA_NODE_WSS_ENDPOINT") -WALLET_TO_TRACK = "..." # Change this to your target wallet +WALLET_TO_TRACK = sys.argv[1] if len(sys.argv) > 1 else "..." # Pass wallet as argv[1] or hardcode # Pump.fun program constants PUMP_BONDING_CURVE_PROGRAM_ID = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P" diff --git a/learning-examples/pumpswap/get_pumpswap_pools.py b/learning-examples/pumpswap/get_pumpswap_pools.py index c6bded3..101bc64 100644 --- a/learning-examples/pumpswap/get_pumpswap_pools.py +++ b/learning-examples/pumpswap/get_pumpswap_pools.py @@ -18,13 +18,15 @@ load_dotenv() RPC_ENDPOINT = os.environ.get("SOLANA_NODE_RPC_ENDPOINT") PUMP_AMM_PROGRAM_ID = Pubkey.from_string("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA") -TOKEN_MINT = Pubkey.from_string("...") +import sys + +TOKEN_MINT = Pubkey.from_string(sys.argv[1] if len(sys.argv) > 1 else "...") # argv[1] or hardcode async def get_market_address_by_base_mint( base_mint_address: Pubkey, amm_program_id: Pubkey ): - async with AsyncClient(RPC_ENDPOINT) as client: + async with AsyncClient(RPC_ENDPOINT, timeout=120) as client: base_mint_bytes = bytes(base_mint_address) # Define the offset for base_mint field @@ -45,7 +47,7 @@ async def get_market_address_by_base_mint( async def get_market_data(market_address: Pubkey): - async with AsyncClient(RPC_ENDPOINT) as client: + async with AsyncClient(RPC_ENDPOINT, timeout=120) as client: response = await client.get_account_info(market_address, encoding="base64") data = response.value.data parsed_data = {}