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"),
}
}
}
@@ -20,6 +20,7 @@ use crate::streaming::event_parser::protocols::pumpswap::events::{
};
use crate::streaming::event_parser::DexEvent;
use prost_types::Timestamp;
use sol_parser_sdk::core::events::normalize_pumpfun_quote_mint as normalize_sdk_pumpfun_quote_mint;
use solana_sdk::{pubkey, pubkey::Pubkey};
use super::adapt::adapt_pm;
@@ -27,10 +28,12 @@ use super::program_ids::{pump_program, pumpswap_program};
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 {
if quote_mint == Pubkey::default() {
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
@@ -858,4 +861,25 @@ mod tests {
_ => panic!("expected PumpFunTradeEvent"),
}
}
#[test]
fn pumpfun_wsol_quote_mint_uses_solscan_sol_sentinel() {
let ev = pumpfun_trade_from_parser_with_event_type(
sol_parser_sdk::core::events::PumpFunTradeEvent {
is_buy: true,
quote_mint: PUMPFUN_WSOL_QUOTE_MINT,
..Default::default()
},
None,
0,
EventType::PumpFunBuy,
);
match ev {
DexEvent::PumpFunTradeEvent(t) => {
assert_eq!(t.quote_mint.to_string(), "So11111111111111111111111111111111111111111");
}
_ => panic!("expected PumpFunTradeEvent"),
}
}
}