diff --git a/x/incentives/keeper/msg_server_test.go b/x/incentives/keeper/msg_server_test.go index 577d344ce..90fe903e5 100644 --- a/x/incentives/keeper/msg_server_test.go +++ b/x/incentives/keeper/msg_server_test.go @@ -29,103 +29,103 @@ func (suite *KeeperTestSuite) TestCreateGauge() { }{ { name: "user creates a non-perpetual gauge and fills gauge with all remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(60)))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(6)))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))), }, { name: "user creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(70)))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(7)))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))), }, { name: "user with multiple denoms creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(70))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(7))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(7)))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))), }, { - name: "user tries to create a non-perpetual gauge but includes too many denoms so does not have enough funds to pay fees", + name: "user tries to create a non-perpetual gauge but includes too many denoms so does not have enough funds to pay fees - 1", accountBalanceToFund: sdk.NewCoins( - sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(40))), // 40 >= 20 (adym) + 10 (creation fee) + 10 (for every denom) = 40 - sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(20))), + sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(40))), // 40 >= 2 (adym) + 1 (creation fee) + 1 (for every denom) = 4 + sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(2))), ), gaugeAddition: sdk.NewCoins( - sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(20))), + sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(2))), ), }, { name: "module account creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(70))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(7))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))), 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("stake", types.DYM.Mul(sdk.NewInt(70))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(10)))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(7))), sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(70)))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))), 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("stake", types.DYM.Mul(sdk.NewInt(5)))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(1)))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(5))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1))), expectErr: true, }, { name: "user tries to create a non-perpetual gauge but does not have the correct fee denom", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(60)))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(10)))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(6)))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("foo", types.DYM.Mul(sdk.NewInt(1)))), expectErr: true, }, { - name: "user tries to create a non-perpetual gauge but includes too many denoms so does not have enough funds to pay fees", + name: "user tries to create a non-perpetual gauge but includes too many denoms so does not have enough funds to pay fees - 2", accountBalanceToFund: sdk.NewCoins( - sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(39))), // 39 < 20 (adym) + 10 (creation fee) + 10 (for every denom) = 40 - sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(20))), + sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(3))), // 3 < 2 (adym) + 1 (creation fee) + 1 (for every denom) = 4 + sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(2))), ), gaugeAddition: sdk.NewCoins( - sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(20))), - sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(20))), + sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("osmo", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("atom", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("abcd", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("efgh", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("igkl", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("mnop", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("qrst", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("uvwx", types.DYM.Mul(sdk.NewInt(2))), + sdk.NewCoin("yzzz", types.DYM.Mul(sdk.NewInt(2))), ), expectErr: true, }, { 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("stake", types.DYM.Mul(sdk.NewInt(20)))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(30)))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(2)))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("stake", types.DYM.Mul(sdk.NewInt(3)))), expectErr: true, }, } diff --git a/x/incentives/types/constants.go b/x/incentives/types/constants.go index 8cdda02a4..fbd407d6d 100644 --- a/x/incentives/types/constants.go +++ b/x/incentives/types/constants.go @@ -6,7 +6,7 @@ var ( // DYM represents 1 DYM DYM = math.NewIntWithDecimal(1, 18) - DefaultCreateGaugeFee = DYM.MulRaw(1) // 10 DYM + DefaultCreateGaugeFee = DYM.MulRaw(1) // 1 DYM DefaultAddToGaugeFee = math.ZeroInt() // 0 DYM DefaultAddDenomFee = DYM // 1 DYM )