Skip to content

Commit

Permalink
Revert "[CL Incentives] Implement CreateIncentive logic and message (
Browse files Browse the repository at this point in the history
…#4519)"

This reverts commit b07e763.
  • Loading branch information
AlpinYukseloglu authored Mar 10, 2023
1 parent b07e763 commit ce4531e
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 3,450 deletions.
2,037 changes: 0 additions & 2,037 deletions go.work.sum

This file was deleted.

53 changes: 0 additions & 53 deletions proto/osmosis/concentrated-liquidity/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,57 +132,4 @@ message MsgCollectIncentivesResponse {
(gogoproto.moretags) = "yaml:\"collected_incentives\"",
(gogoproto.nullable) = false
];
}

// ===================== MsgCreateIncentive
message MsgCreateIncentive {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string sender = 2 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
string incentive_denom = 3;
string incentive_amount = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"incentive_amount\"",
(gogoproto.nullable) = false
];
string emission_rate = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"emission_rate\"",
(gogoproto.nullable) = false
];
google.protobuf.Timestamp start_time = 6 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"start_time\""
];
google.protobuf.Duration min_uptime = 7 [
(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\""
];
}
11 changes: 0 additions & 11 deletions x/concentrated-liquidity/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func NewTxCmd() *cobra.Command {
osmocli.AddTxCmd(txCmd, NewCreateConcentratedPoolCmd)
osmocli.AddTxCmd(txCmd, NewCollectFeesCmd)
osmocli.AddTxCmd(txCmd, NewCollectIncentivesCmd)
osmocli.AddTxCmd(txCmd, NewCreateIncentiveCmd)
return txCmd
}

Expand Down Expand Up @@ -72,13 +71,3 @@ func NewCollectIncentivesCmd() (*osmocli.TxCliDesc, *types.MsgCollectIncentives)
Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetJustPoolId()}},
}, &types.MsgCollectIncentives{}
}

func NewCreateIncentiveCmd() (*osmocli.TxCliDesc, *types.MsgCreateIncentive) {
return &osmocli.TxCliDesc{
Use: "create-incentive [incentive-denom] [incentive-amount] [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 100 2023-03-03 03:20:35.419543805 24h --pool-id 1 --from val --chain-id osmosis-1",
CustomFlagOverrides: poolIdFlagOverride,
Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetJustPoolId()}},
}, &types.MsgCreateIncentive{}
}
4 changes: 0 additions & 4 deletions x/concentrated-liquidity/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,3 @@ func (k Keeper) CollectIncentives(ctx sdk.Context, poolId uint64, owner sdk.AccA
func GetUptimeTrackerValues(uptimeTrackers []model.UptimeTracker) []sdk.DecCoins {
return getUptimeTrackerValues(uptimeTrackers)
}

func (k Keeper) CreateIncentive(ctx sdk.Context, poolId uint64, sender sdk.AccAddress, incentiveDenom string, incentiveAmount sdk.Int, emissionRate sdk.Dec, startTime time.Time, minUptime time.Duration) (types.IncentiveRecord, error) {
return k.createIncentive(ctx, poolId, sender, incentiveDenom, incentiveAmount, emissionRate, startTime, minUptime)
}
67 changes: 0 additions & 67 deletions x/concentrated-liquidity/incentives.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,70 +501,3 @@ func (k Keeper) collectIncentives(ctx sdk.Context, poolId uint64, owner sdk.AccA
}
return collectedIncentives, nil
}

// createIncentive creates an incentive record in state for the given pool
func (k Keeper) createIncentive(ctx sdk.Context, poolId uint64, sender sdk.AccAddress, incentiveDenom string, incentiveAmount sdk.Int, emissionRate sdk.Dec, startTime time.Time, minUptime time.Duration) (types.IncentiveRecord, error) {
pool, err := k.getPoolById(ctx, poolId)
if err != nil {
return types.IncentiveRecord{}, err
}

// Ensure incentive amount is nonzero and nonnegative
if !incentiveAmount.IsPositive() {
return types.IncentiveRecord{}, types.NonPositiveIncentiveAmountError{PoolId: poolId, IncentiveAmount: incentiveAmount.ToDec()}
}

// Ensure start time is >= current blocktime
if startTime.Before(ctx.BlockTime()) {
return types.IncentiveRecord{}, types.StartTimeTooEarlyError{PoolId: poolId, CurrentBlockTime: ctx.BlockTime(), StartTime: startTime}
}

// Ensure emission rate is nonzero and nonnegative
if !emissionRate.IsPositive() {
return types.IncentiveRecord{}, types.NonPositiveEmissionRateError{PoolId: poolId, EmissionRate: emissionRate}
}

// Ensure min uptime is one of the supported periods
validUptime := false
for _, supportedUptime := range types.SupportedUptimes {
if minUptime == supportedUptime {
validUptime = true
}
}
if !validUptime {
return types.IncentiveRecord{}, types.InvalidMinUptimeError{PoolId: poolId, MinUptime: minUptime, SupportedUptimes: types.SupportedUptimes}
}

// Ensure sender has balance for incentive denom
incentiveCoin := sdk.NewCoin(incentiveDenom, incentiveAmount)
senderHasBalance := k.bankKeeper.HasBalance(ctx, sender, incentiveCoin)
if !senderHasBalance {
return types.IncentiveRecord{}, types.IncentiveInsufficientBalanceError{PoolId: poolId, IncentiveDenom: incentiveDenom, IncentiveAmount: incentiveAmount}
}

// Sync global uptime accumulators to current blocktime to ensure consistency in reward emissions
err = k.updateUptimeAccumulatorsToNow(ctx, poolId)
if err != nil {
return types.IncentiveRecord{}, err
}

// Set up incentive record to put in state
incentiveRecord := types.IncentiveRecord{
PoolId: poolId,
IncentiveDenom: incentiveDenom,
RemainingAmount: incentiveAmount.ToDec(),
EmissionRate: emissionRate,
StartTime: startTime,
MinUptime: minUptime,
}

// Set incentive record in state
k.setIncentiveRecord(ctx, incentiveRecord)

// Transfer tokens from sender to pool balance
if err := k.bankKeeper.SendCoins(ctx, sender, pool.GetAddress(), sdk.NewCoins(incentiveCoin)); err != nil {
return types.IncentiveRecord{}, err
}

return incentiveRecord, nil
}
Loading

0 comments on commit ce4531e

Please sign in to comment.