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)]
+1
View File
@@ -174,6 +174,7 @@ mod tests {
assert_eq!(st.mint, mint);
assert_eq!(st.global, global);
assert_eq!(st.event_authority, event_authority);
assert_eq!(st.ix_name, "create_v2");
assert!(st.is_mayhem_mode);
assert!(st.is_cashback_enabled);
}
@@ -60,6 +60,7 @@ pub(crate) fn pumpfun_create_token_from_parser(
is_cashback_enabled: c.is_cashback_enabled,
quote_mint: normalize_pumpfun_quote_mint(c.quote_mint),
virtual_quote_reserves: c.virtual_quote_reserves,
ix_name: "create".to_string(),
..Default::default()
}
}
@@ -87,6 +88,7 @@ pub(crate) fn pumpfun_create_token_from_parser_v2(
is_cashback_enabled: c.is_cashback_enabled,
quote_mint: normalize_pumpfun_quote_mint(c.quote_mint),
virtual_quote_reserves: c.virtual_quote_reserves,
ix_name: "create_v2".to_string(),
mint_authority: c.mint_authority,
associated_bonding_curve: c.associated_bonding_curve,
global: c.global,