diff --git a/Cargo.toml b/Cargo.toml index 5599ee9..251d860 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-streamer-sdk" -version = "1.5.6" +version = "1.5.7" edition = "2021" authors = ["William ", "sgxiang ", "wei <1415121722@qq.com>"] repository = "https://github.com/0xfnzero/solana-streamer" @@ -21,7 +21,7 @@ sdk-perf-stats = ["sol-parser-sdk/perf-stats"] sdk-ultra-perf = ["sol-parser-sdk/ultra-perf"] [dependencies] -sol-parser-sdk = { version = "0.5.6", default-features = false } +sol-parser-sdk = { version = "0.5.7", default-features = false } solana-sdk = "3.0.0" solana-client = "3.1.12" solana-transaction-status = "3.1.12" diff --git a/src/streaming/event_parser/common/filter.rs b/src/streaming/event_parser/common/filter.rs index 8fa7fcf..6383dc9 100644 --- a/src/streaming/event_parser/common/filter.rs +++ b/src/streaming/event_parser/common/filter.rs @@ -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, diff --git a/src/streaming/event_parser/common/types.rs b/src/streaming/event_parser/common/types.rs index d6cc79e..fef0f8f 100755 --- a/src/streaming/event_parser/common/types.rs +++ b/src/streaming/event_parser/common/types.rs @@ -82,6 +82,7 @@ pub enum EventType { // PumpFun events PumpFunCreateToken, PumpFunCreateV2Token, + PumpFunTrade, PumpFunBuy, PumpFunBuyExactSolIn, PumpFunSell, diff --git a/src/streaming/event_parser/protocols/pumpfun/events.rs b/src/streaming/event_parser/protocols/pumpfun/events.rs index 3393b25..9a27bd0 100755 --- a/src/streaming/event_parser/protocols/pumpfun/events.rs +++ b/src/streaming/event_parser/protocols/pumpfun/events.rs @@ -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)] diff --git a/src/streaming/parser_sdk_bridge/mod.rs b/src/streaming/parser_sdk_bridge/mod.rs index 770a1b0..ce21068 100644 --- a/src/streaming/parser_sdk_bridge/mod.rs +++ b/src/streaming/parser_sdk_bridge/mod.rs @@ -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); } diff --git a/src/streaming/parser_sdk_bridge/pump_pumpswap.rs b/src/streaming/parser_sdk_bridge/pump_pumpswap.rs index 505f540..1c0d165 100644 --- a/src/streaming/parser_sdk_bridge/pump_pumpswap.rs +++ b/src/streaming/parser_sdk_bridge/pump_pumpswap.rs @@ -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,