Skip to content

Commit

Permalink
remove MsgCreateIncentive (#5234)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpinYukseloglu authored and pysel committed Jun 6, 2023
1 parent 96cd8a6 commit ada5223
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 1,085 deletions.
52 changes: 0 additions & 52 deletions proto/osmosis/concentrated-liquidity/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ service Msg {
rpc CollectFees(MsgCollectFees) returns (MsgCollectFeesResponse);
rpc CollectIncentives(MsgCollectIncentives)
returns (MsgCollectIncentivesResponse);
rpc CreateIncentive(MsgCreateIncentive) returns (MsgCreateIncentiveResponse);
rpc FungifyChargedPositions(MsgFungifyChargedPositions)
returns (MsgFungifyChargedPositionsResponse);
}
Expand Down Expand Up @@ -161,57 +160,6 @@ message MsgCollectIncentivesResponse {
];
}

// ===================== MsgCreateIncentive
message MsgCreateIncentive {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string sender = 2 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
cosmos.base.v1beta1.Coin incentive_coin = 3 [
(gogoproto.moretags) = "yaml:\"incentive_coin\"",
(gogoproto.nullable) = false
];
string emission_rate = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"emission_rate\"",
(gogoproto.nullable) = false
];
google.protobuf.Timestamp start_time = 5 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"start_time\""
];
google.protobuf.Duration min_uptime = 6 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"min_uptime\""
];
}

message MsgCreateIncentiveResponse {
string incentive_denom = 1;
string incentive_amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"incentive_amount\"",
(gogoproto.nullable) = false
];
string emission_rate = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"emission_rate\"",
(gogoproto.nullable) = false
];
google.protobuf.Timestamp start_time = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"start_time\""
];
google.protobuf.Duration min_uptime = 5 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"min_uptime\""
];
}

// ===================== MsgFungifyChargedPositions
message MsgFungifyChargedPositions {
repeated uint64 position_ids = 1
Expand Down
12 changes: 0 additions & 12 deletions x/concentrated-liquidity/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
flag "github.com/spf13/pflag"

"github.com/spf13/cobra"

Expand All @@ -29,7 +28,6 @@ func NewTxCmd() *cobra.Command {
osmocli.AddTxCmd(txCmd, NewCreateConcentratedPoolCmd)
osmocli.AddTxCmd(txCmd, NewCollectFeesCmd)
osmocli.AddTxCmd(txCmd, NewCollectIncentivesCmd)
osmocli.AddTxCmd(txCmd, NewCreateIncentiveCmd)
osmocli.AddTxCmd(txCmd, NewFungifyChargedPositionsCmd)
return txCmd
}
Expand Down Expand Up @@ -87,16 +85,6 @@ func NewCollectIncentivesCmd() (*osmocli.TxCliDesc, *types.MsgCollectIncentives)
}, &types.MsgCollectIncentives{}
}

func NewCreateIncentiveCmd() (*osmocli.TxCliDesc, *types.MsgCreateIncentive) {
return &osmocli.TxCliDesc{
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 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]",
Expand Down
1 change: 0 additions & 1 deletion x/concentrated-liquidity/clmodule/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,5 @@ func (am AppModule) Actions() []simtypes.Action {
simtypes.NewMsgBasedAction("WithdrawPosition", am.keeper, simulation.RandMsgWithdrawPosition),
simtypes.NewMsgBasedAction("CollectFees", am.keeper, simulation.RandMsgCollectFees),
simtypes.NewMsgBasedAction("CollectIncentives", am.keeper, simulation.RandMsgCollectIncentives),
simtypes.NewMsgBasedAction("CreateIncentives", am.keeper, simulation.RandMsgCreateIncentives),
}
}
41 changes: 0 additions & 41 deletions x/concentrated-liquidity/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package concentrated_liquidity

import (
"context"
"strconv"

sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -195,46 +194,6 @@ func (server msgServer) CollectIncentives(goCtx context.Context, msg *types.MsgC
return &types.MsgCollectIncentivesResponse{CollectedIncentives: totalCollectedIncentives, ForfeitedIncentives: totalForefeitedIncentives}, nil
}

func (server msgServer) CreateIncentive(goCtx context.Context, msg *types.MsgCreateIncentive) (*types.MsgCreateIncentiveResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

sender, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
return nil, err
}

incentiveRecord, err := server.keeper.CreateIncentive(ctx, msg.PoolId, sender, msg.IncentiveCoin, msg.EmissionRate, msg.StartTime, msg.MinUptime)
if err != nil {
return nil, err
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender),
),
sdk.NewEvent(
types.TypeEvtCreateIncentive,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender),
sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(msg.PoolId, 10)),
sdk.NewAttribute(types.AttributeIncentiveCoin, msg.IncentiveCoin.String()),
sdk.NewAttribute(types.AttributeIncentiveEmissionRate, msg.EmissionRate.String()),
sdk.NewAttribute(types.AttributeIncentiveStartTime, msg.StartTime.String()),
sdk.NewAttribute(types.AttributeIncentiveMinUptime, msg.MinUptime.String()),
),
})

return &types.MsgCreateIncentiveResponse{
IncentiveDenom: incentiveRecord.IncentiveDenom,
IncentiveAmount: incentiveRecord.IncentiveRecordBody.RemainingAmount,
EmissionRate: incentiveRecord.IncentiveRecordBody.EmissionRate,
StartTime: incentiveRecord.IncentiveRecordBody.StartTime,
MinUptime: incentiveRecord.MinUptime,
}, nil
}

func (server msgServer) FungifyChargedPositions(goCtx context.Context, msg *types.MsgFungifyChargedPositions) (*types.MsgFungifyChargedPositionsResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

Expand Down
38 changes: 0 additions & 38 deletions x/concentrated-liquidity/simulation/sim_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package simulation
import (
"errors"
"fmt"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
legacysimulationtype "github.com/cosmos/cosmos-sdk/types/simulation"
Expand Down Expand Up @@ -223,43 +222,6 @@ func RandMsgCollectIncentives(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx s
}, nil
}

func RandMsgCreateIncentives(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx sdk.Context) (*cltypes.MsgCreateIncentive, error) {
rand := sim.GetRand()
// get random pool
clPool, poolDenoms, err := getRandCLPool(k, sim, ctx)
if err != nil {
return nil, err
}

// incentiveCreator creates the incentives by supplying tokens
incentiveCreator, incentivesTokens, senderExists := sim.SelAddrWithDenoms(ctx, poolDenoms)
if !senderExists {
return nil, fmt.Errorf("no sender with denoms %s exists", poolDenoms)
}

// emission rate is nonzero and nonnegative from 1 to 1million
randEmissionVal := sim.RandomDecAmount(sdk.MustNewDecFromStr("1000000"))

startTimeSecs := rand.Intn(1 * 60 * 60 * 24 * 7) // range of 1 week
startTime := ctx.BlockTime().Add(time.Duration(startTimeSecs) * time.Second)

durations := cltypes.DefaultParams().AuthorizedUptimes
randomDurationIndex := rand.Intn(len(durations))

// Get the duration value at the random index
randomDuration := durations[randomDurationIndex]
incentiveCoin := sdk.NewCoin(incentivesTokens[0].Denom, incentivesTokens[0].Amount)

return &cltypes.MsgCreateIncentive{
PoolId: clPool.GetId(),
Sender: incentiveCreator.Address.String(),
IncentiveCoin: incentiveCoin,
EmissionRate: randEmissionVal,
StartTime: startTime,
MinUptime: randomDuration,
}, nil
}

// createPoolRestriction creates specific restriction for the creation of a pool.
func createPoolRestriction(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx sdk.Context) osmosimtypes.SimAccountConstraint {
return func(acc legacysimulationtype.Account) bool {
Expand Down
2 changes: 0 additions & 2 deletions x/concentrated-liquidity/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgWithdrawPosition{}, "osmosis/cl-withdraw-position", nil)
cdc.RegisterConcrete(&MsgCollectFees{}, "osmosis/cl-collect-fees", nil)
cdc.RegisterConcrete(&MsgCollectIncentives{}, "osmosis/cl-collect-incentives", nil)
cdc.RegisterConcrete(&MsgCreateIncentive{}, "osmosis/cl-create-incentive", nil)
cdc.RegisterConcrete(&MsgFungifyChargedPositions{}, "osmosis/cl-fungify-charged-positions", nil)
cdc.RegisterConcrete(&CreateConcentratedLiquidityPoolProposal{}, "osmosis/cretae-concentrated-liquidity-pool-proposal", nil)
cdc.RegisterConcrete(&TickSpacingDecreaseProposal{}, "osmosis/cl-tick-spacing-dec-prop", nil)
Expand All @@ -35,7 +34,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
&MsgWithdrawPosition{},
&MsgCollectFees{},
&MsgCollectIncentives{},
&MsgCreateIncentive{},
&MsgFungifyChargedPositions{},
)

Expand Down
34 changes: 0 additions & 34 deletions x/concentrated-liquidity/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const (
TypeMsgWithdrawPosition = "withdraw-position"
TypeMsgCollectFees = "collect-fees"
TypeMsgCollectIncentives = "collect-incentives"
TypeMsgCreateIncentive = "create-incentive"
TypeMsgFungifyChargedPositions = "fungify-charged-positions"
)

Expand Down Expand Up @@ -189,39 +188,6 @@ func (msg MsgCollectIncentives) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sender}
}

var _ sdk.Msg = &MsgCreateIncentive{}

func (msg MsgCreateIncentive) Route() string { return RouterKey }
func (msg MsgCreateIncentive) Type() string { return TypeMsgCreateIncentive }
func (msg MsgCreateIncentive) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
return fmt.Errorf("Invalid sender address (%s)", err)
}

if !msg.IncentiveCoin.IsValid() {
return InvalidIncentiveCoinError{PoolId: msg.PoolId, IncentiveCoin: msg.IncentiveCoin}
}

if !msg.EmissionRate.IsPositive() {
return NonPositiveEmissionRateError{PoolId: msg.PoolId, EmissionRate: msg.EmissionRate}
}

return nil
}

func (msg MsgCreateIncentive) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}

func (msg MsgCreateIncentive) GetSigners() []sdk.AccAddress {
sender, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
panic(err)
}
return []sdk.AccAddress{sender}
}

var _ sdk.Msg = &MsgFungifyChargedPositions{}

func (msg MsgFungifyChargedPositions) Route() string { return RouterKey }
Expand Down
Loading

0 comments on commit ada5223

Please sign in to comment.