This commit is contained in:
ysq
2025-09-12 10:13:21 +08:00
parent 008694daf8
commit bbad566c3b
4 changed files with 33 additions and 20 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "sol-trade-sdk" name = "sol-trade-sdk"
version = "0.6.7" version = "0.6.8"
edition = "2021" edition = "2021"
authors = [ authors = [
"William <byteblock6@gmail.com>", "William <byteblock6@gmail.com>",
+2 -2
View File
@@ -89,14 +89,14 @@ Add the dependency to your `Cargo.toml`:
```toml ```toml
# Add to your Cargo.toml # Add to your Cargo.toml
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.6.7" } sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.6.8" }
``` ```
### Use crates.io ### Use crates.io
```toml ```toml
# Add to your Cargo.toml # Add to your Cargo.toml
sol-trade-sdk = "0.6.7" sol-trade-sdk = "0.6.8"
``` ```
## 🛠️ Usage Examples ## 🛠️ Usage Examples
+2 -2
View File
@@ -89,14 +89,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk
```toml ```toml
# 添加到您的 Cargo.toml # 添加到您的 Cargo.toml
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.6.7" } sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.6.8" }
``` ```
### 使用 crates.io ### 使用 crates.io
```toml ```toml
# 添加到您的 Cargo.toml # 添加到您的 Cargo.toml
sol-trade-sdk = "0.6.7" sol-trade-sdk = "0.6.8"
``` ```
## 🛠️ 使用示例 ## 🛠️ 使用示例
+28 -15
View File
@@ -74,18 +74,12 @@ async fn parallel_execute(
) -> Result<Signature> { ) -> Result<Signature> {
let cores = core_affinity::get_core_ids().unwrap(); let cores = core_affinity::get_core_ids().unwrap();
let mut handles: Vec<JoinHandle<Result<Signature>>> = Vec::with_capacity(swqos_clients.len()); let mut handles: Vec<JoinHandle<Result<Signature>>> = Vec::with_capacity(swqos_clients.len());
if is_buy
&& (swqos_clients.len() > priority_fee.buy_tip_fees.len() if is_buy && with_tip && priority_fee.buy_tip_fees.is_empty() {
|| priority_fee.buy_tip_fees.is_empty()) return Err(anyhow!("buy_tip_fees is empty"));
{
return Err(anyhow!("Number of tip clients exceeds the configured buy tip fees. Please configure buy_tip_fees to match swqos_clients"));
} }
if !is_buy if !is_buy && with_tip && priority_fee.sell_tip_fees.is_empty() {
&& !with_tip return Err(anyhow!("sell_tip_fees is empty"));
&& (swqos_clients.len() > priority_fee.sell_tip_fees.len()
|| priority_fee.sell_tip_fees.is_empty())
{
return Err(anyhow!("Number of tip clients exceeds the configured sell tip fees. Please configure sell_tip_fees to match swqos_clients"));
} }
let instructions = Arc::new(instructions); let instructions = Arc::new(instructions);
@@ -111,12 +105,31 @@ async fn parallel_execute(
let tip_account_str = swqos_client.get_tip_account()?; let tip_account_str = swqos_client.get_tip_account()?;
let tip_account = Arc::new(Pubkey::from_str(&tip_account_str).unwrap_or_default()); let tip_account = Arc::new(Pubkey::from_str(&tip_account_str).unwrap_or_default());
let tip_amount = if priority_fee.buy_tip_fees.len() > i { let tip_amount = if with_tip {
priority_fee.buy_tip_fees[i] if is_buy {
if priority_fee.buy_tip_fees.len() > i {
priority_fee.buy_tip_fees[i]
} else {
println!(
"❗️❗️❗️[{:?}] - Using buy_tip_fees[0]: {:?}",
swqos_type, priority_fee.buy_tip_fees[0]
);
priority_fee.buy_tip_fees[0]
}
} else {
if priority_fee.sell_tip_fees.len() > i {
priority_fee.sell_tip_fees[i]
} else {
println!(
"❗️❗️❗️[{:?}] - Using sell_tip_fees[0]: {:?}",
swqos_type, priority_fee.sell_tip_fees[0]
);
priority_fee.sell_tip_fees[0]
}
}
} else { } else {
priority_fee.buy_tip_fees[0] 0.0
}; };
let tip_amount = if with_tip { tip_amount } else { 0.0 };
let transaction = build_transaction( let transaction = build_transaction(
payer, payer,