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

move gauge fees to types #2234

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions x/incentives/keeper/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import (
"github.com/osmosis-labs/osmosis/v10/x/incentives/types"
)

var (
// CreateGaugeFee is the fee required to create a new gauge.
CreateGaugeFee = createGaugeFee
// AddToGagugeFee is the fee required to add to gauge.
AddToGaugeFee = addToGaugeFee
)

// AddGaugeRefByKey appends the provided gauge ID into an array associated with the provided key.
func (k Keeper) AddGaugeRefByKey(ctx sdk.Context, key []byte, gaugeID uint64) error {
return k.addGaugeRefByKey(ctx, key, gaugeID)
Expand Down
7 changes: 0 additions & 7 deletions x/incentives/keeper/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

var (
// createGaugeFee is the fee required to create a new gauge.
createGaugeFee = sdk.NewInt(50 * 1_000_000)
// addToGagugeFee is the fee required to add to gauge.
addToGaugeFee = sdk.NewInt(25 * 1_000_000)
)

// getGaugesFromIterator iterates over everything in a gauge's iterator, until it reaches the end. Return all gauges iterated over.
func (k Keeper) getGaugesFromIterator(ctx sdk.Context, iterator db.Iterator) []types.Gauge {
gauges := []types.Gauge{}
Expand Down
4 changes: 2 additions & 2 deletions x/incentives/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (server msgServer) CreateGauge(goCtx context.Context, msg *types.MsgCreateG
return nil, err
}

if err := server.keeper.chargeFeeIfSufficientFeeDenomBalance(ctx, owner, createGaugeFee, msg.Coins); err != nil {
if err := server.keeper.chargeFeeIfSufficientFeeDenomBalance(ctx, owner, types.CreateGaugeFee, msg.Coins); err != nil {
return nil, err
}

Expand Down Expand Up @@ -61,7 +61,7 @@ func (server msgServer) AddToGauge(goCtx context.Context, msg *types.MsgAddToGau
return nil, err
}

if err := server.keeper.chargeFeeIfSufficientFeeDenomBalance(ctx, owner, addToGaugeFee, msg.Rewards); err != nil {
if err := server.keeper.chargeFeeIfSufficientFeeDenomBalance(ctx, owner, types.AddToGaugeFee, msg.Rewards); err != nil {
return nil, err
}
err = server.keeper.AddToGaugeRewards(ctx, owner, msg.Rewards, msg.GaugeId)
Expand Down
4 changes: 2 additions & 2 deletions x/incentives/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (suite *KeeperTestSuite) TestCreateGauge_Fee() {
if tc.expectErr {
suite.Require().Equal(tc.accountBalanceToFund.String(), balanceAmount.String(), "test: %v", tc.name)
} else {
fee := sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, keeper.CreateGaugeFee))
fee := sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, types.CreateGaugeFee))
accountBalance := tc.accountBalanceToFund.Sub(tc.gaugeAddition)
finalAccountBalance := accountBalance.Sub(fee)
suite.Require().Equal(finalAccountBalance.String(), balanceAmount.String(), "test: %v", tc.name)
Expand Down Expand Up @@ -234,7 +234,7 @@ func (suite *KeeperTestSuite) TestAddToGauge_Fee() {
if tc.expectErr {
suite.Require().Equal(tc.accountBalanceToFund.String(), bal.String(), "test: %v", tc.name)
} else {
fee := sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, keeper.AddToGaugeFee))
fee := sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, types.AddToGaugeFee))
accountBalance := tc.accountBalanceToFund.Sub(tc.gaugeAddition)
finalAccountBalance := accountBalance.Sub(fee)
suite.Require().Equal(finalAccountBalance.String(), bal.String(), "test: %v", tc.name)
Expand Down
11 changes: 2 additions & 9 deletions x/incentives/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ const (
OpWeightMsgAddToGauge = "op_weight_msg_add_to_gauge"
)

var (
// createGaugeFee is the fee required to create a new gauge.
createGaugeFee = sdk.NewInt(50 * 1_000_000)
// addToGagugeFee is the fee required to add to gauge.
addToGaugeFee = sdk.NewInt(25 * 1_000_000)
)

// WeightedOperations returns all the operations from the module with their respective weights.
func WeightedOperations(
appParams simtypes.AppParams, cdc codec.JSONCodec, ak stakingTypes.AccountKeeper,
Expand Down Expand Up @@ -124,7 +117,7 @@ func SimulateMsgCreateGauge(ak stakingTypes.AccountKeeper, bk stakingTypes.BankK
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
simAccount, _ := simtypes.RandomAcc(r, accs)
simCoins := bk.SpendableCoins(ctx, simAccount.Address)
if simCoins.Len() <= 0 || simCoins.AmountOf(appparams.BaseCoinUnit).LT(createGaugeFee) {
if simCoins.Len() <= 0 || simCoins.AmountOf(appparams.BaseCoinUnit).LT(types.CreateGaugeFee) {
return simtypes.NoOpMsg(
types.ModuleName, types.TypeMsgCreateGauge, "Account have no coin"), nil, nil
}
Expand Down Expand Up @@ -163,7 +156,7 @@ func SimulateMsgAddToGauge(ak stakingTypes.AccountKeeper, bk stakingTypes.BankKe
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
simAccount, _ := simtypes.RandomAcc(r, accs)
simCoins := bk.SpendableCoins(ctx, simAccount.Address)
if simCoins.Len() <= 0 || simCoins.AmountOf(appparams.BaseCoinUnit).LT(addToGaugeFee) {
if simCoins.Len() <= 0 || simCoins.AmountOf(appparams.BaseCoinUnit).LT(types.AddToGaugeFee) {
return simtypes.NoOpMsg(
types.ModuleName, types.TypeMsgAddToGauge, "Account have no coin"), nil, nil
}
Expand Down
7 changes: 7 additions & 0 deletions x/incentives/types/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

var (
// CreateGaugeFee is the fee required to create a new gauge.
CreateGaugeFee = sdk.NewInt(50 * 1_000_000)
// AddToGagugeFee is the fee required to add to gauge.
AddToGaugeFee = sdk.NewInt(25 * 1_000_000)
)

// NewGauge creates a new gauge struct given the required gauge parameters.
func NewGauge(id uint64, isPerpetual bool, distrTo lockuptypes.QueryCondition, coins sdk.Coins, startTime time.Time, numEpochsPaidOver uint64, filledEpochs uint64, distrCoins sdk.Coins) Gauge {
return Gauge{
Expand Down