fix pumpfun wsol quote normalization

This commit is contained in:
0xfnzero
2026-06-08 03:13:04 +08:00
parent aa065e7cae
commit e263caa75d
3 changed files with 60 additions and 12 deletions
@@ -1,10 +1,22 @@
#![allow(clippy::single_match)]
use crate::streaming::event_parser::DexEvent;
use sol_parser_sdk::core::events::normalize_pumpfun_quote_mint as normalize_sdk_pumpfun_quote_mint;
use solana_sdk::{pubkey, pubkey::Pubkey};
const PUMPFUN_SOLSCAN_SOL_QUOTE_MINT: Pubkey =
pubkey!("So11111111111111111111111111111111111111111");
const PUMPFUN_WSOL_QUOTE_MINT: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
#[inline]
fn normalize_pumpfun_quote_mint(quote_mint: Pubkey) -> Pubkey {
let quote_mint = normalize_sdk_pumpfun_quote_mint(quote_mint);
if quote_mint == PUMPFUN_WSOL_QUOTE_MINT {
PUMPFUN_SOLSCAN_SOL_QUOTE_MINT
} else {
quote_mint
}
}
#[inline]
fn fill_pubkey(to: &mut Pubkey, from: Pubkey) {
@@ -13,15 +25,6 @@ fn fill_pubkey(to: &mut Pubkey, from: Pubkey) {
}
}
#[inline]
fn normalize_pumpfun_quote_mint(quote_mint: Pubkey) -> Pubkey {
if quote_mint == Pubkey::default() {
PUMPFUN_SOLSCAN_SOL_QUOTE_MINT
} else {
quote_mint
}
}
#[inline]
fn fill_pumpfun_quote_mint(to: &mut Pubkey, from: Pubkey) {
let from = normalize_pumpfun_quote_mint(from);
@@ -927,4 +930,25 @@ mod tests {
_ => panic!("expected PumpFunTradeEvent"),
}
}
#[test]
fn pumpfun_merge_treats_wsol_quote_as_sol_sentinel() {
let mut instruction_event = DexEvent::PumpFunTradeEvent(PumpFunTradeEvent {
quote_mint: PUMPFUN_SOLSCAN_SOL_QUOTE_MINT,
..Default::default()
});
let cpi_log_event = DexEvent::PumpFunTradeEvent(PumpFunTradeEvent {
quote_mint: PUMPFUN_WSOL_QUOTE_MINT,
..Default::default()
});
merge(&mut instruction_event, cpi_log_event);
match instruction_event {
DexEvent::PumpFunTradeEvent(t) => {
assert_eq!(t.quote_mint, PUMPFUN_SOLSCAN_SOL_QUOTE_MINT)
}
_ => panic!("expected PumpFunTradeEvent"),
}
}
}