- 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.
40 lines
1.2 KiB
Rust
Executable File
40 lines
1.2 KiB
Rust
Executable File
use crate::swqos::SwqosConfig;
|
|
use solana_commitment_config::CommitmentConfig;
|
|
|
|
#[derive(Debug, Clone)]
|
|
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 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 {
|
|
pub fn new(
|
|
rpc_url: String,
|
|
swqos_configs: Vec<SwqosConfig>,
|
|
commitment: CommitmentConfig,
|
|
create_wsol_ata_on_startup: bool,
|
|
wsol_use_seed: bool,
|
|
mint_use_seed: bool,
|
|
) -> Self {
|
|
Self {
|
|
rpc_url,
|
|
swqos_configs,
|
|
commitment,
|
|
create_wsol_ata_on_startup,
|
|
wsol_use_seed,
|
|
mint_use_seed,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub type SolanaRpcClient = solana_client::nonblocking::rpc_client::RpcClient;
|
|
pub type AnyResult<T> = anyhow::Result<T>;
|