From d0aaca037266adee132ba743e8ea23ee69db370a Mon Sep 17 00:00:00 2001 From: Sishir Giri Date: Tue, 2 Aug 2022 17:19:10 -0700 Subject: [PATCH] x/incentives: refactor create gauge and add to gauge fees to use txfees denom (#2283) * revert to use dynamic denom * fixed keeper issue * rom comments * nit * adam comments --- CHANGELOG.md | 1 + app/keepers/keepers.go | 27 ++++++------ x/incentives/keeper/gauge.go | 16 ++++--- x/incentives/keeper/gauge_test.go | 33 +++++++------- x/incentives/keeper/keeper.go | 4 +- x/incentives/keeper/msg_server_test.go | 59 +++++++++++++------------- x/incentives/simulation/operations.go | 6 +-- x/incentives/types/expected_keepers.go | 5 +++ 8 files changed, 81 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57488f765f4..1a32735bd12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#2147](https://github.com/osmosis-labs/osmosis/pull/2147) Set MaxAgeNumBlocks in v11 Upgrade Handler to two weeks. * [#2193](https://github.com/osmosis-labs/osmosis/pull/2193) Add TwapKeeper to the Osmosis app * [#2227](https://github.com/osmosis-labs/osmosis/pull/2227) Enable charging fee in base denom for `CreateGauge` and `AddToGauge`. +* [#2283](https://github.com/osmosis-labs/osmosis/pull/2283) x/incentives: refactor `CreateGauge` and `AddToGauge` fees to use txfees denom #### Golang API breaks diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 3369228ba26..b88217fde6b 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -260,6 +260,19 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.EpochsKeeper = epochskeeper.NewKeeper(appCodec, appKeepers.keys[epochstypes.StoreKey]) + txFeesKeeper := txfeeskeeper.NewKeeper( + appCodec, + appKeepers.AccountKeeper, + appKeepers.BankKeeper, + appKeepers.EpochsKeeper, + appKeepers.keys[txfeestypes.StoreKey], + appKeepers.GAMMKeeper, + appKeepers.GAMMKeeper, + txfeestypes.FeeCollectorName, + txfeestypes.NonNativeFeeCollectorName, + ) + appKeepers.TxFeesKeeper = &txFeesKeeper + appKeepers.IncentivesKeeper = incentiveskeeper.NewKeeper( appCodec, appKeepers.keys[incentivestypes.StoreKey], @@ -268,6 +281,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.LockupKeeper, appKeepers.EpochsKeeper, appKeepers.DistrKeeper, + appKeepers.TxFeesKeeper, ) appKeepers.SuperfluidKeeper = superfluidkeeper.NewKeeper( @@ -300,19 +314,6 @@ func (appKeepers *AppKeepers) InitNormalKeepers( ) appKeepers.PoolIncentivesKeeper = &poolIncentivesKeeper - txFeesKeeper := txfeeskeeper.NewKeeper( - appCodec, - appKeepers.AccountKeeper, - appKeepers.BankKeeper, - appKeepers.EpochsKeeper, - appKeepers.keys[txfeestypes.StoreKey], - appKeepers.GAMMKeeper, - appKeepers.GAMMKeeper, - txfeestypes.FeeCollectorName, - txfeestypes.NonNativeFeeCollectorName, - ) - appKeepers.TxFeesKeeper = &txFeesKeeper - tokenFactoryKeeper := tokenfactorykeeper.NewKeeper( appCodec, appKeepers.keys[tokenfactorytypes.StoreKey], diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index 8a8638bc243..636597714d2 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -11,7 +11,6 @@ import ( "github.com/gogo/protobuf/proto" db "github.com/tendermint/tm-db" - appparams "github.com/osmosis-labs/osmosis/v10/app/params" epochtypes "github.com/osmosis-labs/osmosis/v10/x/epochs/types" "github.com/osmosis-labs/osmosis/v10/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v10/x/lockup/types" @@ -287,12 +286,19 @@ func (k Keeper) GetEpochInfo(ctx sdk.Context) epochtypes.EpochInfo { // The fee is sent to the community pool. // Returns nil on success, error otherwise. func (k Keeper) chargeFeeIfSufficientFeeDenomBalance(ctx sdk.Context, address sdk.AccAddress, fee sdk.Int, gaugeCoins sdk.Coins) (err error) { - totalCost := gaugeCoins.AmountOf(appparams.BaseCoinUnit).Add(fee) - accountBalance := k.bk.GetBalance(ctx, address, appparams.BaseCoinUnit).Amount + feeDenom, err := k.tk.GetBaseDenom(ctx) + if err != nil { + return err + } + + totalCost := gaugeCoins.AmountOf(feeDenom).Add(fee) + accountBalance := k.bk.GetBalance(ctx, address, feeDenom).Amount + if accountBalance.LT(totalCost) { - return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "account's balance of %s (%s) is less than the total cost of the message (%s)", appparams.BaseCoinUnit, accountBalance, totalCost) + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "account's balance of %s (%s) is less than the total cost of the message (%s)", feeDenom, accountBalance, totalCost) } - if err := k.dk.FundCommunityPool(ctx, sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, fee)), address); err != nil { + + if err := k.dk.FundCommunityPool(ctx, sdk.NewCoins(sdk.NewCoin(feeDenom, fee)), address); err != nil { return err } return nil diff --git a/x/incentives/keeper/gauge_test.go b/x/incentives/keeper/gauge_test.go index 2e36c881846..8ea072d5502 100644 --- a/x/incentives/keeper/gauge_test.go +++ b/x/incentives/keeper/gauge_test.go @@ -5,7 +5,6 @@ import ( "github.com/stretchr/testify/suite" - appparams "github.com/osmosis-labs/osmosis/v10/app/params" "github.com/osmosis-labs/osmosis/v10/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v10/x/lockup/types" @@ -250,51 +249,51 @@ func (suite *KeeperTestSuite) TestChargeFeeIfSufficientFeeDenomBalance() { expectError bool }{ "fee + base denom gauge coin == acount balance, success": { - accountBalanceToFund: sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), feeToCharge: baseFee / 2, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), }, "fee + base denom gauge coin < acount balance, success": { - accountBalanceToFund: sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), feeToCharge: baseFee/2 - 1, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), }, "fee + base denom gauge coin > acount balance, error": { accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), feeToCharge: baseFee/2 + 1, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), expectError: true, }, "fee + base denom gauge coin < acount balance, custom values, success": { - accountBalanceToFund: sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(11793193112)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(11793193112)), feeToCharge: 55, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(328812))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(328812))), }, "account funded with coins other than base denom, error": { accountBalanceToFund: sdk.NewCoin("usdc", sdk.NewInt(baseFee)), feeToCharge: baseFee, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), expectError: true, }, "fee == account balance, no gauge coins, success": { - accountBalanceToFund: sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), feeToCharge: baseFee, }, "gauge coins == account balance, no fee, success": { - accountBalanceToFund: sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee)), - gaugeCoins: sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee))), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee))), }, "fee == account balance, gauge coins in denom other than base, success": { - accountBalanceToFund: sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), feeToCharge: baseFee, gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(baseFee*2))), }, "fee + gauge coins == account balance, multiple gauge coins, one in denom other than base, success": { - accountBalanceToFund: sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), feeToCharge: baseFee / 2, - gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(baseFee*2)), sdk.NewCoin(appparams.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(baseFee*2)), sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), }, } @@ -311,13 +310,13 @@ func (suite *KeeperTestSuite) TestChargeFeeIfSufficientFeeDenomBalance() { // Pre-fund account. suite.FundAcc(testAccount, sdk.NewCoins(tc.accountBalanceToFund)) - oldBalanceAmount := bankKeeper.GetBalance(ctx, testAccount, appparams.DefaultBondDenom).Amount + oldBalanceAmount := bankKeeper.GetBalance(ctx, testAccount, sdk.DefaultBondDenom).Amount // System under test. err := incentivesKeepers.ChargeFeeIfSufficientFeeDenomBalance(ctx, testAccount, sdk.NewInt(tc.feeToCharge), tc.gaugeCoins) // Assertions. - newBalanceAmount := bankKeeper.GetBalance(ctx, testAccount, appparams.DefaultBondDenom).Amount + newBalanceAmount := bankKeeper.GetBalance(ctx, testAccount, sdk.DefaultBondDenom).Amount if tc.expectError { suite.Require().Error(err) diff --git a/x/incentives/keeper/keeper.go b/x/incentives/keeper/keeper.go index d21abad3579..37cbfb3397f 100644 --- a/x/incentives/keeper/keeper.go +++ b/x/incentives/keeper/keeper.go @@ -23,10 +23,11 @@ type Keeper struct { lk types.LockupKeeper ek types.EpochKeeper dk types.DistrKeeper + tk types.TxFeesKeeper } // NewKeeper returns a new instance of the incentive module keeper struct. -func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, bk types.BankKeeper, lk types.LockupKeeper, ek types.EpochKeeper, dk types.DistrKeeper) *Keeper { +func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, bk types.BankKeeper, lk types.LockupKeeper, ek types.EpochKeeper, dk types.DistrKeeper, txfk types.TxFeesKeeper) *Keeper { if !paramSpace.HasKeyTable() { paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) } @@ -39,6 +40,7 @@ func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Sub lk: lk, ek: ek, dk: dk, + tk: txfk, } } diff --git a/x/incentives/keeper/msg_server_test.go b/x/incentives/keeper/msg_server_test.go index 497a5d2d92b..f6c8518a957 100644 --- a/x/incentives/keeper/msg_server_test.go +++ b/x/incentives/keeper/msg_server_test.go @@ -8,7 +8,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - appparams "github.com/osmosis-labs/osmosis/v10/app/params" "github.com/osmosis-labs/osmosis/v10/x/incentives/keeper" "github.com/osmosis-labs/osmosis/v10/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v10/x/lockup/types" @@ -30,36 +29,36 @@ func (suite *KeeperTestSuite) TestCreateGauge_Fee() { }{ { name: "user creates a non-perpetual gauge and fills gauge with all remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(60000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(60000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), }, { name: "user creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(70000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), }, { name: "user with multiple denoms creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), }, { name: "module account creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), isPerpetual: true, isModuleAccount: true, }, { name: "user with multiple denoms creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), isPerpetual: true, }, { name: "user tries to create a non-perpetual gauge but does not have enough funds to pay for the create gauge fee", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(40000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(40000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), expectErr: true, }, { @@ -70,8 +69,8 @@ func (suite *KeeperTestSuite) TestCreateGauge_Fee() { }, { name: "one user tries to create a gauge, has enough funds to pay for the create gauge fee but not enough to fill the gauge", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(60000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(30000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(60000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(30000000))), expectErr: true, }, } @@ -126,7 +125,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, types.CreateGaugeFee)) + fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, types.CreateGaugeFee)) accountBalance := tc.accountBalanceToFund.Sub(tc.gaugeAddition) finalAccountBalance := accountBalance.Sub(fee) suite.Require().Equal(finalAccountBalance.String(), balanceAmount.String(), "test: %v", tc.name) @@ -147,36 +146,36 @@ func (suite *KeeperTestSuite) TestAddToGauge_Fee() { }{ { name: "user creates a non-perpetual gauge and fills gauge with all remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(35000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(35000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), }, { name: "user creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(70000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), }, { name: "user with multiple denoms creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), }, { name: "module account creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), isPerpetual: true, isModuleAccount: true, }, { name: "user with multiple denoms creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), isPerpetual: true, }, { name: "user tries to create a non-perpetual gauge but does not have enough funds to pay for the create gauge fee", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(20000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))), expectErr: true, }, { @@ -210,7 +209,7 @@ func (suite *KeeperTestSuite) TestAddToGauge_Fee() { } // System under test. - coins := sdk.NewCoins(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(500000000))) + coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(500000000))) gaugeID, _, _, _ := suite.SetupNewGauge(true, coins) if tc.nonexistentGauge { gaugeID = incentivesKeeper.GetLastGaugeID(ctx) + 1 @@ -234,7 +233,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, types.AddToGaugeFee)) + fee := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, types.AddToGaugeFee)) accountBalance := tc.accountBalanceToFund.Sub(tc.gaugeAddition) finalAccountBalance := accountBalance.Sub(fee) suite.Require().Equal(finalAccountBalance.String(), bal.String(), "test: %v", tc.name) diff --git a/x/incentives/simulation/operations.go b/x/incentives/simulation/operations.go index 81d4e0854c7..a8d10d2816c 100644 --- a/x/incentives/simulation/operations.go +++ b/x/incentives/simulation/operations.go @@ -18,8 +18,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - appparams "github.com/osmosis-labs/osmosis/v10/app/params" ) // Simulation operation weights constants. @@ -117,7 +115,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(types.CreateGaugeFee) { + if simCoins.AmountOf(sdk.DefaultBondDenom).LT(types.CreateGaugeFee) { return simtypes.NoOpMsg( types.ModuleName, types.TypeMsgCreateGauge, "Account have no coin"), nil, nil } @@ -156,7 +154,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(types.AddToGaugeFee) { + if simCoins.AmountOf(sdk.DefaultBondDenom).LT(types.AddToGaugeFee) { return simtypes.NoOpMsg( types.ModuleName, types.TypeMsgAddToGauge, "Account have no coin"), nil, nil } diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go index 5319039c3fd..c0c04916feb 100644 --- a/x/incentives/types/expected_keepers.go +++ b/x/incentives/types/expected_keepers.go @@ -42,3 +42,8 @@ type EpochKeeper interface { type DistrKeeper interface { FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error } + +// TxFeesKeeper defines the expected interface needed to managing transaction fees. +type TxFeesKeeper interface { + GetBaseDenom(ctx sdk.Context) (denom string, err error) +}