refactor: split seed optimization config into wsol_use_seed and mint_use_seed
- Split use_seed_optimize parameter into two independent configs:
* wsol_use_seed: controls seed optimization for WSOL ATA operations (default: false)
* mint_use_seed: controls seed optimization for other mint ATA operations (default: true)
- Refactor TradeConfig to accept all parameters in new() constructor
- Remove deprecated builder methods (with_seed_config, with_wsol_ata_config)
- Add wsol_use_seed and mint_use_seed fields to SwapParams
- Remove open_seed_optimize field from SwapParams
- Update all instruction builders to use correct seed parameter:
* Use params.wsol_use_seed for WSOL token operations
* Use params.mint_use_seed for other token operations
* Fix token type detection in bonk.rs, raydium_cpmm.rs, and raydium_amm_v4.rs
to properly select wsol_use_seed when dealing with WSOL tokens
- Update wsol_manager functions to accept is_use_seed parameter:
* handle_wsol()
* close_wsol()
* create_wsol_ata()
* wrap_sol_only()
* wrap_wsol_to_sol()
- Add wrap_wsol_to_sol() function with smart temporary account selection:
* If source is seed-created, use normal ATA for temp account
* If source is normal ATA, use seed ATA for temp account
* Prevents address conflicts while optimizing performance
This provides fine-grained control over seed optimization strategies,
allowing different configurations for WSOL and other tokens.
This commit is contained in:
+10
-17
@@ -9,8 +9,10 @@ pub struct TradeConfig {
|
||||
/// Whether to create WSOL ATA on startup (default: true)
|
||||
/// If true, SDK will check WSOL ATA on initialization and create if not exists
|
||||
pub create_wsol_ata_on_startup: bool,
|
||||
/// Whether to use seed optimization for all ATA operations (default: true)
|
||||
pub use_seed_optimize: bool,
|
||||
/// Whether to use seed optimization for WSOL ATA operations (default: false)
|
||||
pub wsol_use_seed: bool,
|
||||
/// Whether to use seed optimization for other mint ATA operations (default: true)
|
||||
pub mint_use_seed: bool,
|
||||
}
|
||||
|
||||
impl TradeConfig {
|
||||
@@ -18,28 +20,19 @@ impl TradeConfig {
|
||||
rpc_url: String,
|
||||
swqos_configs: Vec<SwqosConfig>,
|
||||
commitment: CommitmentConfig,
|
||||
create_wsol_ata_on_startup: bool,
|
||||
wsol_use_seed: bool,
|
||||
mint_use_seed: bool,
|
||||
) -> Self {
|
||||
println!("🔧 TradeConfig create_wsol_ata_on_startup default value: true");
|
||||
println!("🔧 TradeConfig use_seed_optimize default value: true");
|
||||
Self {
|
||||
rpc_url,
|
||||
swqos_configs,
|
||||
commitment,
|
||||
create_wsol_ata_on_startup: true, // 默认:启动时检查并创建
|
||||
use_seed_optimize: true, // 默认:使用seed优化
|
||||
create_wsol_ata_on_startup,
|
||||
wsol_use_seed,
|
||||
mint_use_seed,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a TradeConfig with custom WSOL ATA settings
|
||||
pub fn with_wsol_ata_config(
|
||||
mut self,
|
||||
create_wsol_ata_on_startup: bool,
|
||||
use_seed_optimize: bool,
|
||||
) -> Self {
|
||||
self.create_wsol_ata_on_startup = create_wsol_ata_on_startup;
|
||||
self.use_seed_optimize = use_seed_optimize;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub type SolanaRpcClient = solana_client::nonblocking::rpc_client::RpcClient;
|
||||
|
||||
Reference in New Issue
Block a user