From 65f44f17a4a1aba198fc22b6d99dd47186e97ea4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:42:32 -0600 Subject: [PATCH] Make more CL operation mutative (#7692) (#7694) (cherry picked from commit fb84df21ea13f469f8c43716839f92eb2528d30b) Co-authored-by: Dev Ojha --- x/concentrated-liquidity/swaps.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index 03e579a0e77..7cb35ceee81 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -493,7 +493,7 @@ func (k Keeper) computeOutAmtGivenIn( // Coin amounts require int values // Round amountIn up to avoid under charging - amountIn := (tokenInMin.Amount.ToLegacyDec().Sub(swapState.amountSpecifiedRemaining)).Ceil().TruncateInt() + amountIn := (tokenInMin.Amount.ToLegacyDec().SubMut(swapState.amountSpecifiedRemaining)).Ceil().TruncateInt() // Round amountOut down to avoid over distributing. amountOut := swapState.amountCalculated.TruncateInt() @@ -620,7 +620,7 @@ func (k Keeper) computeInAmtGivenOut( amountIn := swapState.amountCalculated.Ceil().TruncateInt() // Round amount out down to avoid over charging the pool. - amountOut := desiredTokenOut.Amount.ToLegacyDec().Sub(swapState.amountSpecifiedRemaining).TruncateInt() + amountOut := desiredTokenOut.Amount.ToLegacyDec().SubMut(swapState.amountSpecifiedRemaining).TruncateInt() ctx.Logger().Debug("final amount in", amountIn) ctx.Logger().Debug("final amount out", amountOut)