mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-08-24 22:29:22 +00:00
feat(programs/amm): add swap exact output functionality
This commit is contained in:
@@ -119,7 +119,7 @@ fn main() {
|
||||
} => {
|
||||
let [pool, vault_a, vault_b, user_holding_a, user_holding_b] = pre_states
|
||||
.try_into()
|
||||
.expect("Transfer instruction requires exactly five accounts");
|
||||
.expect("Swap instruction requires exactly five accounts");
|
||||
amm_program::swap::swap(
|
||||
pool,
|
||||
vault_a,
|
||||
@@ -131,6 +131,25 @@ fn main() {
|
||||
token_definition_id_in,
|
||||
)
|
||||
}
|
||||
Instruction::SwapExactOutput {
|
||||
exact_amount_out,
|
||||
max_amount_in,
|
||||
token_definition_id_in,
|
||||
} => {
|
||||
let [pool, vault_a, vault_b, user_holding_a, user_holding_b] = pre_states
|
||||
.try_into()
|
||||
.expect("SwapExactOutput instruction requires exactly five accounts");
|
||||
amm_program::swap::swap_exact_output(
|
||||
pool,
|
||||
vault_a,
|
||||
vault_b,
|
||||
user_holding_a,
|
||||
user_holding_b,
|
||||
exact_amount_out,
|
||||
max_amount_in,
|
||||
token_definition_id_in,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
ProgramOutput::new(instruction_words, pre_states_clone, post_states)
|
||||
|
||||
Reference in New Issue
Block a user