feat: add seed optimization and refactor wSOL account control
- Add `open_seed_optimize` parameter for enhanced performance - Move wSOL account flags from protocol params to buy/sell params - Add seed_trading example demonstrating optimization features - Update all examples and upgrade dependencies - Improve wSOL account management flexibility BREAKING CHANGE: Modified buy/sell method signatures and protocol param structs
This commit is contained in:
@@ -91,7 +91,7 @@ impl InstructionBuilder for BonkInstructionBuilder {
|
||||
// ========================================
|
||||
let mut instructions = Vec::with_capacity(6);
|
||||
|
||||
if protocol_params.create_wsol_ata {
|
||||
if params.create_wsol_ata {
|
||||
instructions
|
||||
.extend(crate::trading::common::handle_wsol(¶ms.payer.pubkey(), amount_in));
|
||||
}
|
||||
@@ -135,7 +135,7 @@ impl InstructionBuilder for BonkInstructionBuilder {
|
||||
|
||||
instructions.push(Instruction::new_with_bytes(accounts::BONK, &data, accounts.to_vec()));
|
||||
|
||||
if protocol_params.close_wsol_ata {
|
||||
if params.close_wsol_ata {
|
||||
instructions.extend(crate::trading::common::close_wsol(¶ms.payer.pubkey()));
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ impl InstructionBuilder for BonkInstructionBuilder {
|
||||
// ========================================
|
||||
let mut instructions = Vec::with_capacity(3);
|
||||
|
||||
if protocol_params.create_wsol_ata {
|
||||
if params.create_wsol_ata {
|
||||
instructions.extend(crate::trading::common::create_wsol_ata(¶ms.payer.pubkey()));
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ impl InstructionBuilder for BonkInstructionBuilder {
|
||||
|
||||
instructions.push(Instruction::new_with_bytes(accounts::BONK, &data, accounts.to_vec()));
|
||||
|
||||
if protocol_params.close_wsol_ata {
|
||||
if params.close_wsol_ata {
|
||||
instructions.extend(crate::trading::common::close_wsol(¶ms.payer.pubkey()));
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
||||
let pool_quote_token_reserves = protocol_params.pool_quote_token_reserves;
|
||||
let params_coin_creator_vault_ata = protocol_params.coin_creator_vault_ata;
|
||||
let params_coin_creator_vault_authority = protocol_params.coin_creator_vault_authority;
|
||||
let create_wsol_ata = protocol_params.create_wsol_ata;
|
||||
let close_wsol_ata = protocol_params.close_wsol_ata;
|
||||
let create_wsol_ata = params.create_wsol_ata;
|
||||
let close_wsol_ata = params.close_wsol_ata;
|
||||
let base_token_program = protocol_params.base_token_program;
|
||||
let quote_token_program = protocol_params.quote_token_program;
|
||||
let pool_base_token_account = protocol_params.pool_base_token_account;
|
||||
@@ -214,8 +214,8 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
||||
let pool_quote_token_account = protocol_params.pool_quote_token_account;
|
||||
let params_coin_creator_vault_ata = protocol_params.coin_creator_vault_ata;
|
||||
let params_coin_creator_vault_authority = protocol_params.coin_creator_vault_authority;
|
||||
let create_wsol_ata = protocol_params.create_wsol_ata;
|
||||
let close_wsol_ata = protocol_params.close_wsol_ata;
|
||||
let create_wsol_ata = params.create_wsol_ata;
|
||||
let close_wsol_ata = params.close_wsol_ata;
|
||||
let base_token_program = protocol_params.base_token_program;
|
||||
let quote_token_program = protocol_params.quote_token_program;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
|
||||
// ========================================
|
||||
let mut instructions = Vec::with_capacity(6);
|
||||
|
||||
if protocol_params.create_wsol_ata {
|
||||
if params.create_wsol_ata {
|
||||
instructions
|
||||
.extend(crate::trading::common::handle_wsol(¶ms.payer.pubkey(), amount_in));
|
||||
}
|
||||
@@ -112,7 +112,7 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
|
||||
accounts.to_vec(),
|
||||
));
|
||||
|
||||
if protocol_params.close_wsol_ata {
|
||||
if params.close_wsol_ata {
|
||||
// Close wSOL ATA account, reclaim rent
|
||||
instructions.extend(crate::trading::common::close_wsol(¶ms.payer.pubkey()));
|
||||
}
|
||||
@@ -167,7 +167,7 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
|
||||
// ========================================
|
||||
let mut instructions = Vec::with_capacity(3);
|
||||
|
||||
if protocol_params.create_wsol_ata {
|
||||
if params.create_wsol_ata {
|
||||
instructions.extend(crate::trading::common::create_wsol_ata(¶ms.payer.pubkey()));
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
|
||||
accounts.to_vec(),
|
||||
));
|
||||
|
||||
if protocol_params.close_wsol_ata {
|
||||
if params.close_wsol_ata {
|
||||
instructions.extend(crate::trading::common::close_wsol(¶ms.payer.pubkey()));
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ impl InstructionBuilder for RaydiumCpmmInstructionBuilder {
|
||||
// ========================================
|
||||
let mut instructions = Vec::with_capacity(6);
|
||||
|
||||
if protocol_params.create_wsol_ata {
|
||||
if params.create_wsol_ata {
|
||||
instructions
|
||||
.extend(crate::trading::common::handle_wsol(¶ms.payer.pubkey(), amount_in));
|
||||
}
|
||||
@@ -143,7 +143,7 @@ impl InstructionBuilder for RaydiumCpmmInstructionBuilder {
|
||||
accounts.to_vec(),
|
||||
));
|
||||
|
||||
if protocol_params.close_wsol_ata {
|
||||
if params.close_wsol_ata {
|
||||
// Close wSOL ATA account, reclaim rent
|
||||
instructions.extend(crate::trading::common::close_wsol(¶ms.payer.pubkey()));
|
||||
}
|
||||
@@ -228,7 +228,7 @@ impl InstructionBuilder for RaydiumCpmmInstructionBuilder {
|
||||
// ========================================
|
||||
let mut instructions = Vec::with_capacity(3);
|
||||
|
||||
if protocol_params.create_wsol_ata {
|
||||
if params.create_wsol_ata {
|
||||
instructions.extend(crate::trading::common::create_wsol_ata(¶ms.payer.pubkey()));
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ impl InstructionBuilder for RaydiumCpmmInstructionBuilder {
|
||||
accounts.to_vec(),
|
||||
));
|
||||
|
||||
if protocol_params.close_wsol_ata {
|
||||
if params.close_wsol_ata {
|
||||
// Close wSOL ATA account, reclaim rent
|
||||
instructions.extend(crate::trading::common::close_wsol(¶ms.payer.pubkey()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user