From a7ccf5afc6c8d90c9a09682a7f08c84f5917bd90 Mon Sep 17 00:00:00 2001 From: armaniferrante Date: Wed, 2 Jun 2021 00:32:07 -0700 Subject: [PATCH] stash --- programs/swap/src/lib.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/programs/swap/src/lib.rs b/programs/swap/src/lib.rs index 5b01fcf..17db4b3 100644 --- a/programs/swap/src/lib.rs +++ b/programs/swap/src/lib.rs @@ -198,17 +198,17 @@ pub mod swap { fn apply_risk_checks<'info>(event: DidSwap) -> Result<()> { emit!(event); - let spill_deduction = { - if event.spill_amount == 0 || event.min_exchange_rate.strict { - 0 - } else { - (event.from_amount.checked_mul(event.spill_amount).unwrap()) - .checked_div(event.quote_amount) - .unwrap() - } - }; - let (to_amount, min_expected_amount) = { + // If there is spill (i.e. quote tokens *not* fully consumed) + let spill_deduction = { + if event.spill_amount == 0 || event.min_exchange_rate.strict { + 0 + } else { + (event.from_amount.checked_mul(event.spill_amount).unwrap()) + .checked_div(event.quote_amount) + .unwrap() + } + }; // Use the exchange rate to calculate the client's expectation. // This number has // @@ -618,8 +618,6 @@ pub struct ExchangeRate { rate: u64, // Number of decimals of the *from* token's mint. decimals: u8, - // Number opf decimals of the *quote* token for a transitive swap. - quote_decimals: u8, // True if *all* of the *from* currency sold should be used when calculating // the executed exchange rate. //