diff --git a/osmoutils/accum/accum.go b/osmoutils/accum/accum.go index 47c072edf0b..3af5c1231df 100644 --- a/osmoutils/accum/accum.go +++ b/osmoutils/accum/accum.go @@ -347,8 +347,9 @@ func (accum AccumulatorObject) deletePosition(positionName string) { accum.store.Delete(FormatPositionPrefixKey(accum.name, positionName)) } -// GetPositionSize returns the number of shares the position corresponding to `addr` -// in accumulator `accum` has, or an error if no position exists. +// GetPositionSize returns the number of shares the position with the given +// name has in the accumulator. Returns error if position does not exist +// or if fails to retrieve position from state. func (accum AccumulatorObject) GetPositionSize(name string) (sdk.Dec, error) { position, err := GetPosition(accum, name) if err != nil { @@ -422,8 +423,8 @@ func (accum AccumulatorObject) GetTotalShares() (sdk.Dec, error) { } // AddToUnclaimedRewards adds the given amount of rewards to the unclaimed rewards -// for the given position. Returns error if no position exists for the given address. -// Returns error if any database errors occur. +// for the given position. Returns error if no position exists for the given position name. +// Returns error if any database errors occur or if neggative rewards are provided. func (accum AccumulatorObject) AddToUnclaimedRewards(positionName string, rewards sdk.DecCoins) error { position, err := GetPosition(accum, positionName) if err != nil { diff --git a/proto/osmosis/poolmanager/v1beta1/query.proto b/proto/osmosis/poolmanager/v1beta1/query.proto index 0eda70e5a35..a01ca4bec21 100644 --- a/proto/osmosis/poolmanager/v1beta1/query.proto +++ b/proto/osmosis/poolmanager/v1beta1/query.proto @@ -152,9 +152,7 @@ message PoolResponse { } //=============================== AllPools -message AllPoolsRequest { - uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; -} +message AllPoolsRequest {} message AllPoolsResponse { repeated google.protobuf.Any pools = 1 [ (cosmos_proto.accepts_interface) = "PoolI" ]; diff --git a/tests/e2e/configurer/chain/commands.go b/tests/e2e/configurer/chain/commands.go index 87d3ca357ec..c9b273f5afe 100644 --- a/tests/e2e/configurer/chain/commands.go +++ b/tests/e2e/configurer/chain/commands.go @@ -72,7 +72,7 @@ func (n *NodeConfig) CollectFees(from, positionIds string) { func (n *NodeConfig) CreateConcentratedPool(from, denom1, denom2 string, tickSpacing uint64, swapFee string) (uint64, error) { n.LogActionF("creating concentrated pool") - cmd := []string{"osmosisd", "tx", "concentratedliquidity", "create-concentrated-pool", denom1, denom2, fmt.Sprintf("%d", tickSpacing), swapFee, fmt.Sprintf("--from=%s", from)} + cmd := []string{"osmosisd", "tx", "concentratedliquidity", "create-pool", denom1, denom2, fmt.Sprintf("%d", tickSpacing), swapFee, fmt.Sprintf("--from=%s", from)} _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) if err != nil { return 0, err diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 57feb842eff..96e7a444885 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -1554,13 +1554,13 @@ func (s *IntegrationTestSuite) TestAConcentratedLiquidity_CanonicalPool_And_Para s.T().Skip("Skipping v16 canonical pool creation test because upgrade is not enabled") } - // Taken from: https://app.osmosis.zone/pool/674 expectedFee := sdk.MustNewDecFromStr("0.002") chainA := s.configurer.GetChainConfig(0) chainANode, err := chainA.GetDefaultNode() s.Require().NoError(err) + // Taken from: https://app.osmosis.zone/pool/674 concentratedPoolId := chainANode.QueryConcentratedPooIdLinkFromCFMM(config.DaiOsmoPoolIdv16) concentratedPool := s.updatedPool(chainANode, concentratedPoolId) diff --git a/x/concentrated-liquidity/README.md b/x/concentrated-liquidity/README.md index c6e4699d9be..372458ba833 100644 --- a/x/concentrated-liquidity/README.md +++ b/x/concentrated-liquidity/README.md @@ -427,6 +427,36 @@ type MsgCollectFeesResponse struct { } ``` +### `MsgFungifyChargedPositions` + +This message allows fungifying the fully charged unlocked positions belonging to the same owner +and located in the same tick range. +MsgFungifyChargedPosition takes in a list of positionIds and combines them into a single position. +It validates that all positions belong to the same owner, are in the same ticks and are fully charged. +Fails if not. Otherwise, it creates a completely new position P. P's liquidity equals to the sum of all +liquidities of positions given by positionIds. The uptime of the join time of the new position equals +to current block time - max authorized uptime duration (to signify that it is fully charged). +The previous positions are deleted from state. Prior to deleting, the rewards are claimed. +The old position's unclaimed rewards are transferred to the new position. +The new position ID is returned. + +```go +type MsgFungifyChargedPositions struct { + PositionIds []uint64 + Sender string +} +``` + +- **Response** + +On successful response, the new position id is returned. + +```go +type MsgFungifyChargedPositionsResponse struct { + NewPositionId uint64 +} +``` + ## Relationship to Pool Manager Module ### Pool Creation diff --git a/x/concentrated-liquidity/client/cli/tx.go b/x/concentrated-liquidity/client/cli/tx.go index 4e87108de96..35358950de8 100644 --- a/x/concentrated-liquidity/client/cli/tx.go +++ b/x/concentrated-liquidity/client/cli/tx.go @@ -30,6 +30,7 @@ func NewTxCmd() *cobra.Command { osmocli.AddTxCmd(txCmd, NewCollectFeesCmd) osmocli.AddTxCmd(txCmd, NewCollectIncentivesCmd) osmocli.AddTxCmd(txCmd, NewCreateIncentiveCmd) + osmocli.AddTxCmd(txCmd, NewFungifyChargedPositionsCmd) return txCmd } @@ -39,10 +40,10 @@ var poolIdFlagOverride = map[string]string{ func NewCreateConcentratedPoolCmd() (*osmocli.TxCliDesc, *clmodel.MsgCreateConcentratedPool) { return &osmocli.TxCliDesc{ - Use: "create-concentrated-pool [denom-0] [denom-1] [tick-spacing] [swap-fee]", + Use: "create-pool [denom-0] [denom-1] [tick-spacing] [swap-fee]", Short: "create a concentrated liquidity pool with the given denom pair, tick spacing, and swap fee", Long: "denom-1 (the quote denom), tick spacing, and swap fees must all be authorized by the concentrated liquidity module", - Example: "create-concentrated-pool uion uosmo 1 0.01 --from val --chain-id osmosis-1", + Example: "create-pool uion uosmo 100 0.01 --from val --chain-id osmosis-1", }, &clmodel.MsgCreateConcentratedPool{} } @@ -88,14 +89,22 @@ func NewCollectIncentivesCmd() (*osmocli.TxCliDesc, *types.MsgCollectIncentives) func NewCreateIncentiveCmd() (*osmocli.TxCliDesc, *types.MsgCreateIncentive) { return &osmocli.TxCliDesc{ - Use: "create-incentive [incentive-denom] [incentive-amount] [emission-rate] [start-time] [min-uptime]", + Use: "create-incentive [incentive-coin] [emission-rate] [start-time] [min-uptime]", Short: "create an incentive record to emit incentives (per second) to a given pool", - Example: "create-incentive uosmo 69082 0.02 2023-03-03 03:20:35.419543805 24h --pool-id 1 --from val --chain-id osmosis-1", + Example: "create-incentive 69082uosmo 0.02 \"2023-03-03T03:20:35.419543805\" 24h --pool-id 1 --from val --chain-id osmosis-1 --fees 875uosmo", CustomFlagOverrides: poolIdFlagOverride, Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetJustPoolId()}}, }, &types.MsgCreateIncentive{} } +func NewFungifyChargedPositionsCmd() (*osmocli.TxCliDesc, *types.MsgFungifyChargedPositions) { + return &osmocli.TxCliDesc{ + Use: "fungify-positions [position-ids]", + Short: "Combine fully charged positions within the same range into a new single fully charged position", + Example: "fungify-positions 1,5,7 --from val --chain-id osmosis-1", + }, &types.MsgFungifyChargedPositions{} +} + // NewCmdCreateConcentratedLiquidityPoolProposal implements a command handler for create concentrated liquidity pool proposal func NewCmdCreateConcentratedLiquidityPoolProposal() *cobra.Command { cmd := &cobra.Command{ diff --git a/x/concentrated-liquidity/export_test.go b/x/concentrated-liquidity/export_test.go index 5375acb6be2..7289be63a9a 100644 --- a/x/concentrated-liquidity/export_test.go +++ b/x/concentrated-liquidity/export_test.go @@ -16,11 +16,14 @@ const ( ) var ( - EmptyCoins = emptyCoins - HundredFooCoins = sdk.NewDecCoin("foo", sdk.NewInt(100)) - HundredBarCoins = sdk.NewDecCoin("bar", sdk.NewInt(100)) - TwoHundredFooCoins = sdk.NewDecCoin("foo", sdk.NewInt(200)) - TwoHundredBarCoins = sdk.NewDecCoin("bar", sdk.NewInt(200)) + EmptyCoins = emptyCoins + HundredFooCoins = sdk.NewDecCoin("foo", sdk.NewInt(100)) + HundredBarCoins = sdk.NewDecCoin("bar", sdk.NewInt(100)) + TwoHundredFooCoins = sdk.NewDecCoin("foo", sdk.NewInt(200)) + TwoHundredBarCoins = sdk.NewDecCoin("bar", sdk.NewInt(200)) + // TODO: this is incorrect. Should be grabbing from + // authorized params instead. Must verify that all tests still make sense. + // https://github.com/osmosis-labs/osmosis/issues/5039 FullyChargedDuration = types.SupportedUptimes[len(types.SupportedUptimes)-1] ) @@ -145,8 +148,8 @@ func (k Keeper) CreateFeeAccumulator(ctx sdk.Context, poolId uint64) error { return k.createFeeAccumulator(ctx, poolId) } -func (k Keeper) InitOrUpdateFeeAccumulatorPosition(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidity sdk.Dec) error { - return k.initOrUpdateFeeAccumulatorPosition(ctx, poolId, lowerTick, upperTick, positionId, liquidity) +func (k Keeper) InitOrUpdatePositionFeeAccumulator(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidity sdk.Dec) error { + return k.initOrUpdatePositionFeeAccumulator(ctx, poolId, lowerTick, upperTick, positionId, liquidity) } func (k Keeper) GetFeeGrowthOutside(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64) (sdk.DecCoins, error) { @@ -212,7 +215,7 @@ func CalcAccruedIncentivesForAccum(ctx sdk.Context, accumUptime time.Duration, q } func (k Keeper) UpdateUptimeAccumulatorsToNow(ctx sdk.Context, poolId uint64) error { - return k.updateUptimeAccumulatorsToNow(ctx, poolId) + return k.updatePoolUptimeAccumulatorsToNow(ctx, poolId) } func (k Keeper) SetIncentiveRecord(ctx sdk.Context, incentiveRecord types.IncentiveRecord) error { @@ -227,12 +230,12 @@ func (k Keeper) GetInitialUptimeGrowthOutsidesForTick(ctx sdk.Context, poolId ui return k.getInitialUptimeGrowthOutsidesForTick(ctx, poolId, tick) } -func (k Keeper) GetAllIncentiveRecordsForUptime(ctx sdk.Context, poolId uint64, minUptime time.Duration) ([]types.IncentiveRecord, error) { - return k.getAllIncentiveRecordsForUptime(ctx, poolId, minUptime) +func (k Keeper) InitOrUpdatePositionUptimeAccumulators(ctx sdk.Context, poolId uint64, position sdk.Dec, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, positionId uint64) error { + return k.initOrUpdatePositionUptimeAccumulators(ctx, poolId, position, owner, lowerTick, upperTick, liquidityDelta, positionId) } -func (k Keeper) InitOrUpdatePositionUptime(ctx sdk.Context, poolId uint64, position sdk.Dec, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, positionId uint64) error { - return k.initOrUpdatePositionUptime(ctx, poolId, position, owner, lowerTick, upperTick, liquidityDelta, joinTime, positionId) +func (k Keeper) GetAllIncentiveRecordsForUptime(ctx sdk.Context, poolId uint64, minUptime time.Duration) ([]types.IncentiveRecord, error) { + return k.getAllIncentiveRecordsForUptime(ctx, poolId, minUptime) } func (k Keeper) CollectIncentives(ctx sdk.Context, owner sdk.AccAddress, positionId uint64) (sdk.Coins, sdk.Coins, error) { diff --git a/x/concentrated-liquidity/fees.go b/x/concentrated-liquidity/fees.go index 68573de4345..22eb3560bcc 100644 --- a/x/concentrated-liquidity/fees.go +++ b/x/concentrated-liquidity/fees.go @@ -46,7 +46,7 @@ func (k Keeper) chargeFee(ctx sdk.Context, poolId uint64, feeUpdate sdk.DecCoin) return nil } -// initOrUpdateFeeAccumulatorPosition mutates the fee accumulator position by either creating or updating it +// initOrUpdatePositionFeeAccumulator mutates the fee accumulator position by either creating or updating it // for the given pool id in the range specified by the given lower and upper ticks, position id and liquidityDelta. // If liquidityDelta is positive, it adds liquidity. If liquidityDelta is negative, it removes liquidity. // If this is a new position, liqudityDelta must be positive. @@ -62,7 +62,7 @@ func (k Keeper) chargeFee(ctx sdk.Context, poolId uint64, feeUpdate sdk.DecCoin) // - fails to create a new position. // - fails to prepare the accumulator for update. // - fails to update the position's accumulator. -func (k Keeper) initOrUpdateFeeAccumulatorPosition(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidityDelta sdk.Dec) error { +func (k Keeper) initOrUpdatePositionFeeAccumulator(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidityDelta sdk.Dec) error { // Get the fee accumulator for the position's pool. feeAccumulator, err := k.GetFeeAccumulator(ctx, poolId) if err != nil { @@ -302,6 +302,7 @@ func calculateFeeGrowth(targetTick int64, feeGrowthOutside sdk.DecCoins, current // as we must set the position's accumulator value to the sum of // - the fee/uptime growth inside at position creation time (position.InitAccumValue) // - fee/uptime growth outside at the current block time (feeGrowthOutside/uptimeGrowthOutside) +// CONTRACT: position accumulator value prior to this call is equal to the growth inside the position at the time of last update. func preparePositionAccumulator(accumulator accum.AccumulatorObject, positionKey string, growthOutside sdk.DecCoins) error { position, err := accum.GetPosition(accumulator, positionKey) if err != nil { diff --git a/x/concentrated-liquidity/fees_test.go b/x/concentrated-liquidity/fees_test.go index c1664bc974e..94537a199ec 100644 --- a/x/concentrated-liquidity/fees_test.go +++ b/x/concentrated-liquidity/fees_test.go @@ -83,7 +83,7 @@ func (s *KeeperTestSuite) TestCreateAndGetFeeAccumulator() { } } -func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition() { +func (s *KeeperTestSuite) TestInitOrUpdatePositionFeeAccumulator() { // Setup is done once so that we test // the relationship between test cases. // For example, that positions with non-zero liquidity @@ -137,42 +137,37 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition() { positionFields positionFields expectedLiquidity sdk.Dec - expectedPass bool + expectedError error } tests := []initFeeAccumTest{ { name: "error: negative liquidity for the first position", positionFields: withLiquidity(defaultPositionFields, DefaultLiquidityAmt.Neg()), - expectedPass: false, + expectedError: types.NonPositiveLiquidityForNewPositionError{LiquidityDelta: DefaultLiquidityAmt.Neg(), PositionId: DefaultPositionId}, }, { name: "first position", positionFields: defaultPositionFields, expectedLiquidity: defaultPositionFields.liquidity, - expectedPass: true, }, { name: "second position", positionFields: withPositionId(withLowerTick(defaultPositionFields, DefaultLowerTick+1), DefaultPositionId+1), expectedLiquidity: defaultPositionFields.liquidity, - expectedPass: true, }, { name: "adding to first position", positionFields: defaultPositionFields, - expectedPass: true, expectedLiquidity: defaultPositionFields.liquidity.MulInt64(2), }, { name: "removing from first position", positionFields: withLiquidity(defaultPositionFields, defaultPositionFields.liquidity.Neg()), - expectedPass: true, expectedLiquidity: defaultPositionFields.liquidity, }, { name: "adding to second position", positionFields: withPositionId(withLowerTick(defaultPositionFields, DefaultLowerTick+1), DefaultPositionId+1), - expectedPass: true, expectedLiquidity: defaultPositionFields.liquidity.MulInt64(2), }, { @@ -185,25 +180,22 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition() { DefaultPositionId, DefaultLiquidityAmt, }, - expectedPass: false, + expectedError: accum.AccumDoesNotExistError{AccumName: types.KeyFeePoolAccumulator(defaultPoolId + 1)}, }, { name: "existing accumulator, different owner - different position", positionFields: withPositionId(withOwner(defaultPositionFields, s.TestAccs[1]), DefaultPositionId+2), expectedLiquidity: defaultPositionFields.liquidity, - expectedPass: true, }, { name: "existing accumulator, different upper tick - different position", positionFields: withPositionId(withUpperTick(defaultPositionFields, DefaultUpperTick+1), DefaultPositionId+3), expectedLiquidity: defaultPositionFields.liquidity, - expectedPass: true, }, { name: "existing accumulator, different lower tick - different position", positionFields: withPositionId(withLowerTick(defaultPositionFields, DefaultUpperTick+1), DefaultPositionId+4), expectedLiquidity: defaultPositionFields.liquidity, - expectedPass: true, }, } @@ -211,8 +203,8 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition() { tc := tc s.Run(tc.name, func() { // System under test - err := clKeeper.InitOrUpdateFeeAccumulatorPosition(s.Ctx, tc.positionFields.poolId, tc.positionFields.lowerTick, tc.positionFields.upperTick, tc.positionFields.positionId, tc.positionFields.liquidity) - if tc.expectedPass { + err := clKeeper.InitOrUpdatePositionFeeAccumulator(s.Ctx, tc.positionFields.poolId, tc.positionFields.lowerTick, tc.positionFields.upperTick, tc.positionFields.positionId, tc.positionFields.liquidity) + if tc.expectedError == nil { s.Require().NoError(err) // get fee accum and see if position size has been properly initialized @@ -243,6 +235,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition() { s.Require().Equal(cl.EmptyCoins, positionRecord.UnclaimedRewards) } else { s.Require().Error(err) + s.Require().ErrorContains(err, tc.expectedError.Error()) } }) } @@ -1302,7 +1295,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition_UpdatingPositio s.Require().NoError(err) // InitOrUpdateFeeAccumulatorPosition #1 lower tick to upper tick - err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateFeeAccumulatorPosition(s.Ctx, poolId, DefaultLowerTick, DefaultUpperTick, DefaultPositionId, DefaultLiquidityAmt) + err = s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionFeeAccumulator(s.Ctx, poolId, DefaultLowerTick, DefaultUpperTick, DefaultPositionId, DefaultLiquidityAmt) s.Require().NoError(err) // Imaginary fee charge #2. @@ -1311,7 +1304,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition_UpdatingPositio } // InitOrUpdateFeeAccumulatorPosition # 2 lower tick to upper tick with a different position id. - err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateFeeAccumulatorPosition(s.Ctx, poolId, DefaultLowerTick, DefaultUpperTick, DefaultPositionId+1, DefaultLiquidityAmt) + err = s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionFeeAccumulator(s.Ctx, poolId, DefaultLowerTick, DefaultUpperTick, DefaultPositionId+1, DefaultLiquidityAmt) s.Require().NoError(err) // Imaginary fee charge #3. @@ -1320,7 +1313,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition_UpdatingPositio } // InitOrUpdateFeeAccumulatorPosition # 3 lower tick to upper tick with the original position id. - err = s.App.ConcentratedLiquidityKeeper.InitOrUpdateFeeAccumulatorPosition(s.Ctx, poolId, DefaultLowerTick, DefaultUpperTick, DefaultPositionId, DefaultLiquidityAmt) + err = s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionFeeAccumulator(s.Ctx, poolId, DefaultLowerTick, DefaultUpperTick, DefaultPositionId, DefaultLiquidityAmt) s.Require().NoError(err) // Imaginary fee charge #4. diff --git a/x/concentrated-liquidity/incentives.go b/x/concentrated-liquidity/incentives.go index f9449d7e894..71f5ecd48a2 100644 --- a/x/concentrated-liquidity/incentives.go +++ b/x/concentrated-liquidity/incentives.go @@ -53,7 +53,6 @@ func (k Keeper) GetUptimeAccumulators(ctx sdk.Context, poolId uint64) ([]accum.A return accums, nil } -// nolint: unused // getUptimeAccumulatorValues gets the accumulator values for the supported uptimes for the given poolId // Returns error if accumulator for the given poolId does not exist. func (k Keeper) getUptimeAccumulatorValues(ctx sdk.Context, poolId uint64) ([]sdk.DecCoins, error) { @@ -70,7 +69,6 @@ func (k Keeper) getUptimeAccumulatorValues(ctx sdk.Context, poolId uint64) ([]sd return uptimeValues, nil } -// nolint: unused // getInitialUptimeGrowthOutsidesForTick returns an array of the initial values of uptime growth outside // for each supported uptime for a given tick. This value depends on the tick's location relative to the current tick. // @@ -105,7 +103,6 @@ func (k Keeper) getInitialUptimeGrowthOutsidesForTick(ctx sdk.Context, poolId ui return emptyUptimeValues, nil } -// nolint: unused // prepareBalancerPoolAsFullRange find the canonical Balancer pool that corresponds to the given CL poolId and, // if it exists, adds the number of full range shares it qualifies for to the CL pool uptime accumulators. // This is functionally equivalent to treating the Balancer pool shares as a single full range position on the CL pool, @@ -295,12 +292,12 @@ func (k Keeper) claimAndResetFullRangeBalancerPool(ctx sdk.Context, clPoolId uin return totalRewards, nil } -// updateUptimeAccumulatorsToNow syncs all uptime accumulators to be up to date. +// updatePoolUptimeAccumulatorsToNow syncs all uptime accumulators to be up to date for the given pool. // Specifically, it gets the time elapsed since the last update and divides it // by the qualifying liquidity for each uptime. It then adds this value to the // respective accumulator and updates relevant time trackers accordingly. // WARNING: this method may mutate the pool, make sure to refetch the pool after calling this method. -func (k Keeper) updateUptimeAccumulatorsToNow(ctx sdk.Context, poolId uint64) error { +func (k Keeper) updatePoolUptimeAccumulatorsToNow(ctx sdk.Context, poolId uint64) error { pool, err := k.getPoolById(ctx, poolId) if err != nil { return err @@ -622,18 +619,27 @@ func (k Keeper) GetUptimeGrowthOutsideRange(ctx sdk.Context, poolId uint64, lowe return osmoutils.SubDecCoinArrays(globalUptimeValues, uptimeGrowthInside) } -// initOrUpdatePositionUptime either adds or updates records for all uptime accumulators `position` qualifies for +// initOrUpdatePositionUptimeAccumulators either initializes or updates liquidity for uptime position accumulators for every supported uptime. +// It syncs the uptime accumulators to the current block time. If this is a new position, it creates a new position accumulator for every supported uptime accumulator. +// If this is an existing position, it updates the existing position accumulator for every supported uptime accumulator. +// Returns error if: +// - fails to update global uptime accumulators +// - fails to get global uptime accumulators +// - fails to calculate uptime growth inside range +// - fails to calculate uptime growth outside range +// - fails to determine if position accumulator is new or existing +// - fails to create/update position uptime accumulators // WARNING: this method may mutate the pool, make sure to refetch the pool after calling this method. -func (k Keeper) initOrUpdatePositionUptime(ctx sdk.Context, poolId uint64, liquidity sdk.Dec, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, positionId uint64) error { +func (k Keeper) initOrUpdatePositionUptimeAccumulators(ctx sdk.Context, poolId uint64, liquidity sdk.Dec, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, positionId uint64) error { // We update accumulators _prior_ to any position-related updates to ensure // past rewards aren't distributed to new liquidity. We also update pool's // LastLiquidityUpdate here. - err := k.updateUptimeAccumulatorsToNow(ctx, poolId) + err := k.updatePoolUptimeAccumulatorsToNow(ctx, poolId) if err != nil { return err } - // Now update or init records for relevant uptime accumulators + // Get uptime accumulators for every supported uptime. uptimeAccumulators, err := k.GetUptimeAccumulators(ctx, poolId) if err != nil { return err @@ -649,10 +655,8 @@ func (k Keeper) initOrUpdatePositionUptime(ctx sdk.Context, poolId uint64, liqui // Loop through uptime accums for all supported uptimes on the pool and init or update position's records positionName := string(types.KeyPositionId(positionId)) - for uptimeIndex := range types.SupportedUptimes { - curUptimeAccum := uptimeAccumulators[uptimeIndex] - - // If a record does not exist for this uptime accumulator for the given position, create a new position. + for uptimeIndex, curUptimeAccum := range uptimeAccumulators { + // If a record does not exist for this uptime accumulator, create a new position. // Otherwise, add to existing record. recordExists, err := curUptimeAccum.HasPosition(positionName) if err != nil { @@ -660,6 +664,11 @@ func (k Keeper) initOrUpdatePositionUptime(ctx sdk.Context, poolId uint64, liqui } if !recordExists { + // Liquidity cannot be negative for a new position + if !liquidityDelta.IsPositive() { + return types.NonPositiveLiquidityForNewPositionError{LiquidityDelta: liquidityDelta, PositionId: positionId} + } + // Since the position should only be entitled to uptime growth within its range, we checkpoint globalUptimeGrowthInsideRange as // its accumulator's init value. During the claiming (or, equivalently, position updating) process, we ensure that incentives are // not overpaid. @@ -687,7 +696,13 @@ func (k Keeper) initOrUpdatePositionUptime(ctx sdk.Context, poolId uint64, liqui } // prepareAccumAndClaimRewards claims and returns the rewards that `positionKey` is entitled to, updating the accumulator's value before -// and after claiming to ensure that rewards are never over distributed. +// and after claiming to ensure that rewards are never overdistributed. +// CONTRACT: position accumulator value prior to this call is equal to the growth inside the position at the time of last update. +// Returns error if: +// - fails to prepare position accumulator +// - fails to claim rewards +// - fails to check if position record exists +// - fails to update position accumulator with the current growth inside the position func prepareAccumAndClaimRewards(accum accum.AccumulatorObject, positionKey string, growthOutside sdk.DecCoins) (sdk.Coins, sdk.DecCoins, error) { // Set the position's accumulator value to it's initial value at creation time plus the growth outside at this moment. err := preparePositionAccumulator(accum, positionKey, growthOutside) @@ -709,8 +724,11 @@ func prepareAccumAndClaimRewards(accum accum.AccumulatorObject, positionKey stri // If position still exists, we update the position's accumulator value to be the current accumulator value minus the growth outside. if hasPosition { - customAccumulatorValue := accum.GetValue().Sub(growthOutside) - err := accum.SetPositionCustomAcc(positionKey, customAccumulatorValue) + // The position accumulator value must always equal to the growth inside at the time of last update. + // Since this is the time we update the accumulator, we must subtract the growth outside from the global accumulator value + // to get growth inside at the current block time. + currentGrowthInsideForPosition := accum.GetValue().Sub(growthOutside) + err := accum.SetPositionCustomAcc(positionKey, currentGrowthInsideForPosition) if err != nil { return sdk.Coins{}, sdk.DecCoins{}, err } @@ -767,7 +785,8 @@ func (k Keeper) claimAllIncentivesForPosition(ctx sdk.Context, positionId uint64 return sdk.Coins{}, sdk.Coins{}, err } - if err := k.updateUptimeAccumulatorsToNow(ctx, position.PoolId); err != nil { + err = k.updatePoolUptimeAccumulatorsToNow(ctx, position.PoolId) + if err != nil { return sdk.Coins{}, sdk.Coins{}, err } @@ -982,7 +1001,7 @@ func (k Keeper) CreateIncentive(ctx sdk.Context, poolId uint64, sender sdk.AccAd } // Sync global uptime accumulators to current blocktime to ensure consistency in reward emissions - err = k.updateUptimeAccumulatorsToNow(ctx, poolId) + err = k.updatePoolUptimeAccumulatorsToNow(ctx, poolId) if err != nil { return types.IncentiveRecord{}, err } diff --git a/x/concentrated-liquidity/incentives_test.go b/x/concentrated-liquidity/incentives_test.go index 5c2425797cb..4a8ed9345ad 100644 --- a/x/concentrated-liquidity/incentives_test.go +++ b/x/concentrated-liquidity/incentives_test.go @@ -1816,7 +1816,7 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthOutsideRange() { } } -func (s *KeeperTestSuite) TestInitOrUpdatePositionUptime() { +func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { uptimeHelper := getExpectedUptimes() type tick struct { tickIndex int64 @@ -1948,6 +1948,23 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptime() { expectedInitAccumValue: uptimeHelper.hundredTokensMultiDenom, expectedUnclaimedRewards: uptimeHelper.emptyExpectedAccumValues, }, + { + name: "error: negative liquidity for first position", + positionLiquidity: DefaultLiquidityAmt.Neg(), + lowerTick: tick{ + tickIndex: -50, + uptimeTrackers: wrapUptimeTrackers(uptimeHelper.hundredTokensMultiDenom), + }, + upperTick: tick{ + tickIndex: 50, + uptimeTrackers: wrapUptimeTrackers(uptimeHelper.hundredTokensMultiDenom), + }, + positionId: DefaultPositionId, + currentTickIndex: sdk.ZeroInt(), + globalUptimeAccumValues: uptimeHelper.threeHundredTokensMultiDenom, + + expectedErr: types.NonPositiveLiquidityForNewPositionError{PositionId: DefaultPositionId, LiquidityDelta: DefaultLiquidityAmt.Neg()}, + }, } for _, test := range tests { @@ -1975,7 +1992,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptime() { // If applicable, set up existing position and update ticks & global accums if test.existingPosition { - err := s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionUptime(s.Ctx, clPool.GetId(), test.positionLiquidity, s.TestAccs[0], test.lowerTick.tickIndex, test.upperTick.tickIndex, test.positionLiquidity, DefaultJoinTime, DefaultPositionId) + err := s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionUptimeAccumulators(s.Ctx, clPool.GetId(), test.positionLiquidity, s.TestAccs[0], test.lowerTick.tickIndex, test.upperTick.tickIndex, test.positionLiquidity, DefaultPositionId) s.Require().NoError(err) 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) @@ -1992,7 +2009,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptime() { // --- System under test --- - err = s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionUptime(s.Ctx, clPool.GetId(), test.positionLiquidity, s.TestAccs[0], test.lowerTick.tickIndex, test.upperTick.tickIndex, test.positionLiquidity, DefaultJoinTime, DefaultPositionId) + err = s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionUptimeAccumulators(s.Ctx, clPool.GetId(), test.positionLiquidity, s.TestAccs[0], test.lowerTick.tickIndex, test.upperTick.tickIndex, test.positionLiquidity, DefaultPositionId) // --- Error catching --- diff --git a/x/concentrated-liquidity/keeper_test.go b/x/concentrated-liquidity/keeper_test.go index 45abf8c26b7..550ea3f2164 100644 --- a/x/concentrated-liquidity/keeper_test.go +++ b/x/concentrated-liquidity/keeper_test.go @@ -160,7 +160,7 @@ func (s *KeeperTestSuite) initializeTick(ctx sdk.Context, currentTick int64, tic // initializeFeeAccumulatorPositionWithLiquidity initializes fee accumulator position with given parameters and updates it with given liquidity. func (s *KeeperTestSuite) initializeFeeAccumulatorPositionWithLiquidity(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidity sdk.Dec) { - err := s.App.ConcentratedLiquidityKeeper.InitOrUpdateFeeAccumulatorPosition(ctx, poolId, lowerTick, upperTick, positionId, liquidity) + err := s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionFeeAccumulator(ctx, poolId, lowerTick, upperTick, positionId, liquidity) s.Require().NoError(err) } diff --git a/x/concentrated-liquidity/lp.go b/x/concentrated-liquidity/lp.go index 7620a191403..9ba93126a48 100644 --- a/x/concentrated-liquidity/lp.go +++ b/x/concentrated-liquidity/lp.go @@ -86,7 +86,7 @@ func (k Keeper) createPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddr return 0, sdk.Int{}, sdk.Int{}, sdk.Dec{}, time.Time{}, errors.New("liquidityDelta calculated equals zero") } - // Update the position in the pool based on the provided tick range and liquidity delta. + // Initialize / update the position in the pool based on the provided tick range and liquidity delta. actualAmount0, actualAmount1, err := k.UpdatePosition(ctx, poolId, owner, lowerTick, upperTick, liquidityDelta, joinTime, positionId) if err != nil { return 0, sdk.Int{}, sdk.Int{}, sdk.Dec{}, time.Time{}, err @@ -374,7 +374,7 @@ func (k Keeper) UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddr return sdk.Int{}, sdk.Int{}, err } - if err := k.initOrUpdateFeeAccumulatorPosition(ctx, poolId, lowerTick, upperTick, positionId, liquidityDelta); err != nil { + if err := k.initOrUpdatePositionFeeAccumulator(ctx, poolId, lowerTick, upperTick, positionId, liquidityDelta); err != nil { return sdk.Int{}, sdk.Int{}, err } diff --git a/x/concentrated-liquidity/msg_server.go b/x/concentrated-liquidity/msg_server.go index 72cf63358a3..0ad3a7bcb08 100644 --- a/x/concentrated-liquidity/msg_server.go +++ b/x/concentrated-liquidity/msg_server.go @@ -2,9 +2,7 @@ package concentrated_liquidity import ( "context" - "fmt" "strconv" - "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -256,13 +254,6 @@ func (server msgServer) FungifyChargedPositions(goCtx context.Context, msg *type sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), ), - sdk.NewEvent( - types.TypeEvtFungifyChargedPosition, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), - sdk.NewAttribute(types.AttributeInputPositionIds, strings.Trim(strings.Join(strings.Fields(fmt.Sprint(msg.PositionIds)), ","), "[]")), - sdk.NewAttribute(types.AttributeOutputPositionId, strconv.FormatUint(newPositionId, 10)), - ), }) return &types.MsgFungifyChargedPositionsResponse{ diff --git a/x/concentrated-liquidity/msg_server_test.go b/x/concentrated-liquidity/msg_server_test.go index d132680a74f..8628c0c1863 100644 --- a/x/concentrated-liquidity/msg_server_test.go +++ b/x/concentrated-liquidity/msg_server_test.go @@ -427,3 +427,88 @@ func (suite *KeeperTestSuite) TestCollectIncentives_Events() { }) } } + +func (suite *KeeperTestSuite) TestFungify_Events() { + testcases := map[string]struct { + positionIdsToFungify []uint64 + numPositionsToCreate int + shouldSetupUnownedPosition bool + shouldSetupUncharged bool + expectedFungifyEvents int + expectedMessageEvents int + expectedError error + }{ + "three position IDs": { + positionIdsToFungify: []uint64{DefaultPositionId, DefaultPositionId + 1, DefaultPositionId + 2}, + numPositionsToCreate: 3, + expectedFungifyEvents: 1, + expectedMessageEvents: 1, // 1 for fungify + }, + "error: single position ID": { + positionIdsToFungify: []uint64{DefaultPositionId}, + numPositionsToCreate: 1, + + expectedError: types.PositionQuantityTooLowError{}, + }, + "error: attempt to fungify with different owner": { + positionIdsToFungify: []uint64{DefaultPositionId, DefaultPositionId + 1}, + shouldSetupUnownedPosition: true, + numPositionsToCreate: 1, + expectedError: types.NotPositionOwnerError{}, + }, + "error: not fully charged": { + positionIdsToFungify: []uint64{DefaultPositionId, DefaultPositionId + 1}, + numPositionsToCreate: 2, + shouldSetupUncharged: true, + expectedError: types.PositionNotFullyChargedError{}, + }, + } + + for name, tc := range testcases { + suite.Run(name, func() { + suite.SetupTest() + + msgServer := cl.NewMsgServerImpl(suite.App.ConcentratedLiquidityKeeper) + + // Create a cl pool with a default position + pool := suite.PrepareConcentratedPool() + for i := 0; i < tc.numPositionsToCreate; i++ { + suite.SetupDefaultPosition(pool.GetId()) + } + + if tc.shouldSetupUnownedPosition { + // Position from another account. + suite.SetupDefaultPositionAcc(pool.GetId(), suite.TestAccs[1]) + } + + fullChargeDuration := suite.App.ConcentratedLiquidityKeeper.GetLargestAuthorizedUptimeDuration(suite.Ctx) + suite.Ctx = suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(fullChargeDuration)) + + if tc.shouldSetupUncharged { + suite.Ctx = suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(-time.Millisecond)) + } + + // Reset event counts to 0 by creating a new manager. + suite.Ctx = suite.Ctx.WithEventManager(sdk.NewEventManager()) + suite.Equal(0, len(suite.Ctx.EventManager().Events())) + + msg := &types.MsgFungifyChargedPositions{ + Sender: suite.TestAccs[0].String(), + PositionIds: tc.positionIdsToFungify, + } + + response, err := msgServer.FungifyChargedPositions(sdk.WrapSDKContext(suite.Ctx), msg) + + if tc.expectedError == nil { + suite.Require().NoError(err) + suite.Require().NotNil(response) + suite.AssertEventEmitted(suite.Ctx, types.TypeEvtFungifyChargedPosition, tc.expectedFungifyEvents) + suite.AssertEventEmitted(suite.Ctx, sdk.EventTypeMessage, tc.expectedMessageEvents) + } else { + suite.Require().Error(err) + suite.Require().ErrorAs(err, &tc.expectedError) + suite.Require().Nil(response) + } + }) + } +} diff --git a/x/concentrated-liquidity/position.go b/x/concentrated-liquidity/position.go index 313a60f8db8..81b471c440f 100644 --- a/x/concentrated-liquidity/position.go +++ b/x/concentrated-liquidity/position.go @@ -2,6 +2,9 @@ package concentrated_liquidity import ( "errors" + "fmt" + "strconv" + "strings" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,7 +16,7 @@ import ( lockuptypes "github.com/osmosis-labs/osmosis/v15/x/lockup/types" ) -const MinNumPositionsToCombine = 2 +const MinNumPositions = 2 var emptyOptions = &accum.Options{} @@ -60,7 +63,7 @@ func (k Keeper) initOrUpdatePosition( return types.NegativeLiquidityError{Liquidity: liquidity} } - err = k.initOrUpdatePositionUptime(ctx, poolId, liquidity, owner, lowerTick, upperTick, liquidityDelta, joinTime, positionId) + err = k.initOrUpdatePositionUptimeAccumulators(ctx, poolId, liquidity, owner, lowerTick, upperTick, liquidityDelta, positionId) if err != nil { return err } @@ -229,6 +232,15 @@ func (k Keeper) SetPosition(ctx sdk.Context, return nil } +// deletePosition deletes the position information for a given position id, user, and pool. +// Besides deleting the position, it also deletes the following mappings: +// - owner-pool-id-position-id to position id +// - pool-id-position-id to position id +// - position-id to underlying lock id if such mapping exists +// Returns error if: +// - the position with the given id does not exist. +// - the owner-pool-id-position-id to position id mapping does not exist. +// - the pool-id-position-id to position id mapping does not exist. func (k Keeper) deletePosition(ctx sdk.Context, positionId uint64, owner sdk.AccAddress, @@ -421,13 +433,23 @@ func (k Keeper) getNextPositionIdAndIncrement(ctx sdk.Context) uint64 { } // fungifyChargedPosition takes in a list of positionIds and combines them into a single position. +// It validates that all positions belong to the same owner, are in the same ticks, in the same pool and fully charged. Fails if not. +// Otherwise, it creates a completely new position P. P's liquidity equals to the sum of all +// liquidities of positions given by positionIds. The uptime of the join time of the new position equals +// to current block time - max authorized uptime duration (to signify that it is fully charged). +// The previous positions are deleted from state. Prior to deleting, the rewards are claimed. // The old position's unclaimed rewards are transferred to the new position. -// The previous positions are deleted from state and the new position ID is returned. -// An error is returned if the caller does not own all the positions, if the positions are all not fully charged, or if the positions are not all in the same pool / tick range. +// The new position ID is returned. +// An error is returned if: +// - the caller does not own all the positions +// - positions are not in the same pool +// - positions are all not fully charged +// - positions are not in the same tick range +// - all positions are unlocked func (k Keeper) fungifyChargedPosition(ctx sdk.Context, owner sdk.AccAddress, positionIds []uint64) (uint64, error) { // Check we meet the minimum number of positions to combine. - if len(positionIds) <= MinNumPositionsToCombine { - return 0, types.PositionQuantityTooLowError{MinNumPositions: MinNumPositionsToCombine, NumPositions: len(positionIds)} + if len(positionIds) < MinNumPositions { + return 0, types.PositionQuantityTooLowError{MinNumPositions: MinNumPositions, NumPositions: len(positionIds)} } // Check that all the positions are in the same pool, tick range, and are fully charged. @@ -437,6 +459,7 @@ func (k Keeper) fungifyChargedPosition(ctx sdk.Context, owner sdk.AccAddress, po return 0, err } + // Get the fully charged duration for the pool. fullyChargedDuration := k.getLargestAuthorizedUptimeDuration(ctx) // The new position's timestamp is the current block time minus the fully charged duration. @@ -445,54 +468,34 @@ func (k Keeper) fungifyChargedPosition(ctx sdk.Context, owner sdk.AccAddress, po // Get the next position ID and increment the global counter. newPositionId := k.getNextPositionIdAndIncrement(ctx) - // Initialize the fee accumulator for the new position. - if err := k.initOrUpdateFeeAccumulatorPosition(ctx, poolId, lowerTick, upperTick, newPositionId, liquidity); err != nil { - return 0, err - } - - // Check if the position already exists. - hasFullPosition := k.hasPosition(ctx, newPositionId) - if !hasFullPosition { - // If the position does not exist, initialize it with the provided liquidity and tick range. - err = k.initOrUpdatePositionUptime(ctx, poolId, liquidity, owner, lowerTick, upperTick, sdk.ZeroDec(), joinTime, newPositionId) - if err != nil { - return 0, err - } - } else { - // If the position already exists, return an error. + // Update pool uptime acccumulators to now + if err := k.updatePoolUptimeAccumulatorsToNow(ctx, poolId); err != nil { return 0, err } // Update the position in the pool based on the provided tick range and liquidity delta. + // This also initializes the fee accumulator and the uptime accumulators for the new position. _, _, err = k.UpdatePosition(ctx, poolId, owner, lowerTick, upperTick, liquidity, joinTime, newPositionId) if err != nil { return 0, err } - // Get the new position - newPosition, err := k.GetPosition(ctx, newPositionId) - if err != nil { - return 0, err - } - - // Get the new position's store name as well as uptime accumulators for the pool. + // Get the new position's name in the pool's uptime accumulators. newPositionUptimeAccName := string(types.KeyPositionId(newPositionId)) - uptimeAccumulators, err := k.GetUptimeAccumulators(ctx, newPosition.PoolId) + uptimeAccumulators, err := k.GetUptimeAccumulators(ctx, poolId) if err != nil { return 0, err } + // Get the new position's name in the pool's fee accumulator. newPositionFeeAccName := types.KeyFeePositionAccumulator(newPositionId) feeAccumulator, err := k.GetFeeAccumulator(ctx, poolId) if err != nil { return 0, err } - // Move unclaimed rewards from the old positions to the new position. - // Also, delete the old positions from state. - // Compute uptime growth outside of the range between lower tick and upper tick - uptimeGrowthOutside, err := k.GetUptimeGrowthOutsideRange(ctx, newPosition.PoolId, newPosition.LowerTick, newPosition.UpperTick) + uptimeGrowthOutside, err := k.GetUptimeGrowthOutsideRange(ctx, poolId, lowerTick, upperTick) if err != nil { return 0, err } @@ -516,11 +519,12 @@ func (k Keeper) fungifyChargedPosition(ctx sdk.Context, owner sdk.AccAddress, po if err != nil { return 0, err } + if !hasPosition { + return 0, types.PositionIdNotFoundError{PositionId: oldPositionId} + } // If the accumulator contains the position, move the unclaimed rewards to the new position. - if hasPosition { - if err := moveRewardsToNewPositionAndDeleteOldAcc(ctx, uptimeAccum, oldPositionName, newPositionUptimeAccName, uptimeGrowthOutside[uptimeIndex]); err != nil { - return 0, err - } + if err := moveRewardsToNewPositionAndDeleteOldAcc(ctx, uptimeAccum, oldPositionName, newPositionUptimeAccName, uptimeGrowthOutside[uptimeIndex]); err != nil { + return 0, err } } @@ -537,14 +541,41 @@ func (k Keeper) fungifyChargedPosition(ctx sdk.Context, owner sdk.AccAddress, po } } + // query claimable incentives for events. + claimableIncentives, _, err := k.GetClaimableIncentives(ctx, newPositionId) + if err != nil { + return 0, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeEvtFungifyChargedPosition, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, owner.String()), + sdk.NewAttribute(types.AttributeInputPositionIds, strings.Trim(strings.Join(strings.Fields(fmt.Sprint(positionIds)), ","), "[]")), + sdk.NewAttribute(types.AttributeOutputPositionId, strconv.FormatUint(newPositionId, 10)), + sdk.NewAttribute(types.AttributeClaimableIncentives, claimableIncentives.String()), + ), + }) + return newPositionId, nil } // validatePositionsAndGetTotalLiquidity validates a list of positions owned by the caller and returns their total liquidity. // It also returns the pool ID, lower tick, and upper tick that all the provided positions are confirmed to share. +// Returns error if: +// - the caller does not own all the positions +// - positions are not in the same pool +// - positions are all not fully charged +// - positions are not in the same tick range +// - all positions are unlocked func (k Keeper) validatePositionsAndGetTotalLiquidity(ctx sdk.Context, owner sdk.AccAddress, positionIds []uint64) (uint64, int64, int64, sdk.Dec, error) { totalLiquidity := sdk.ZeroDec() + if len(positionIds) < 1 { + return 0, 0, 0, sdk.Dec{}, types.PositionQuantityTooLowError{MinNumPositions: MinNumPositions, NumPositions: 1} + } + // Note the first position's params to use as the base for comparison. basePosition, err := k.GetPosition(ctx, positionIds[0]) if err != nil { @@ -553,7 +584,7 @@ func (k Keeper) validatePositionsAndGetTotalLiquidity(ctx sdk.Context, owner sdk fullyChargedDuration := k.getLargestAuthorizedUptimeDuration(ctx) - for i, positionId := range positionIds { + for _, positionId := range positionIds { position, err := k.GetPosition(ctx, positionId) if err != nil { return 0, 0, 0, sdk.Dec{}, err @@ -582,13 +613,11 @@ func (k Keeper) validatePositionsAndGetTotalLiquidity(ctx sdk.Context, owner sdk } // Check that all the positions are in the same pool and tick range. - if i > 0 { - if position.PoolId != basePosition.PoolId { - return 0, 0, 0, sdk.Dec{}, types.PositionsNotInSamePoolError{Position1PoolId: position.PoolId, Position2PoolId: basePosition.PoolId} - } - if position.LowerTick != basePosition.LowerTick || position.UpperTick != basePosition.UpperTick { - return 0, 0, 0, sdk.Dec{}, types.PositionsNotInSameTickRangeError{Position1TickLower: position.LowerTick, Position1TickUpper: position.UpperTick, Position2TickLower: basePosition.LowerTick, Position2TickUpper: basePosition.UpperTick} - } + if position.PoolId != basePosition.PoolId { + return 0, 0, 0, sdk.Dec{}, types.PositionsNotInSamePoolError{Position1PoolId: position.PoolId, Position2PoolId: basePosition.PoolId} + } + if position.LowerTick != basePosition.LowerTick || position.UpperTick != basePosition.UpperTick { + return 0, 0, 0, sdk.Dec{}, types.PositionsNotInSameTickRangeError{Position1TickLower: position.LowerTick, Position1TickUpper: position.UpperTick, Position2TickLower: basePosition.LowerTick, Position2TickUpper: basePosition.UpperTick} } // Add the liquidity of the position to the total liquidity. diff --git a/x/concentrated-liquidity/position_test.go b/x/concentrated-liquidity/position_test.go index dd566aa6248..a96238c904c 100644 --- a/x/concentrated-liquidity/position_test.go +++ b/x/concentrated-liquidity/position_test.go @@ -680,6 +680,11 @@ func (s *KeeperTestSuite) TestCalculateUnderlyingAssetsFromPosition() { } func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { + const ( + locked = true + unlocked = !locked + ) + var ( defaultAddress = s.TestAccs[0] secondAddress = s.TestAccs[1] @@ -694,23 +699,27 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { coins sdk.Coins lowerTick int64 upperTick int64 + isLocked bool } tests := []struct { name string setupFullyChargedPositions []position setupUnchargedPositions []position + lockPositionIds []uint64 positionIdsToMigrate []uint64 accountCallingMigration sdk.AccAddress + unlockBeforeBlockTimeMs time.Duration expectedNewPositionId uint64 expectedErr error + doesValidatePass bool }{ { name: "Happy path: Fungify three fully charged positions", setupFullyChargedPositions: []position{ - {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, - {2, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, - {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, + {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + {2, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, }, positionIdsToMigrate: []uint64{1, 2, 3}, accountCallingMigration: defaultAddress, @@ -719,11 +728,11 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { { name: "Error: Fungify three positions, but one of them is not fully charged", setupFullyChargedPositions: []position{ - {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, - {2, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, + {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + {2, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, }, setupUnchargedPositions: []position{ - {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, + {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, }, positionIdsToMigrate: []uint64{1, 2, 3}, accountCallingMigration: defaultAddress, @@ -733,9 +742,9 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { { name: "Error: Fungify three positions, but one of them is not in the same pool", setupFullyChargedPositions: []position{ - {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, - {2, 2, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, - {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, + {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + {2, 2, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, }, positionIdsToMigrate: []uint64{1, 2, 3}, accountCallingMigration: defaultAddress, @@ -745,9 +754,9 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { { name: "Error: Fungify three positions, but one of them is not owned by the same owner", setupFullyChargedPositions: []position{ - {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, - {2, defaultPoolId, secondAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, - {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, + {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + {2, defaultPoolId, secondAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, }, positionIdsToMigrate: []uint64{1, 2, 3}, accountCallingMigration: defaultAddress, @@ -757,15 +766,56 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { { name: "Error: Fungify three positions, but one of them is not in the same range", setupFullyChargedPositions: []position{ - {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, - {2, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick - 100, DefaultUpperTick}, - {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick}, + {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + {2, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick - 100, DefaultUpperTick, unlocked}, + {3, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, }, positionIdsToMigrate: []uint64{1, 2, 3}, accountCallingMigration: defaultAddress, expectedNewPositionId: 0, expectedErr: types.PositionsNotInSameTickRangeError{Position1TickLower: DefaultLowerTick - 100, Position1TickUpper: DefaultUpperTick, Position2TickLower: DefaultLowerTick, Position2TickUpper: DefaultUpperTick}, }, + { + name: "Error: Fungify one position, must have at least two", + setupFullyChargedPositions: []position{ + {1, defaultPoolId, defaultAddress, DefaultCoins, DefaultLowerTick, DefaultUpperTick, unlocked}, + }, + setupUnchargedPositions: []position{}, + positionIdsToMigrate: []uint64{1}, + accountCallingMigration: defaultAddress, + expectedNewPositionId: 0, + expectedErr: types.PositionQuantityTooLowError{MinNumPositions: cl.MinNumPositions, NumPositions: 1}, + doesValidatePass: true, + }, + { + name: "Error: one of the full range positions is locked", + setupFullyChargedPositions: []position{ + {1, defaultPoolId, defaultAddress, DefaultCoins, types.MinTick, types.MaxTick, unlocked}, + {2, defaultPoolId, defaultAddress, DefaultCoins, types.MinTick, types.MaxTick, locked}, + {3, defaultPoolId, defaultAddress, DefaultCoins, types.MinTick, types.MaxTick, unlocked}, + }, + lockPositionIds: []uint64{2}, + positionIdsToMigrate: []uint64{1, 2, 3}, + accountCallingMigration: defaultAddress, + expectedNewPositionId: 0, + expectedErr: types.LockNotMatureError{PositionId: 2, LockId: 1}, + }, + { + name: "Pass: one of the full range positions was locked but got unlocked 1ms before fungification", + setupFullyChargedPositions: []position{ + {1, defaultPoolId, defaultAddress, DefaultCoins, types.MinTick, types.MaxTick, unlocked}, + {2, defaultPoolId, defaultAddress, DefaultCoins, types.MinTick, types.MaxTick, locked}, + {3, defaultPoolId, defaultAddress, DefaultCoins, types.MinTick, types.MaxTick, unlocked}, + }, + + lockPositionIds: []uint64{2}, + positionIdsToMigrate: []uint64{1, 2, 3}, + accountCallingMigration: defaultAddress, + // Subtracting one millisecond from the block time (when it's supposed to be unlocked + // by default, makes the lock mature) + unlockBeforeBlockTimeMs: time.Millisecond * -1, + expectedNewPositionId: 4, + }, } for _, test := range tests { @@ -794,9 +844,24 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { // Set up fully charged positions totalLiquidity := sdk.ZeroDec() + + // See increases in the test below. + // The reason we double testFullChargeDurationis is because that is by how much we increase block time in total + // to set up the fully charged positions. + lockDuration := testFullChargeDuration + testFullChargeDuration + test.unlockBeforeBlockTimeMs for _, pos := range test.setupFullyChargedPositions { - _, _, _, liquidityCreated, _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, pos.poolId, pos.acc, pos.coins, sdk.ZeroInt(), sdk.ZeroInt(), pos.lowerTick, pos.upperTick) - s.Require().NoError(err) + var ( + liquidityCreated sdk.Dec + err error + ) + if pos.isLocked { + _, _, _, liquidityCreated, _, _, err = s.App.ConcentratedLiquidityKeeper.CreateFullRangePositionUnlocking(s.Ctx, pos.poolId, pos.acc, pos.coins, lockDuration) + s.Require().NoError(err) + } else { + _, _, _, liquidityCreated, _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, pos.poolId, pos.acc, pos.coins, sdk.ZeroInt(), sdk.ZeroInt(), pos.lowerTick, pos.upperTick) + s.Require().NoError(err) + } + totalLiquidity = totalLiquidity.Add(liquidityCreated) } @@ -814,7 +879,7 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { // First run non mutative validation and check results poolId, lowerTick, upperTick, liquidity, err := s.App.ConcentratedLiquidityKeeper.ValidatePositionsAndGetTotalLiquidity(s.Ctx, test.accountCallingMigration, test.positionIdsToMigrate) - if test.expectedErr != nil { + if test.expectedErr != nil && !test.doesValidatePass { s.Require().Error(err) s.Require().ErrorIs(err, test.expectedErr) s.Require().Equal(uint64(0), poolId) @@ -931,6 +996,7 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { // Check that the old position has been deleted. _, err := s.App.ConcentratedLiquidityKeeper.GetPosition(s.Ctx, positionId) s.Require().Error(err) + s.Require().ErrorAs(err, &types.PositionIdNotFoundError{}) } // The new position's unclaimed rewards should be the sum of the old positions' unclaimed rewards. @@ -1232,12 +1298,16 @@ func (s *KeeperTestSuite) TestFungifyChargedPositions_ClaimIncentives() { s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(testFullChargeDuration)) // sync accumulators - err = s.App.ConcentratedLiquidityKeeper.UpdateUptimeAccumulatorsToNow(s.Ctx, pool.GetId()) + // We use cache context to update uptime accumulators for estimating claimable incentives + // prior to running fungify. However, we do not want the mutations made in test setup to have + // impact on the system under test because it (fungify) must update the uptime accumulators itself. + cacheCtx, _ := s.Ctx.CacheContext() + err = s.App.ConcentratedLiquidityKeeper.UpdateUptimeAccumulatorsToNow(cacheCtx, pool.GetId()) s.Require().NoError(err) claimableIncentives := sdk.NewCoins() for i := 0; i < numPositions; i++ { - positionIncentices, forfeitedIncentives, err := s.App.ConcentratedLiquidityKeeper.GetClaimableIncentives(s.Ctx, uint64(i+1)) + positionIncentices, forfeitedIncentives, err := s.App.ConcentratedLiquidityKeeper.GetClaimableIncentives(cacheCtx, uint64(i+1)) s.Require().NoError(err) s.Require().Equal(sdk.Coins(nil), forfeitedIncentives) claimableIncentives = claimableIncentives.Add(positionIncentices...) @@ -1279,7 +1349,6 @@ func (s *KeeperTestSuite) TestCreateFullRangePosition() { concentratedLockId uint64 err error ) - defaultPositionCoins := sdk.NewCoins(DefaultCoin0, DefaultCoin1) invalidCoinsAmount := sdk.NewCoins(DefaultCoin0) invalidCoin0Denom := sdk.NewCoins(sdk.NewCoin("invalidDenom", sdk.NewInt(1000000000000000000)), DefaultCoin1) invalidCoin1Denom := sdk.NewCoins(DefaultCoin0, sdk.NewCoin("invalidDenom", sdk.NewInt(1000000000000000000))) @@ -1294,18 +1363,18 @@ func (s *KeeperTestSuite) TestCreateFullRangePosition() { }{ { name: "full range position", - coinsForPosition: defaultPositionCoins, + coinsForPosition: DefaultCoins, }, { name: "full range position: locked", remainingLockDuration: 24 * time.Hour * 14, - coinsForPosition: defaultPositionCoins, + coinsForPosition: DefaultCoins, isLocked: true, }, { name: "full range position: unlocking", remainingLockDuration: 24 * time.Hour, - coinsForPosition: defaultPositionCoins, + coinsForPosition: DefaultCoins, isUnlocking: true, }, { diff --git a/x/concentrated-liquidity/tick.go b/x/concentrated-liquidity/tick.go index a3ada7834e4..05d9f491e79 100644 --- a/x/concentrated-liquidity/tick.go +++ b/x/concentrated-liquidity/tick.go @@ -85,7 +85,7 @@ func (k Keeper) crossTick(ctx sdk.Context, poolId uint64, tickIndex int64, swapS tickInfo.FeeGrowthOutside = feeAccum.GetValue().Add(swapStateFeeGrowth).Sub(tickInfo.FeeGrowthOutside) // Update global accums to now before uptime outside changes - if err := k.updateUptimeAccumulatorsToNow(ctx, poolId); err != nil { + if err := k.updatePoolUptimeAccumulatorsToNow(ctx, poolId); err != nil { return sdk.Dec{}, err } @@ -128,7 +128,7 @@ func (k Keeper) GetTickInfo(ctx sdk.Context, poolId uint64, tickIndex int64) (ti } // Sync global uptime accumulators to ensure the uptime tracker init values are up to date. - if err := k.updateUptimeAccumulatorsToNow(ctx, poolId); err != nil { + if err := k.updatePoolUptimeAccumulatorsToNow(ctx, poolId); err != nil { return tickStruct, err } diff --git a/x/concentrated-liquidity/types/events.go b/x/concentrated-liquidity/types/events.go index e13ea784433..091a8189c6f 100644 --- a/x/concentrated-liquidity/types/events.go +++ b/x/concentrated-liquidity/types/events.go @@ -10,6 +10,7 @@ const ( TypeEvtCollectIncentives = "collect_incentives" TypeEvtCreateIncentive = "create_incentive" TypeEvtFungifyChargedPosition = "fungify_charged_position" + TypeEvtMoveRewards = "move_rewards" AttributeValueCategory = ModuleName AttributeKeyPositionId = "position_id" @@ -33,4 +34,11 @@ const ( AttributeIncentiveMinUptime = "incentive_min_uptime" AttributeInputPositionIds = "input_position_ids" AttributeOutputPositionId = "output_position_id" + AttributePoolAccumName = "pool_accum_name" + AttributeOldPositionAccumName = "old_position_accum_name" + AttributeNewPositionAccumName = "new_position_accum_name" + AttributeGlobalGrowth = "global_growth" + AttributeInsideGrowth = "inside_growth" + AttributeMovedRewards = "moved_rewards" + AttributeClaimableIncentives = "claimable_incentives" ) diff --git a/x/concentrated-liquidity/types/msgs_test.go b/x/concentrated-liquidity/types/msgs_test.go index 9131ea4f584..a1aa02c26dd 100644 --- a/x/concentrated-liquidity/types/msgs_test.go +++ b/x/concentrated-liquidity/types/msgs_test.go @@ -137,7 +137,63 @@ func TestMsgCreatePosition(t *testing.T) { if test.expectPass { require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) require.Equal(t, msg.Route(), types.RouterKey) - require.Equal(t, msg.Type(), "create-position") + require.Equal(t, msg.Type(), types.TypeMsgCreatePosition) + signers := msg.GetSigners() + require.Equal(t, len(signers), 1) + require.Equal(t, signers[0].String(), addr1) + } else { + require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) + } + } +} + +func TestMsgFungifyChargedPositions(t *testing.T) { + appParams.SetAddressPrefixes() + var ( + pk1 = ed25519.GenPrivKey().PubKey() + addr1 = sdk.AccAddress(pk1.Address()).String() + invalidAddr = sdk.AccAddress("invalid") + validPositionIds = []uint64{1, 2} + ) + + tests := []struct { + name string + msg types.MsgFungifyChargedPositions + expectPass bool + }{ + { + name: "proper msg", + msg: types.MsgFungifyChargedPositions{ + Sender: addr1, + PositionIds: validPositionIds, + }, + expectPass: true, + }, + { + name: "error: invalid sender", + msg: types.MsgFungifyChargedPositions{ + Sender: invalidAddr.String(), + PositionIds: validPositionIds, + }, + expectPass: false, + }, + { + name: "error: only one id given, must have at least 2", + msg: types.MsgFungifyChargedPositions{ + Sender: addr1, + PositionIds: []uint64{1}, + }, + expectPass: false, + }, + } + + for _, test := range tests { + msg := test.msg + + if test.expectPass { + require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) + require.Equal(t, msg.Route(), types.RouterKey) + require.Equal(t, msg.Type(), types.TypeMsgFungifyChargedPositions) signers := msg.GetSigners() require.Equal(t, len(signers), 1) require.Equal(t, signers[0].String(), addr1) @@ -184,7 +240,7 @@ func TestMsgWithdrawPosition(t *testing.T) { if test.expectPass { require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) require.Equal(t, msg.Route(), types.RouterKey) - require.Equal(t, msg.Type(), "withdraw-position") + require.Equal(t, msg.Type(), types.TypeMsgWithdrawPosition) signers := msg.GetSigners() require.Equal(t, len(signers), 1) require.Equal(t, signers[0].String(), addr1) @@ -232,6 +288,13 @@ func TestConcentratedLiquiditySerialization(t *testing.T) { TokenMinAmount1: sdk.OneInt(), }, }, + { + name: "MsgFungifyChargedPositions", + clMsg: &types.MsgFungifyChargedPositions{ + Sender: addr1, + PositionIds: []uint64{1, 2}, + }, + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { diff --git a/x/gamm/keeper/msg_server_test.go b/x/gamm/keeper/msg_server_test.go index 4681d4f3606..5d4fb40f9df 100644 --- a/x/gamm/keeper/msg_server_test.go +++ b/x/gamm/keeper/msg_server_test.go @@ -386,7 +386,7 @@ func (suite *KeeperTestSuite) TestMsgMigrateShares_Events() { }, sharesToCreate: defaultGammShares.Amount, expectedMigrateShareEvents: 1, - expectedMessageEvents: 4, // 2 exitPool(send coin, exit pool itself), 1 createPosition, 1 migrateShares. + expectedMessageEvents: 4, // 1 create pool, 1 exitPool, 1 createPosition, 1 migrateShares. }, { name: "migrate half of the shares", @@ -397,7 +397,7 @@ func (suite *KeeperTestSuite) TestMsgMigrateShares_Events() { }, sharesToCreate: defaultGammShares.Amount, expectedMigrateShareEvents: 1, - expectedMessageEvents: 4, // 2 exitPool(send coin, exit pool itself), 1 createPosition, 1 migrateShares. + expectedMessageEvents: 4, // 1 create pool, 1 exitPool, 1 createPosition, 1 migrateShares. }, { name: "double the created shares, migrate 1/4 of the shares", @@ -408,7 +408,7 @@ func (suite *KeeperTestSuite) TestMsgMigrateShares_Events() { }, sharesToCreate: defaultGammShares.Amount.Mul(sdk.NewInt(2)), expectedMigrateShareEvents: 1, - expectedMessageEvents: 4, // 2 exitPool(send coin, exit pool itself), 1 createPosition, 1 migrateShares. + expectedMessageEvents: 4, // 1 create pool, 1 exitPool, 1 createPosition, 1 migrateShares. }, { name: "error: attempt to migrate shares from non-existent pool", @@ -428,7 +428,7 @@ func (suite *KeeperTestSuite) TestMsgMigrateShares_Events() { sharesToMigrateAmount: defaultGammShares.Amount.Add(sdk.NewInt(1)), }, sharesToCreate: defaultGammShares.Amount, - expectedMessageEvents: 1, // 1 exitPool. + expectedMessageEvents: 1, // 1 create pool expectError: true, }, } diff --git a/x/poolmanager/client/cli/query.go b/x/poolmanager/client/cli/query.go index cc1087f4f37..1a49ed9f89c 100644 --- a/x/poolmanager/client/cli/query.go +++ b/x/poolmanager/client/cli/query.go @@ -27,6 +27,7 @@ func GetQueryCmd() *cobra.Command { osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdEstimateSinglePoolSwapExactAmountOut) osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdSpotPrice) osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdTotalPoolLiquidity) + osmocli.AddQueryCmd(cmd, queryproto.NewQueryClient, GetCmdAllPools) return cmd } @@ -68,6 +69,15 @@ func GetCmdNumPools() (*osmocli.QueryDescriptor, *queryproto.NumPoolsRequest) { }, &queryproto.NumPoolsRequest{} } +// GetCmdAllPools return all pools available across Osmosis modules. +func GetCmdAllPools() (*osmocli.QueryDescriptor, *queryproto.AllPoolsRequest) { + return &osmocli.QueryDescriptor{ + Use: "all-pools", + Short: "Query all pools on the Osmosis chain", + Long: "{{.Short}}", + }, &queryproto.AllPoolsRequest{} +} + // GetCmdPool returns pool information. func GetCmdPool() (*osmocli.QueryDescriptor, *queryproto.PoolRequest) { return &osmocli.QueryDescriptor{ diff --git a/x/poolmanager/client/queryproto/query.pb.go b/x/poolmanager/client/queryproto/query.pb.go index 4477b00356b..35dcd685410 100644 --- a/x/poolmanager/client/queryproto/query.pb.go +++ b/x/poolmanager/client/queryproto/query.pb.go @@ -613,7 +613,6 @@ func (m *PoolResponse) GetPool() *types1.Any { // =============================== AllPools type AllPoolsRequest struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` } func (m *AllPoolsRequest) Reset() { *m = AllPoolsRequest{} } @@ -649,13 +648,6 @@ func (m *AllPoolsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_AllPoolsRequest proto.InternalMessageInfo -func (m *AllPoolsRequest) GetPoolId() uint64 { - if m != nil { - return m.PoolId - } - return 0 -} - type AllPoolsResponse struct { Pools []*types1.Any `protobuf:"bytes,1,rep,name=pools,proto3" json:"pools,omitempty"` } @@ -924,91 +916,91 @@ func init() { } var fileDescriptor_6256a4106f701b7d = []byte{ - // 1338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0xcd, 0x6f, 0x1b, 0x45, - 0x1c, 0xcd, 0x26, 0x6e, 0x1a, 0x4f, 0x9b, 0xd8, 0x19, 0xda, 0x92, 0xb8, 0x95, 0x37, 0x4c, 0x4b, - 0x71, 0x9b, 0x66, 0x57, 0xe9, 0x07, 0x48, 0x95, 0x68, 0x15, 0xa7, 0xa1, 0x31, 0x2a, 0x34, 0x6c, - 0x41, 0x20, 0xa4, 0x62, 0x6d, 0x92, 0xc1, 0xac, 0xba, 0x3b, 0xb3, 0xf1, 0xcc, 0xb6, 0x8d, 0x50, - 0x2f, 0x9c, 0x38, 0xa1, 0x22, 0x24, 0x40, 0xe2, 0xc0, 0x9d, 0x33, 0x7f, 0x44, 0x85, 0x54, 0x14, - 0x89, 0x0b, 0xe2, 0x60, 0x50, 0xcb, 0x81, 0x43, 0x2f, 0xf8, 0x2f, 0x40, 0xf3, 0xb1, 0x6b, 0xc7, - 0x4d, 0xd6, 0x6b, 0x97, 0x53, 0xec, 0x99, 0xdf, 0xc7, 0x7b, 0x6f, 0x9e, 0x67, 0x7e, 0x0a, 0x78, - 0x8d, 0xb2, 0x80, 0x32, 0x8f, 0xd9, 0x21, 0xa5, 0x7e, 0xe0, 0x12, 0xb7, 0x81, 0x9b, 0xf6, 0xdd, - 0xc5, 0x75, 0xcc, 0xdd, 0x45, 0x7b, 0x2b, 0xc2, 0xcd, 0x6d, 0x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 0x69, 0x60, 0x8b, 0x20, 0x4f, 0xa2, 0xa0, 0x2e, 0x14, 0x64, 0x5a, 0xe2, 0x2e, 0xca, 0xc9, 0x16, - 0x72, 0x26, 0x88, 0x4e, 0x45, 0x97, 0xc1, 0x21, 0xf1, 0x61, 0x98, 0x23, 0x42, 0xcb, 0xe0, 0xb0, - 0xca, 0xd5, 0xed, 0x2f, 0x80, 0x9c, 0xd8, 0xd1, 0xd7, 0xf3, 0x11, 0x4b, 0xdd, 0xf9, 0x56, 0x7c, - 0xe7, 0x5b, 0x4b, 0x64, 0xbb, 0x9a, 0xff, 0xe5, 0xe7, 0x85, 0x03, 0x22, 0xab, 0xe6, 0xc8, 0x60, - 0x74, 0x05, 0x14, 0x96, 0x7c, 0xbf, 0x9b, 0xda, 0x60, 0x20, 0x6a, 0xa0, 0xd8, 0xc9, 0xd7, 0x40, - 0x2e, 0x81, 0x03, 0xb1, 0x06, 0x63, 0x59, 0x90, 0xa8, 0x68, 0xb4, 0x63, 0x80, 0xe2, 0xad, 0x90, - 0xf2, 0xb5, 0xa6, 0xb7, 0x81, 0x87, 0x32, 0xed, 0x0a, 0x28, 0x8a, 0x17, 0xb6, 0xee, 0x32, 0x86, - 0xf9, 0x2e, 0xdb, 0x1e, 0xef, 0x5c, 0x26, 0xbd, 0x11, 0xc8, 0x99, 0x12, 0x4b, 0x4b, 0x62, 0x45, - 0x59, 0x77, 0x15, 0x4c, 0x6f, 0x45, 0x94, 0xef, 0xae, 0xa3, 0x2c, 0x7c, 0xa2, 0xdd, 0x32, 0x67, - 0x54, 0x9d, 0xe7, 0x42, 0x90, 0x53, 0x90, 0x6b, 0x9d, 0x4a, 0xa8, 0x06, 0xa6, 0xbb, 0x18, 0x69, - 0x79, 0x2e, 0x02, 0xc0, 0x42, 0xca, 0xeb, 0xa1, 0x58, 0xd5, 0xd6, 0x3d, 0xda, 0x6e, 0x99, 0xd3, - 0xaa, 0x6e, 0x67, 0x0f, 0x39, 0x79, 0x16, 0x67, 0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0x7c, 0x3d, 0xb5, 0xf7, 0xbe, 0x63, 0x41, 0xe9, 0x8d, 0x81, 0xf3, 0x34, 0xf8, - 0x9a, 0x04, 0xbf, 0x0c, 0x97, 0x06, 0x39, 0x79, 0x9b, 0x8b, 0x82, 0xea, 0x87, 0x94, 0xbc, 0xe7, - 0xd5, 0xdb, 0x8f, 0x9e, 0x94, 0x8d, 0x9d, 0x27, 0x65, 0xe3, 0xaf, 0x27, 0x65, 0xe3, 0xe1, 0xd3, - 0xf2, 0xc8, 0xce, 0xd3, 0xf2, 0xc8, 0xef, 0x4f, 0xcb, 0x23, 0x1f, 0x2f, 0x77, 0x8d, 0x07, 0xba, - 0xcd, 0x82, 0xef, 0xae, 0xb3, 0xa4, 0xe7, 0xdd, 0xc5, 0x4b, 0xf6, 0xfd, 0x5d, 0x9d, 0x37, 0x7c, - 0x0f, 0x13, 0xae, 0xfe, 0x83, 0xa2, 0xa6, 0xc9, 0x71, 0xf9, 0xe7, 0xc2, 0x7f, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x31, 0x52, 0xaa, 0x15, 0x5d, 0x12, 0x00, 0x00, + // 1335 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0xcd, 0x6f, 0x1b, 0xc5, + 0x1b, 0xce, 0x26, 0x6e, 0x1a, 0x4f, 0x9b, 0xc4, 0x99, 0x5f, 0xdb, 0x5f, 0xb2, 0xad, 0xbc, 0x61, + 0x5a, 0x8a, 0xdb, 0x34, 0xbb, 0x4a, 0x3f, 0x40, 0xaa, 0x04, 0x55, 0x9c, 0x86, 0xc6, 0xa8, 0xd0, + 0xb0, 0x05, 0x81, 0x90, 0x8a, 0xb5, 0x49, 0x06, 0xb3, 0xea, 0xee, 0xcc, 0xc6, 0x33, 0xdb, 0x36, + 0x42, 0xbd, 0x70, 0xe2, 0x84, 0x8a, 0x90, 0x00, 0x89, 0x03, 0x77, 0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9, 0x6c, 0xa6, 0xdd, 0xb2, 0x8e, 0x77, 0xab, 0x2c, 0x51, 0xcb, 0x51, 0xad, 0x35, 0x29, 0x96, + 0x6e, 0x7a, 0x23, 0x79, 0xe8, 0xa1, 0x6f, 0x0c, 0x80, 0xb2, 0x36, 0x51, 0x0b, 0x2c, 0x4a, 0xa4, + 0xec, 0x93, 0x6e, 0x7d, 0xad, 0xec, 0x5b, 0x5f, 0x27, 0x7a, 0x98, 0x24, 0xf2, 0x1a, 0xd7, 0x54, + 0xb4, 0xba, 0xa6, 0xc0, 0xe4, 0x3b, 0x71, 0x28, 0xba, 0x9b, 0x9e, 0x8f, 0xcb, 0xa0, 0xd4, 0x59, + 0xd2, 0x85, 0x2d, 0x80, 0x22, 0x89, 0xc3, 0xba, 0xe8, 0x20, 0xd3, 0x2d, 0xde, 0x41, 0x39, 0x35, + 0x21, 0x77, 0x8c, 0x68, 0x57, 0x74, 0x15, 0x1c, 0x11, 0x0f, 0x83, 0x6c, 0x11, 0x5a, 0x02, 0x47, + 0x95, 0xaf, 0x4e, 0x7f, 0x09, 0x14, 0x84, 0x45, 0x1f, 0xcf, 0xc7, 0x6c, 0x75, 0xe6, 0xdb, 0xc9, + 0x99, 0x6f, 0x2f, 0x92, 0xad, 0x6a, 0xf1, 0xe7, 0x9f, 0xe6, 0x0f, 0x09, 0xaf, 0x9a, 0x2b, 0xc1, + 0x82, 0xda, 0x62, 0x10, 0x74, 0x51, 0xab, 0x81, 0x52, 0x67, 0x49, 0xc7, 0xbe, 0x02, 0x0e, 0x25, + 0xb4, 0x46, 0xf2, 0x04, 0x57, 0x68, 0xb4, 0x6d, 0x80, 0xd2, 0xed, 0x88, 0xf2, 0xd5, 0xa6, 0xbf, + 0x8e, 0x07, 0xd2, 0xe1, 0x32, 0x28, 0x89, 0x4b, 0xb3, 0xee, 0x31, 0x86, 0x79, 0x97, 0x12, 0x4f, + 0x76, 0xce, 0x87, 0x5e, 0x04, 0x72, 0x27, 0xc4, 0xd2,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9, 0xad, 0x64, 0x24, 0xe8, 0xd3, 0xad, 0x9e, 0x61, 0xa2, 0x4f, 0xb7, + 0x7a, 0xe7, 0x8c, 0x9c, 0xdd, 0xf2, 0x82, 0x60, 0x5e, 0x75, 0xeb, 0x07, 0x03, 0x14, 0xd3, 0xeb, + 0x18, 0x66, 0x27, 0xeb, 0x1d, 0x44, 0x4c, 0x3b, 0x2f, 0x5c, 0x17, 0x77, 0x49, 0x16, 0x37, 0x0f, + 0xe7, 0x76, 0x2d, 0xae, 0xa7, 0x69, 0x8e, 0xbc, 0xef, 0x19, 0xdc, 0x36, 0x00, 0x7c, 0xf1, 0x6a, + 0x86, 0xaf, 0x66, 0xe6, 0xde, 0x73, 0x2c, 0x30, 0x5f, 0xdb, 0xb7, 0x9f, 0x2e, 0xbe, 0x26, 0x8b, + 0x5f, 0x82, 0x8b, 0xfb, 0xd9, 0x79, 0x87, 0x8b, 0x80, 0xea, 0x43, 0x4a, 0xef, 0xf3, 0xea, 0x9d, + 0xc7, 0x4f, 0xcb, 0xc6, 0xf6, 0xd3, 0xb2, 0xf1, 0xe7, 0xd3, 0xb2, 0xf1, 0xe8, 0x59, 0x79, 0x68, + 0xfb, 0x59, 0x79, 0xe8, 0xb7, 0x67, 0xe5, 0xa1, 0x8f, 0x96, 0x76, 0x8c, 0x07, 0x3a, 0xcd, 0x7c, + 0xe0, 0xad, 0xb1, 0x34, 0xe7, 0xbd, 0x85, 0x2b, 0xce, 0x83, 0xae, 0xcc, 0xeb, 0x81, 0x8f, 0x09, + 0x57, 0x7f, 0x8a, 0xa8, 0x69, 0x72, 0x54, 0xfe, 0x5c, 0xfa, 0x37, 0x00, 0x00, 0xff, 0xff, 0xcd, + 0x94, 0x7a, 0x82, 0x30, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1867,11 +1859,6 @@ func (m *AllPoolsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.PoolId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } @@ -2238,9 +2225,6 @@ func (m *AllPoolsRequest) Size() (n int) { } var l int _ = l - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) - } return n } @@ -3465,25 +3449,6 @@ func (m *AllPoolsRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: AllPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) - } - m.PoolId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/poolmanager/client/queryproto/query.pb.gw.go b/x/poolmanager/client/queryproto/query.pb.gw.go index 8bec1cf7060..981b243b087 100644 --- a/x/poolmanager/client/queryproto/query.pb.gw.go +++ b/x/poolmanager/client/queryproto/query.pb.gw.go @@ -411,21 +411,10 @@ func local_request_Query_Pool_0(ctx context.Context, marshaler runtime.Marshaler } -var ( - filter_Query_AllPools_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - func request_Query_AllPools_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq AllPoolsRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllPools_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.AllPools(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -435,13 +424,6 @@ func local_request_Query_AllPools_0(ctx context.Context, marshaler runtime.Marsh var protoReq AllPoolsRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AllPools_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.AllPools(ctx, &protoReq) return msg, metadata, err