Update SWQOS submit behavior
This commit is contained in:
@@ -19,7 +19,7 @@ Include lookup tables in your trade parameters:
|
||||
|
||||
```rust
|
||||
let lookup_table_key = Pubkey::from_str("use_your_lookup_table_key_here").unwrap();
|
||||
let address_lookup_table_account = fetch_address_lookup_table_account(&client.rpc, &lookup_table_key).await.ok();
|
||||
let alt = fetch_address_lookup_table_account(&client.rpc, &lookup_table_key).await?;
|
||||
|
||||
// Include lookup table in trade parameters
|
||||
let buy_params = sol_trade_sdk::TradeBuyParams {
|
||||
@@ -29,7 +29,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams {
|
||||
slippage_basis_points: Some(100),
|
||||
recent_blockhash: Some(recent_blockhash),
|
||||
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
|
||||
address_lookup_table_account: address_lookup_table_account, // Include lookup table
|
||||
address_lookup_table_accounts: vec![alt], // One ALT
|
||||
wait_transaction_confirmed: true,
|
||||
create_wsol_ata: false,
|
||||
close_wsol_ata: false,
|
||||
@@ -41,6 +41,26 @@ let buy_params = sol_trade_sdk::TradeBuyParams {
|
||||
client.buy(buy_params).await?;
|
||||
```
|
||||
|
||||
Multiple lookup tables are also supported:
|
||||
|
||||
```rust
|
||||
let alt1 = fetch_address_lookup_table_account(&client.rpc, &lookup_table_key_1).await?;
|
||||
let alt2 = fetch_address_lookup_table_account(&client.rpc, &lookup_table_key_2).await?;
|
||||
|
||||
let params = SimpleBuyParams::new(
|
||||
DexType::PumpFun,
|
||||
TradeTokenType::SOL,
|
||||
mint_pubkey,
|
||||
BuyAmount::ExactInput(buy_lamports),
|
||||
extension_params,
|
||||
recent_blockhash,
|
||||
gas_fee_strategy,
|
||||
)
|
||||
.address_lookup_table_accounts(vec![alt1, alt2]);
|
||||
```
|
||||
|
||||
Use the same `address_lookup_table_accounts` field for one or many ALTs: `vec![alt]` for a single ALT, `vec![alt1, alt2]` for multiple ALTs.
|
||||
|
||||
## 📊 Performance Comparison
|
||||
|
||||
| Aspect | Without ALT | With ALT | Improvement |
|
||||
@@ -64,4 +84,4 @@ client.buy(buy_params).await?;
|
||||
|
||||
## 📚 External Resources
|
||||
|
||||
- [Solana Address Lookup Tables Documentation](https://docs.solana.com/developing/lookup-tables)
|
||||
- [Solana Address Lookup Tables Documentation](https://docs.solana.com/developing/lookup-tables)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
```rust
|
||||
let lookup_table_key = Pubkey::from_str("use_your_lookup_table_key_here").unwrap();
|
||||
let address_lookup_table_account = fetch_address_lookup_table_account(&client.rpc, &lookup_table_key).await.ok();
|
||||
let alt = fetch_address_lookup_table_account(&client.rpc, &lookup_table_key).await?;
|
||||
|
||||
// 在交易参数中包含查找表
|
||||
let buy_params = sol_trade_sdk::TradeBuyParams {
|
||||
@@ -29,7 +29,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams {
|
||||
slippage_basis_points: Some(100),
|
||||
recent_blockhash: Some(recent_blockhash),
|
||||
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
|
||||
address_lookup_table_account: address_lookup_table_account, // 包含查找表
|
||||
address_lookup_table_accounts: vec![alt], // 1 个 ALT
|
||||
wait_transaction_confirmed: true,
|
||||
create_wsol_ata: false,
|
||||
close_wsol_ata: false,
|
||||
@@ -41,6 +41,26 @@ let buy_params = sol_trade_sdk::TradeBuyParams {
|
||||
client.buy(buy_params).await?;
|
||||
```
|
||||
|
||||
也支持同时传入多个查找表:
|
||||
|
||||
```rust
|
||||
let alt1 = fetch_address_lookup_table_account(&client.rpc, &lookup_table_key_1).await?;
|
||||
let alt2 = fetch_address_lookup_table_account(&client.rpc, &lookup_table_key_2).await?;
|
||||
|
||||
let params = SimpleBuyParams::new(
|
||||
DexType::PumpFun,
|
||||
TradeTokenType::SOL,
|
||||
mint_pubkey,
|
||||
BuyAmount::ExactInput(buy_lamports),
|
||||
extension_params,
|
||||
recent_blockhash,
|
||||
gas_fee_strategy,
|
||||
)
|
||||
.address_lookup_table_accounts(vec![alt1, alt2]);
|
||||
```
|
||||
|
||||
单 ALT 和多 ALT 都使用同一个 `address_lookup_table_accounts` 字段:单 ALT 传 `vec![alt]`,多 ALT 传 `vec![alt1, alt2]`。
|
||||
|
||||
## 📊 性能对比
|
||||
|
||||
| 方面 | 不使用 ALT | 使用 ALT | 改进幅度 |
|
||||
@@ -64,4 +84,4 @@ client.buy(buy_params).await?;
|
||||
|
||||
## 📚 外部资源
|
||||
|
||||
- [Solana 地址查找表文档](https://docs.solana.com/developing/lookup-tables)
|
||||
- [Solana 地址查找表文档](https://docs.solana.com/developing/lookup-tables)
|
||||
|
||||
@@ -49,7 +49,6 @@ let buy_params = sol_trade_sdk::TradeBuyParams {
|
||||
slippage_basis_points: Some(100),
|
||||
recent_blockhash: Some(recent_blockhash),
|
||||
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
|
||||
address_lookup_table_account: None,
|
||||
wait_transaction_confirmed: true,
|
||||
create_wsol_ata: false,
|
||||
close_wsol_ata: false,
|
||||
|
||||
@@ -49,7 +49,6 @@ let buy_params = sol_trade_sdk::TradeBuyParams {
|
||||
slippage_basis_points: Some(100),
|
||||
recent_blockhash: Some(recent_blockhash),
|
||||
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
|
||||
address_lookup_table_account: None,
|
||||
wait_transaction_confirmed: true,
|
||||
create_wsol_ata: false,
|
||||
close_wsol_ata: false,
|
||||
|
||||
@@ -27,9 +27,9 @@ Use `SimpleBuyParams` and `SimpleSellParams` for new integrations. They keep the
|
||||
| `gas_fee_strategy` | `GasFeeStrategy` | ✅ | Compute unit price/limit and relay tip configuration. |
|
||||
| `slippage_basis_points` | `Option<u64>` | ❌ | Optional slippage override. `100` means 1%. |
|
||||
| `account_policy` | `AccountPolicy` | ❌ | ATA creation/close behavior. Default is `Auto`. |
|
||||
| `address_lookup_table_account` | `Option<AddressLookupTableAccount>` | ❌ | Optional ALT to reduce transaction size. |
|
||||
| `address_lookup_table_accounts` | `Vec<AddressLookupTableAccount>` | ❌ | Optional ALT list. Pass one element for a single ALT or multiple elements for multi-ALT to reduce transaction size. |
|
||||
| `wait_tx_confirmed` | `bool` | ❌ | Whether to wait for chain confirmation before returning. Default is `false`. |
|
||||
| `wait_for_all_submits` | `bool` | ❌ | Fast-submit mode only: wait for every SWQoS lane response and return all signatures. |
|
||||
| `wait_for_all_submits` | `bool` | ❌ | Wait for every SWQoS lane response and return submitted signatures; useful for poll-any confirmation or external monitoring. Recent-blockhash route variants are not mutually exclusive; durable nonce variants are. |
|
||||
| `durable_nonce` | `Option<DurableNonceInfo>` | ❌ | Durable nonce info. Use `.durable_nonce(nonce_info)` or `SimpleBuyParams::with_durable_nonce(...)`; do not combine with `recent_blockhash`. |
|
||||
| `simulate` | `bool` | ❌ | Build and simulate instead of submitting. Default is `false`. |
|
||||
| `grpc_recv_us` | `Option<i64>` | ❌ | Upstream receive timestamp in microseconds for latency tracing. |
|
||||
@@ -47,9 +47,9 @@ Use `SimpleBuyParams` and `SimpleSellParams` for new integrations. They keep the
|
||||
| `gas_fee_strategy` | `GasFeeStrategy` | ✅ | Compute unit price/limit and relay tip configuration. |
|
||||
| `slippage_basis_points` | `Option<u64>` | ❌ | Optional slippage override. `100` means 1%. |
|
||||
| `account_policy` | `AccountPolicy` | ❌ | ATA creation/close behavior. Default is `Auto`. |
|
||||
| `address_lookup_table_account` | `Option<AddressLookupTableAccount>` | ❌ | Optional ALT to reduce transaction size. |
|
||||
| `address_lookup_table_accounts` | `Vec<AddressLookupTableAccount>` | ❌ | Optional ALT list. Pass one element for a single ALT or multiple elements for multi-ALT to reduce transaction size. |
|
||||
| `wait_tx_confirmed` | `bool` | ❌ | Whether to wait for chain confirmation before returning. Default is `false`. |
|
||||
| `wait_for_all_submits` | `bool` | ❌ | Fast-submit mode only: wait for every SWQoS lane response and return all signatures. |
|
||||
| `wait_for_all_submits` | `bool` | ❌ | Wait for every SWQoS lane response and return submitted signatures; useful for poll-any confirmation or external monitoring. Recent-blockhash route variants are not mutually exclusive; durable nonce variants are. |
|
||||
| `durable_nonce` | `Option<DurableNonceInfo>` | ❌ | Durable nonce info. Use `.durable_nonce(nonce_info)` or `SimpleSellParams::with_durable_nonce(...)`; do not combine with `recent_blockhash`. |
|
||||
| `simulate` | `bool` | ❌ | Build and simulate instead of submitting. Default is `false`. |
|
||||
| `with_tip` | `bool` | ❌ | Whether sells include relay tips. Default is `true`; set with `.with_tip(false)`. |
|
||||
@@ -119,7 +119,6 @@ Calling `.durable_nonce(...)` clears `recent_blockhash`; nonce transactions use
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `address_lookup_table_account` | `Option<AddressLookupTableAccount>` | ❌ | Address lookup table for transaction optimization |
|
||||
| `wait_tx_confirmed` | `bool` | ✅ | Whether to wait for transaction confirmation |
|
||||
| `create_input_token_ata` | `bool` | ✅ | Whether to create input token Associated Token Account |
|
||||
| `close_input_token_ata` | `bool` | ✅ | Whether to close input token ATA after transaction |
|
||||
@@ -151,7 +150,6 @@ The `TradeSellParams` struct contains all parameters required for executing sell
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `address_lookup_table_account` | `Option<Pubkey>` | ❌ | Address lookup table for transaction optimization |
|
||||
| `wait_tx_confirmed` | `bool` | ✅ | Whether to wait for transaction confirmation |
|
||||
| `create_output_token_ata` | `bool` | ✅ | Whether to create output token Associated Token Account |
|
||||
| `close_output_token_ata` | `bool` | ✅ | Whether to close output token ATA after transaction |
|
||||
@@ -192,7 +190,7 @@ These parameters control automatic account creation and management:
|
||||
|
||||
These parameters enable advanced optimizations:
|
||||
|
||||
- **address_lookup_table_account**: Use address lookup tables for reduced transaction size
|
||||
- **address_lookup_table_accounts**: Use one or more address lookup tables for reduced transaction size
|
||||
|
||||
### 🔄 Token Type Parameters
|
||||
|
||||
@@ -236,7 +234,7 @@ The account management parameters provide granular control:
|
||||
|
||||
### 🔍 Address Lookup Tables
|
||||
|
||||
Before using `address_lookup_table_account`:
|
||||
Before using `address_lookup_table_accounts`:
|
||||
- Lookup tables reduce transaction size and improve success rates
|
||||
- Particularly beneficial for complex transactions with many account references
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
| `gas_fee_strategy` | `GasFeeStrategy` | ✅ | CU price/limit 和 relay tip 配置。 |
|
||||
| `slippage_basis_points` | `Option<u64>` | ❌ | 可选滑点覆盖。`100` 表示 1%。 |
|
||||
| `account_policy` | `AccountPolicy` | ❌ | ATA 创建/关闭策略。默认 `Auto`。 |
|
||||
| `address_lookup_table_account` | `Option<AddressLookupTableAccount>` | ❌ | 可选 ALT,用于减少交易体积。 |
|
||||
| `address_lookup_table_accounts` | `Vec<AddressLookupTableAccount>` | ❌ | 可选 ALT 列表。传 1 个元素表示单 ALT,传多个元素表示多 ALT,用于减少交易体积。 |
|
||||
| `wait_tx_confirmed` | `bool` | ❌ | 是否等链上确认后再返回。默认 `false`。 |
|
||||
| `wait_for_all_submits` | `bool` | ❌ | fast-submit 模式下,是否等待所有 SWQoS 通道返回并拿到全部签名。 |
|
||||
| `wait_for_all_submits` | `bool` | ❌ | 是否等待所有 SWQoS 通道返回并拿到已提交签名;适合 poll-any 确认或外部监控。recent blockhash 多路交易不互斥;durable nonce 多路交易互斥。 |
|
||||
| `durable_nonce` | `Option<DurableNonceInfo>` | ❌ | durable nonce 信息。使用 `.durable_nonce(nonce_info)` 或 `SimpleBuyParams::with_durable_nonce(...)` 设置,不要和 `recent_blockhash` 混用。 |
|
||||
| `simulate` | `bool` | ❌ | 只构建并模拟交易,不提交。默认 `false`。 |
|
||||
| `grpc_recv_us` | `Option<i64>` | ❌ | 上游收到事件的微秒时间戳,用于延迟追踪。 |
|
||||
@@ -47,9 +47,9 @@
|
||||
| `gas_fee_strategy` | `GasFeeStrategy` | ✅ | CU price/limit 和 relay tip 配置。 |
|
||||
| `slippage_basis_points` | `Option<u64>` | ❌ | 可选滑点覆盖。`100` 表示 1%。 |
|
||||
| `account_policy` | `AccountPolicy` | ❌ | ATA 创建/关闭策略。默认 `Auto`。 |
|
||||
| `address_lookup_table_account` | `Option<AddressLookupTableAccount>` | ❌ | 可选 ALT,用于减少交易体积。 |
|
||||
| `address_lookup_table_accounts` | `Vec<AddressLookupTableAccount>` | ❌ | 可选 ALT 列表。传 1 个元素表示单 ALT,传多个元素表示多 ALT,用于减少交易体积。 |
|
||||
| `wait_tx_confirmed` | `bool` | ❌ | 是否等链上确认后再返回。默认 `false`。 |
|
||||
| `wait_for_all_submits` | `bool` | ❌ | fast-submit 模式下,是否等待所有 SWQoS 通道返回并拿到全部签名。 |
|
||||
| `wait_for_all_submits` | `bool` | ❌ | 是否等待所有 SWQoS 通道返回并拿到已提交签名;适合 poll-any 确认或外部监控。recent blockhash 多路交易不互斥;durable nonce 多路交易互斥。 |
|
||||
| `durable_nonce` | `Option<DurableNonceInfo>` | ❌ | durable nonce 信息。使用 `.durable_nonce(nonce_info)` 或 `SimpleSellParams::with_durable_nonce(...)` 设置,不要和 `recent_blockhash` 混用。 |
|
||||
| `simulate` | `bool` | ❌ | 只构建并模拟交易,不提交。默认 `false`。 |
|
||||
| `with_tip` | `bool` | ❌ | 卖出交易是否带 relay tip。默认 `true`,可通过 `.with_tip(false)` 关闭。 |
|
||||
@@ -119,7 +119,6 @@ let buy_params = SimpleBuyParams::new(
|
||||
|
||||
| 参数 | 类型 | 必需 | 描述 |
|
||||
|------|------|------|------|
|
||||
| `address_lookup_table_account` | `Option<Pubkey>` | ❌ | 用于交易优化的地址查找表 |
|
||||
| `wait_tx_confirmed` | `bool` | ✅ | 是否等待交易确认 |
|
||||
| `create_input_token_ata` | `bool` | ✅ | 是否创建输入代币关联代币账户 |
|
||||
| `close_input_token_ata` | `bool` | ✅ | 交易后是否关闭输入代币 ATA |
|
||||
@@ -151,7 +150,6 @@ let buy_params = SimpleBuyParams::new(
|
||||
|
||||
| 参数 | 类型 | 必需 | 描述 |
|
||||
|------|------|------|------|
|
||||
| `address_lookup_table_account` | `Option<AddressLookupTableAccount>` | ❌ | 用于交易优化的地址查找表 |
|
||||
| `wait_tx_confirmed` | `bool` | ✅ | 是否等待交易确认 |
|
||||
| `create_output_token_ata` | `bool` | ✅ | 是否创建输出代币关联代币账户 |
|
||||
| `close_output_token_ata` | `bool` | ✅ | 交易后是否关闭输出代币 ATA |
|
||||
@@ -192,7 +190,7 @@ let buy_params = SimpleBuyParams::new(
|
||||
|
||||
这些参数启用高级优化:
|
||||
|
||||
- **address_lookup_table_account**: 使用地址查找表减少交易大小
|
||||
- **address_lookup_table_accounts**: 使用一个或多个地址查找表减少交易大小
|
||||
|
||||
### 🔄 代币类型参数
|
||||
|
||||
@@ -236,7 +234,7 @@ let trade_config = TradeConfig::new(rpc_url, swqos_configs, commitment)
|
||||
|
||||
### 🔍 地址查找表
|
||||
|
||||
使用 `address_lookup_table_account` 之前:
|
||||
使用 `address_lookup_table_accounts` 之前:
|
||||
- 查找表减少交易大小并提高成功率
|
||||
- 对于有许多账户引用的复杂交易特别有益
|
||||
|
||||
|
||||
Reference in New Issue
Block a user