feat: v1.0.1 - add custom compute unit limit support
Add custom_cu_limit parameter to parallel trading functions, allowing users to override default compute unit limits for both buy and sell operations.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sol-trade-sdk"
|
name = "sol-trade-sdk"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [
|
authors = [
|
||||||
"William <byteblock6@gmail.com>",
|
"William <byteblock6@gmail.com>",
|
||||||
|
|||||||
@@ -87,14 +87,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 = "1.0.0" }
|
sol-trade-sdk = { path = "./sol-trade-sdk", version = "1.0.1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use crates.io
|
### Use crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
sol-trade-sdk = "1.0.0"
|
sol-trade-sdk = "1.0.1"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🛠️ Usage Examples
|
## 🛠️ Usage Examples
|
||||||
|
|||||||
+2
-2
@@ -87,14 +87,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
sol-trade-sdk = { path = "./sol-trade-sdk", version = "1.0.0" }
|
sol-trade-sdk = { path = "./sol-trade-sdk", version = "1.0.1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 crates.io
|
### 使用 crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
sol-trade-sdk = "1.0.0"
|
sol-trade-sdk = "1.0.1"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🛠️ 使用示例
|
## 🛠️ 使用示例
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ pub async fn buy_parallel_execute(
|
|||||||
true,
|
true,
|
||||||
params.wait_transaction_confirmed,
|
params.wait_transaction_confirmed,
|
||||||
true,
|
true,
|
||||||
|
params.custom_cu_limit,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
@@ -52,6 +53,7 @@ pub async fn sell_parallel_execute(
|
|||||||
false,
|
false,
|
||||||
params.wait_transaction_confirmed,
|
params.wait_transaction_confirmed,
|
||||||
params.with_tip,
|
params.with_tip,
|
||||||
|
params.custom_cu_limit,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
@@ -69,6 +71,7 @@ async fn parallel_execute(
|
|||||||
is_buy: bool,
|
is_buy: bool,
|
||||||
wait_transaction_confirmed: bool,
|
wait_transaction_confirmed: bool,
|
||||||
with_tip: bool,
|
with_tip: bool,
|
||||||
|
custom_cu_limit: Option<u32>,
|
||||||
) -> Result<Signature> {
|
) -> Result<Signature> {
|
||||||
if swqos_settings.is_empty() {
|
if swqos_settings.is_empty() {
|
||||||
return Err(anyhow!("swqos_settings is empty"));
|
return Err(anyhow!("swqos_settings is empty"));
|
||||||
@@ -101,9 +104,13 @@ async fn parallel_execute(
|
|||||||
let swqos_client = swqos_client.clone();
|
let swqos_client = swqos_client.clone();
|
||||||
let buy_tip_fee = swqos_settings[i].buy_tip_fee;
|
let buy_tip_fee = swqos_settings[i].buy_tip_fee;
|
||||||
let sell_tip_fee = swqos_settings[i].sell_tip_fee;
|
let sell_tip_fee = swqos_settings[i].sell_tip_fee;
|
||||||
let unit_limit = swqos_settings[i].unit_limit;
|
let mut unit_limit = swqos_settings[i].unit_limit;
|
||||||
let unit_price = swqos_settings[i].unit_price;
|
let unit_price = swqos_settings[i].unit_price;
|
||||||
|
|
||||||
|
if let Some(custom_cu_limit) = custom_cu_limit {
|
||||||
|
unit_limit = custom_cu_limit;
|
||||||
|
}
|
||||||
|
|
||||||
let handle = tokio::spawn(async move {
|
let handle = tokio::spawn(async move {
|
||||||
core_affinity::set_for_current(core_id);
|
core_affinity::set_for_current(core_id);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user