diff --git a/proto/osmosis/concentrated-liquidity/pool.proto b/proto/osmosis/concentrated-liquidity/pool.proto index 81eea146973..6c0b47ef047 100644 --- a/proto/osmosis/concentrated-liquidity/pool.proto +++ b/proto/osmosis/concentrated-liquidity/pool.proto @@ -40,19 +40,12 @@ message Pool { (gogoproto.moretags) = "yaml:\"spot_price\"", (gogoproto.nullable) = false ]; - string current_tick = 8 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"current_tick\"", - (gogoproto.nullable) = false - ]; + int64 current_tick = 8 [ (gogoproto.moretags) = "yaml:\"current_tick\"" ]; // tick_spacing must be one of the authorized_tick_spacing values set in the // concentrated-liquidity parameters uint64 tick_spacing = 9 [ (gogoproto.moretags) = "yaml:\"tick_spacing\"" ]; - string exponent_at_price_one = 10 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"exponent_at_price_one\"", - (gogoproto.nullable) = false - ]; + int64 exponent_at_price_one = 10 + [ (gogoproto.moretags) = "yaml:\"exponent_at_price_one\"" ]; // swap_fee is the ratio that is charged on the amount of token in. string swap_fee = 11 [ diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 15df18bc7d3..5ad1b14daba 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -222,7 +222,7 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() { concentratedPool := s.updatedPool(chainANode, poolID) // Sanity check that pool initialized with valid parameters (the ones that we haven't explicitly specified) - s.Require().Equal(concentratedPool.GetCurrentTick().Int64(), int64(0)) + s.Require().Equal(concentratedPool.GetCurrentTick(), int64(0)) s.Require().Equal(concentratedPool.GetCurrentSqrtPrice(), sdk.ZeroDec()) s.Require().Equal(concentratedPool.GetLiquidity(), sdk.ZeroDec()) @@ -231,7 +231,7 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() { s.Require().Equal(concentratedPool.GetToken0(), denom0) s.Require().Equal(concentratedPool.GetToken1(), denom1) s.Require().Equal(concentratedPool.GetTickSpacing(), tickSpacing) - s.Require().Equal(concentratedPool.GetExponentAtPriceOne().Int64(), cltypes.ExponentAtPriceOne) + s.Require().Equal(concentratedPool.GetExponentAtPriceOne(), cltypes.ExponentAtPriceOne) s.Require().Equal(concentratedPool.GetSwapFee(sdk.Context{}), sdk.MustNewDecFromStr(swapFee)) fundTokens := []string{"100000000uosmo", "100000000uion", "100000000stake"} diff --git a/x/concentrated-liquidity/bench_test.go b/x/concentrated-liquidity/bench_test.go index 3720e78c7b7..95cec986ea6 100644 --- a/x/concentrated-liquidity/bench_test.go +++ b/x/concentrated-liquidity/bench_test.go @@ -120,14 +120,14 @@ func BenchmarkSwapExactAmountIn(b *testing.B) { // Decreasing price so want to be below current tick // minTick <= lowerTick <= currentTick - lowerTick = rand.Int63n(currentTick.Int64()-types.MinTick+1) + types.MinTick + lowerTick = rand.Int63n(currentTick-types.MinTick+1) + types.MinTick // lowerTick <= upperTick <= currentTick - upperTick = currentTick.Int64() - rand.Int63n(int64(math.Abs(float64(currentTick.Int64()-lowerTick)))) + upperTick = currentTick - rand.Int63n(int64(math.Abs(float64(currentTick-lowerTick)))) } else { // Increasing price so want to be above current tick // currentTick <= lowerTick <= maxTick - lowerTick := rand.Int63n(types.MaxTick-currentTick.Int64()+1) + currentTick.Int64() + lowerTick := rand.Int63n(types.MaxTick-currentTick+1) + currentTick // lowerTick <= upperTick <= maxTick upperTick = types.MaxTick - rand.Int63n(int64(math.Abs(float64(types.MaxTick-lowerTick)))) } @@ -171,8 +171,8 @@ func BenchmarkSwapExactAmountIn(b *testing.B) { // Within 10 ticks of the current if tickSpacing <= 10 { for i := 0; i < numberOfPositions; i++ { - lowerTick := currentTick.Int64() - 10 - upperTick := currentTick.Int64() + 10 + lowerTick := currentTick - 10 + upperTick := currentTick + 10 tokenDesired0 := sdk.NewCoin(denom0, sdk.NewInt(maxAmountDeposited).MulRaw(5)) tokenDesired1 := sdk.NewCoin(denom1, sdk.NewInt(maxAmountDeposited).MulRaw(5)) @@ -190,8 +190,8 @@ func BenchmarkSwapExactAmountIn(b *testing.B) { // Within 100 ticks of the current for i := 0; i < numberOfPositions; i++ { - lowerTick := currentTick.Int64() - 100 - upperTick := currentTick.Int64() + 100 + lowerTick := currentTick - 100 + upperTick := currentTick + 100 // Normalize lowerTick to be a multiple of tickSpacing lowerTick = lowerTick + (tickSpacing - lowerTick%tickSpacing) // Normalize upperTick to be a multiple of tickSpacing @@ -214,7 +214,7 @@ func BenchmarkSwapExactAmountIn(b *testing.B) { swapAmountIn := sdk.MustNewDecFromStr(amountIn).TruncateInt() largeSwapInCoin := sdk.NewCoin(denomIn, swapAmountIn) - liquidityNet, err := clKeeper.GetTickLiquidityNetInDirection(s.Ctx, pool.GetId(), largeSwapInCoin.Denom, currentTick, sdk.Int{}) + liquidityNet, err := clKeeper.GetTickLiquidityNetInDirection(s.Ctx, pool.GetId(), largeSwapInCoin.Denom, sdk.NewInt(currentTick), sdk.Int{}) noError(err) fmt.Println("num_ticks_traversed", len(liquidityNet)) diff --git a/x/concentrated-liquidity/client/query_proto_wrap.go b/x/concentrated-liquidity/client/query_proto_wrap.go index 7e1a3b1dcb3..caf8d9c2252 100644 --- a/x/concentrated-liquidity/client/query_proto_wrap.go +++ b/x/concentrated-liquidity/client/query_proto_wrap.go @@ -153,7 +153,7 @@ func (q Querier) LiquidityNetInDirection(ctx sdk.Context, req clquery.LiquidityN return nil, err } - return &clquery.LiquidityNetInDirectionResponse{LiquidityDepths: liquidityDepths, CurrentLiquidity: pool.GetLiquidity(), CurrentTick: pool.GetCurrentTick().Int64()}, nil + return &clquery.LiquidityNetInDirectionResponse{LiquidityDepths: liquidityDepths, CurrentLiquidity: pool.GetLiquidity(), CurrentTick: pool.GetCurrentTick()}, nil } func (q Querier) ClaimableFees(ctx sdk.Context, req clquery.ClaimableFeesRequest) (*clquery.ClaimableFeesResponse, error) { diff --git a/x/concentrated-liquidity/fees.go b/x/concentrated-liquidity/fees.go index 6d9ccb28464..e6b3d5cc2a2 100644 --- a/x/concentrated-liquidity/fees.go +++ b/x/concentrated-liquidity/fees.go @@ -128,7 +128,7 @@ func (k Keeper) getFeeGrowthOutside(ctx sdk.Context, poolId uint64, lowerTick, u if err != nil { return sdk.DecCoins{}, err } - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() // get lower, upper tick info lowerTickInfo, err := k.GetTickInfo(ctx, poolId, lowerTick) @@ -164,7 +164,7 @@ func (k Keeper) getInitialFeeGrowthOppositeDirectionOfLastTraversalForTick(ctx s return sdk.DecCoins{}, err } - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() if currentTick >= tick { feeAccumulator, err := k.GetFeeAccumulator(ctx, poolId) if err != nil { diff --git a/x/concentrated-liquidity/fees_test.go b/x/concentrated-liquidity/fees_test.go index e9c72b7de86..b76182c02d4 100644 --- a/x/concentrated-liquidity/fees_test.go +++ b/x/concentrated-liquidity/fees_test.go @@ -401,11 +401,11 @@ func (s *KeeperTestSuite) TestGetFeeGrowthOutside() { var pool types.ConcentratedPoolExtension if tc.poolSetup { pool = s.PrepareConcentratedPool() - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() s.initializeTick(s.Ctx, currentTick, tc.lowerTick, defaultInitialLiquidity, tc.lowerTickFeeGrowthOutside, emptyUptimeTrackers, false) s.initializeTick(s.Ctx, currentTick, tc.upperTick, defaultInitialLiquidity, tc.upperTickFeeGrowthOutside, emptyUptimeTrackers, true) - pool.SetCurrentTick(sdk.NewInt(tc.currentTick)) + pool.SetCurrentTick(tc.currentTick) err := s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) s.Require().NoError(err) err = s.App.ConcentratedLiquidityKeeper.ChargeFee(s.Ctx, validPoolId, tc.globalFeeGrowth) @@ -916,7 +916,7 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() { s.initializeTick(ctx, tc.currentTick, tc.upperTick, tc.initialLiquidity, tc.upperTickFeeGrowthOutside, emptyUptimeTrackers, true) - validPool.SetCurrentTick(sdk.NewInt(tc.currentTick)) + validPool.SetCurrentTick(tc.currentTick) err = clKeeper.SetPool(ctx, validPool) s.Require().NoError(err) @@ -1179,7 +1179,7 @@ func (s *KeeperTestSuite) TestPrepareClaimableFees() { s.initializeFeeAccumulatorPositionWithLiquidity(ctx, validPoolId, tc.lowerTick, tc.upperTick, DefaultPositionId, tc.initialLiquidity) s.initializeTick(ctx, tc.currentTick, tc.lowerTick, tc.initialLiquidity, tc.lowerTickFeeGrowthOutside, emptyUptimeTrackers, false) s.initializeTick(ctx, tc.currentTick, tc.upperTick, tc.initialLiquidity, tc.upperTickFeeGrowthOutside, emptyUptimeTrackers, true) - validPool.SetCurrentTick(sdk.NewInt(tc.currentTick)) + validPool.SetCurrentTick(tc.currentTick) _ = clKeeper.SetPool(ctx, validPool) @@ -1287,10 +1287,10 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition_UpdatingPositio s.crossTickAndChargeFee(poolId, DefaultLowerTick) } - err := s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(s.Ctx, poolId, pool.GetCurrentTick().Int64(), DefaultLowerTick, DefaultLiquidityAmt, false) + err := s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(s.Ctx, poolId, pool.GetCurrentTick(), DefaultLowerTick, DefaultLiquidityAmt, false) s.Require().NoError(err) - err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(s.Ctx, poolId, pool.GetCurrentTick().Int64(), DefaultUpperTick, DefaultLiquidityAmt, true) + err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(s.Ctx, poolId, pool.GetCurrentTick(), DefaultUpperTick, DefaultLiquidityAmt, true) s.Require().NoError(err) // InitOrUpdateFeeAccumulatorPosition #1 lower tick to upper tick @@ -1456,11 +1456,11 @@ func (s *KeeperTestSuite) TestFunctional_Fees_Swaps() { // Swap multiple times USDC for ETH, therefore increasing the spot price ticksActivatedAfterEachSwap, totalFeesExpected, _, _ := s.swapAndTrackXTimesInARow(clPool.GetId(), DefaultCoin1, ETH, types.MaxSpotPrice, positions.numSwaps) - s.CollectAndAssertFees(s.Ctx, clPool.GetId(), totalFeesExpected, positionIds, [][]sdk.Int{ticksActivatedAfterEachSwap}, onlyUSDC, positions) + s.CollectAndAssertFees(s.Ctx, clPool.GetId(), totalFeesExpected, positionIds, [][]int64{ticksActivatedAfterEachSwap}, onlyUSDC, positions) // Swap multiple times ETH for USDC, therefore decreasing the spot price ticksActivatedAfterEachSwap, totalFeesExpected, _, _ = s.swapAndTrackXTimesInARow(clPool.GetId(), DefaultCoin0, USDC, types.MinSpotPrice, positions.numSwaps) - s.CollectAndAssertFees(s.Ctx, clPool.GetId(), totalFeesExpected, positionIds, [][]sdk.Int{ticksActivatedAfterEachSwap}, onlyETH, positions) + s.CollectAndAssertFees(s.Ctx, clPool.GetId(), totalFeesExpected, positionIds, [][]int64{ticksActivatedAfterEachSwap}, onlyETH, positions) // Do the same swaps as before, however this time we collect fees after both swap directions are complete. ticksActivatedAfterEachSwapUp, totalFeesExpectedUp, _, _ := s.swapAndTrackXTimesInARow(clPool.GetId(), DefaultCoin1, ETH, types.MaxSpotPrice, positions.numSwaps) @@ -1469,7 +1469,7 @@ func (s *KeeperTestSuite) TestFunctional_Fees_Swaps() { // We expect all positions to have both denoms in their fee accumulators except USDC for the overlapping range position since // it was not activated during the USDC -> ETH swap direction but was activated during the ETH -> USDC swap direction. - ticksActivatedAfterEachSwapTest := [][]sdk.Int{ticksActivatedAfterEachSwapUp, ticksActivatedAfterEachSwapDown} + ticksActivatedAfterEachSwapTest := [][]int64{ticksActivatedAfterEachSwapUp, ticksActivatedAfterEachSwapDown} denomsExpected := [][]string{{USDC, ETH}, {USDC, ETH}, {USDC, ETH}, {NoUSDCExpected, ETH}} s.CollectAndAssertFees(s.Ctx, clPool.GetId(), totalFeesExpected, positionIds, ticksActivatedAfterEachSwapTest, denomsExpected, positions) @@ -1514,7 +1514,7 @@ func (s *KeeperTestSuite) TestFunctional_Fees_LP() { s.Require().NoError(err) // Collect fees. - feesCollected := s.collectFeesAndCheckInvariance(ctx, 0, DefaultMinTick, DefaultMaxTick, positionIdOne, sdk.NewCoins(), []string{USDC}, [][]sdk.Int{ticksActivatedAfterEachSwap}) + feesCollected := s.collectFeesAndCheckInvariance(ctx, 0, DefaultMinTick, DefaultMaxTick, positionIdOne, sdk.NewCoins(), []string{USDC}, [][]int64{ticksActivatedAfterEachSwap}) expectedFeesTruncated := totalFeesExpected for i, feeToken := range totalFeesExpected { // We run expected fees through a cycle of divison and multiplication by liquidity to capture appropriate rounding behavior @@ -1547,7 +1547,7 @@ func (s *KeeperTestSuite) TestFunctional_Fees_LP() { _, err = s.App.ConcentratedLiquidityKeeper.CollectFees(ctx, owner, positionIdTwo) s.Require().Error(err) - feesCollected = s.collectFeesAndCheckInvariance(ctx, 0, DefaultMinTick, DefaultMaxTick, positionIdOne, sdk.NewCoins(), []string{ETH}, [][]sdk.Int{ticksActivatedAfterEachSwap}) + feesCollected = s.collectFeesAndCheckInvariance(ctx, 0, DefaultMinTick, DefaultMaxTick, positionIdOne, sdk.NewCoins(), []string{ETH}, [][]int64{ticksActivatedAfterEachSwap}) // total fees * half liquidity / (full liquidity + half liquidity) expectesFeesCollected := totalFeesExpected.AmountOf(ETH).ToDec().Mul(halfLiquidity.Quo(fullLiquidity.Add(halfLiquidity))).TruncateInt() @@ -1565,7 +1565,7 @@ func (s *KeeperTestSuite) TestFunctional_Fees_LP() { // CollectAndAssertFees collects fees from a given pool for all positions and verifies that the total fees collected match the expected total fees. // The method also checks that if the ticks that were active during the swap lie within the range of a position, then the position's fee accumulators // are not empty. The total fees collected are compared to the expected total fees within an additive tolerance defined by an error tolerance struct. -func (s *KeeperTestSuite) CollectAndAssertFees(ctx sdk.Context, poolId uint64, totalFees sdk.Coins, positionIds [][]uint64, activeTicks [][]sdk.Int, expectedFeeDenoms [][]string, positions Positions) { +func (s *KeeperTestSuite) CollectAndAssertFees(ctx sdk.Context, poolId uint64, totalFees sdk.Coins, positionIds [][]uint64, activeTicks [][]int64, expectedFeeDenoms [][]string, positions Positions) { var totalFeesCollected sdk.Coins // Claim full range position fees across all four accounts for i := 0; i < positions.numFullRange; i++ { @@ -1602,12 +1602,12 @@ func (s *KeeperTestSuite) CollectAndAssertFees(ctx sdk.Context, poolId uint64, t // tickStatusInvariance tests if the swap position was active during the given tick range and // checks that the fees collected are non-zero if the position was active, or zero otherwise. -func (s *KeeperTestSuite) tickStatusInvariance(ticksActivatedAfterEachSwap [][]sdk.Int, lowerTick, upperTick int64, coins sdk.Coins, expectedFeeDenoms []string) { +func (s *KeeperTestSuite) tickStatusInvariance(ticksActivatedAfterEachSwap [][]int64, lowerTick, upperTick int64, coins sdk.Coins, expectedFeeDenoms []string) { var positionWasActive bool // Check if the position was active during the swap for i, ticks := range ticksActivatedAfterEachSwap { for _, tick := range ticks { - if tick.GTE(sdk.NewInt(lowerTick)) && tick.LTE(sdk.NewInt(upperTick)) { + if tick >= lowerTick && tick <= upperTick { positionWasActive = true break } @@ -1626,7 +1626,7 @@ func (s *KeeperTestSuite) tickStatusInvariance(ticksActivatedAfterEachSwap [][]s // swapAndTrackXTimesInARow performs `numSwaps` swaps and tracks the tick activated after each swap. // It also returns the total fees collected, the total token in, and the total token out. -func (s *KeeperTestSuite) swapAndTrackXTimesInARow(poolId uint64, coinIn sdk.Coin, coinOutDenom string, priceLimit sdk.Dec, numSwaps int) (ticksActivatedAfterEachSwap []sdk.Int, totalFees sdk.Coins, totalTokenIn sdk.Coin, totalTokenOut sdk.Coin) { +func (s *KeeperTestSuite) swapAndTrackXTimesInARow(poolId uint64, coinIn sdk.Coin, coinOutDenom string, priceLimit sdk.Dec, numSwaps int) (ticksActivatedAfterEachSwap []int64, totalFees sdk.Coins, totalTokenIn sdk.Coin, totalTokenOut sdk.Coin) { // Retrieve pool clPool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) @@ -1656,7 +1656,7 @@ func (s *KeeperTestSuite) swapAndTrackXTimesInARow(poolId uint64, coinIn sdk.Coi } // collectFeesAndCheckInvariance collects fees from the concentrated liquidity pool and checks the resulting tick status invariance. -func (s *KeeperTestSuite) collectFeesAndCheckInvariance(ctx sdk.Context, accountIndex int, minTick, maxTick int64, positionId uint64, feesCollected sdk.Coins, expectedFeeDenoms []string, activeTicks [][]sdk.Int) (totalFeesCollected sdk.Coins) { +func (s *KeeperTestSuite) collectFeesAndCheckInvariance(ctx sdk.Context, accountIndex int, minTick, maxTick int64, positionId uint64, feesCollected sdk.Coins, expectedFeeDenoms []string, activeTicks [][]int64) (totalFeesCollected sdk.Coins) { coins, err := s.App.ConcentratedLiquidityKeeper.CollectFees(ctx, s.TestAccs[accountIndex], positionId) s.Require().NoError(err) totalFeesCollected = feesCollected.Add(coins...) diff --git a/x/concentrated-liquidity/incentives.go b/x/concentrated-liquidity/incentives.go index 5670f329e6a..e9b9bddcfb3 100644 --- a/x/concentrated-liquidity/incentives.go +++ b/x/concentrated-liquidity/incentives.go @@ -84,7 +84,7 @@ func (k Keeper) getInitialUptimeGrowthOppositeDirectionOfLastTraversalForTick(ct return []sdk.DecCoins{}, err } - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() if currentTick >= tick { uptimeAccumulatorValues, err := k.getUptimeAccumulatorValues(ctx, poolId) if err != nil { @@ -566,7 +566,7 @@ func (k Keeper) GetUptimeGrowthInsideRange(ctx sdk.Context, poolId uint64, lower } // Get current, lower, and upper ticks - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() lowerTickInfo, err := k.GetTickInfo(ctx, poolId, lowerTick) if err != nil { return []sdk.DecCoins{}, err diff --git a/x/concentrated-liquidity/incentives_test.go b/x/concentrated-liquidity/incentives_test.go index 0bea1561d1b..506541a99a7 100644 --- a/x/concentrated-liquidity/incentives_test.go +++ b/x/concentrated-liquidity/incentives_test.go @@ -940,7 +940,7 @@ func (s *KeeperTestSuite) TestUpdateUptimeAccumulatorsToNow() { if !tc.isInvalidBalancerPool { depositedCoins := sdk.NewCoins(sdk.NewCoin(clPool.GetToken0(), testQualifyingDepositsOne), sdk.NewCoin(clPool.GetToken1(), testQualifyingDepositsOne)) s.FundAcc(testAddressOne, depositedCoins) - _, _, _, qualifyingLiquidity, _, _, _, err = clKeeper.CreatePosition(s.Ctx, clPool.GetId(), testAddressOne, depositedCoins, sdk.ZeroInt(), sdk.ZeroInt(), clPool.GetCurrentTick().Int64()-100, clPool.GetCurrentTick().Int64()+100) + _, _, _, qualifyingLiquidity, _, _, _, err = clKeeper.CreatePosition(s.Ctx, clPool.GetId(), testAddressOne, depositedCoins, sdk.ZeroInt(), sdk.ZeroInt(), clPool.GetCurrentTick()-100, clPool.GetCurrentTick()+100) s.Require().NoError(err) // If a canonical balancer pool exists, we add its respective shares to the qualifying amount as well. @@ -1463,7 +1463,7 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthInsideRange() { var pool types.ConcentratedPoolExtension if tc.poolSetup { pool = s.PrepareConcentratedPool() - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() // Update global uptime accums err := addToUptimeAccums(s.Ctx, pool.GetId(), s.App.ConcentratedLiquidityKeeper, tc.globalUptimeGrowth) @@ -1472,7 +1472,7 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthInsideRange() { // Update tick-level uptime trackers s.initializeTick(s.Ctx, currentTick, tc.lowerTick, defaultInitialLiquidity, cl.EmptyCoins, wrapUptimeTrackers(tc.lowerTickUptimeGrowthOutside), true) s.initializeTick(s.Ctx, currentTick, tc.upperTick, defaultInitialLiquidity, cl.EmptyCoins, wrapUptimeTrackers(tc.upperTickUptimeGrowthOutside), false) - pool.SetCurrentTick(sdk.NewInt(tc.currentTick)) + pool.SetCurrentTick(tc.currentTick) err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) s.Require().NoError(err) } @@ -1788,7 +1788,7 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthOutsideRange() { var pool types.ConcentratedPoolExtension if tc.poolSetup { pool = s.PrepareConcentratedPool() - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() // Update global uptime accums err := addToUptimeAccums(s.Ctx, pool.GetId(), s.App.ConcentratedLiquidityKeeper, tc.globalUptimeGrowth) @@ -1797,7 +1797,7 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthOutsideRange() { // Update tick-level uptime trackers s.initializeTick(s.Ctx, currentTick, tc.lowerTick, defaultInitialLiquidity, cl.EmptyCoins, wrapUptimeTrackers(tc.lowerTickUptimeGrowthOutside), true) s.initializeTick(s.Ctx, currentTick, tc.upperTick, defaultInitialLiquidity, cl.EmptyCoins, wrapUptimeTrackers(tc.upperTickUptimeGrowthOutside), false) - pool.SetCurrentTick(sdk.NewInt(tc.currentTick)) + pool.SetCurrentTick(tc.currentTick) err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) s.Require().NoError(err) } @@ -1830,7 +1830,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { lowerTick tick upperTick tick positionId uint64 - currentTickIndex sdk.Int + currentTickIndex int64 globalUptimeAccumValues []sdk.DecCoins // For testing updates on existing liquidity @@ -1857,7 +1857,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { uptimeTrackers: wrapUptimeTrackers(uptimeHelper.hundredTokensMultiDenom), }, positionId: DefaultPositionId, - currentTickIndex: sdk.ZeroInt(), + currentTickIndex: 0, globalUptimeAccumValues: uptimeHelper.threeHundredTokensMultiDenom, expectedInitAccumValue: uptimeHelper.hundredTokensMultiDenom, expectedUnclaimedRewards: uptimeHelper.emptyExpectedAccumValues, @@ -1874,7 +1874,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { uptimeTrackers: wrapUptimeTrackers(uptimeHelper.threeHundredTokensMultiDenom), }, positionId: DefaultPositionId, - currentTickIndex: sdk.NewInt(51), + currentTickIndex: 51, globalUptimeAccumValues: uptimeHelper.fourHundredTokensMultiDenom, expectedInitAccumValue: uptimeHelper.twoHundredTokensMultiDenom, expectedUnclaimedRewards: uptimeHelper.emptyExpectedAccumValues, @@ -1891,7 +1891,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { uptimeTrackers: wrapUptimeTrackers(uptimeHelper.hundredTokensMultiDenom), }, positionId: DefaultPositionId, - currentTickIndex: sdk.NewInt(-51), + currentTickIndex: -51, globalUptimeAccumValues: uptimeHelper.fourHundredTokensMultiDenom, expectedInitAccumValue: uptimeHelper.twoHundredTokensMultiDenom, expectedUnclaimedRewards: uptimeHelper.emptyExpectedAccumValues, @@ -1908,7 +1908,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { uptimeTrackers: wrapUptimeTrackers(uptimeHelper.hundredTokensMultiDenom), }, positionId: DefaultPositionId, - currentTickIndex: sdk.ZeroInt(), + currentTickIndex: 0, // We set up the global accum values such that the growth inside is equal to 100 of each denom // for each uptime tracker. Let the uptime growth inside (UGI) = 100 @@ -1960,7 +1960,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { uptimeTrackers: wrapUptimeTrackers(uptimeHelper.hundredTokensMultiDenom), }, positionId: DefaultPositionId, - currentTickIndex: sdk.ZeroInt(), + currentTickIndex: 0, globalUptimeAccumValues: uptimeHelper.threeHundredTokensMultiDenom, expectedErr: types.NonPositiveLiquidityForNewPositionError{PositionId: DefaultPositionId, LiquidityDelta: DefaultLiquidityAmt.Neg()}, @@ -1980,8 +1980,8 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { clPool := s.PrepareConcentratedPool() // Initialize lower, upper, and current ticks - s.initializeTick(s.Ctx, test.currentTickIndex.Int64(), test.lowerTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.lowerTick.uptimeTrackers, true) - s.initializeTick(s.Ctx, test.currentTickIndex.Int64(), test.upperTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.upperTick.uptimeTrackers, false) + s.initializeTick(s.Ctx, test.currentTickIndex, test.lowerTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.lowerTick.uptimeTrackers, true) + s.initializeTick(s.Ctx, test.currentTickIndex, test.upperTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.upperTick.uptimeTrackers, false) clPool.SetCurrentTick(test.currentTickIndex) err := s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, clPool) s.Require().NoError(err) @@ -1997,8 +1997,8 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { err = s.App.ConcentratedLiquidityKeeper.SetPosition(s.Ctx, clPool.GetId(), s.TestAccs[0], test.lowerTick.tickIndex, test.upperTick.tickIndex, DefaultJoinTime, test.positionLiquidity, DefaultPositionId, DefaultUnderlyingLockId) s.Require().NoError(err) - s.initializeTick(s.Ctx, test.currentTickIndex.Int64(), test.newLowerTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.newLowerTick.uptimeTrackers, true) - s.initializeTick(s.Ctx, test.currentTickIndex.Int64(), test.newUpperTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.newUpperTick.uptimeTrackers, false) + s.initializeTick(s.Ctx, test.currentTickIndex, test.newLowerTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.newLowerTick.uptimeTrackers, true) + s.initializeTick(s.Ctx, test.currentTickIndex, test.newUpperTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.newUpperTick.uptimeTrackers, false) clPool.SetCurrentTick(test.currentTickIndex) err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, clPool) s.Require().NoError(err) @@ -2891,7 +2891,7 @@ func (s *KeeperTestSuite) TestQueryAndCollectIncentives() { } } - validPool.SetCurrentTick(sdk.NewInt(tc.currentTick)) + validPool.SetCurrentTick(tc.currentTick) err := clKeeper.SetPool(ctx, validPool) s.Require().NoError(err) @@ -3432,11 +3432,11 @@ func (s *KeeperTestSuite) TestQueryAndClaimAllIncentives() { clPool.SetCurrentTick(DefaultCurrTick) if tc.growthOutside != nil { - s.addUptimeGrowthOutsideRange(s.Ctx, validPoolId, defaultSender, DefaultCurrTick.Int64(), DefaultLowerTick, DefaultUpperTick, tc.growthOutside) + s.addUptimeGrowthOutsideRange(s.Ctx, validPoolId, defaultSender, DefaultCurrTick, DefaultLowerTick, DefaultUpperTick, tc.growthOutside) } if tc.growthInside != nil { - s.addUptimeGrowthInsideRange(s.Ctx, validPoolId, defaultSender, DefaultCurrTick.Int64(), DefaultLowerTick, DefaultUpperTick, tc.growthInside) + s.addUptimeGrowthInsideRange(s.Ctx, validPoolId, defaultSender, DefaultCurrTick, DefaultLowerTick, DefaultUpperTick, tc.growthInside) } err = clKeeper.SetPool(s.Ctx, clPool) diff --git a/x/concentrated-liquidity/keeper_test.go b/x/concentrated-liquidity/keeper_test.go index 14e541bd4bc..25704c53e48 100644 --- a/x/concentrated-liquidity/keeper_test.go +++ b/x/concentrated-liquidity/keeper_test.go @@ -21,39 +21,39 @@ import ( ) var ( - DefaultMinTick, DefaultMaxTick = types.MinTick, types.MaxTick - DefaultLowerPrice = sdk.NewDec(4545) - DefaultLowerTick = int64(30545000) - DefaultUpperPrice = sdk.NewDec(5500) - DefaultUpperTick = int64(31500000) - DefaultCurrPrice = sdk.NewDec(5000) - DefaultCurrTick = sdk.NewInt(31000000) - DefaultCurrSqrtPrice, _ = DefaultCurrPrice.ApproxSqrt() // 70.710678118654752440 - DefaultZeroSwapFee = sdk.ZeroDec() - DefaultFeeAccumCoins = sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(50))) - DefaultPositionId = uint64(1) - DefaultUnderlyingLockId = uint64(0) - DefaultJoinTime = time.Unix(0, 0).UTC() - ETH = "eth" - DefaultAmt0 = sdk.NewInt(1000000) - DefaultAmt0Expected = sdk.NewInt(998976) - DefaultCoin0 = sdk.NewCoin(ETH, DefaultAmt0) - USDC = "usdc" - DefaultAmt1 = sdk.NewInt(5000000000) - DefaultAmt1Expected = sdk.NewInt(5000000000) - DefaultCoin1 = sdk.NewCoin(USDC, DefaultAmt1) - DefaultCoins = sdk.NewCoins(DefaultCoin0, DefaultCoin1) - DefaultLiquidityAmt = sdk.MustNewDecFromStr("1517882343.751510418088349649") - FullRangeLiquidityAmt = sdk.MustNewDecFromStr("70710678.118654752940000000") - DefaultTickSpacing = uint64(100) - PoolCreationFee = poolmanagertypes.DefaultParams().PoolCreationFee - DefaultExponentConsecutivePositionLowerTick, _ = math.PriceToTickRoundDown(sdk.NewDec(5500), DefaultTickSpacing) - DefaultExponentConsecutivePositionUpperTick, _ = math.PriceToTickRoundDown(sdk.NewDec(6250), DefaultTickSpacing) - DefaultExponentOverlappingPositionLowerTick, _ = math.PriceToTickRoundDown(sdk.NewDec(4000), DefaultTickSpacing) - DefaultExponentOverlappingPositionUpperTick, _ = math.PriceToTickRoundDown(sdk.NewDec(4999), DefaultTickSpacing) - BAR = "bar" - FOO = "foo" - InsufficientFundsError = fmt.Errorf("insufficient funds") + DefaultMinTick, DefaultMaxTick = types.MinTick, types.MaxTick + DefaultLowerPrice = sdk.NewDec(4545) + DefaultLowerTick = int64(30545000) + DefaultUpperPrice = sdk.NewDec(5500) + DefaultUpperTick = int64(31500000) + DefaultCurrPrice = sdk.NewDec(5000) + DefaultCurrTick int64 = 31000000 + DefaultCurrSqrtPrice, _ = DefaultCurrPrice.ApproxSqrt() // 70.710678118654752440 + DefaultZeroSwapFee = sdk.ZeroDec() + DefaultFeeAccumCoins = sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(50))) + DefaultPositionId = uint64(1) + DefaultUnderlyingLockId = uint64(0) + DefaultJoinTime = time.Unix(0, 0).UTC() + ETH = "eth" + DefaultAmt0 = sdk.NewInt(1000000) + DefaultAmt0Expected = sdk.NewInt(998976) + DefaultCoin0 = sdk.NewCoin(ETH, DefaultAmt0) + USDC = "usdc" + DefaultAmt1 = sdk.NewInt(5000000000) + DefaultAmt1Expected = sdk.NewInt(5000000000) + DefaultCoin1 = sdk.NewCoin(USDC, DefaultAmt1) + DefaultCoins = sdk.NewCoins(DefaultCoin0, DefaultCoin1) + DefaultLiquidityAmt = sdk.MustNewDecFromStr("1517882343.751510418088349649") + FullRangeLiquidityAmt = sdk.MustNewDecFromStr("70710678.118654752940000000") + DefaultTickSpacing = uint64(100) + PoolCreationFee = poolmanagertypes.DefaultParams().PoolCreationFee + DefaultExponentConsecutivePositionLowerTick, _ = math.PriceToTickRoundDown(sdk.NewDec(5500), DefaultTickSpacing) + DefaultExponentConsecutivePositionUpperTick, _ = math.PriceToTickRoundDown(sdk.NewDec(6250), DefaultTickSpacing) + DefaultExponentOverlappingPositionLowerTick, _ = math.PriceToTickRoundDown(sdk.NewDec(4000), DefaultTickSpacing) + DefaultExponentOverlappingPositionUpperTick, _ = math.PriceToTickRoundDown(sdk.NewDec(4999), DefaultTickSpacing) + BAR = "bar" + FOO = "foo" + InsufficientFundsError = fmt.Errorf("insufficient funds") ) type KeeperTestSuite struct { diff --git a/x/concentrated-liquidity/lp.go b/x/concentrated-liquidity/lp.go index 9caeebb3e96..b8ad381fd58 100644 --- a/x/concentrated-liquidity/lp.go +++ b/x/concentrated-liquidity/lp.go @@ -343,7 +343,7 @@ func (k Keeper) UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddr return sdk.Int{}, sdk.Int{}, err } - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() // update lower tickInfo state err = k.initOrUpdateTick(ctx, poolId, currentTick, lowerTick, liquidityDelta, false) @@ -440,7 +440,7 @@ func (k Keeper) initializeInitialPositionForPool(ctx sdk.Context, pool types.Con // In such a case, we do not want to round the sqrt price to 100_000_000 X/Y, but rather // let it float within the possible tick range. pool.SetCurrentSqrtPrice(initialCurSqrtPrice) - pool.SetCurrentTick(sdk.NewInt(initialTick)) + pool.SetCurrentTick(initialTick) err = k.setPool(ctx, pool) if err != nil { return err @@ -468,7 +468,7 @@ func (k Keeper) uninitializePool(ctx sdk.Context, poolId uint64) error { } pool.SetCurrentSqrtPrice(sdk.ZeroDec()) - pool.SetCurrentTick(sdk.ZeroInt()) + pool.SetCurrentTick(0) if err := k.setPool(ctx, pool); err != nil { return err diff --git a/x/concentrated-liquidity/lp_test.go b/x/concentrated-liquidity/lp_test.go index 50dcfba66f0..101d156412e 100644 --- a/x/concentrated-liquidity/lp_test.go +++ b/x/concentrated-liquidity/lp_test.go @@ -17,7 +17,7 @@ import ( type lpTest struct { poolId uint64 - currentTick sdk.Int + currentTick int64 lowerTick int64 expectedLowerTick int64 upperTick int64 @@ -94,7 +94,7 @@ var ( "lower tick < upper tick < current tick -> both tick's fee accumulators are updated with one eth": { lowerTick: DefaultLowerTick, upperTick: DefaultUpperTick, - currentTick: sdk.NewInt(DefaultUpperTick + 100), + currentTick: DefaultUpperTick + 100, preSetChargeFee: oneEth, expectedFeeGrowthOutsideLower: oneEthCoins, @@ -106,7 +106,7 @@ var ( "lower tick < upper tick < current tick -> the fee is not charged so tick accumulators are unset": { lowerTick: DefaultLowerTick, upperTick: DefaultUpperTick, - currentTick: sdk.NewInt(DefaultUpperTick + 100), + currentTick: DefaultUpperTick + 100, preSetChargeFee: sdk.NewDecCoin(ETH, sdk.ZeroInt()), // zero fee expectedFeeGrowthOutsideLower: oneEthCoins, @@ -118,7 +118,7 @@ var ( "current tick < lower tick < upper tick -> both tick's fee accumulators are unitilialized": { lowerTick: DefaultLowerTick, upperTick: DefaultUpperTick, - currentTick: sdk.NewInt(DefaultLowerTick - 100), + currentTick: DefaultLowerTick - 100, preSetChargeFee: oneEth, expectedFeeGrowthOutsideLower: oneEthCoins, @@ -130,7 +130,7 @@ var ( "lower tick < upper tick == current tick -> both tick's fee accumulators are updated with one eth": { lowerTick: DefaultLowerTick, upperTick: DefaultUpperTick, - currentTick: sdk.NewInt(DefaultUpperTick), + currentTick: DefaultUpperTick, preSetChargeFee: oneEth, expectedFeeGrowthOutsideLower: oneEthCoins, @@ -142,7 +142,7 @@ var ( "second position: lower tick < upper tick == current tick -> both tick's fee accumulators are updated with one eth": { lowerTick: DefaultLowerTick, upperTick: DefaultUpperTick, - currentTick: sdk.NewInt(DefaultUpperTick), + currentTick: DefaultUpperTick, isNotFirstPositionWithSameAccount: true, positionId: 2, @@ -160,7 +160,7 @@ var ( expectedLowerTick: -161000000, upperTick: -160009800, expectedUpperTick: -160000000, - currentTick: sdk.NewInt(DefaultUpperTick), + currentTick: DefaultUpperTick, isNotFirstPositionWithSameAccount: true, positionId: 2, @@ -1489,7 +1489,7 @@ func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() { amount1Desired sdk.Int tickSpacing uint64 expectedCurrSqrtPrice sdk.Dec - expectedTick sdk.Int + expectedTick int64 expectedError error } tests := map[string]sendTest{ @@ -1505,21 +1505,21 @@ func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() { amount1Desired: sdk.NewInt(100_000_050), tickSpacing: DefaultTickSpacing, expectedCurrSqrtPrice: sqrt(100_000_050), - expectedTick: sdk.NewInt(72000000), + expectedTick: 72000000, }, "100_000_051 and tick spacing 100, price level where curr sqrt price does not translate to allowed tick (assumes exponent at price one of -6 and tick spacing of 100)": { amount0Desired: sdk.OneInt(), amount1Desired: sdk.NewInt(100_000_051), tickSpacing: DefaultTickSpacing, expectedCurrSqrtPrice: sqrt(100_000_051), - expectedTick: sdk.NewInt(72000000), + expectedTick: 72000000, }, "100_000_051 and tick spacing 1, price level where curr sqrt price translates to allowed tick (assumes exponent at price one of -6 and tick spacing of 1)": { amount0Desired: sdk.OneInt(), amount1Desired: sdk.NewInt(100_000_051), tickSpacing: 1, expectedCurrSqrtPrice: sqrt(100_000_051), - expectedTick: sdk.NewInt(72000001), + expectedTick: 72000001, }, "error: amount0Desired is zero": { amount0Desired: sdk.ZeroInt(), @@ -1562,7 +1562,7 @@ func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() { s.Require().NoError(err) s.Require().Equal(tc.expectedCurrSqrtPrice.String(), pool.GetCurrentSqrtPrice().String()) - s.Require().Equal(tc.expectedTick.String(), pool.GetCurrentTick().String()) + s.Require().Equal(tc.expectedTick, pool.GetCurrentTick()) } }) } @@ -1736,7 +1736,7 @@ func (s *KeeperTestSuite) TestUninitializePool() { actualSqrtPrice := pool.GetCurrentSqrtPrice() actualTick := pool.GetCurrentTick() s.Require().Equal(sdk.ZeroDec(), actualSqrtPrice) - s.Require().Equal(sdk.ZeroInt(), actualTick) + s.Require().Equal(int64(0), actualTick) }) } } diff --git a/x/concentrated-liquidity/model/pool.go b/x/concentrated-liquidity/model/pool.go index d1693043631..5869ba60f09 100644 --- a/x/concentrated-liquidity/model/pool.go +++ b/x/concentrated-liquidity/model/pool.go @@ -41,12 +41,12 @@ func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpac IncentivesAddress: osmoutils.NewModuleAddressWithPrefix(types.ModuleName, incentivesAddressPrefix, sdk.Uint64ToBigEndian(poolId)).String(), Id: poolId, CurrentSqrtPrice: sdk.ZeroDec(), - CurrentTick: sdk.ZeroInt(), + CurrentTick: 0, CurrentTickLiquidity: sdk.ZeroDec(), Token0: denom0, Token1: denom1, TickSpacing: tickSpacing, - ExponentAtPriceOne: sdk.NewInt(types.ExponentAtPriceOne), + ExponentAtPriceOne: types.ExponentAtPriceOne, SwapFee: swapFee, } return pool, nil @@ -129,7 +129,7 @@ func (p Pool) GetCurrentSqrtPrice() sdk.Dec { } // GetCurrentTick returns the current tick of the pool -func (p Pool) GetCurrentTick() sdk.Int { +func (p Pool) GetCurrentTick() int64 { return p.CurrentTick } @@ -139,7 +139,7 @@ func (p Pool) GetTickSpacing() uint64 { } // GetExponentAtPriceOne returns the precision factor at price one of the pool -func (p Pool) GetExponentAtPriceOne() sdk.Int { +func (p Pool) GetExponentAtPriceOne() int64 { return p.ExponentAtPriceOne } @@ -168,7 +168,7 @@ func (p *Pool) SetCurrentSqrtPrice(newSqrtPrice sdk.Dec) { } // SetCurrentTick updates the current tick of the pool when the first position is created. -func (p *Pool) SetCurrentTick(newTick sdk.Int) { +func (p *Pool) SetCurrentTick(newTick int64) { p.CurrentTick = newTick } @@ -241,7 +241,7 @@ func (p Pool) CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liq currentSqrtPrice := p.CurrentSqrtPrice actualAmountDenom0 = math.CalcAmount0Delta(liquidityDelta, currentSqrtPrice, sqrtPriceUpperTick, roundUp) actualAmountDenom1 = math.CalcAmount1Delta(liquidityDelta, currentSqrtPrice, sqrtPriceLowerTick, roundUp) - } else if p.CurrentTick.LT(sdk.NewInt(lowerTick)) { + } else if p.CurrentTick < lowerTick { // outcome two: position is below current price // this means position is solely made up of asset0 actualAmountDenom1 = sdk.ZeroDec() @@ -259,12 +259,12 @@ func (p Pool) CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liq // isCurrentTickInRange returns true if pool's current tick is within // the range of the lower and upper ticks. False otherwise. func (p Pool) IsCurrentTickInRange(lowerTick, upperTick int64) bool { - return p.CurrentTick.GTE(sdk.NewInt(lowerTick)) && p.CurrentTick.LTE(sdk.NewInt(upperTick)) + return p.CurrentTick >= lowerTick && p.CurrentTick <= upperTick } // ApplySwap state of pool after swap. // It specifically overwrites the pool's liquidity, curr tick and the curr sqrt price -func (p *Pool) ApplySwap(newLiquidity sdk.Dec, newCurrentTick sdk.Int, newCurrentSqrtPrice sdk.Dec) error { +func (p *Pool) ApplySwap(newLiquidity sdk.Dec, newCurrentTick int64, newCurrentSqrtPrice sdk.Dec) error { // Check if the new liquidity provided is not negative. if newLiquidity.IsNegative() { return types.NegativeLiquidityError{Liquidity: newLiquidity} @@ -276,11 +276,11 @@ func (p *Pool) ApplySwap(newLiquidity sdk.Dec, newCurrentTick sdk.Int, newCurren } // Check if the new tick provided is within boundaries of the pool's precision factor. - if newCurrentTick.LT(sdk.NewInt(types.MinTick)) || newCurrentTick.GT(sdk.NewInt(types.MaxTick)) { + if newCurrentTick < types.MinTick || newCurrentTick > types.MaxTick { return types.TickIndexNotWithinBoundariesError{ MaxTick: types.MaxTick, MinTick: types.MinTick, - ActualTick: newCurrentTick.Int64(), + ActualTick: newCurrentTick, } } diff --git a/x/concentrated-liquidity/model/pool.pb.go b/x/concentrated-liquidity/model/pool.pb.go index 99375479d94..fcce45b1a57 100644 --- a/x/concentrated-liquidity/model/pool.pb.go +++ b/x/concentrated-liquidity/model/pool.pb.go @@ -45,11 +45,11 @@ type Pool struct { Token0 string `protobuf:"bytes,5,opt,name=token0,proto3" json:"token0,omitempty"` Token1 string `protobuf:"bytes,6,opt,name=token1,proto3" json:"token1,omitempty"` CurrentSqrtPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=current_sqrt_price,json=currentSqrtPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_sqrt_price" yaml:"spot_price"` - CurrentTick github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=current_tick,json=currentTick,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"current_tick" yaml:"current_tick"` + CurrentTick int64 `protobuf:"varint,8,opt,name=current_tick,json=currentTick,proto3" json:"current_tick,omitempty" yaml:"current_tick"` // tick_spacing must be one of the authorized_tick_spacing values set in the // concentrated-liquidity parameters - TickSpacing uint64 `protobuf:"varint,9,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` - ExponentAtPriceOne github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=exponent_at_price_one,json=exponentAtPriceOne,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"exponent_at_price_one" yaml:"exponent_at_price_one"` + TickSpacing uint64 `protobuf:"varint,9,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` + ExponentAtPriceOne int64 `protobuf:"varint,10,opt,name=exponent_at_price_one,json=exponentAtPriceOne,proto3" json:"exponent_at_price_one,omitempty" yaml:"exponent_at_price_one"` // swap_fee is the ratio that is charged on the amount of token in. SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee" yaml:"swap_fee"` // last_liquidity_update is the last time either the pool liquidity or the @@ -98,47 +98,46 @@ func init() { } var fileDescriptor_3526ea5373d96c9a = []byte{ - // 626 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x4e, 0xdb, 0x40, - 0x10, 0xb6, 0x29, 0x10, 0xd8, 0x20, 0x5a, 0x96, 0x9f, 0x1a, 0x54, 0x6c, 0x64, 0xa9, 0x55, 0x2a, - 0x35, 0x76, 0xd3, 0xaa, 0x17, 0x6e, 0xa4, 0x3f, 0x12, 0x12, 0x2a, 0xc8, 0xd0, 0x4b, 0x85, 0x64, - 0x39, 0xf6, 0x62, 0x56, 0xb1, 0xbd, 0x8e, 0x77, 0x43, 0xc9, 0xb1, 0x87, 0x4a, 0x3d, 0x72, 0xec, - 0x91, 0x87, 0xe8, 0x43, 0xa0, 0x9e, 0x50, 0x4f, 0x55, 0x0f, 0x6e, 0x95, 0xbc, 0x41, 0x9e, 0xa0, - 0xf2, 0x7a, 0x9d, 0x58, 0x22, 0x3d, 0xe4, 0x64, 0xcf, 0x37, 0x33, 0xdf, 0x7c, 0x33, 0xbb, 0xb3, - 0xe0, 0x29, 0xa1, 0x21, 0xa1, 0x98, 0x9a, 0x2e, 0x89, 0x5c, 0x14, 0xb1, 0xc4, 0x61, 0xc8, 0xab, - 0x07, 0xb8, 0xd3, 0xc5, 0x1e, 0x66, 0x3d, 0x33, 0x26, 0x24, 0x30, 0xe2, 0x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, 0x10, 0x82, 0x97, 0x60, 0x3d, - 0x70, 0x28, 0x1b, 0xdf, 0x29, 0xbb, 0x1b, 0x7b, 0x0e, 0x43, 0xca, 0xd2, 0x8e, 0x5c, 0xab, 0xbe, - 0xd8, 0x32, 0xf2, 0x45, 0x34, 0x8a, 0x45, 0x34, 0x4e, 0x8a, 0x45, 0x6c, 0xd6, 0x32, 0x19, 0xe3, - 0x96, 0x26, 0xd2, 0xe8, 0x57, 0x7f, 0x34, 0xd9, 0x5a, 0xcd, 0x7c, 0xa3, 0xeb, 0xf9, 0x81, 0x7b, - 0x76, 0x57, 0xbe, 0x5e, 0x6b, 0xd2, 0xb7, 0x6b, 0x4d, 0xfa, 0xf1, 0xbd, 0x3e, 0x97, 0xad, 0xf2, - 0x7e, 0xf3, 0xf4, 0xa6, 0xaf, 0xca, 0xb7, 0x7d, 0x55, 0xfe, 0xdb, 0x57, 0xe5, 0xab, 0x81, 0x2a, - 0xdd, 0x0e, 0x54, 0xe9, 0xd7, 0x40, 0x95, 0x3e, 0x36, 0x4b, 0xad, 0x8a, 0x27, 0xa7, 0x1e, 0x38, - 0x2d, 0x5a, 0x18, 0xe6, 0x45, 0xe3, 0x95, 0x79, 0xf9, 0xbf, 0x07, 0x2b, 0x24, 0x1e, 0x0a, 0x5a, - 0xf3, 0xbc, 0x87, 0x97, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xdf, 0xcb, 0xdc, 0x32, 0xdf, 0x04, - 0x00, 0x00, + // 617 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xb6, 0xfb, 0x93, 0xb6, 0x9b, 0xaa, 0xd0, 0xed, 0x0f, 0x6e, 0x45, 0xed, 0xc8, 0x12, 0x28, + 0x48, 0xc4, 0x26, 0x20, 0x2e, 0xbd, 0x35, 0x20, 0x24, 0xa4, 0x4a, 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xf3, 0xb5, 0x39, 0xf8, + 0xdf, 0x9b, 0x12, 0x12, 0x0f, 0x05, 0xed, 0x0a, 0xef, 0xe1, 0xd5, 0xbf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x17, 0x07, 0xb8, 0x83, 0x82, 0x04, 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -179,31 +178,21 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x5a - { - size := m.ExponentAtPriceOne.Size() - i -= size - if _, err := m.ExponentAtPriceOne.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintPool(dAtA, i, uint64(size)) + if m.ExponentAtPriceOne != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.ExponentAtPriceOne)) + i-- + dAtA[i] = 0x50 } - i-- - dAtA[i] = 0x52 if m.TickSpacing != 0 { i = encodeVarintPool(dAtA, i, uint64(m.TickSpacing)) i-- dAtA[i] = 0x48 } - { - size := m.CurrentTick.Size() - i -= size - if _, err := m.CurrentTick.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintPool(dAtA, i, uint64(size)) + if m.CurrentTick != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.CurrentTick)) + i-- + dAtA[i] = 0x40 } - i-- - dAtA[i] = 0x42 { size := m.CurrentSqrtPrice.Size() i -= size @@ -300,13 +289,15 @@ func (m *Pool) Size() (n int) { } l = m.CurrentSqrtPrice.Size() n += 1 + l + sovPool(uint64(l)) - l = m.CurrentTick.Size() - n += 1 + l + sovPool(uint64(l)) + if m.CurrentTick != 0 { + n += 1 + sovPool(uint64(m.CurrentTick)) + } if m.TickSpacing != 0 { n += 1 + sovPool(uint64(m.TickSpacing)) } - l = m.ExponentAtPriceOne.Size() - n += 1 + l + sovPool(uint64(l)) + if m.ExponentAtPriceOne != 0 { + n += 1 + sovPool(uint64(m.ExponentAtPriceOne)) + } l = m.SwapFee.Size() n += 1 + l + sovPool(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastLiquidityUpdate) @@ -565,10 +556,10 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 8: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CurrentTick", wireType) } - var stringLen uint64 + m.CurrentTick = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -578,26 +569,11 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.CurrentTick |= int64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPool - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CurrentTick.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TickSpacing", wireType) @@ -618,10 +594,10 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } } case 10: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ExponentAtPriceOne", wireType) } - var stringLen uint64 + m.ExponentAtPriceOne = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowPool @@ -631,26 +607,11 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ExponentAtPriceOne |= int64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPool - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ExponentAtPriceOne.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SwapFee", wireType) diff --git a/x/concentrated-liquidity/model/pool_test.go b/x/concentrated-liquidity/model/pool_test.go index 820baef8656..030c520b46b 100644 --- a/x/concentrated-liquidity/model/pool_test.go +++ b/x/concentrated-liquidity/model/pool_test.go @@ -23,14 +23,14 @@ const ( ) var ( - DefaultSpotPrice = sdk.MustNewDecFromStr("0.2") - DefaultReverseSpotPrice = sdk.NewDec(1).Quo(DefaultSpotPrice) - DefaultSqrtSpotPrice, _ = DefaultSpotPrice.ApproxSqrt() - DefaultLiquidityAmt = sdk.MustNewDecFromStr("1517882343.751510418088349649") - DefaultCurrTick = sdk.NewInt(310000) - DefaultCurrPrice = sdk.NewDec(5000) - DefaultCurrSqrtPrice, _ = DefaultCurrPrice.ApproxSqrt() // 70.710678118654752440 - DefaultSwapFee = sdk.MustNewDecFromStr("0.01") + DefaultSpotPrice = sdk.MustNewDecFromStr("0.2") + DefaultReverseSpotPrice = sdk.NewDec(1).Quo(DefaultSpotPrice) + DefaultSqrtSpotPrice, _ = DefaultSpotPrice.ApproxSqrt() + DefaultLiquidityAmt = sdk.MustNewDecFromStr("1517882343.751510418088349649") + DefaultCurrTick int64 = 310000 + DefaultCurrPrice = sdk.NewDec(5000) + DefaultCurrSqrtPrice, _ = DefaultCurrPrice.ApproxSqrt() // 70.710678118654752440 + DefaultSwapFee = sdk.MustNewDecFromStr("0.01") ) type ConcentratedPoolTestSuite struct { @@ -150,26 +150,26 @@ func (s *ConcentratedPoolTestSuite) TestIsCurrentTickInRange() { }{ { "given lower tick tick is within range of pool tick", - DefaultCurrTick.Int64() - 1, - DefaultCurrTick.Int64() + 1, + DefaultCurrTick - 1, + DefaultCurrTick + 1, true, }, { "lower tick and upper tick are equal to pool tick", - DefaultCurrTick.Int64(), - DefaultCurrTick.Int64(), + DefaultCurrTick, + DefaultCurrTick, true, }, { "lower tick is greater then pool tick", - DefaultCurrTick.Int64() + 1, - DefaultCurrTick.Int64() + 3, + DefaultCurrTick + 1, + DefaultCurrTick + 3, false, }, { "upper tick is lower then pool tick", - DefaultCurrTick.Int64() - 3, - DefaultCurrTick.Int64() - 1, + DefaultCurrTick - 3, + DefaultCurrTick - 1, false, }, } @@ -200,10 +200,10 @@ func (s *ConcentratedPoolTestSuite) TestApplySwap() { tests := []struct { name string currentLiquidity sdk.Dec - currentTick sdk.Int + currentTick int64 currentSqrtPrice sdk.Dec newLiquidity sdk.Dec - newTick sdk.Int + newTick int64 newSqrtPrice sdk.Dec expectErr error }{ @@ -213,7 +213,7 @@ func (s *ConcentratedPoolTestSuite) TestApplySwap() { currentTick: DefaultCurrTick, currentSqrtPrice: DefaultCurrSqrtPrice, newLiquidity: DefaultLiquidityAmt.Mul(sdk.NewDec(2)), - newTick: DefaultCurrTick.Mul(sdk.NewInt(2)), + newTick: DefaultCurrTick * 2, newSqrtPrice: DefaultCurrSqrtPrice.Mul(sdk.NewDec(2)), expectErr: nil, }, @@ -240,10 +240,10 @@ func (s *ConcentratedPoolTestSuite) TestApplySwap() { { name: "upper tick too big", currentLiquidity: DefaultLiquidityAmt, - currentTick: sdk.NewInt(1), + currentTick: 1, currentSqrtPrice: DefaultCurrSqrtPrice, newLiquidity: DefaultLiquidityAmt, - newTick: sdk.NewInt(math.MaxInt64), + newTick: math.MaxInt64, newSqrtPrice: DefaultCurrSqrtPrice, expectErr: types.TickIndexNotWithinBoundariesError{ MaxTick: types.MaxTick, @@ -254,10 +254,10 @@ func (s *ConcentratedPoolTestSuite) TestApplySwap() { { name: "lower tick too small", currentLiquidity: DefaultLiquidityAmt, - currentTick: sdk.NewInt(1), + currentTick: 1, currentSqrtPrice: DefaultCurrSqrtPrice, newLiquidity: DefaultLiquidityAmt, - newTick: sdk.NewInt(math.MinInt64), + newTick: math.MinInt64, newSqrtPrice: DefaultCurrSqrtPrice, expectErr: types.TickIndexNotWithinBoundariesError{ MaxTick: types.MaxTick, @@ -271,7 +271,7 @@ func (s *ConcentratedPoolTestSuite) TestApplySwap() { s.Run(tt.name, func() { // Create a concentrated liquidity pool struct instance mock_pool := model.Pool{ - ExponentAtPriceOne: sdk.NewInt(types.ExponentAtPriceOne), + ExponentAtPriceOne: types.ExponentAtPriceOne, CurrentTickLiquidity: tt.currentLiquidity, CurrentTick: tt.currentTick, CurrentSqrtPrice: tt.currentSqrtPrice, @@ -515,9 +515,9 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { suite.Setup() pool := model.Pool{ - CurrentTick: sdk.NewInt(tc.currentTick), + CurrentTick: tc.currentTick, } - _, pool.CurrentSqrtPrice, _ = clmath.TickToSqrtPrice(pool.CurrentTick.Int64()) + _, pool.CurrentSqrtPrice, _ = clmath.TickToSqrtPrice(pool.CurrentTick) actualAmount0, actualAmount1, err := pool.CalcActualAmounts(suite.Ctx, tc.lowerTick, tc.upperTick, tc.liquidityDelta) @@ -608,10 +608,10 @@ func (suite *ConcentratedPoolTestSuite) TestUpdateLiquidityIfActivePosition() { suite.Setup() pool := model.Pool{ - CurrentTick: sdk.NewInt(tc.currentTick), + CurrentTick: tc.currentTick, CurrentTickLiquidity: defaultLiquidityAmt, } - _, pool.CurrentSqrtPrice, _ = clmath.TickToSqrtPrice(pool.CurrentTick.Int64()) + _, pool.CurrentSqrtPrice, _ = clmath.TickToSqrtPrice(pool.CurrentTick) wasUpdated := pool.UpdateLiquidityIfActivePosition(suite.Ctx, tc.lowerTick, tc.upperTick, tc.liquidityDelta) if tc.lowerTick <= tc.currentTick && tc.currentTick <= tc.upperTick { diff --git a/x/concentrated-liquidity/pool_test.go b/x/concentrated-liquidity/pool_test.go index 1a5a2a2e1e4..dbd12441169 100644 --- a/x/concentrated-liquidity/pool_test.go +++ b/x/concentrated-liquidity/pool_test.go @@ -347,9 +347,9 @@ func (s *KeeperTestSuite) TestSetPool() { Token0: ETH, Token1: USDC, CurrentSqrtPrice: sdk.OneDec(), - CurrentTick: sdk.ZeroInt(), + CurrentTick: 0, TickSpacing: DefaultTickSpacing, - ExponentAtPriceOne: sdk.NewInt(-6), + ExponentAtPriceOne: -6, SwapFee: sdk.MustNewDecFromStr("0.003"), LastLiquidityUpdate: s.Ctx.BlockTime(), } diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index 5e799632aa8..11b3c9bbd89 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -313,7 +313,7 @@ func (k Keeper) computeOutAmtGivenIn( amountCalculated: sdk.ZeroDec(), // tokenOut sqrtPrice: curSqrtPrice, // Pad (or don't pad) current tick based on swap direction to avoid off-by-one errors - tick: swapStrategy.InitializeTickValue(p.GetCurrentTick().Int64()), + tick: swapStrategy.InitializeTickValue(p.GetCurrentTick()), liquidity: p.GetLiquidity(), feeGrowthGlobal: sdk.ZeroDec(), } @@ -489,7 +489,7 @@ func (k Keeper) computeInAmtGivenOut( amountSpecifiedRemaining: desiredTokenOut.Amount.ToDec(), // tokenOut amountCalculated: sdk.ZeroDec(), // tokenIn sqrtPrice: curSqrtPrice, - tick: swapStrategy.InitializeTickValue(p.GetCurrentTick().Int64()), + tick: swapStrategy.InitializeTickValue(p.GetCurrentTick()), liquidity: p.GetLiquidity(), feeGrowthGlobal: sdk.ZeroDec(), } @@ -629,7 +629,7 @@ func (k Keeper) updatePoolForSwap( return types.InsufficientPoolBalanceError{Err: err} } - err = pool.ApplySwap(newLiquidity, sdk.NewInt(newCurrentTick), newSqrtPrice) + err = pool.ApplySwap(newLiquidity, newCurrentTick, newSqrtPrice) if err != nil { return fmt.Errorf("error applying swap: %w", err) } diff --git a/x/concentrated-liquidity/swaps_test.go b/x/concentrated-liquidity/swaps_test.go index 591b516bb6c..faef3b5279c 100644 --- a/x/concentrated-liquidity/swaps_test.go +++ b/x/concentrated-liquidity/swaps_test.go @@ -1825,7 +1825,7 @@ func (s *KeeperTestSuite) TestComputeAndSwapInAmtGivenOut() { s.Require().Equal(test.expectedTokenOut.String(), tokenOut.String()) s.Require().Equal(test.expectedSqrtPrice, sqrtPrice) // also ensure the pool's currentTick and currentSqrtPrice was updated due to calling a mutative method - s.Require().Equal(test.expectedTick, pool.GetCurrentTick().Int64()) + s.Require().Equal(test.expectedTick, pool.GetCurrentTick()) if test.newLowerPrice.IsNil() && test.newUpperPrice.IsNil() { test.newLowerPrice = DefaultLowerPrice @@ -2811,7 +2811,7 @@ func (suite *KeeperTestSuite) TestUpdatePoolForSwap() { suite.FundAcc(sender, tc.senderInitialBalance) // Default pool values are initialized to one. - err := pool.ApplySwap(sdk.OneDec(), sdk.OneInt(), sdk.OneDec()) + err := pool.ApplySwap(sdk.OneDec(), 1, sdk.OneDec()) suite.Require().NoError(err) // Write default pool to state. @@ -2837,7 +2837,7 @@ func (suite *KeeperTestSuite) TestUpdatePoolForSwap() { } suite.Require().NoError(err) - suite.Require().Equal(tc.newCurrentTick, poolAfterUpdate.GetCurrentTick().Int64()) + suite.Require().Equal(tc.newCurrentTick, poolAfterUpdate.GetCurrentTick()) suite.Require().Equal(tc.newLiquidity, poolAfterUpdate.GetLiquidity()) suite.Require().Equal(tc.newSqrtPrice, poolAfterUpdate.GetCurrentSqrtPrice()) diff --git a/x/concentrated-liquidity/tick.go b/x/concentrated-liquidity/tick.go index badc8f2f363..e07b63d4652 100644 --- a/x/concentrated-liquidity/tick.go +++ b/x/concentrated-liquidity/tick.go @@ -325,13 +325,13 @@ func (k Keeper) GetTickLiquidityNetInDirection(ctx sdk.Context, poolId uint64, t return []queryproto.TickLiquidityNet{}, err } - ctx.Logger().Debug(fmt.Sprintf("userGivenStartTick %s, boundTick %s, currentTick %s\n", userGivenStartTick, boundTick, p.GetCurrentTick())) + ctx.Logger().Debug(fmt.Sprintf("userGivenStartTick %s, boundTick %s, currentTick %d\n", userGivenStartTick, boundTick, p.GetCurrentTick())) startTick := p.GetCurrentTick() // If start tick is set, use it as the current tick for grabbing liquidities from. if !userGivenStartTick.IsNil() { - startTick = userGivenStartTick - ctx.Logger().Debug(fmt.Sprintf("startTick %s set to user given\n", startTick)) + startTick = userGivenStartTick.Int64() + ctx.Logger().Debug(fmt.Sprintf("startTick %d set to user given\n", startTick)) } // sanity check that given tokenIn is an asset in pool. @@ -361,12 +361,12 @@ func (k Keeper) GetTickLiquidityNetInDirection(ctx sdk.Context, poolId uint64, t swapStrategy := swapstrategy.New(zeroForOne, sdk.ZeroDec(), k.storeKey, sdk.ZeroDec(), p.GetTickSpacing()) currentTick := p.GetCurrentTick() - _, currentTickSqrtPrice, err := math.TickToSqrtPrice(currentTick.Int64()) + _, currentTickSqrtPrice, err := math.TickToSqrtPrice(currentTick) if err != nil { return []queryproto.TickLiquidityNet{}, err } - ctx.Logger().Debug(fmt.Sprintf("currentTick %s; current tick's sqrt price%s\n", currentTick, currentTickSqrtPrice)) + ctx.Logger().Debug(fmt.Sprintf("currentTick %d; current tick's sqrt price%s\n", currentTick, currentTickSqrtPrice)) // function to validate that start tick and bound tick are // between current tick and the min/max tick depending on the swap direction. @@ -390,15 +390,15 @@ func (k Keeper) GetTickLiquidityNetInDirection(ctx sdk.Context, poolId uint64, t } ctx.Logger().Debug("validating start tick") - if err := validateTickIsInValidRange(startTick); err != nil { - return []queryproto.TickLiquidityNet{}, fmt.Errorf("failed validating start tick (%s) with current sqrt price of (%s): %w", startTick, currentTickSqrtPrice, err) + if err := validateTickIsInValidRange(sdk.NewInt(startTick)); err != nil { + return []queryproto.TickLiquidityNet{}, fmt.Errorf("failed validating start tick (%d) with current sqrt price of (%s): %w", startTick, currentTickSqrtPrice, err) } // iterator assignments store := ctx.KVStore(k.storeKey) prefixBz := types.KeyTickPrefixByPoolId(poolId) prefixStore := prefix.NewStore(store, prefixBz) - startTickKey := types.TickIndexToBytes(startTick.Int64()) + startTickKey := types.TickIndexToBytes(startTick) boundTickKey := types.TickIndexToBytes(boundTick.Int64()) // define iterator depending on swap strategy diff --git a/x/concentrated-liquidity/tick_test.go b/x/concentrated-liquidity/tick_test.go index 5df29365a8c..8e95e6d22e3 100644 --- a/x/concentrated-liquidity/tick_test.go +++ b/x/concentrated-liquidity/tick_test.go @@ -262,7 +262,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { // Create a default CL pool pool := s.PrepareConcentratedPool() - currentTick := pool.GetCurrentTick().Int64() + currentTick := pool.GetCurrentTick() _, err := s.App.ConcentratedLiquidityKeeper.GetFeeAccumulator(s.Ctx, 1) s.Require().NoError(err) @@ -282,7 +282,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { s.Require().NoError(err) err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(s.Ctx, test.param.poolId, currentTick, test.param.tickIndex, DefaultLiquidityAmt, test.param.upper) s.Require().NoError(err) - if tickInfoBefore.LiquidityGross.IsZero() && test.param.tickIndex <= pool.GetCurrentTick().Int64() { + if tickInfoBefore.LiquidityGross.IsZero() && test.param.tickIndex <= pool.GetCurrentTick() { tickInfoAfter, err := s.App.ConcentratedLiquidityKeeper.GetTickInfo(s.Ctx, 1, test.param.tickIndex) s.Require().NoError(err) s.Require().Equal(tickInfoAfter.FeeGrowthOppositeDirectionOfLastTraversal, feeAccum.GetValue()) @@ -299,7 +299,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { // Initialize or update the tick according to the test case err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(s.Ctx, test.param.poolId, currentTick, test.param.tickIndex, test.param.liquidityIn, test.param.upper) - if tickInfoAfter.LiquidityGross.IsZero() && test.param.tickIndex <= pool.GetCurrentTick().Int64() { + if tickInfoAfter.LiquidityGross.IsZero() && test.param.tickIndex <= pool.GetCurrentTick() { tickInfoAfter, err := s.App.ConcentratedLiquidityKeeper.GetTickInfo(s.Ctx, 1, test.param.tickIndex) s.Require().NoError(err) s.Require().Equal(tickInfoAfter.FeeGrowthOppositeDirectionOfLastTraversal, feeAccum.GetValue()) @@ -333,7 +333,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { func (s *KeeperTestSuite) TestGetTickInfo() { var ( - preInitializedTickIndex = DefaultCurrTick.Int64() + 2 + preInitializedTickIndex = DefaultCurrTick + 2 expectedUptimes = getExpectedUptimes() emptyUptimeTrackers = wrapUptimeTrackers(expectedUptimes.emptyExpectedAccumValues) varyingTokensAndDenoms = wrapUptimeTrackers(expectedUptimes.varyingTokensMultiDenom) @@ -375,7 +375,7 @@ func (s *KeeperTestSuite) TestGetTickInfo() { { name: "Get tick info for active tick on existing pool with existing tick", poolToGet: validPoolId, - tickToGet: DefaultCurrTick.Int64(), + tickToGet: DefaultCurrTick, preInitUptimeAccumValues: expectedUptimes.varyingTokensMultiDenom, // Both fee growth and uptime trackers are set to global since tickToGet <= current tick expectedTickInfo: model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec(), FeeGrowthOppositeDirectionOfLastTraversal: sdk.NewDecCoins(oneEth), UptimeTrackers: varyingTokensAndDenoms}, @@ -383,21 +383,21 @@ func (s *KeeperTestSuite) TestGetTickInfo() { { name: "Get tick info on existing pool with no existing tick (cur pool tick > tick)", poolToGet: validPoolId, - tickToGet: DefaultCurrTick.Int64() + 1, + tickToGet: DefaultCurrTick + 1, // Note that FeeGrowthOutside and UptimeGrowthOutside(s) are not initialized. expectedTickInfo: model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec(), UptimeTrackers: emptyUptimeTrackers}, }, { name: "Get tick info on existing pool with no existing tick (cur pool tick == tick), initialized fee growth outside", poolToGet: validPoolId, - tickToGet: DefaultCurrTick.Int64(), + tickToGet: DefaultCurrTick, // Note that FeeGrowthOutside and UptimeGrowthOutside(s) are initialized. expectedTickInfo: model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec(), FeeGrowthOppositeDirectionOfLastTraversal: sdk.NewDecCoins(oneEth), UptimeTrackers: emptyUptimeTrackers}, }, { name: "Get tick info on a non-existing pool with no existing tick", poolToGet: 2, - tickToGet: DefaultCurrTick.Int64() + 1, + tickToGet: DefaultCurrTick + 1, expectedErr: types.PoolNotFoundError{PoolId: 2}, }, } @@ -417,7 +417,7 @@ func (s *KeeperTestSuite) TestGetTickInfo() { } // Set up an initialized tick - err := clKeeper.InitOrUpdateTick(s.Ctx, validPoolId, DefaultCurrTick.Int64(), preInitializedTickIndex, DefaultLiquidityAmt, true) + err := clKeeper.InitOrUpdateTick(s.Ctx, validPoolId, DefaultCurrTick, preInitializedTickIndex, DefaultLiquidityAmt, true) s.Require().NoError(err) // Charge fee to make sure that the global fee accumulator is always updated. @@ -446,7 +446,7 @@ func (s *KeeperTestSuite) TestGetTickInfo() { func (s *KeeperTestSuite) TestCrossTick() { var ( - preInitializedTickIndex = DefaultCurrTick.Int64() - 2 + preInitializedTickIndex = DefaultCurrTick - 2 expectedUptimes = getExpectedUptimes() emptyUptimeTrackers = wrapUptimeTrackers(expectedUptimes.emptyExpectedAccumValues) defaultAdditiveFee = sdk.NewDecCoinFromDec(USDC, sdk.NewDec(1000)) @@ -494,8 +494,8 @@ func (s *KeeperTestSuite) TestCrossTick() { { name: "Get tick info of an existing tick above current tick (nonzero uptime trackers)", poolToGet: validPoolId, - preInitializedTickIndex: DefaultCurrTick.Int64() + 1, - tickToGet: DefaultCurrTick.Int64() + 1, + preInitializedTickIndex: DefaultCurrTick + 1, + tickToGet: DefaultCurrTick + 1, additiveFee: defaultAdditiveFee, // Global uptime accums remain unchanged after tick init initGlobalUptimeAccumValues: expectedUptimes.twoHundredTokensMultiDenom, @@ -511,7 +511,7 @@ func (s *KeeperTestSuite) TestCrossTick() { name: "Get tick info of new tick with a separate existing tick below current tick (nonzero uptime trackers)", poolToGet: validPoolId, preInitializedTickIndex: preInitializedTickIndex, - tickToGet: DefaultCurrTick.Int64() + 1, + tickToGet: DefaultCurrTick + 1, additiveFee: defaultAdditiveFee, // Global uptime accums remain unchanged after tick init initGlobalUptimeAccumValues: expectedUptimes.twoHundredTokensMultiDenom, @@ -527,8 +527,8 @@ func (s *KeeperTestSuite) TestCrossTick() { // Note that this test case covers technically undefined behavior (crossing into the current tick). name: "Get tick info of existing tick at current tick (nonzero uptime trackers)", poolToGet: validPoolId, - preInitializedTickIndex: DefaultCurrTick.Int64(), - tickToGet: DefaultCurrTick.Int64(), + preInitializedTickIndex: DefaultCurrTick, + tickToGet: DefaultCurrTick, additiveFee: defaultAdditiveFee, // Global uptime accums remain unchanged after tick init initGlobalUptimeAccumValues: expectedUptimes.twoHundredTokensMultiDenom, @@ -588,7 +588,7 @@ func (s *KeeperTestSuite) TestCrossTick() { } // Set up an initialized tick - err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(s.Ctx, validPoolId, DefaultCurrTick.Int64(), test.preInitializedTickIndex, DefaultLiquidityAmt, true) + err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(s.Ctx, validPoolId, DefaultCurrTick, test.preInitializedTickIndex, DefaultLiquidityAmt, true) s.Require().NoError(err) // Update global uptime accums for edge case testing @@ -1187,7 +1187,7 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { curPrice = sqrtPrice } pool.SetCurrentSqrtPrice(curPrice) - pool.SetCurrentTick(sdk.NewInt(curTick)) + pool.SetCurrentTick(curTick) err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) s.Require().NoError(err) diff --git a/x/concentrated-liquidity/types/pool.go b/x/concentrated-liquidity/types/pool.go index 51332d67a5e..f4496c6e5ac 100644 --- a/x/concentrated-liquidity/types/pool.go +++ b/x/concentrated-liquidity/types/pool.go @@ -15,18 +15,18 @@ type ConcentratedPoolExtension interface { GetToken0() string GetToken1() string GetCurrentSqrtPrice() sdk.Dec - GetCurrentTick() sdk.Int - GetExponentAtPriceOne() sdk.Int + GetCurrentTick() int64 + GetExponentAtPriceOne() int64 GetTickSpacing() uint64 GetLiquidity() sdk.Dec GetLastLiquidityUpdate() time.Time SetCurrentSqrtPrice(newSqrtPrice sdk.Dec) - SetCurrentTick(newTick sdk.Int) + SetCurrentTick(newTick int64) SetTickSpacing(newTickSpacing uint64) SetLastLiquidityUpdate(newTime time.Time) UpdateLiquidity(newLiquidity sdk.Dec) - ApplySwap(newLiquidity sdk.Dec, newCurrentTick sdk.Int, newCurrentSqrtPrice sdk.Dec) error + ApplySwap(newLiquidity sdk.Dec, newCurrentTick int64, newCurrentSqrtPrice sdk.Dec) error CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta sdk.Dec) (actualAmountDenom0 sdk.Dec, actualAmountDenom1 sdk.Dec, err error) UpdateLiquidityIfActivePosition(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta sdk.Dec) bool }