refactor: Refactor SDK core architecture and trading parameter system

- Refactor SolanaTrade main class structure with improved modular design
- Refactor trading parameter system: BuyParams/SellParams -> InternalBuyParams/InternalSellParams
- Remove deprecated PriorityFee and related utility functions
- Add SwqosSettings to replace legacy SwqosConfig
- Add comprehensive technical documentation:
  • Address Lookup Table usage guide (EN/CN)
  • Nonce Cache mechanism documentation (EN/CN)
  • Trading Parameters documentation (EN/CN)
- Refactor all example code to adapt to new API interfaces
- Optimize public API design and code comments
- Clean up redundant utility functions and type definitions

Impact: 43 files changed, 2013 insertions(+), 1735 deletions(-)
This commit is contained in:
ysq
2025-09-17 00:10:33 +08:00
parent 943c2627f3
commit c5ff7c1cbb
43 changed files with 2010 additions and 1732 deletions
+94
View File
@@ -0,0 +1,94 @@
# Address Lookup Table Guide
This guide explains how to use Address Lookup Tables (ALT) in Sol Trade SDK to optimize transaction size and reduce fees.
## 📋 What are Address Lookup Tables?
Address Lookup Tables are a Solana feature that allows you to store frequently used addresses in a compact table format. Instead of including full 32-byte addresses in transactions, you can reference addresses by their index in the lookup table, significantly reducing transaction size and cost.
## 🚀 Core Benefits
- **Transaction Size Optimization**: Reduce transaction size by using address indices instead of full addresses
- **Cost Reduction**: Lower transaction fees due to reduced transaction size
- **Performance Improvement**: Faster transaction processing and validation
- **Network Efficiency**: Reduced bandwidth usage and block space consumption
## 🛠️ Implementation
### 1. Setting up Address Lookup Table Cache
The SDK provides a global cache to manage address lookup tables:
```rust
use sol_trade_sdk::common::address_lookup_cache::AddressLookupTableCache;
use solana_sdk::pubkey::Pubkey;
use std::str::FromStr;
/// Setup lookup table cache
async fn setup_lookup_table_cache(
client: Arc<SolanaRpcClient>,
lookup_table_address: Pubkey,
) -> AnyResult<()> {
AddressLookupTableCache::get_instance()
.set_address_lookup_table(client, &lookup_table_address)
.await
.map_err(|e| anyhow::anyhow!("Failed to set address lookup table: {}", e))?;
Ok(())
}
```
### 2. Using Lookup Tables in Trade Parameters
Include lookup tables in your trade parameters:
```rust
// Initialize lookup table
let lookup_table_key = Pubkey::from_str("your_lookup_table_address_here").unwrap();
setup_lookup_table_cache(client.rpc.clone(), lookup_table_key).await?;
// Include lookup table in trade parameters
let buy_params = sol_trade_sdk::TradeBuyParams {
dex_type: DexType::PumpFun,
mint: mint_pubkey,
sol_amount: buy_sol_amount,
slippage_basis_points: Some(100),
recent_blockhash: recent_blockhash,
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
lookup_table_key: Some(lookup_table_key), // Include lookup table
wait_transaction_confirmed: true,
create_wsol_ata: false,
close_wsol_ata: false,
create_mint_ata: true,
open_seed_optimize: false,
custom_cu_limit: None,
};
// Execute transaction
client.buy(buy_params).await?;
```
## 📊 Performance Comparison
| Aspect | Without ALT | With ALT | Improvement |
|--------|-------------|----------|-------------|
| **Transaction Size** | ~1,232 bytes | ~800 bytes | 35% reduction |
| **Address Storage** | 32 bytes per address | 1 byte per address | 97% reduction |
| **Transaction Fees** | Higher | Lower | Up to 30% savings |
| **Block Space Usage** | More | Less | Improved network efficiency |
## ⚠️ Important Notes
1. **Lookup Table Address**: Must provide a valid address lookup table address
2. **Cache Management**: SDK automatically manages lookup table cache
3. **RPC Compatibility**: Ensure your RPC provider supports lookup tables
4. **Network Specific**: Lookup tables are network-specific (mainnet/devnet/testnet)
5. **Testing**: Always test on devnet before using on mainnet
## 🔗 Related Documentation
- [Trading Parameters Reference](TRADING_PARAMETERS.md)
- [Example: Address Lookup Table](../examples/address_lookup/)
## 📚 External Resources
- [Solana Address Lookup Tables Documentation](https://docs.solana.com/developing/lookup-tables)
+94
View File
@@ -0,0 +1,94 @@
# 地址查找表指南
本指南介绍如何在 Sol Trade SDK 中使用地址查找表 (ALT) 来优化交易大小并降低费用。
## 📋 什么是地址查找表?
地址查找表是 Solana 的一项功能,允许您将经常使用的地址以紧凑的表格格式存储。您可以通过查找表中的索引来引用地址,而不是在交易中包含完整的 32 字节地址,从而显著减少交易大小和成本。
## 🚀 核心优势
- **交易大小优化**: 使用地址索引而非完整地址来减少交易大小
- **成本降低**: 由于交易大小减小而降低交易费用
- **性能提升**: 更快的交易处理和验证速度
- **网络效率**: 减少带宽使用和区块空间消耗
## 🛠️ 实现方法
### 1. 设置地址查找表缓存
SDK 提供了一个全局缓存来管理地址查找表:
```rust
use sol_trade_sdk::common::address_lookup_cache::AddressLookupTableCache;
use solana_sdk::pubkey::Pubkey;
use std::str::FromStr;
/// 设置查找表缓存
async fn setup_lookup_table_cache(
client: Arc<SolanaRpcClient>,
lookup_table_address: Pubkey,
) -> AnyResult<()> {
AddressLookupTableCache::get_instance()
.set_address_lookup_table(client, &lookup_table_address)
.await
.map_err(|e| anyhow::anyhow!("Failed to set address lookup table: {}", e))?;
Ok(())
}
```
### 2. 在交易参数中使用查找表
在您的交易参数中包含查找表:
```rust
// 初始化查找表
let lookup_table_key = Pubkey::from_str("your_lookup_table_address_here").unwrap();
setup_lookup_table_cache(client.rpc.clone(), lookup_table_key).await?;
// 在交易参数中包含查找表
let buy_params = sol_trade_sdk::TradeBuyParams {
dex_type: DexType::PumpFun,
mint: mint_pubkey,
sol_amount: buy_sol_amount,
slippage_basis_points: Some(100),
recent_blockhash: recent_blockhash,
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
lookup_table_key: Some(lookup_table_key), // 包含查找表
wait_transaction_confirmed: true,
create_wsol_ata: false,
close_wsol_ata: false,
create_mint_ata: true,
open_seed_optimize: false,
custom_cu_limit: None,
};
// 执行交易
client.buy(buy_params).await?;
```
## 📊 性能对比
| 方面 | 不使用 ALT | 使用 ALT | 改进幅度 |
|------|-----------|----------|----------|
| **交易大小** | ~1,232 字节 | ~800 字节 | 减少 35% |
| **地址存储** | 每个地址 32 字节 | 每个地址 1 字节 | 减少 97% |
| **交易费用** | 更高 | 更低 | 节省高达 30% |
| **区块空间使用** | 更多 | 更少 | 提高网络效率 |
## ⚠️ 重要注意事项
1. **查找表地址**: 必须提供有效的地址查找表地址
2. **缓存管理**: SDK 自动管理查找表缓存
3. **RPC 兼容性**: 确保您的 RPC 提供商支持查找表
4. **网络**: 查找表是特定于网络的(主网/开发网/测试网)
5. **测试**: 在主网使用前请务必在开发网测试
## 🔗 相关文档
- [交易参数参考手册](TRADING_PARAMETERS_CN.md)
- [示例:地址查找表](../examples/address_lookup/)
## 📚 外部资源
- [Solana 地址查找表文档](https://docs.solana.com/developing/lookup-tables)
+84
View File
@@ -0,0 +1,84 @@
# Nonce Cache Guide
This guide explains how to use Nonce Cache in Sol Trade SDK to implement transaction replay protection and optimize transaction processing.
## 📋 What is Nonce Cache?
Nonce Cache is a global singleton cache system for managing durable nonce accounts in the Solana network. Durable nonce is a Solana feature that allows you to create transactions that remain valid for extended periods, not limited by the 150-block constraint of recent block hashes.
## 🚀 Core Benefits
- **Transaction Replay Protection**: Prevents the same transaction from being executed multiple times
- **Extended Time Window**: Transactions can remain valid for longer periods
- **Network Performance Optimization**: Reduces dependency on recent block hashes
- **Transaction Determinism**: Provides consistent transaction processing experience
- **Offline Transaction Support**: Supports offline processing of pre-signed transactions
## 🛠️ Implementation
### Prerequisites:
You need to create a nonce account for your payer account first.
Reference: https://solana.com/developers/guides/advanced/introduction-to-durable-nonces
### 1. Initialize Nonce Cache
First, set up the nonce account and initialize the cache:
```rust
use sol_trade_sdk::common::nonce_cache::NonceCache;
// Set nonce account
let nonce_account_str = "your_nonce_account_address_here";
NonceCache::get_instance().init(Some(nonce_account_str.to_string()));
```
### 2. Fetch Nonce Information
Get the latest nonce information from RPC:
```rust
// Fetch and update nonce information
NonceCache::get_instance().fetch_nonce_info_use_rpc(&client.rpc).await?;
// Get current nonce value
let nonce_info = NonceCache::get_instance().get_nonce_info();
let current_nonce = nonce_info.current_nonce;
println!("Current nonce: {}", current_nonce);
```
### 3. Use Nonce in Transactions
Pass the nonce as the recent_blockhash parameter to transactions:
```rust
let buy_params = sol_trade_sdk::TradeBuyParams {
dex_type: DexType::PumpFun,
mint: mint_pubkey,
sol_amount: buy_sol_amount,
slippage_basis_points: Some(100),
recent_blockhash: current_nonce, // Use nonce as blockhash
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
lookup_table_key: None,
wait_transaction_confirmed: true,
create_wsol_ata: false,
close_wsol_ata: false,
create_mint_ata: true,
open_seed_optimize: false,
custom_cu_limit: None,
};
// Execute transaction
client.buy(buy_params).await?;
```
## 🔄 Nonce Lifecycle
1. **Initialize**: Set nonce account address
2. **Fetch**: Get the latest nonce value from RPC
4. **Use**: Use as blockhash in transactions
6. **Refresh**: Re-fetch new nonce value before next use
## 🔗 Related Documentation
- [Example: Nonce Cache](../examples/nonce_cache/)
+84
View File
@@ -0,0 +1,84 @@
# Nonce 缓存指南
本指南介绍如何在 Sol Trade SDK 中使用 Nonce 缓存来实现交易重放保护和优化交易处理。
## 📋 什么是 Nonce 缓存?
Nonce 缓存是一个全局单例模式的缓存系统,用于管理 Solana 网络中的 durable nonce 账户。Durable nonce 是 Solana 的一项功能,允许您创建在较长时间内有效的交易,而不受最近区块哈希的 150 个区块限制。
## 🚀 核心优势
- **交易重放保护**: 防止相同交易被重复执行
- **时间窗口扩展**: 交易可在更长时间内保持有效
- **网络性能优化**: 减少对最新区块哈希的依赖
- **交易确定性**: 提供一致的交易处理体验
- **离线交易支持**: 支持预签名交易的离线处理
## 🛠️ 实现方法
### 前提:
需要先创建你 payer 账号使用的 nonce 账户。
参考资料: https://solana.com/zh/developers/guides/advanced/introduction-to-durable-nonces
### 1. 初始化 Nonce 缓存
首先需要设置 nonce 账户并初始化缓存:
```rust
use sol_trade_sdk::common::nonce_cache::NonceCache;
// 设置 nonce 账户
let nonce_account_str = "your_nonce_account_address_here";
NonceCache::get_instance().init(Some(nonce_account_str.to_string()));
```
### 2. 获取 Nonce 信息
从 RPC 获取最新的 nonce 信息:
```rust
// 获取并更新 nonce 信息
NonceCache::get_instance().fetch_nonce_info_use_rpc(&client.rpc).await?;
// 获取当前 nonce 值
let nonce_info = NonceCache::get_instance().get_nonce_info();
let current_nonce = nonce_info.current_nonce;
println!("Current nonce: {}", current_nonce);
```
### 3. 在交易中使用 Nonce
将 nonce 作为 recent_blockhash 参数传递给交易:
```rust
let buy_params = sol_trade_sdk::TradeBuyParams {
dex_type: DexType::PumpFun,
mint: mint_pubkey,
sol_amount: buy_sol_amount,
slippage_basis_points: Some(100),
recent_blockhash: current_nonce, // 使用 nonce 作为 blockhash
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
lookup_table_key: None,
wait_transaction_confirmed: true,
create_wsol_ata: false,
close_wsol_ata: false,
create_mint_ata: true,
open_seed_optimize: false,
custom_cu_limit: None,
};
// 执行交易
client.buy(buy_params).await?;
```
## 🔄 Nonce 生命周期
1. **初始化**: 设置 nonce 账户地址
2. **获取**: 从 RPC 获取最新 nonce 值
4. **使用**: 在交易中作为 blockhash 使用
6. **刷新**: 下次使用前重新获取新的 nonce 值
## 🔗 相关文档
- [示例:Nonce 缓存](../examples/nonce_cache/)
+142
View File
@@ -0,0 +1,142 @@
# 📋 Trading Parameters Reference
This document provides a comprehensive reference for all trading parameters used in the Sol Trade SDK.
## 📋 Table of Contents
- [TradeBuyParams](#tradebuyparams)
- [TradeSellParams](#tradesellparams)
- [Parameter Categories](#parameter-categories)
- [Important Notes](#important-notes)
## TradeBuyParams
The `TradeBuyParams` struct contains all parameters required for executing buy orders across different DEX protocols.
### Basic Trading Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `dex_type` | `DexType` | ✅ | The trading protocol to use (PumpFun, PumpSwap, Bonk, RaydiumCpmm, RaydiumAmmV4) |
| `mint` | `Pubkey` | ✅ | The public key of the token mint to purchase |
| `sol_amount` | `u64` | ✅ | Amount of SOL to spend (in lamports) |
| `slippage_basis_points` | `Option<u64>` | ❌ | Slippage tolerance in basis points (e.g., 100 = 1%, 500 = 5%) |
| `recent_blockhash` | `Hash` | ✅ | Recent blockhash for transaction validity |
| `extension_params` | `Box<dyn ProtocolParams>` | ✅ | Protocol-specific parameters (PumpFunParams, PumpSwapParams, etc.) |
### Advanced Configuration Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `custom_cu_limit` | `Option<u32>` | ❌ | Custom compute unit limit for the transaction |
| `lookup_table_key` | `Option<Pubkey>` | ❌ | Address lookup table key for transaction optimization |
| `wait_transaction_confirmed` | `bool` | ✅ | Whether to wait for transaction confirmation |
| `create_wsol_ata` | `bool` | ✅ | Whether to create wSOL Associated Token Account |
| `close_wsol_ata` | `bool` | ✅ | Whether to close wSOL ATA after transaction |
| `create_mint_ata` | `bool` | ✅ | Whether to create token mint ATA |
| `open_seed_optimize` | `bool` | ✅ | Whether to use seed optimization for reduced CU consumption |
## TradeSellParams
The `TradeSellParams` struct contains all parameters required for executing sell orders across different DEX protocols.
### Basic Trading Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `dex_type` | `DexType` | ✅ | The trading protocol to use (PumpFun, PumpSwap, Bonk, RaydiumCpmm, RaydiumAmmV4) |
| `mint` | `Pubkey` | ✅ | The public key of the token mint to sell |
| `token_amount` | `u64` | ✅ | Amount of tokens to sell (in smallest token units) |
| `slippage_basis_points` | `Option<u64>` | ❌ | Slippage tolerance in basis points (e.g., 100 = 1%, 500 = 5%) |
| `recent_blockhash` | `Hash` | ✅ | Recent blockhash for transaction validity |
| `with_tip` | `bool` | ✅ | Whether to include tip in the transaction |
| `extension_params` | `Box<dyn ProtocolParams>` | ✅ | Protocol-specific parameters (PumpFunParams, PumpSwapParams, etc.) |
### Advanced Configuration Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `custom_cu_limit` | `Option<u32>` | ❌ | Custom compute unit limit for the transaction |
| `lookup_table_key` | `Option<Pubkey>` | ❌ | Address lookup table key for transaction optimization |
| `wait_transaction_confirmed` | `bool` | ✅ | Whether to wait for transaction confirmation |
| `create_wsol_ata` | `bool` | ✅ | Whether to create wSOL Associated Token Account |
| `close_wsol_ata` | `bool` | ✅ | Whether to close wSOL ATA after transaction |
| `open_seed_optimize` | `bool` | ✅ | Whether to use seed optimization for reduced CU consumption |
## Parameter Categories
### 🎯 Core Trading Parameters
These parameters are essential for defining the basic trading operation:
- **dex_type**: Determines which protocol to use for trading
- **mint**: Specifies the token to trade
- **sol_amount** (buy) / **token_amount** (sell): Defines the trade size
- **recent_blockhash**: Ensures transaction validity
### ⚙️ Transaction Control Parameters
These parameters control how the transaction is processed:
- **slippage_basis_points**: Controls acceptable price slippage
- **custom_cu_limit**: Override default compute unit limits
- **wait_transaction_confirmed**: Controls whether to wait for confirmation
### 🔧 Account Management Parameters
These parameters control automatic account creation and management:
- **create_wsol_ata**: Automatically wrap SOL to wSOL when needed
- **close_wsol_ata**: Automatically unwrap wSOL to SOL after trading
- **create_mint_ata**: Automatically create token accounts
### 🚀 Optimization Parameters
These parameters enable advanced optimizations:
- **lookup_table_key**: Use address lookup tables for reduced transaction size
- **open_seed_optimize**: Use seed-based account creation for lower CU consumption
## Important Notes
### 🌱 Seed Optimization
When `open_seed_optimize: true`:
- ⚠️ **Warning**: Tokens purchased with seed optimization must be sold through this SDK
- ⚠️ **Warning**: Official platform selling methods may fail
- 📝 **Note**: Use `get_associated_token_address_with_program_id_fast_use_seed` to get ATA addresses
### 💰 wSOL Account Management
The `create_wsol_ata` and `close_wsol_ata` parameters provide granular control:
- **Independent Control**: Create and close operations can be controlled separately
- **Batch Operations**: Create once, trade multiple times, then close
- **Rent Optimization**: Automatic rent reclamation when closing accounts
### 🔍 Address Lookup Tables
Before using `lookup_table_key`:
- Initialize `AddressLookupTableCache` to manage cached lookup tables
- Lookup tables reduce transaction size and improve success rates
- Particularly beneficial for complex transactions with many account references
### 📊 Slippage Configuration
Recommended slippage settings:
- **Conservative**: 100-300 basis points (1-3%)
- **Moderate**: 300-500 basis points (3-5%)
- **Aggressive**: 500-1000 basis points (5-10%)
### 🎯 Protocol-Specific Parameters
Each DEX protocol requires specific `extension_params`:
- **PumpFun**: `PumpFunParams`
- **PumpSwap**: `PumpSwapParams`
- **Bonk**: `BonkParams`
- **Raydium CPMM**: `RaydiumCpmmParams`
- **Raydium AMM V4**: `RaydiumAmmV4Params`
Refer to the respective protocol documentation for detailed parameter specifications.
+142
View File
@@ -0,0 +1,142 @@
# 📋 交易参数参考手册
本文档提供 Sol Trade SDK 中所有交易参数的完整参考说明。
## 📋 目录
- [TradeBuyParams](#tradebuyparams)
- [TradeSellParams](#tradesellparams)
- [参数分类](#参数分类)
- [重要说明](#重要说明)
## TradeBuyParams
`TradeBuyParams` 结构体包含在不同 DEX 协议上执行买入订单所需的所有参数。
### 基础交易参数
| 参数 | 类型 | 必需 | 描述 |
|------|------|------|------|
| `dex_type` | `DexType` | ✅ | 要使用的交易协议 (PumpFun, PumpSwap, Bonk, RaydiumCpmm, RaydiumAmmV4) |
| `mint` | `Pubkey` | ✅ | 要购买的代币 mint 公钥 |
| `sol_amount` | `u64` | ✅ | 要花费的 SOL 数量(以 lamports 为单位) |
| `slippage_basis_points` | `Option<u64>` | ❌ | 滑点容忍度(基点单位,例如 100 = 1%, 500 = 5% |
| `recent_blockhash` | `Hash` | ✅ | 用于交易有效性的最新区块哈希 |
| `extension_params` | `Box<dyn ProtocolParams>` | ✅ | 协议特定参数 (PumpFunParams, PumpSwapParams 等) |
### 高级配置参数
| 参数 | 类型 | 必需 | 描述 |
|------|------|------|------|
| `custom_cu_limit` | `Option<u32>` | ❌ | 交易的自定义计算单元限制 |
| `lookup_table_key` | `Option<Pubkey>` | ❌ | 用于交易优化的地址查找表键 |
| `wait_transaction_confirmed` | `bool` | ✅ | 是否等待交易确认 |
| `create_wsol_ata` | `bool` | ✅ | 是否创建 wSOL 关联代币账户 |
| `close_wsol_ata` | `bool` | ✅ | 交易后是否关闭 wSOL ATA |
| `create_mint_ata` | `bool` | ✅ | 是否创建代币 mint ATA |
| `open_seed_optimize` | `bool` | ✅ | 是否使用 seed 优化以减少 CU 消耗 |
## TradeSellParams
`TradeSellParams` 结构体包含在不同 DEX 协议上执行卖出订单所需的所有参数。
### 基础交易参数
| 参数 | 类型 | 必需 | 描述 |
|------|------|------|------|
| `dex_type` | `DexType` | ✅ | 要使用的交易协议 (PumpFun, PumpSwap, Bonk, RaydiumCpmm, RaydiumAmmV4) |
| `mint` | `Pubkey` | ✅ | 要出售的代币 mint 公钥 |
| `token_amount` | `u64` | ✅ | 要出售的代币数量(最小代币单位) |
| `slippage_basis_points` | `Option<u64>` | ❌ | 滑点容忍度(基点单位,例如 100 = 1%, 500 = 5% |
| `recent_blockhash` | `Hash` | ✅ | 用于交易有效性的最新区块哈希 |
| `with_tip` | `bool` | ✅ | 交易中是否包含小费 |
| `extension_params` | `Box<dyn ProtocolParams>` | ✅ | 协议特定参数 (PumpFunParams, PumpSwapParams 等) |
### 高级配置参数
| 参数 | 类型 | 必需 | 描述 |
|------|------|------|------|
| `custom_cu_limit` | `Option<u32>` | ❌ | 交易的自定义计算单元限制 |
| `lookup_table_key` | `Option<Pubkey>` | ❌ | 用于交易优化的地址查找表键 |
| `wait_transaction_confirmed` | `bool` | ✅ | 是否等待交易确认 |
| `create_wsol_ata` | `bool` | ✅ | 是否创建 wSOL 关联代币账户 |
| `close_wsol_ata` | `bool` | ✅ | 交易后是否关闭 wSOL ATA |
| `open_seed_optimize` | `bool` | ✅ | 是否使用 seed 优化以减少 CU 消耗 |
## 参数分类
### 🎯 核心交易参数
这些参数对于定义基本交易操作至关重要:
- **dex_type**: 确定用于交易的协议
- **mint**: 指定要交易的代币
- **sol_amount** (买入) / **token_amount** (卖出): 定义交易规模
- **recent_blockhash**: 确保交易有效性
### ⚙️ 交易控制参数
这些参数控制交易的处理方式:
- **slippage_basis_points**: 控制可接受的价格滑点
- **custom_cu_limit**: 覆盖默认的计算单元限制
- **wait_transaction_confirmed**: 控制是否等待确认
### 🔧 账户管理参数
这些参数控制自动账户创建和管理:
- **create_wsol_ata**: 需要时自动将 SOL 包装为 wSOL
- **close_wsol_ata**: 交易后自动将 wSOL 解包装为 SOL
- **create_mint_ata**: 自动创建代币账户
### 🚀 优化参数
这些参数启用高级优化:
- **lookup_table_key**: 使用地址查找表减少交易大小
- **open_seed_optimize**: 使用基于 seed 的账户创建以降低 CU 消耗
## 重要说明
### 🌱 Seed 优化
`open_seed_optimize: true` 时:
- ⚠️ **警告**: 使用 seed 优化购买的代币必须通过此 SDK 出售
- ⚠️ **警告**: 官方平台的出售方法可能会失败
- 📝 **注意**: 使用 `get_associated_token_address_with_program_id_fast_use_seed` 获取 ATA 地址
### 💰 wSOL 账户管理
`create_wsol_ata``close_wsol_ata` 参数提供精细控制:
- **独立控制**: 创建和关闭操作可以分别控制
- **批量操作**: 创建一次,多次交易,然后关闭
- **租金优化**: 关闭账户时自动回收租金
### 🔍 地址查找表
使用 `lookup_table_key` 之前:
- 初始化 `AddressLookupTableCache` 来管理缓存的查找表
- 查找表减少交易大小并提高成功率
- 对于有许多账户引用的复杂交易特别有益
### 📊 滑点配置
推荐的滑点设置:
- **保守**: 100-300 基点 (1-3%)
- **中等**: 300-500 基点 (3-5%)
- **激进**: 500-1000 基点 (5-10%)
### 🎯 协议特定参数
每个 DEX 协议需要特定的 `extension_params`
- **PumpFun**: `PumpFunParams`
- **PumpSwap**: `PumpSwapParams`
- **Bonk**: `BonkParams`
- **Raydium CPMM**: `RaydiumCpmmParams`
- **Raydium AMM V4**: `RaydiumAmmV4Params`
请参阅相应的协议文档了解详细的参数规格。