A lightweight Rust streaming facade over sol-parser-sdk, with low-latency subscriptions and a stable bot-facing API.
δΈζ | English | Website | Telegram | Discord
β Support This Project
This SDK is completely free and open source. However, maintaining and continuously updating it requires significant AI computing resources and token consumption. If this SDK helps with your development, consider making a monthly SOL donation β any amount is appreciated and helps keep this project alive!
Donation Wallet:
6oW7AXz1yRb57pYSxysuXnMs2aR1ha5rzGzReZ1MjPV8
- π Project Features
- β‘ Installation
- π Migration Guide
- βοΈ Configuration System
- π Usage Examples
- π§ Supported Protocols
- π Event Streaming Services
- ποΈ Architecture Features
- π Project Structure
- β‘ Performance Considerations
- π License
- π Contact
β οΈ Important Notes
- Real-time Event Streaming: Subscribe to live trading events from multiple Solana DEX protocols
- SDK-backed Parser Core: Transaction, RPC, account, and ShredStream parsing are backed by
sol-parser-sdk - Yellowstone gRPC Support: High-performance event subscription using Yellowstone gRPC
- ShredStream Support: Alternative event streaming using ShredStream protocol
- Unified Event Interface: Consistent event handling across all supported protocols
- PumpFun: Meme coin trading platform events
- Pump Fees: Pump fee-sharing configuration events
- PumpSwap: PumpFun's swap protocol events
- Raydium Launchpad / Bonk: Token launch platform events (letsbonk.fun / LaunchLab)
- Raydium CPMM: Raydium's Concentrated Pool Market Maker events
- Raydium CLMM: Raydium's Concentrated Liquidity Market Maker events
- Raydium AMM V4: Raydium's Automated Market Maker V4 events
- Meteora DAMM v2: Meteora DAMM v2 swap and liquidity events
- Orca Whirlpool: Orca Whirlpool swap and liquidity events
- Meteora Pools: Meteora Pools swap, liquidity, bootstrap, and fee events
- Meteora DLMM: Meteora DLMM swap, liquidity, pool, bin-array, and fee events
- Event Parsing System: Automatic parsing and categorization of protocol-specific events
- Account State Monitoring: Real-time monitoring of protocol account states and configuration changes
- Transaction & Account Event Filtering: Separate filtering for transaction events and account state changes
- Dynamic Subscription Management: Runtime filter updates without reconnection, enabling adaptive monitoring strategies
- Multi-Filter Support: Support for multiple transaction and account filters in a single subscription
- Advanced Account Filtering: Memcmp filters for precise account data matching and monitoring
- Token2022 Support: Enhanced support for SPL Token 2022 with extended state parsing
- RPC Transaction Parsing: Parse already-fetched RPC transactions or fetch by signature through streamer-compatible helpers
- Advanced SDK Interop: Access the raw
sol-parser-sdkcrate throughparser_sdkorsdk_bridge::raw
- High Performance: Optimized for low-latency event processing
- Batch Processing Optimization: Batch processing events to reduce callback overhead
- Performance Monitoring: Built-in performance metrics monitoring, including event processing speed
- Memory Optimization: Object pooling and caching mechanisms to reduce memory allocations
- Flexible Configuration System: Support for custom batch sizes, backpressure strategies, channel sizes
- Preset Configurations: High-throughput and low-latency preset configurations optimized for different use cases
- Backpressure Handling: Supports blocking and dropping backpressure strategies
- Runtime Configuration Updates: Dynamic configuration parameter updates at runtime
- Graceful Shutdown: Support for programmatic stop() method for clean shutdown
Clone this project to your project directory:
cd your_project_root_directory
git clone https://github.com/0xfnzero/solana-streamerAdd the dependency to your Cargo.toml:
# Add to your Cargo.toml
solana-streamer-sdk = { path = "./solana-streamer", version = "1.4.7" }# Add to your Cargo.toml
solana-streamer-sdk = "1.4.7"Parser backend features:
# Default: sol-parser-sdk parse-borsh backend
solana-streamer-sdk = "1.4.7"
# Zero-copy parser backend for latency-sensitive bots
solana-streamer-sdk = { version = "1.4.7", default-features = false, features = ["sdk-parse-zero-copy"] }If both sdk-parse-borsh and sdk-parse-zero-copy are enabled, sol-parser-sdk 0.4.11+ uses the zero-copy backend.
Version 1.4.7 uses sol-parser-sdk 0.4.11 from crates.io and adds the SDK-compatible Yellowstone gRPC ordering modes to the streamer facade while preserving the existing subscription and callback API. Existing bots can keep the default ultra-low-latency Unordered mode or opt into Ordered, StreamingOrdered, or MicroBatch through ClientConfig.
New optional capabilities:
solana_streamer_sdk::parser_sdkre-exports the rawsol-parser-sdkcrate.solana_streamer_sdk::sdk_bridgeadapts raw SDK events back into streamerDexEvent.fetch_rpc_transaction_as_streamer_eventsandparse_encoded_rpc_transaction_as_streamer_eventsparse RPC transactions into streamer events.grpc::ClientConfig::order_modesupportsUnordered,Ordered,StreamingOrdered, andMicroBatch.sdk-parse-zero-copyenables the SDK zero-copy parser backend.
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:
- Event Type Changed -
Box<dyn UnifiedEvent>βDexEventenum - Callback Signature - Callbacks now receive concrete
DexEventinstead of trait objects - Event Matching - Use standard Rust
matchinstead ofmatch_event!macro - Metadata Access - Event properties now accessed through
.metadata()method
For 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, OrderMode},
YellowstoneGrpc,
};
// 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
config.order_mode = OrderMode::MicroBatch; // Unordered / Ordered / StreamingOrdered / MicroBatch
config.order_timeout_ms = 100;
config.micro_batch_us = 100;
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)order_mode: Transaction event output ordering mode (default:Unordered)order_timeout_ms: Flush timeout forOrderedandStreamingOrderedmodes (default: 100)micro_batch_us: Micro-batch window forMicroBatchmode (default: 100)
use solana_streamer_sdk::streaming::{
event_parser::{
common::{filter::EventTypeFilter, EventType},
core::EventDispatcher,
DexEvent, Protocol,
},
yellowstone_grpc::{AccountFilter, TransactionFilter},
YellowstoneGrpc,
};
let grpc = YellowstoneGrpc::new(endpoint, token)?;
let protocols = vec![
Protocol::PumpFun,
Protocol::PumpFees,
Protocol::PumpSwap,
Protocol::RaydiumLaunchpad,
Protocol::RaydiumCpmm,
Protocol::RaydiumClmm,
Protocol::RaydiumAmmV4,
Protocol::OrcaWhirlpool,
Protocol::MeteoraPools,
Protocol::MeteoraDammV2,
Protocol::MeteoraDlmm,
];
let program_ids = EventDispatcher::get_program_ids(&protocols)
.into_iter()
.map(|pubkey| pubkey.to_string())
.collect::<Vec<_>>();
let transaction_filter = TransactionFilter {
account_include: program_ids.clone(),
account_exclude: vec![],
account_required: vec![],
};
let account_filter = AccountFilter { account: vec![], owner: program_ids, filters: vec![] };
let event_type_filter = Some(EventTypeFilter::include_only(vec![
EventType::PumpFunBuy,
EventType::PumpSwapBuy,
EventType::BonkBuyExactIn,
EventType::RaydiumCpmmSwapBaseInput,
EventType::MeteoraDlmmSwap,
]));
grpc.subscribe_events_immediate(
protocols,
None,
vec![transaction_filter],
vec![account_filter],
event_type_filter,
None,
|event: DexEvent| {
println!("{:?}", event.metadata().event_type);
},
)
.await?;| 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 |
Parse PumpFun transaction from RPC (signature: TX_SIGNATURE or CLI arg) |
cargo run --example parse_pump_tx --release |
examples/parse_pump_tx.rs |
| Parse PumpSwap transaction from RPC | cargo run --example parse_pumpswap_tx --release |
examples/parse_pumpswap_tx.rs |
| Parse Meteora DAMM v2 transaction from RPC | TX_SIGNATURE=<sig> cargo run --example parse_meteora_damm_tx --release |
examples/parse_meteora_damm_tx.rs |
| Debug PumpFun transaction (fetch, print meta/logs, parse) | TX_SIGNATURE=<sig> cargo run --example debug_pump_tx --release |
examples/debug_pump_tx.rs |
| Debug PumpSwap transaction (fetch, print meta, parse) | TX_SIGNATURE=<sig> cargo run --example debug_pumpswap_tx --release |
examples/debug_pumpswap_tx.rs |
| Update filters at runtime | cargo run --example dynamic_subscription |
examples/dynamic_subscription.rs |
| Quick test: subscribe to PumpFun, print first 10 or run 60s | cargo run --example pumpfun_quick_test --release |
examples/pumpfun_quick_test.rs |
| PumpFun trade filter: Buy/Sell/Create with latency | cargo run --example pumpfun_trade_filter --release |
examples/pumpfun_trade_filter.rs |
| PumpFun gRPC subscription with metrics | cargo run --example pumpfun_with_metrics --release |
examples/pumpfun_with_metrics.rs |
| PumpSwap gRPC subscription with metrics | cargo run --example pumpswap_with_metrics --release |
examples/pumpswap_with_metrics.rs |
| Meteora DAMM v2 gRPC subscription | cargo run --example meteora_damm_grpc --release |
examples/meteora_damm_grpc.rs |
| Monitor specific token account balance changes | cargo run --example token_balance_listen_example |
examples/token_balance_listen_example.rs |
| Monitor token decimals via account subscription | cargo run --example token_decimals_listen_example |
examples/token_decimals_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_only(vec![
EventType::PumpSwapBuy,
EventType::PumpSwapSell,
]));
// Exclude noisy events while keeping everything else
let event_type_filter = Some(EventTypeFilter::exclude_only(vec![EventType::BlockMeta]));Event filtering can provide significant performance improvements:
- 60-80% reduction in unnecessary event processing
- Lower memory usage by filtering out irrelevant events
- Reduced network bandwidth in distributed setups
- Better focus on events that matter to your application
Trading Bot (Focus on Trade Events)
let event_type_filter = Some(EventTypeFilter::include_only(vec![
EventType::PumpFunBuy,
EventType::PumpFunBuyExactSolIn,
EventType::PumpFunSell,
EventType::PumpSwapBuy,
EventType::PumpSwapSell,
EventType::BonkBuyExactIn,
EventType::BonkSellExactIn,
EventType::RaydiumCpmmSwapBaseInput,
EventType::RaydiumCpmmSwapBaseOutput,
EventType::RaydiumClmmSwap,
EventType::RaydiumAmmV4SwapBaseIn,
EventType::RaydiumAmmV4SwapBaseOut,
EventType::OrcaWhirlpoolSwap,
EventType::MeteoraPoolsSwap,
EventType::MeteoraDammV2Swap,
EventType::MeteoraDlmmSwap,
]));Pool Monitoring (Focus on Liquidity Events)
let event_type_filter = Some(EventTypeFilter::include_only(vec![
EventType::PumpFeesUpdateFeeShares,
EventType::PumpSwapCreatePool,
EventType::PumpSwapDeposit,
EventType::PumpSwapWithdraw,
EventType::RaydiumCpmmInitialize,
EventType::RaydiumCpmmDeposit,
EventType::RaydiumCpmmWithdraw,
EventType::RaydiumClmmCreatePool,
EventType::OrcaWhirlpoolPoolInitialized,
EventType::MeteoraPoolsPoolCreated,
EventType::MeteoraDammV2AddLiquidity,
EventType::MeteoraPoolsAddLiquidity,
EventType::MeteoraDlmmAddLiquidity,
]));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?;- No Reconnection: Filter changes apply immediately without closing the stream
- Atomic Updates: Both transaction and account filters updated together
- Single Subscription: One active subscription per client instance
- Compatible: Works with both immediate and advanced subscription methods
Note: Multiple subscription attempts on the same client return an error.
- PumpFun: Primary meme coin trading platform
- Pump Fees: Pump fee-sharing configuration events
- PumpSwap: PumpFun's swap protocol
- Raydium Launchpad / Bonk: Token launch platform (letsbonk.fun / LaunchLab)
- Raydium CPMM: Raydium's Concentrated Pool Market Maker protocol
- Raydium CLMM: Raydium's Concentrated Liquidity Market Maker protocol
- Raydium AMM V4: Raydium's Automated Market Maker V4 protocol
- Meteora DAMM v2: Meteora DAMM v2 protocol
- Orca Whirlpool: Orca Whirlpool protocol
- Meteora Pools: Meteora Pools protocol
- Meteora DLMM: Meteora Dynamic Liquidity Market Maker protocol
- Common events: Token accounts, token metadata, nonce accounts, block metadata, and ComputeBudget events
- Yellowstone gRPC: High-performance Solana event streaming
- ShredStream: Alternative event streaming protocol
- DexEvent Enum: Type-safe enum containing all protocol events
- Protocol Enum: Easy identification of event sources
- SDK Bridge: Adapts
sol-parser-sdk::DexEventinto streamerDexEvent
- sol-parser-sdk Facade: Yellowstone gRPC, ShredStream, RPC transaction parsing, and account parsing delegate protocol parsing to
sol-parser-sdk - Local Non-DEX Pass: Local handling is limited to streamer infrastructure and non-DEX compatibility cases such as ComputeBudget metadata
- Extensible Bridge:
streaming::sdk_bridgeexposes raw SDK access without forcing existing bots to change callbacks
- Yellowstone gRPC Client: Optimized for Solana event streaming
- ShredStream Client: Alternative streaming implementation
- Async Processing: Non-blocking event handling
src/
βββ common/ # Common functionality and types
βββ protos/ # Protocol buffer definitions
βββ streaming/ # Event streaming system
β βββ event_parser/ # Streamer-compatible event facade over sol-parser-sdk
β β βββ common/ # Public event metadata and filter types
β β βββ core/ # SDK dispatch entry points and compatibility wrappers
β β βββ protocols/# Streamer event types and legacy module paths
β β β βββ sol_parser_forward/ # SDK-forwarded protocol event wrappers
β βββ parser_sdk_bridge/ # sol-parser-sdk event adapter
β βββ rpc_parse.rs # RPC transaction parsing helpers
β βββ sdk_bridge.rs # Public advanced SDK interop module
β βββ 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
- Connection Management: Properly handle connection lifecycle and reconnection
- Event Filtering: Use protocol filtering to reduce unnecessary event processing
- Memory Management: Implement appropriate cleanup for long-running streams
- Error Handling: Robust error handling for network issues and service interruptions
- Batch Processing Optimization: Use batch processing to reduce callback overhead and improve throughput
- Performance Monitoring: Enable performance monitoring to identify bottlenecks and optimization opportunities
- Graceful Shutdown: Use the stop() method for clean shutdown and implement signal handlers for proper resource cleanup
MIT License
- Website: https://fnzero.dev/
- Project Repository: https://github.com/0xfnzero/solana-streamer
- Telegram Group: https://t.me/fnzero_group
- Discord: https://discord.gg/vuazbGkqQE
- Network Stability: Ensure stable network connection for continuous event streaming
- Rate Limiting: Be aware of rate limits on public gRPC endpoints
- Error Recovery: Implement proper error handling and reconnection logic
- Compliance: Ensure compliance with relevant laws and regulations