| Crates.io | solana-streamer-sdk |
| lib.rs | solana-streamer-sdk |
| version | 1.1.6 |
| created_at | 2025-07-19 16:05:52.41675+00 |
| updated_at | 2025-12-14 12:59:58.899895+00 |
| description | A lightweight Rust library for real-time event streaming from Solana DEX trading programs. Supports PumpFun, PumpSwap, Bonk, and Raydium protocols with Yellowstone gRPC and ShredStream. |
| homepage | |
| repository | https://github.com/0xfnzero/solana-streamer |
| max_upload_size | |
| id | 1760352 |
| size | 746,937 |
A lightweight Rust library providing efficient event parsing and subscription capabilities for PumpFun, PumpSwap, Bonk, and Raydium protocols.
δΈζ | English | Website | Telegram | Discord
Clone this project to your project directory:
cd your_project_root_directory
git clone https://github.com/0xfnzero/solana-streamer
Add the dependency to your Cargo.toml:
# Add to your Cargo.toml
solana-streamer-sdk = { path = "./solana-streamer", version = "1.1.6" }
# Add to your Cargo.toml
solana-streamer-sdk = "1.1.6"
Version 1.0.0 introduces a major architectural change from trait-based event handling to enum-based events. This provides better type safety, improved performance, and simpler code patterns.
Key Changes:
Box<dyn UnifiedEvent> β DexEvent enumDexEvent instead of trait objectsmatch instead of match_event! macro.metadata() methodFor detailed migration steps and code examples, see MIGRATION.md or MIGRATION_CN.md (Chinese version).
Quick Migration Example:
// Old (v0.5.x)
let callback = |event: Box<dyn UnifiedEvent>| {
println!("Event: {:?}", event.event_type());
};
// New (v1.x.x)
let callback = |event: DexEvent| {
println!("Event: {:?}", event.metadata().event_type);
};
You can customize client configuration:
use solana_streamer_sdk::streaming::grpc::ClientConfig;
// Use default configuration
let grpc = YellowstoneGrpc::new(endpoint, token)?;
// Or create custom configuration
let mut config = ClientConfig::default();
config.enable_metrics = true; // Enable performance monitoring
config.connection.connect_timeout = 30; // 30 seconds
config.connection.request_timeout = 120; // 120 seconds
let grpc = YellowstoneGrpc::new_with_config(endpoint, token, config)?;
Available Configuration Options:
enable_metrics: Enable/disable performance monitoring (default: false)connection.connect_timeout: Connection timeout in seconds (default: 10)connection.request_timeout: Request timeout in seconds (default: 60)connection.max_decoding_message_size: Maximum message size in bytes (default: 10MB)| Description | Run Command | Source Path |
|---|---|---|
| Monitor transaction events using Yellowstone gRPC | cargo run --example grpc_example |
examples/grpc_example.rs |
| Monitor transaction events using ShredStream | cargo run --example shred_example |
examples/shred_example.rs |
| Parse Solana mainnet transaction data | cargo run --example parse_tx_events |
examples/parse_tx_events.rs |
| Update filters at runtime | cargo run --example dynamic_subscription |
examples/dynamic_subscription.rs |
| Monitor specific token account balance changes | cargo run --example token_balance_listen_example |
examples/token_balance_listen_example.rs |
| Track nonce account state changes | cargo run --example nonce_listen_example |
examples/nonce_listen_example.rs |
| Monitor PumpSwap pool accounts using memcmp filters | cargo run --example pumpswap_pool_account_listen_example |
examples/pumpswap_pool_account_listen_example.rs |
| Monitor all associated token accounts for specific mints using memcmp filters | cargo run --example mint_all_ata_account_listen_example |
examples/mint_all_ata_account_listen_example.rs |
The library supports flexible event filtering to reduce processing overhead and improve performance:
use solana_streamer_sdk::streaming::event_parser::common::{filter::EventTypeFilter, EventType};
// No filtering - receive all events
let event_type_filter = None;
// Filter specific event types - only receive PumpSwap buy/sell events
let event_type_filter = Some(EventTypeFilter {
include: vec![EventType::PumpSwapBuy, EventType::PumpSwapSell]
});
Event filtering can provide significant performance improvements:
Trading Bot (Focus on Trade Events)
let event_type_filter = Some(EventTypeFilter {
include: vec![
EventType::PumpSwapBuy,
EventType::PumpSwapSell,
EventType::PumpFunTrade,
EventType::RaydiumCpmmSwap,
EventType::RaydiumClmmSwap,
EventType::RaydiumAmmV4Swap,
......
]
});
Pool Monitoring (Focus on Liquidity Events)
let event_type_filter = Some(EventTypeFilter {
include: vec![
EventType::PumpSwapCreatePool,
EventType::PumpSwapDeposit,
EventType::PumpSwapWithdraw,
EventType::RaydiumCpmmInitialize,
EventType::RaydiumCpmmDeposit,
EventType::RaydiumCpmmWithdraw,
EventType::RaydiumClmmCreatePool,
......
]
});
Update subscription filters at runtime without reconnecting to the stream.
// Update filters on existing subscription
grpc.update_subscription(
vec![TransactionFilter {
account_include: vec!["new_program_id".to_string()],
account_exclude: vec![],
account_required: vec![],
}],
vec![AccountFilter {
account: vec![],
owner: vec![],
filters: vec![],
}],
).await?;
Note: Multiple subscription attempts on the same client return an error.
src/
βββ common/ # Common functionality and types
βββ protos/ # Protocol buffer definitions
βββ streaming/ # Event streaming system
β βββ event_parser/ # Event parsing system
β β βββ common/ # Common event parsing tools
β β βββ core/ # Core parsing traits and interfaces
β β βββ protocols/# Protocol-specific parsers
β β β βββ bonk/ # Bonk event parsing
β β β βββ pumpfun/ # PumpFun event parsing
β β β βββ pumpswap/ # PumpSwap event parsing
β β β βββ raydium_amm_v4/ # Raydium AMM V4 event parsing
β β β βββ raydium_cpmm/ # Raydium CPMM event parsing
β β β βββ raydium_clmm/ # Raydium CLMM event parsing
β β βββ factory.rs # Parser factory
β βββ shred_stream.rs # ShredStream client
β βββ yellowstone_grpc.rs # Yellowstone gRPC client
β βββ yellowstone_sub_system.rs # Yellowstone subsystem
βββ lib.rs # Main library file
βββ main.rs # Example program
MIT License