fix: skip 8-byte discriminator when decoding PumpSwap pool data
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 可能不为空但解码全部失败)
|
||||
|
||||
Reference in New Issue
Block a user