diff --git a/x/amm/keeper/calc_in_route_spot_price.go b/x/amm/keeper/calc_in_route_spot_price.go index 3d96d59c7..26efefb66 100644 --- a/x/amm/keeper/calc_in_route_spot_price.go +++ b/x/amm/keeper/calc_in_route_spot_price.go @@ -85,12 +85,12 @@ func (k Keeper) CalcInRouteSpotPrice(ctx sdk.Context, tokenIn sdk.Coin, routes [ return sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), sdk.ZeroDec(), sdk.Coin{}, sdk.ZeroDec(), types.ErrSpotPriceIsZero } - // invert the spot price - spotPrice = sdk.OneDec().Quo(spotPrice) - // Calculate the token out amount tokenOutAmt := sdk.NewDecFromInt(tokenIn.Amount).Mul(spotPrice) + // invert the spot price + spotPrice = sdk.OneDec().Quo(spotPrice) + // Construct the token out coin tokenOut := sdk.NewCoin(tokenOutDenom, tokenOutAmt.TruncateInt()) diff --git a/x/amm/keeper/calc_out_route_spot_price.go b/x/amm/keeper/calc_out_route_spot_price.go index 312ff3e7b..1d8862c90 100644 --- a/x/amm/keeper/calc_out_route_spot_price.go +++ b/x/amm/keeper/calc_out_route_spot_price.go @@ -83,6 +83,9 @@ func (k Keeper) CalcOutRouteSpotPrice(ctx sdk.Context, tokenOut sdk.Coin, routes // Calculate the token in amount tokenInAmt := sdk.NewDecFromInt(tokenOut.Amount).Mul(spotPrice) + // invert the spot price + spotPrice = sdk.OneDec().Quo(spotPrice) + // Construct the token out coin tokenIn := sdk.NewCoin(tokenInDenom, tokenInAmt.TruncateInt())