Skip to content

Commit

Permalink
Make more CL operation mutative (#7692)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon committed Mar 8, 2024
1 parent c6c2449 commit fb84df2
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 @@ -494,7 +494,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 @@ -622,7 +622,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 fb84df2

Please sign in to comment.