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

Feat: Provider Rewards to Zero #358

Merged
merged 2 commits into from
Jul 6, 2023
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
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ func NewJackalApp(
)

app.mm.SetOrderEndBlockers(
upgradetypes.ModuleName,
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
Expand All @@ -809,7 +810,6 @@ func NewJackalApp(
authz.ModuleName,
feegrant.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
// additional non simd modules
ibctransfertypes.ModuleName,
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v210/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (u *Upgrade) Name() string {
// Handler implements upgrades.Upgrade
func (u *Upgrade) Handler() upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
fromVM[mintmoduletypes.ModuleName] = 3
fromVM[mintmoduletypes.ModuleName] = 2

newVM, err := u.mm.RunMigrations(ctx, u.configurator, fromVM)
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions x/jklmint/keeper/mint.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import (
)

func (k Keeper) BlockMint(ctx sdk.Context) {
mintTokens := sdk.NewDec(6_000_000)
tokensPerBlock := k.GetParams(ctx).TokensPerBlock

mintTokens := sdk.NewDec(tokensPerBlock * 1_000_000)
denom := k.GetParams(ctx).MintDenom

providerRatio := sdk.NewDec(4)
pRatio := k.GetParams(ctx).ProviderRatio
valRatio := 10 - pRatio

providerRatio := sdk.NewDec(pRatio)
providerRatio = providerRatio.QuoInt64(10)
validatorRatio := sdk.NewDec(6)
validatorRatio := sdk.NewDec(valRatio)
validatorRatio = validatorRatio.QuoInt64(10)

// get correct ratio
Expand Down
41 changes: 41 additions & 0 deletions x/jklmint/keeper/mint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,44 @@ func (suite *MintTestSuite) TestBlockMint() {
suite.Require().Equal(sdk.NewInt(6_000_000), supplyAfter.Supply.AmountOf(denom))
// After BlockMint we now have exactly 3.6JKL in the fee collector account
}

func (suite *MintTestSuite) TestNoProviderBlockMint() {
suite.SetupTest()
app, ctx, k := suite.app, suite.ctx, suite.app.MintKeeper

params := k.GetParams(ctx)
params.ProviderRatio = 0
k.SetParams(ctx, params)

denom := k.GetParams(ctx).MintDenom

pr := k.GetParams(ctx).ProviderRatio
suite.Require().Equal(int64(0), pr)

feeAccount := app.AccountKeeper.GetModuleAccount(ctx, authtypes.FeeCollectorName)
feeBalanceBefore, err := app.BankKeeper.Balance(sdk.WrapSDKContext(ctx), &types.QueryBalanceRequest{
Address: feeAccount.GetAddress().String(),
Denom: denom,
})
suite.Require().NoError(err)
suite.Require().Equal(sdk.ZeroInt(), feeBalanceBefore.Balance.Amount)
supplyBefore, err := app.BankKeeper.TotalSupply(sdk.WrapSDKContext(ctx), &types.QueryTotalSupplyRequest{})
suite.Require().NoError(err)
suite.Require().True(supplyBefore.Supply.Empty())
// We have now proved we started with nothing

k.BlockMint(ctx)

feeBalanceAfter, err := app.BankKeeper.Balance(sdk.WrapSDKContext(ctx), &types.QueryBalanceRequest{
Address: feeAccount.GetAddress().String(),
Denom: denom,
})

suite.Require().NoError(err)
suite.Require().Equal(sdk.NewInt(6_000_000), feeBalanceAfter.Balance.Amount)
supplyAfter, err := app.BankKeeper.TotalSupply(sdk.WrapSDKContext(ctx), &types.QueryTotalSupplyRequest{})
suite.Require().NoError(err)
suite.Require().Equal(1, len(supplyAfter.Supply))
suite.Require().Equal(sdk.NewInt(6_000_000), supplyAfter.Supply.AmountOf(denom))
// After BlockMint we now have exactly 3.6JKL in the fee collector account
}
2 changes: 2 additions & 0 deletions x/jklmint/legacy/v210/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func MigrateStore(ctx sdk.Context, paramsSubspace *paramstypes.Subspace) error {
// Set the module params
params := types.DefaultParams()

params.ProviderRatio = 0

paramsSubspace.SetParamSet(ctx, &params)

return nil
Expand Down
4 changes: 2 additions & 2 deletions x/jklmint/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
}

// Validate validates the set of params
func (p Params) Validate() error {
func (p *Params) Validate() error {
err := validateMintDenom(p.MintDenom)
if err != nil {
return err
Expand All @@ -76,7 +76,7 @@ func (p Params) Validate() error {
}

// String implements the Stringer interface.
func (p Params) String() string {
func (p *Params) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}
Expand Down
4 changes: 2 additions & 2 deletions x/storage/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ func validatePricePerTbPerMonth(i interface{}) error {
}

// Validate validates the set of params
func (p Params) Validate() error {
func (p *Params) Validate() error {
return nil
}

// String implements the Stringer interface.
func (p Params) String() string {
func (p *Params) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}