Add PumpFun trade filter and create ix_name support

This commit is contained in:
0xfnzero
2026-06-03 01:07:45 +08:00
parent 9e93d2c5d1
commit 590801db7c
6 changed files with 35 additions and 2 deletions
@@ -192,6 +192,12 @@ fn push_streamer_event_sdk_grpc_types(
out.push(Sdk::PumpFunCreate);
out.push(Sdk::PumpFunCreateV2);
}
St::PumpFunTrade => {
out.push(Sdk::PumpFunTrade);
out.push(Sdk::PumpFunBuy);
out.push(Sdk::PumpFunSell);
out.push(Sdk::PumpFunBuyExactSolIn);
}
St::PumpFunBuy => {
if matches!(mode, FilterMapMode::Include) {
out.push(Sdk::PumpFunTrade);
@@ -450,6 +456,12 @@ fn event_type_matches(filter_type: &EventType, event_type: &EventType) -> bool {
(filter_type, event_type),
(EventType::PumpFunCreateToken, EventType::PumpFunCreateV2Token)
| (EventType::PumpFunCreateV2Token, EventType::PumpFunCreateToken)
| (EventType::PumpFunTrade, EventType::PumpFunBuy)
| (EventType::PumpFunTrade, EventType::PumpFunSell)
| (EventType::PumpFunTrade, EventType::PumpFunBuyExactSolIn)
| (EventType::PumpFunBuy, EventType::PumpFunTrade)
| (EventType::PumpFunSell, EventType::PumpFunTrade)
| (EventType::PumpFunBuyExactSolIn, EventType::PumpFunTrade)
| (EventType::PumpFunBuy, EventType::PumpFunBuyExactSolIn)
| (EventType::PumpFunBuyExactSolIn, EventType::PumpFunBuy)
| (EventType::TokenAccount, EventType::TokenInfo)
@@ -580,6 +592,19 @@ mod tests {
assert!(!f.passes_event_type(&EventType::PumpFunSell));
}
#[test]
fn pumpfun_trade_filter_matches_concrete_trade_events() {
let f = EventTypeFilter { include: vec![EventType::PumpFunTrade], ..Default::default() };
let sdk_f = build_sdk_parse_event_filter(Some(&f)).expect("mapped");
assert!(sdk_f.should_include(SdkGrpcEventType::PumpFunTrade));
assert!(sdk_f.should_include(SdkGrpcEventType::PumpFunBuy));
assert!(sdk_f.should_include(SdkGrpcEventType::PumpFunSell));
assert!(sdk_f.should_include(SdkGrpcEventType::PumpFunBuyExactSolIn));
assert!(f.passes_event_type(&EventType::PumpFunBuy));
assert!(f.passes_event_type(&EventType::PumpFunSell));
assert!(f.passes_event_type(&EventType::PumpFunBuyExactSolIn));
}
#[test]
fn pumpfun_create_filter_matches_create_v2_for_backward_compat() {
let f =
@@ -669,6 +694,7 @@ mod tests {
EventType::BlockMeta,
EventType::PumpFunCreateToken,
EventType::PumpFunCreateV2Token,
EventType::PumpFunTrade,
EventType::PumpFunBuy,
EventType::PumpFunBuyExactSolIn,
EventType::PumpFunSell,
@@ -82,6 +82,7 @@ pub enum EventType {
// PumpFun events
PumpFunCreateToken,
PumpFunCreateV2Token,
PumpFunTrade,
PumpFunBuy,
PumpFunBuyExactSolIn,
PumpFunSell,
@@ -32,6 +32,9 @@ pub struct PumpFunCreateTokenEvent {
pub quote_mint: Pubkey,
#[borsh(skip)]
pub virtual_quote_reserves: u64,
/// Original PumpFun instruction name: "create" or "create_v2".
#[borsh(skip)]
pub ix_name: String,
#[borsh(skip)]
pub mint_authority: Pubkey,
#[borsh(skip)]