Solana Streamer
A lightweight Rust library for real-time event streaming from Solana DEX trading programs. This library provides efficient event parsing and subscription capabilities for PumpFun, PumpSwap, Bonk, and Raydium CPMM protocols.
Project Features
- 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
- 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
- Unified Event Interface: Consistent event handling across all supported protocols
- Event Parsing System: Automatic parsing and categorization of protocol-specific events
- 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, etc.
- Memory Optimization: Object pooling and caching mechanisms to reduce memory allocations
- Flexible Configuration System: Support for custom batch sizes, backpressure strategies, channel sizes, and other parameters
- Preset Configurations: Provides high-performance, low-latency, ordered processing, and other preset configurations
- Backpressure Handling: Supports blocking, dropping, retrying, ordered, and other backpressure strategies
- Runtime Configuration Updates: Supports dynamic configuration parameter updates at runtime
- Full Function Performance Monitoring: All subscribe_events functions support performance monitoring, automatically collecting and reporting performance metrics
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.2.0" }
Use crates.io
# Add to your Cargo.toml
= "0.2.0"
Usage Examples
Quick Start - Parse Transaction Events
You can quickly test the library by running the built-in example that parses transaction events:
This example demonstrates:
- How to parse transaction data from Solana mainnet using RPC
- Event parsing for multiple protocols (PumpFun, PumpSwap, Bonk, Raydium CPMM/CLMM)
- Transaction details extraction including fees, logs, and compute units
The example uses a predefined transaction signature and shows how to extract protocol-specific events from the transaction data.
Advanced Usage with Batch Processing and Backpressure
use ;
async
async
async
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
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_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
License
MIT License
Contact
- Project Repository: https://github.com/0xfnzero/solana-streamer
- Telegram Group: https://t.me/fnzero_group
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
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