Skip to content

Commit

Permalink
Make more CL operation mutative (#7692) (#7694)
Browse files Browse the repository at this point in the history
(cherry picked from commit fb84df2)

Co-authored-by: Dev Ojha <[email protected]>
  • Loading branch information
mergify[bot] and ValarDragon authored Mar 8, 2024
1 parent b170cd3 commit 65f44f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x/concentrated-liquidity/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 65f44f1

Please sign in to comment.