Skip to content

Commit

Permalink
Make more CL operation mutative (#7692)
Browse files Browse the repository at this point in the history
(cherry picked from commit fb84df2)
  • Loading branch information
ValarDragon authored and mergify[bot] committed Mar 8, 2024
1 parent dba4b88 commit 317b07f
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 317b07f

Please sign in to comment.