From 7a05ec216c37287149443c4ba1cc27b01607f655 Mon Sep 17 00:00:00 2001 From: ysq Date: Thu, 24 Jul 2025 21:38:22 +0800 Subject: [PATCH] feat: Upgrade SDK version to 0.2.4 and optimize tip fee setting logic - Upgrade SDK version from 0.2.3 to 0.2.4 - Update solana-streamer-sdk dependency to version 0.1.3 - Optimize buy_tip_fees setting logic using map function instead of hardcoded array - Update version numbers in README documentation --- Cargo.toml | 4 ++-- README.md | 6 +++--- README_CN.md | 6 +++--- src/lib.rs | 22 ++++++++++------------ src/main.rs | 2 +- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b588025..1d25d72 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sol-trade-sdk" -version = "0.2.3" +version = "0.2.4" edition = "2021" authors = ["William ", "sgxiang ", "wei <1415121722@qq.com>"] repository = "https://github.com/0xfnzero/sol-trade-sdk" @@ -13,7 +13,7 @@ readme = "README.md" crate-type = ["cdylib", "rlib"] [dependencies] -solana-streamer-sdk = "0.1.2" +solana-streamer-sdk = "0.1.3" solana-sdk = "2.1.16" solana-client = "2.1.16" solana-program = "2.1.16" diff --git a/README.md b/README.md index abbec42..5387f45 100755 --- a/README.md +++ b/README.md @@ -31,14 +31,14 @@ Add the dependency to your `Cargo.toml`: ```toml # Add to your Cargo.toml -sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.3" } +sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.4" } ``` ### Use crates.io ```toml # Add to your Cargo.toml -sol-trade-sdk = "0.2.3" +sol-trade-sdk = "0.2.4" ``` ## Usage Examples @@ -127,7 +127,7 @@ async fn test_grpc() -> Result<(), Box> { // Subscribe to events from multiple protocols println!("Starting to listen for events, press Ctrl+C to stop..."); let protocols = vec![Protocol::PumpFun, Protocol::PumpSwap, Protocol::Bonk, Protocol::RaydiumCpmm]; - grpc.subscribe_events(protocols, None, None, None, callback) + grpc.subscribe_events(protocols, None, None, None, None, None, callback) .await?; Ok(()) diff --git a/README_CN.md b/README_CN.md index 9112474..3c37837 100755 --- a/README_CN.md +++ b/README_CN.md @@ -31,14 +31,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk ```toml # 添加到您的 Cargo.toml -sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.3" } +sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.4" } ``` ### 使用 crates.io ```toml # 添加到您的 Cargo.toml -sol-trade-sdk = "0.2.3" +sol-trade-sdk = "0.2.4" ``` ## 使用示例 @@ -127,7 +127,7 @@ async fn test_grpc() -> Result<(), Box> { // 订阅多个协议的事件 println!("开始监听事件,按 Ctrl+C 停止..."); let protocols = vec![Protocol::PumpFun, Protocol::PumpSwap, Protocol::Bonk, Protocol::RaydiumCpmm]; - grpc.subscribe_events(protocols, None, None, None, callback) + grpc.subscribe_events(protocols, None, None, None, None, None, callback) .await?; Ok(()) diff --git a/src/lib.rs b/src/lib.rs index efd7532..25744d6 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -204,12 +204,11 @@ impl SolanaTrade { let mut priority_fee = buy_params.priority_fee.clone(); if custom_buy_tip_fee.is_some() { priority_fee.buy_tip_fee = custom_buy_tip_fee.unwrap(); - priority_fee.buy_tip_fees = vec![ - custom_buy_tip_fee.unwrap(), - custom_buy_tip_fee.unwrap(), - custom_buy_tip_fee.unwrap(), - custom_buy_tip_fee.unwrap(), - ]; + priority_fee.buy_tip_fees = priority_fee + .buy_tip_fees + .iter() + .map(|_| custom_buy_tip_fee.unwrap()) + .collect(); } let buy_with_tip_params = buy_params.clone().with_tip(self.swqos_clients.clone()); @@ -328,12 +327,11 @@ impl SolanaTrade { let mut priority_fee = sell_params.priority_fee.clone(); if custom_buy_tip_fee.is_some() { priority_fee.buy_tip_fee = custom_buy_tip_fee.unwrap(); - priority_fee.buy_tip_fees = vec![ - custom_buy_tip_fee.unwrap(), - custom_buy_tip_fee.unwrap(), - custom_buy_tip_fee.unwrap(), - custom_buy_tip_fee.unwrap(), - ]; + priority_fee.buy_tip_fees = priority_fee + .buy_tip_fees + .iter() + .map(|_| custom_buy_tip_fee.unwrap()) + .collect(); } let sell_with_tip_params = sell_params.clone().with_tip(self.swqos_clients.clone()); diff --git a/src/main.rs b/src/main.rs index f9412fc..51ed403 100755 --- a/src/main.rs +++ b/src/main.rs @@ -399,7 +399,7 @@ async fn test_grpc() -> Result<(), Box> { let protocols = vec![Protocol::PumpFun, Protocol::PumpSwap, Protocol::Bonk, Protocol::RaydiumCpmm]; println!("开始监听事件,按 Ctrl+C 停止..."); - grpc.subscribe_events(protocols, None, None, None, callback).await?; + grpc.subscribe_events(protocols, None, None, None, None, None, callback).await?; Ok(()) }