Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Delete the governance proposal code for creating a CL pool #9026

Merged
merged 9 commits into from
Mar 10, 2025
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ func NewOsmosisApp(
gammclient.UpdateMigrationRecordsProposalHandler,
gammclient.CreateCLPoolAndLinkToCFMMProposalHandler,
gammclient.SetScalingFactorControllerProposalHandler,
clclient.CreateConcentratedLiquidityPoolProposalHandler,
clclient.TickSpacingDecreaseProposalHandler,
cwpoolclient.UploadCodeIdAndWhitelistProposalHandler,
cwpoolclient.MigratePoolContractsProposalHandler,
Expand Down
1 change: 0 additions & 1 deletion app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ var AppModuleBasics = module.NewBasicManager(
gammclient.UpdateMigrationRecordsProposalHandler,
gammclient.CreateCLPoolAndLinkToCFMMProposalHandler,
gammclient.SetScalingFactorControllerProposalHandler,
clclient.CreateConcentratedLiquidityPoolProposalHandler,
clclient.TickSpacingDecreaseProposalHandler,
cwpoolclient.UploadCodeIdAndWhitelistProposalHandler,
cwpoolclient.MigratePoolContractsProposalHandler,
Expand Down
7 changes: 1 addition & 6 deletions proto/osmosis/concentratedliquidity/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ message PoolRecord {
string denom1 = 2 [ (gogoproto.moretags) = "yaml:\"denom1\"" ];
uint64 tick_spacing = 3 [ (gogoproto.moretags) = "yaml:\"tick_spacing\"" ];
// DEPRECATED
string exponent_at_price_one = 4 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"exponent_at_price_one\",deprecated:\"true\"",
(gogoproto.nullable) = false,
deprecated = true
];
reserved 4;
string spread_factor = 5 [

(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
Expand Down
16 changes: 0 additions & 16 deletions tests/e2e/configurer/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,3 @@ func (c *Config) getNodeAtIndex(nodeIndex int) (*NodeConfig, error) {
}
return c.NodeConfigs[nodeIndex], nil
}

func (c *Config) SubmitCreateConcentratedPoolProposal(chainANode *NodeConfig, isLegacy bool) (uint64, error) {
propNumber := chainANode.SubmitCreateConcentratedPoolProposal(false, isLegacy)

AllValsVoteOnProposal(c, propNumber)

require.Eventually(c.t, func() bool {
status, err := chainANode.QueryPropStatus(propNumber)
if err != nil {
return false
}
return status == proposalStatusPassed
}, time.Second*30, 10*time.Millisecond)
poolId := chainANode.QueryNumPools()
return poolId, nil
}
63 changes: 28 additions & 35 deletions tests/e2e/e2e_cl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,26 @@ import (
// Note: do not use chain B in this test as it has taker fee set.
// This TWAP test depends on specific values that might be affected
// by the taker fee.
func (s *IntegrationTestSuite) CreateConcentratedLiquidityPoolVoting_And_TWAP() {
func (s *IntegrationTestSuite) ConcentratedLiquidityPoolTWAP() {
chainA, chainANode := s.getChainACfgs()

poolId, err := chainA.SubmitCreateConcentratedPoolProposal(chainANode, true)
s.NoError(err)
fmt.Println("poolId", poolId)

var (
expectedDenom0 = "stake"
expectedDenom1 = appparams.BaseCoinUnit
expectedTickspacing = uint64(100)
expectedSpreadFactor = "0.001000000000000000"
)

var concentratedPool cltypes.ConcentratedPoolExtension
s.Eventually(
func() bool {
concentratedPool = s.updatedConcentratedPool(chainANode, poolId)
s.Require().Equal(poolmanagertypes.Concentrated, concentratedPool.GetType())
s.Require().Equal(expectedDenom0, concentratedPool.GetToken0())
s.Require().Equal(expectedDenom1, concentratedPool.GetToken1())
s.Require().Equal(expectedTickspacing, concentratedPool.GetTickSpacing())
s.Require().Equal(expectedSpreadFactor, concentratedPool.GetSpreadFactor(sdk.Context{}).String())

return true
},
1*time.Minute,
10*time.Millisecond,
"create concentrated liquidity pool was not successful.",
)
s.enablePermissionlessCL(chainA, chainANode)
poolId := chainANode.CreateConcentratedPool(initialization.ValidatorWalletName, expectedDenom0, expectedDenom1, expectedTickspacing, expectedSpreadFactor)
fmt.Println("poolId", poolId)

concentratedPool := s.updatedConcentratedPool(chainANode, poolId)
s.Require().Equal(poolmanagertypes.Concentrated, concentratedPool.GetType())
s.Require().Equal(expectedDenom0, concentratedPool.GetToken0())
s.Require().Equal(expectedDenom1, concentratedPool.GetToken1())
s.Require().Equal(expectedTickspacing, concentratedPool.GetTickSpacing())
s.Require().Equal(expectedSpreadFactor, concentratedPool.GetSpreadFactor(sdk.Context{}).String())

fundTokens := []string{"100000000stake", "100000000uosmo"}

Expand Down Expand Up @@ -130,6 +120,22 @@ func (s *IntegrationTestSuite) CreateConcentratedLiquidityPoolVoting_And_TWAP()
s.Require().Equal(osmomath.NewDec(2), secondTwapBOverA)
}

func (s *IntegrationTestSuite) enablePermissionlessCL(chain *chain.Config, chainNode *chain.NodeConfig) {
// Get the permisionless pool creation parameter.
isPermisionlessCreationEnabledStr := chainNode.QueryParams(cltypes.ModuleName, string(cltypes.KeyIsPermisionlessPoolCreationEnabled), false)
if !strings.EqualFold(isPermisionlessCreationEnabledStr, "true") {
// Change the parameter to enable permisionless pool creation.
err := chainNode.ParamChangeProposal("concentratedliquidity", string(cltypes.KeyIsPermisionlessPoolCreationEnabled), []byte("true"), chain, true)
s.Require().NoError(err)
}

// Confirm that the parameter has been changed.
isPermisionlessCreationEnabledStr = chainNode.QueryParams(cltypes.ModuleName, string(cltypes.KeyIsPermisionlessPoolCreationEnabled), false)
if !strings.EqualFold(isPermisionlessCreationEnabledStr, "true") {
s.T().Fatal("concentrated liquidity pool creation is not enabled")
}
}

// Note: this test depends on taker fee being set.
// As a result, we use chain B. Chain A has zero taker fee.
// TODO: Move this test and its components to its own file, Its way too big and needs to be split up significantly.
Expand All @@ -148,20 +154,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() {
var adminWalletAddr string

enablePermissionlessCl := func() {
// Get the permisionless pool creation parameter.
isPermisionlessCreationEnabledStr := chainBNode.QueryParams(cltypes.ModuleName, string(cltypes.KeyIsPermisionlessPoolCreationEnabled), false)
if !strings.EqualFold(isPermisionlessCreationEnabledStr, "true") {
// Change the parameter to enable permisionless pool creation.
err := chainBNode.ParamChangeProposal("concentratedliquidity", string(cltypes.KeyIsPermisionlessPoolCreationEnabled), []byte("true"), chainB, true)
s.Require().NoError(err)
}

// Confirm that the parameter has been changed.
isPermisionlessCreationEnabledStr = chainBNode.QueryParams(cltypes.ModuleName, string(cltypes.KeyIsPermisionlessPoolCreationEnabled), false)
if !strings.EqualFold(isPermisionlessCreationEnabledStr, "true") {
s.T().Fatal("concentrated liquidity pool creation is not enabled")
}

s.enablePermissionlessCL(chainB, chainBNode)
go func() {
s.T().Run("test update pool tick spacing", func(t *testing.T) {
s.TickSpacingUpdateProp()
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func (s *IntegrationTestSuite) TestPrepE2E() {
// TODO: Find more scalable way to do this
func (s *IntegrationTestSuite) TestStartE2E() {
// Zero Dependent Tests
s.T().Run("CreateConcentratedLiquidityPoolVoting_And_TWAP", func(t *testing.T) {
s.T().Run("ConcentratedLiquidityPoolTWAP", func(t *testing.T) {
t.Parallel()
s.CreateConcentratedLiquidityPoolVoting_And_TWAP()
s.ConcentratedLiquidityPoolTWAP()
})

s.T().Run("ProtoRev", func(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion x/concentrated-liquidity/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
const (
FlagPoolId = "pool-id"
FlagPoolIdToTickSpacingRecords = "pool-tick-spacing-records"
FlagPoolRecords = "pool-records"
)

func FlagSetJustPoolId() *flag.FlagSet {
Expand Down
112 changes: 0 additions & 112 deletions x/concentrated-liquidity/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils/osmocli"
clmodel "github.com/osmosis-labs/osmosis/v29/x/concentrated-liquidity/model"
"github.com/osmosis-labs/osmosis/v29/x/concentrated-liquidity/types"
Expand Down Expand Up @@ -103,49 +102,6 @@ func NewTransferPositionsCmd() (*osmocli.TxCliDesc, *types.MsgTransferPositions)
}, &types.MsgTransferPositions{}
}

// NewCmdCreateConcentratedLiquidityPoolsProposal implements a command handler for create concentrated liquidity pool proposal
func NewCmdCreateConcentratedLiquidityPoolsProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "create-concentratedliquidity-pool-proposal [flags]",
Args: cobra.ExactArgs(0),
Short: "Submit a create concentrated liquidity pool proposal",
Long: strings.TrimSpace(`Submit a create concentrated liquidity pool proposal.

Passing in FlagPoolRecords separated by commas would be parsed automatically to pairs of pool records.
Ex) --pool-records=uion,uosmo,100,0.003,stake,uosmo,1000,0.005 ->
[uion<>uosmo, tickSpacing 100, spreadFactor 0.3%]
[stake<>uosmo, tickSpacing 1000, spreadFactor 0.5%]

`),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, proposalTitle, summary, deposit, isExpedited, authority, err := osmocli.GetProposalInfo(cmd)
if err != nil {
return err
}

content, err := parseCreateConcentratedLiquidityPoolArgsToContent(cmd)
if err != nil {
return err
}

msg, err := v1.NewLegacyContent(content, authority.String())
if err != nil {
return err
}
proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, isExpedited)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg)
},
}
osmocli.AddCommonProposalFlags(cmd)
cmd.Flags().String(FlagPoolRecords, "", "The pool records array")

return cmd
}

func NewTickSpacingDecreaseProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "tick-spacing-decrease-proposal [flags]",
Expand Down Expand Up @@ -190,31 +146,6 @@ Note: The new tick spacing value must be less than the current tick spacing valu
return cmd
}

func parseCreateConcentratedLiquidityPoolArgsToContent(cmd *cobra.Command) (govtypesv1beta1.Content, error) {
title, err := cmd.Flags().GetString(govcli.FlagTitle)
if err != nil {
return nil, err
}

description, err := cmd.Flags().GetString(govcli.FlagSummary)
if err != nil {
return nil, err
}

poolRecords, err := parsePoolRecords(cmd)
if err != nil {
return nil, err
}

content := &types.CreateConcentratedLiquidityPoolsProposal{
Title: title,
Description: description,
PoolRecords: poolRecords,
}

return content, nil
}

func parsePoolIdToTickSpacingRecordsArgsToContent(cmd *cobra.Command) (govtypesv1beta1.Content, error) {
title, err := cmd.Flags().GetString(govcli.FlagTitle)
if err != nil {
Expand Down Expand Up @@ -274,46 +205,3 @@ func parsePoolIdToTickSpacingRecords(cmd *cobra.Command) ([]types.PoolIdToTickSp

return poolIdToTickSpacingRecords, nil
}

func parsePoolRecords(cmd *cobra.Command) ([]types.PoolRecord, error) {
poolRecordsStr, err := cmd.Flags().GetString(FlagPoolRecords)
if err != nil {
return nil, err
}

poolRecords := strings.Split(poolRecordsStr, ",")

if len(poolRecords)%4 != 0 {
return nil, fmt.Errorf("poolRecords must be a list of denom0, denom1, tickSpacing, and spreadFactor")
}

finalPoolRecords := []types.PoolRecord{}
i := 0
for i < len(poolRecords) {
denom0 := poolRecords[i]
denom1 := poolRecords[i+1]

tickSpacing, err := strconv.Atoi(poolRecords[i+2])
if err != nil {
return nil, err
}

spreadFactorStr := poolRecords[i+3]
spreadFactor, err := osmomath.NewDecFromStr(spreadFactorStr)
if err != nil {
return nil, err
}

finalPoolRecords = append(finalPoolRecords, types.PoolRecord{
Denom0: denom0,
Denom1: denom1,
TickSpacing: uint64(tickSpacing),
SpreadFactor: spreadFactor,
})

// increase counter by the next 4
i = i + 4
}

return finalPoolRecords, nil
}
3 changes: 1 addition & 2 deletions x/concentrated-liquidity/client/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ import (
)

var (
TickSpacingDecreaseProposalHandler = govclient.NewProposalHandler(cli.NewTickSpacingDecreaseProposal)
CreateConcentratedLiquidityPoolProposalHandler = govclient.NewProposalHandler(cli.NewCmdCreateConcentratedLiquidityPoolsProposal)
TickSpacingDecreaseProposalHandler = govclient.NewProposalHandler(cli.NewTickSpacingDecreaseProposal)
)
17 changes: 0 additions & 17 deletions x/concentrated-liquidity/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,9 @@ import (

govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

clmodel "github.com/osmosis-labs/osmosis/v29/x/concentrated-liquidity/model"
"github.com/osmosis-labs/osmosis/v29/x/concentrated-liquidity/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v29/x/poolmanager/types"
)

func (k Keeper) HandleCreateConcentratedLiquidityPoolsProposal(ctx sdk.Context, p *types.CreateConcentratedLiquidityPoolsProposal) error {
poolmanagerModuleAcc := k.accountKeeper.GetModuleAccount(ctx, poolmanagertypes.ModuleName)
poolCreatorAddress := poolmanagerModuleAcc.GetAddress()
for _, record := range p.PoolRecords {
createPoolMsg := clmodel.NewMsgCreateConcentratedPool(poolCreatorAddress, record.Denom0, record.Denom1, record.TickSpacing, record.SpreadFactor)
_, err := k.poolmanagerKeeper.CreateConcentratedPoolAsPoolManager(ctx, createPoolMsg)
if err != nil {
return err
}
}
return nil
}

// HandleTickSpacingDecreaseProposal handles a tick spacing decrease proposal to the corresponding keeper method.
func (k Keeper) HandleTickSpacingDecreaseProposal(ctx sdk.Context, p *types.TickSpacingDecreaseProposal) error {
return k.DecreaseConcentratedPoolTickSpacing(ctx, p.PoolIdToTickSpacingRecords)
Expand All @@ -35,8 +20,6 @@ func NewConcentratedLiquidityProposalHandler(k Keeper) govtypesv1.Handler {
switch c := content.(type) {
case *types.TickSpacingDecreaseProposal:
return k.HandleTickSpacingDecreaseProposal(ctx, c)
case *types.CreateConcentratedLiquidityPoolsProposal:
return k.HandleCreateConcentratedLiquidityPoolsProposal(ctx, c)
default:
return fmt.Errorf("unrecognized concentrated liquidity proposal content type: %T", c)
}
Expand Down
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgFungifyChargedPositions{}, "osmosis/cl-fungify-charged-positions", nil)

// gov proposals
// TODO: Keeping CreateConcentratedLiquidityPoolsProposal here for now, until clarity on removing messages from codec. We already removed the functionality in a previous PR.
cdc.RegisterConcrete(&CreateConcentratedLiquidityPoolsProposal{}, "osmosis/create-cl-pools-proposal", nil)
cdc.RegisterConcrete(&TickSpacingDecreaseProposal{}, "osmosis/cl-tick-spacing-dec-prop", nil)
}
Expand All @@ -42,7 +43,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {

registry.RegisterImplementations(
(*govtypesv1.Content)(nil),
&CreateConcentratedLiquidityPoolsProposal{},
&TickSpacingDecreaseProposal{},
)

Expand Down
Loading