From ae2958995f42da19b2985e2bab09e531f2bbc086 Mon Sep 17 00:00:00 2001 From: Wood Date: Fri, 12 Dec 2025 15:37:24 +0800 Subject: [PATCH] fix: skip 8-byte discriminator when decoding PumpSwap pool data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a critical bug in find_by_base_mint and find_by_quote_mint functions where pool data decoding failed because the 8-byte discriminator was not being skipped. This caused all PumpSwapParams::from_mint_by_rpc calls to fail with "No valid pool decoded" error. Changes: - Modified find_by_base_mint to skip discriminator: pool_decode(&acc.data[8..]) - Modified find_by_quote_mint to skip discriminator: pool_decode(&acc.data[8..]) - Added data length check to prevent out-of-bounds access - Aligned with fetch_pool function which correctly uses &account.data[8..] 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/instruction/utils/pumpswap.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/instruction/utils/pumpswap.rs b/src/instruction/utils/pumpswap.rs index 17977c7..5c466b7 100644 --- a/src/instruction/utils/pumpswap.rs +++ b/src/instruction/utils/pumpswap.rs @@ -233,7 +233,14 @@ pub async fn find_by_base_mint( let accounts_count = accounts.len(); // 🔧 保存长度,因为 into_iter() 会消耗 accounts let mut pools: Vec<_> = accounts .into_iter() - .filter_map(|(addr, acc)| pool_decode(&acc.data).map(|pool| (addr, pool))) + .filter_map(|(addr, acc)| { + // 🔧 修复:跳过8字节的discriminator + if acc.data.len() > 8 { + pool_decode(&acc.data[8..]).map(|pool| (addr, pool)) + } else { + None + } + }) .collect(); // 🔧 修复:检查过滤后的 pools 是否为空(accounts 可能不为空但解码全部失败) @@ -276,7 +283,14 @@ pub async fn find_by_quote_mint( let accounts_count = accounts.len(); // 🔧 保存长度,因为 into_iter() 会消耗 accounts let mut pools: Vec<_> = accounts .into_iter() - .filter_map(|(addr, acc)| pool_decode(&acc.data).map(|pool| (addr, pool))) + .filter_map(|(addr, acc)| { + // 🔧 修复:跳过8字节的discriminator + if acc.data.len() > 8 { + pool_decode(&acc.data[8..]).map(|pool| (addr, pool)) + } else { + None + } + }) .collect(); // 🔧 修复:检查过滤后的 pools 是否为空(accounts 可能不为空但解码全部失败)