refactor: optimize trading execution architecture and add wSOL management
- Simplify TradeExecutor interface by integrating middleware and swqos clients into params - Refactor parallel execution module with dedicated buy/sell execute functions - Add SOL wrapping/unwrapping functionality for wSOL management - Remove redundant parameter passing in sell operations - Delete example main.rs file - Optimize transaction building with integrated parameter structures BREAKING CHANGE: TradeExecutor interface simplified, middleware and swqos_clients now passed through params
This commit is contained in:
@@ -14,13 +14,13 @@ pub fn handle_wsol(payer: &Pubkey, amount_in: u64) -> SmallVec<[Instruction; 3]>
|
||||
);
|
||||
|
||||
let mut insts = SmallVec::<[Instruction; 3]>::new();
|
||||
insts.extend(create_associated_token_account_idempotent_fast(
|
||||
&payer,
|
||||
&payer,
|
||||
&crate::constants::WSOL_TOKEN_ACCOUNT,
|
||||
&crate::constants::TOKEN_PROGRAM,
|
||||
));
|
||||
insts.extend([
|
||||
create_associated_token_account_idempotent_fast(
|
||||
&payer,
|
||||
&payer,
|
||||
&crate::constants::WSOL_TOKEN_ACCOUNT,
|
||||
&crate::constants::TOKEN_PROGRAM,
|
||||
),
|
||||
transfer(&payer, &wsol_token_account, amount_in),
|
||||
spl_token::instruction::sync_native(&crate::constants::TOKEN_PROGRAM, &wsol_token_account)
|
||||
.unwrap(),
|
||||
@@ -29,33 +29,33 @@ pub fn handle_wsol(payer: &Pubkey, amount_in: u64) -> SmallVec<[Instruction; 3]>
|
||||
insts
|
||||
}
|
||||
|
||||
pub fn close_wsol(payer: &Pubkey) -> Instruction {
|
||||
pub fn close_wsol(payer: &Pubkey) -> Vec<Instruction> {
|
||||
let wsol_token_account =
|
||||
crate::common::fast_fn::get_associated_token_address_with_program_id_fast(
|
||||
&payer,
|
||||
&crate::constants::WSOL_TOKEN_ACCOUNT,
|
||||
&crate::constants::TOKEN_PROGRAM,
|
||||
);
|
||||
crate::common::fast_fn::get_cached_instruction(
|
||||
crate::common::fast_fn::get_cached_instructions(
|
||||
crate::common::fast_fn::InstructionCacheKey::CloseWsolAccount {
|
||||
payer: *payer,
|
||||
wsol_token_account,
|
||||
},
|
||||
|| {
|
||||
close_account(
|
||||
vec![close_account(
|
||||
&crate::constants::TOKEN_PROGRAM,
|
||||
&wsol_token_account,
|
||||
&payer,
|
||||
&payer,
|
||||
&[],
|
||||
)
|
||||
.unwrap()
|
||||
.unwrap()]
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn create_wsol_ata(payer: &Pubkey) -> Instruction {
|
||||
pub fn create_wsol_ata(payer: &Pubkey) -> Vec<Instruction> {
|
||||
create_associated_token_account_idempotent_fast(
|
||||
&payer,
|
||||
&payer,
|
||||
|
||||
Reference in New Issue
Block a user