feat: refactor seed optimization to global configuration in v3.2.0
- Remove open_seed_optimize parameter from TradeBuyParams and TradeSellParams structs - Add global use_seed_optimize configuration in TradeConfig with default value true - Add create_wsol_ata_on_startup configuration in TradeConfig with default value true - Implement automatic WSOL ATA creation and verification on SDK initialization - Add with_wsol_ata_config() builder method to TradeConfig for custom WSOL settings - Update all examples to remove open_seed_optimize parameter usage - Update documentation (README, TRADING_PARAMETERS) to reflect new configuration approach - Upgrade package version from 3.1.7 to 3.2.0 Breaking Changes: - open_seed_optimize parameter removed from trade parameters (now global setting) - Seed optimization is now enabled by default for all operations
This commit is contained in:
+25
-1
@@ -6,6 +6,11 @@ pub struct TradeConfig {
|
||||
pub rpc_url: String,
|
||||
pub swqos_configs: Vec<SwqosConfig>,
|
||||
pub commitment: CommitmentConfig,
|
||||
/// 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,
|
||||
}
|
||||
|
||||
impl TradeConfig {
|
||||
@@ -14,7 +19,26 @@ impl TradeConfig {
|
||||
swqos_configs: Vec<SwqosConfig>,
|
||||
commitment: CommitmentConfig,
|
||||
) -> Self {
|
||||
Self { rpc_url, swqos_configs, commitment }
|
||||
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 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user