Table of Contents
- π Project Features
- β‘ Installation
- βοΈ Configuration System
- π Usage Examples
- π§ Supported Protocols
- π Event Streaming Services
- ποΈ Architecture Features
- π Project Structure
- β‘ Performance Considerations
- π License
- π Contact
- β οΈ Important Notes
π Project Features
Core Capabilities
- Real-time Event Streaming: Subscribe to live trading events from multiple Solana DEX protocols
- 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
Multi-Protocol Support
- PumpFun: Meme coin trading platform events
- PumpSwap: PumpFun's swap protocol events
- Bonk: Token launch platform events (letsbonk.fun)
- 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
Advanced Features
- 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
Performance & Optimization
- 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
β‘ Installation
Direct Clone
Clone this project to your project directory:
Add the dependency to your Cargo.toml:
# Add to your Cargo.toml
= { = "./solana-streamer", = "0.4.6" }
Use crates.io
# Add to your Cargo.toml
= "0.4.6"
βοΈ Configuration System
Preset Configurations
The library provides three preset configurations optimized for different use cases:
1. High Throughput Configuration (high_throughput())
Optimized for high-concurrency scenarios, prioritizing throughput over latency:
let config = high_throughput;
// Or use convenience methods
let grpc = new_high_throughput?;
let shred = new_high_throughput.await?;
Features:
- Backpressure Strategy: Drop - drops messages during high load to avoid blocking
- Buffer Size: 5,000 permits to handle burst traffic
- Use Case: Scenarios where you need to process large volumes of data and can tolerate occasional message drops during peak loads
2. Low Latency Configuration (low_latency())
Optimized for real-time scenarios, prioritizing latency over throughput:
let config = low_latency;
// Or use convenience methods
let grpc = new_low_latency?;
let shred = new_low_latency.await?;
Features:
- Backpressure Strategy: Block - ensures no data loss
- Buffer Size: 4000 permits for balanced throughput and latency
- Immediate Processing: No buffering, processes events immediately
- Use Case: Scenarios where every millisecond counts and you cannot afford to lose any events, such as trading applications or real-time monitoring
Custom Configuration
You can also create custom configurations:
let config = StreamClientConfig ;
π Usage Examples
Usage Examples Summary Table
| Feature Type | Example File | Description | Run Command | Source Path |
|---|---|---|---|---|
| Yellowstone gRPC Stream | grpc_example.rs |
Monitor transaction events using Yellowstone gRPC | cargo run --example grpc_example |
examples/grpc_example.rs |
| ShredStream Stream | shred_example.rs |
Monitor transaction events using ShredStream | cargo run --example shred_example |
examples/shred_example.rs |
| Parse Transaction Events | parse_tx_events |
Parse Solana mainnet transaction data | cargo run --example parse_tx_events |
examples/parse_tx_events.rs |
| Dynamic Subscription Management | dynamic_subscription |
Update filters at runtime | cargo run --example dynamic_subscription |
examples/dynamic_subscription.rs |
| Token Balance Monitoring | token_balance_listen_example |
Monitor specific token account balance changes | cargo run --example token_balance_listen_example |
examples/token_balance_listen_example.rs |
| Nonce Account Monitoring | nonce_listen_example |
Track nonce account state changes | cargo run --example nonce_listen_example |
examples/nonce_listen_example.rs |
Event Filtering
The library supports flexible event filtering to reduce processing overhead and improve performance:
Basic Filtering
use ;
// 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;
Performance Impact
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
Filtering Examples by Use Case
Trading Bot (Focus on Trade Events)
let event_type_filter = Some;
Pool Monitoring (Focus on Liquidity Events)
let event_type_filter = Some;
Dynamic Subscription Management
Update subscription filters at runtime without reconnecting to the stream.
// Update filters on existing subscription
grpc.update_subscription.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.
π§ Supported Protocols
- PumpFun: Primary meme coin trading platform
- PumpSwap: PumpFun's swap protocol
- Bonk: Token launch platform (letsbonk.fun)
- 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
π Event Streaming Services
- Yellowstone gRPC: High-performance Solana event streaming
- ShredStream: Alternative event streaming protocol
ποΈ Architecture Features
Unified Event Interface
- UnifiedEvent Trait: All protocol events implement a common interface
- Protocol Enum: Easy identification of event sources
- Event Factory: Automatic event parsing and categorization
Event Parsing System
- Protocol-specific Parsers: Dedicated parsers for each supported protocol
- Event Factory: Centralized event creation and parsing
- Extensible Design: Easy to add new protocols and event types
Streaming Infrastructure
- Yellowstone gRPC Client: Optimized for Solana event streaming
- ShredStream Client: Alternative streaming implementation
- Async Processing: Non-blocking event handling
π Project Structure
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
β‘ Performance Considerations
- 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
π License
MIT License
π Contact
- Website: https://fnzero.dev/
- Project Repository: https://github.com/0xfnzero/solana-streamer
- Telegram Group: https://t.me/fnzero_group
β οΈ Important Notes
- 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