From 322acf8bafef616db520bea78697f9737a969216 Mon Sep 17 00:00:00 2001 From: vibes Date: Wed, 25 Mar 2026 12:28:23 +0000 Subject: [PATCH] Fix getProgramAccounts missing Token2022 pools (643 bytes vs 252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DataSize(252) filter rejects Token2022 PumpSwap pools which are 643 bytes. This causes find_by_mint to miss pools that already exist on-chain, leading to unnecessary 45s+ wait loops during migration detection. Remove the DataSize filter from find_by_base_mint and find_by_quote_mint — the Memcmp filter on program-owned accounts is specific enough. Also add diagnostic logging on find_by_mint failure for debugging. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/instruction/utils/pumpswap.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/instruction/utils/pumpswap.rs b/src/instruction/utils/pumpswap.rs index 6ec0c41..5d3ab8a 100644 --- a/src/instruction/utils/pumpswap.rs +++ b/src/instruction/utils/pumpswap.rs @@ -307,8 +307,8 @@ pub async fn find_by_base_mint( ) -> Result<(Pubkey, Pool), anyhow::Error> { // Use getProgramAccounts to find pools for the given mint. // base_mint 在账户布局中的偏移:8(discriminator) + 1(bump) + 2(index) + 32(creator) = 43 + // No DataSize filter: Token2022 pools are 643 bytes vs 252 for SPL Token pools let filters = vec![ - solana_rpc_client_api::filter::RpcFilterType::DataSize(POOL_ACCOUNT_DATA_LEN), solana_rpc_client_api::filter::RpcFilterType::Memcmp( solana_client::rpc_filter::Memcmp::new_base58_encoded(43, base_mint.as_ref()), ), @@ -363,8 +363,8 @@ pub async fn find_by_quote_mint( ) -> Result<(Pubkey, Pool), anyhow::Error> { // Use getProgramAccounts to find pools for the given mint. // quote_mint 在账户布局中的偏移:8 + 1 + 2 + 32 + 32 = 75 + // No DataSize filter: Token2022 pools are 643 bytes vs 252 for SPL Token pools let filters = vec![ - solana_rpc_client_api::filter::RpcFilterType::DataSize(POOL_ACCOUNT_DATA_LEN), solana_rpc_client_api::filter::RpcFilterType::Memcmp( solana_client::rpc_filter::Memcmp::new_base58_encoded(75, quote_mint.as_ref()), ), @@ -454,10 +454,12 @@ pub async fn find_by_mint( Err(e) => diag.push(format!("getProgramAccounts(quote_mint): {}", e)), } + let diag_str = diag.join("; "); + eprintln!("[find_by_mint] {} failed: {}", mint, diag_str); Err(anyhow!( - "No pool found for mint {}. 诊断: {}。若使用自建 RPC 请确认已开启 getProgramAccounts 或换用公共 RPC 重试;若代币未在 PumpSwap 建池请先在 pump.fun/DEX 上确认", + "No pool found for mint {}. diag: {}", mint, - diag.join("; ") + diag_str )) }