mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-07-27 17:37:45 +00:00
Add PumpFun trade filter and create ix_name support
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "solana-streamer-sdk"
|
||||
version = "1.5.6"
|
||||
version = "1.5.7"
|
||||
edition = "2021"
|
||||
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "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"
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user