refactor: split auto_handle_wsol into create/close_wsol_ata params

- Replace auto_handle_wsol with create_wsol_ata and close_wsol_ata
- Enable fine-grained control over wSOL account lifecycle
- Update all trading protocols and documentation
- Add open_seed_optimize support in fast functions

This provides better flexibility for batch operations and advanced trading.
This commit is contained in:
ysq
2025-09-09 17:35:09 +08:00
parent 1c5cfd4511
commit 7d7ee3cfbf
7 changed files with 94 additions and 66 deletions
+6 -11
View File
@@ -63,7 +63,7 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
// ========================================
let mut instructions = Vec::with_capacity(6);
if protocol_params.auto_handle_wsol {
if protocol_params.create_wsol_ata {
instructions
.extend(crate::trading::common::handle_wsol(&params.payer.pubkey(), amount_in));
}
@@ -109,7 +109,7 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
accounts.to_vec(),
));
if protocol_params.auto_handle_wsol {
if protocol_params.close_wsol_ata {
// Close wSOL ATA account, reclaim rent
instructions.extend(crate::trading::common::close_wsol(&params.payer.pubkey()));
}
@@ -162,14 +162,9 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
// ========================================
let mut instructions = Vec::with_capacity(3);
instructions.extend(
crate::common::fast_fn::create_associated_token_account_idempotent_fast(
&params.payer.pubkey(),
&params.payer.pubkey(),
&crate::constants::WSOL_TOKEN_ACCOUNT,
&crate::constants::TOKEN_PROGRAM,
),
);
if protocol_params.create_wsol_ata {
instructions.extend(crate::trading::common::create_wsol_ata(&params.payer.pubkey()));
}
// Create buy instruction
let accounts: [AccountMeta; 17] = [
@@ -203,7 +198,7 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
accounts.to_vec(),
));
if protocol_params.auto_handle_wsol {
if protocol_params.close_wsol_ata {
instructions.extend(crate::trading::common::close_wsol(&params.payer.pubkey()));
}