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:
Wood
2025-11-21 13:05:39 +08:00
parent c0e026a88a
commit eb8de36f50
11 changed files with 196 additions and 135 deletions
+2 -1
View File
@@ -31,7 +31,8 @@ pub struct SwapParams {
pub data_size_limit: u32,
pub wait_transaction_confirmed: bool,
pub protocol_params: Box<dyn ProtocolParams>,
pub open_seed_optimize: bool,
pub wsol_use_seed: bool,
pub mint_use_seed: bool,
pub swqos_clients: Vec<Arc<SwqosClient>>,
pub middleware_manager: Option<Arc<MiddlewareManager>>,
pub durable_nonce: Option<DurableNonceInfo>,