Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make one more CL operation mutative #7692

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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