diff --git a/x/liquidity/amm/tick.go b/x/liquidity/amm/tick.go index 312a4543..db5d53d0 100644 --- a/x/liquidity/amm/tick.go +++ b/x/liquidity/amm/tick.go @@ -145,7 +145,9 @@ func DownTick(price sdk.Dec, prec int) sdk.Dec { // HighestTick returns the highest possible price tick. func HighestTick(prec int) sdk.Dec { - i := new(big.Int).SetBits([]big.Word{0, 0, 0, 0, 0x1000000000000000}) + i := big.NewInt(2) + // Maximum 315 bits possible, but take slightly less value for safety. + i.Exp(i, big.NewInt(300), nil).Sub(i, big.NewInt(1)) return PriceToDownTick(sdk.NewDecFromBigIntWithPrec(i, sdk.Precision), prec) } diff --git a/x/liquidity/amm/tick_test.go b/x/liquidity/amm/tick_test.go index 7a09226a..5b688b94 100644 --- a/x/liquidity/amm/tick_test.go +++ b/x/liquidity/amm/tick_test.go @@ -110,18 +110,15 @@ func TestHighestTick(t *testing.T) { prec int expected string }{ - {3, "133400000000000000000000000000000000000000000000000000000000000000000000000000"}, - {0, "100000000000000000000000000000000000000000000000000000000000000000000000000000"}, - {1, "130000000000000000000000000000000000000000000000000000000000000000000000000000"}, + {3, "2037000000000000000000000000000000000000000000000000000000000000000000000"}, + {0, "2000000000000000000000000000000000000000000000000000000000000000000000000"}, + {1, "2000000000000000000000000000000000000000000000000000000000000000000000000"}, } { t.Run("", func(t *testing.T) { i, ok := new(big.Int).SetString(tc.expected, 10) require.True(t, ok) tick := amm.HighestTick(tc.prec) require.True(sdk.DecEq(t, sdk.NewDecFromBigInt(i), tick)) - require.Panics(t, func() { - amm.UpTick(tick, tc.prec) - }) }) } }