Skip to content

Commit

Permalink
[fix] Fix CreateGauge CLI and add gas cost to create gauge (#5511)
Browse files Browse the repository at this point in the history
* added cleanup code

* fixed test

* added changelog

* cleanup
  • Loading branch information
stackman27 authored Jun 17, 2023
1 parent 6af3bf4 commit bd809a9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ and control over token transfers.
* [#5363](https://github.com/osmosis-labs/osmosis/pull/5363) fix: twap record upgrade handler
* [#5265](https://github.com/osmosis-labs/osmosis/pull/5265) fix: expect single synthetic lock per native lock ID
* [#4983](https://github.com/osmosis-labs/osmosis/pull/4983) implement gas consume on denom creation
* [#4830](https://github.com/osmosis-labs/osmosis/pull/4830) Scale gas costs by denoms in gauge
* [#4830](https://github.com/osmosis-labs/osmosis/pull/4830) Scale gas costs by denoms in gauge (AddToGaugeReward)
* [#5511](https://github.com/osmosis-labs/osmosis/pull/5511) Scale gas costs by denoms in gauge (CreateGauge)
* [#4336](https://github.com/osmosis-labs/osmosis/pull/4336) feat: make epochs standalone
* [#4801](https://github.com/osmosis-labs/osmosis/pull/4801) refactor: remove GetTotalShares, GetTotalLiquidity and GetExitFee from PoolI
* [#4951](https://github.com/osmosis-labs/osmosis/pull/4951) feat: implement pool liquidity query in pool manager, deprecate the one in gamm
Expand Down
8 changes: 7 additions & 1 deletion x/incentives/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func GetTxCmd() *cobra.Command {
// NewCreateGaugeCmd broadcasts a CreateGauge message.
func NewCreateGaugeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create-gauge [lockup_denom] [reward] [flags]",
Use: "create-gauge [lockup_denom] [reward] [poolId] [flags]",
Short: "create a gauge to distribute rewards to users",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -82,6 +82,11 @@ func NewCreateGaugeCmd() *cobra.Command {
return err
}

poolId, err := strconv.ParseUint(args[2], 10, 64)
if err != nil {
return err
}

distributeTo := lockuptypes.QueryCondition{
LockQueryType: lockuptypes.ByDuration,
Denom: denom,
Expand All @@ -96,6 +101,7 @@ func NewCreateGaugeCmd() *cobra.Command {
coins,
startTime,
epochs,
poolId,
)

return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg)
Expand Down
3 changes: 3 additions & 0 deletions x/incentives/keeper/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ func (k Keeper) CreateGauge(ctx sdk.Context, isPerpetual bool, owner sdk.AccAddr
NumEpochsPaidOver: numEpochsPaidOver,
}

// Fixed gas consumption create gauge based on the number of coins to add
ctx.GasMeter().ConsumeGas(uint64(types.BaseGasFeeForCreateGauge*len(gauge.Coins)), "scaling gas cost for creating gauge rewards")

if err := k.bk.SendCoinsFromAccountToModule(ctx, owner, types.ModuleName, gauge.Coins); err != nil {
return 0, err
}
Expand Down
1 change: 1 addition & 0 deletions x/incentives/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import time "time"

var (
BaseGasFeeForCreateGauge = 10_000
BaseGasFeeForAddRewardToGauge = 10_000
// We set the default value to 1ns, as this is the only uptime we support as long as charging is disabled (or
// until more supported uptimes are authorized by governance).
Expand Down
3 changes: 2 additions & 1 deletion x/incentives/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ const (
var _ sdk.Msg = &MsgCreateGauge{}

// NewMsgCreateGauge creates a message to create a gauge with the provided parameters.
func NewMsgCreateGauge(isPerpetual bool, owner sdk.AccAddress, distributeTo lockuptypes.QueryCondition, coins sdk.Coins, startTime time.Time, numEpochsPaidOver uint64) *MsgCreateGauge {
func NewMsgCreateGauge(isPerpetual bool, owner sdk.AccAddress, distributeTo lockuptypes.QueryCondition, coins sdk.Coins, startTime time.Time, numEpochsPaidOver uint64, poolId uint64) *MsgCreateGauge {
return &MsgCreateGauge{
IsPerpetual: isPerpetual,
Owner: owner.String(),
DistributeTo: distributeTo,
Coins: coins,
StartTime: startTime,
NumEpochsPaidOver: numEpochsPaidOver,
PoolId: poolId,
}
}

Expand Down
1 change: 1 addition & 0 deletions x/incentives/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestMsgCreateGauge(t *testing.T) {
sdk.Coins{},
time.Now(),
2,
0,
)

return after(properMsg)
Expand Down

0 comments on commit bd809a9

Please sign in to comment.