Skip to content

Conversation

@yugure-orca
Copy link
Collaborator

For event emission release

note: PR59

Copy link
Member

@wjthieme wjthieme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀🚀🚀


let pre_sqrt_price_one = whirlpool_one.sqrt_price;
let (input_amount_one, input_transfer_fee_one, output_amount_one, output_transfer_fee_one) =
if a_to_b_one {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think to reduce branching and enhance readability, I generally like to split the variables prior to function calls, so in this case it might be something like

let (input_amount_one, output_amount_one) = if a_to_b_one {
   (swap_update_one.amount_a, swap_update_one.amount_b)
} else {
   (swap_update_one.amount_b, swap_update_one.amount_a)
};
let input_transfer_fee_one = calculate_transfer_fee_excluded_amount(&ctx.accounts.token_mint_input, input_amount_one);
let output_transfer_fee_one = calculate_transfer_fee_excluded_amount(&ctx.accounts.token_mint_intermediate, output_amount_one);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! updated. It is much cleaner 😂

@yugure-orca yugure-orca merged commit 7488726 into main Feb 27, 2025
6 checks passed
@yugure-orca yugure-orca deleted the yugure/em branch February 27, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants