mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-23 13:58:06 +00:00
feat(api): Upgrade to v0.1.5 with improved event subscription API
This update includes the following improvements: - Version upgraded to 0.1.5 - Added subscribe_events_v2 API with more granular account filtering - Marked original subscribe_events API as deprecated - Fixed bug
This commit is contained in:
@@ -33,14 +33,14 @@ Add the dependency to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
# Add to your Cargo.toml
|
||||
solana-streamer-sdk = { path = "./solana-streamer", version = "0.1.4" }
|
||||
solana-streamer-sdk = { path = "./solana-streamer", version = "0.1.5" }
|
||||
```
|
||||
|
||||
### Use crates.io
|
||||
|
||||
```toml
|
||||
# Add to your Cargo.toml
|
||||
solana-streamer-sdk = "0.1.4"
|
||||
solana-streamer-sdk = "0.1.5"
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
@@ -51,10 +51,16 @@ use solana_streamer_sdk::{
|
||||
streaming::{
|
||||
event_parser::{
|
||||
protocols::{
|
||||
bonk::{BonkPoolCreateEvent, BonkTradeEvent}, pumpfun::{PumpFunCreateTokenEvent, PumpFunTradeEvent}, pumpswap::{
|
||||
PumpSwapBuyEvent, PumpSwapCreatePoolEvent, PumpSwapDepositEvent,
|
||||
PumpSwapSellEvent, PumpSwapWithdrawEvent,
|
||||
}, raydium_clmm::{RaydiumClmmSwapEvent, RaydiumClmmSwapV2Event}, raydium_cpmm::RaydiumCpmmSwapEvent
|
||||
bonk::{parser::BONK_PROGRAM_ID, BonkPoolCreateEvent, BonkTradeEvent},
|
||||
pumpfun::{parser::PUMPFUN_PROGRAM_ID, PumpFunCreateTokenEvent, PumpFunTradeEvent},
|
||||
pumpswap::{
|
||||
parser::PUMPSWAP_PROGRAM_ID, PumpSwapBuyEvent, PumpSwapCreatePoolEvent,
|
||||
PumpSwapDepositEvent, PumpSwapSellEvent, PumpSwapWithdrawEvent,
|
||||
},
|
||||
raydium_clmm::{
|
||||
parser::RAYDIUM_CLMM_PROGRAM_ID, RaydiumClmmSwapEvent, RaydiumClmmSwapV2Event,
|
||||
},
|
||||
raydium_cpmm::{parser::RAYDIUM_CPMM_PROGRAM_ID, RaydiumCpmmSwapEvent},
|
||||
},
|
||||
Protocol, UnifiedEvent,
|
||||
},
|
||||
@@ -78,6 +84,8 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
)?;
|
||||
|
||||
let callback = create_event_callback();
|
||||
|
||||
// Will try to parse corresponding protocol events from transactions
|
||||
let protocols = vec![
|
||||
Protocol::PumpFun,
|
||||
Protocol::PumpSwap,
|
||||
@@ -86,9 +94,29 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Protocol::RaydiumClmm,
|
||||
];
|
||||
|
||||
println!("Listening for events, press Ctrl+C to stop...");
|
||||
grpc.subscribe_events(protocols, None, None, None, None, None, callback)
|
||||
.await?;
|
||||
// Filter accounts
|
||||
let account_include = vec![
|
||||
PUMPFUN_PROGRAM_ID.to_string(), // Listen to pumpfun program ID
|
||||
PUMPSWAP_PROGRAM_ID.to_string(), // Listen to pumpswap program ID
|
||||
BONK_PROGRAM_ID.to_string(), // Listen to bonk program ID
|
||||
RAYDIUM_CPMM_PROGRAM_ID.to_string(), // Listen to raydium_cpmm program ID
|
||||
RAYDIUM_CLMM_PROGRAM_ID.to_string(), // Listen to raydium_clmm program ID
|
||||
"xxxxxxxx".to_string(), // Listen to xxxxx account
|
||||
];
|
||||
let account_exclude = vec![];
|
||||
let account_required = vec![];
|
||||
|
||||
println!("Starting to listen for events, press Ctrl+C to stop...");
|
||||
grpc.subscribe_events_v2(
|
||||
protocols,
|
||||
None,
|
||||
account_include,
|
||||
account_exclude,
|
||||
account_required,
|
||||
None,
|
||||
callback,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user