Skip to content

Commit

Permalink
Added new inflation rates
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Dec 9, 2022
1 parent 6f13e69 commit 29d4099
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 24 deletions.
1 change: 1 addition & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ func NewApp(
app.keys[paramstypes.ModuleName],
app.accountKeeper,
app.bankKeeper,
app.customMintKeeper,
app.mintKeeper,
app.stakingKeeper,
app.vpnKeeper,
Expand Down
48 changes: 44 additions & 4 deletions upgrades/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,25 @@ import (
ibcicatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"

hubutils "github.com/sentinel-official/hub/utils"
custommintkeeper "github.com/sentinel-official/hub/x/mint/keeper"
customminttypes "github.com/sentinel-official/hub/x/mint/types"
nodetypes "github.com/sentinel-official/hub/x/node/types"
providertypes "github.com/sentinel-official/hub/x/provider/types"
vpnkeeper "github.com/sentinel-official/hub/x/vpn/keeper"
)

func Handler(mm *module.Manager, configurator module.Configurator, paramsStoreKey sdk.StoreKey,
ak authkeeper.AccountKeeper, bk bankkeeper.Keeper, mk mintkeeper.Keeper,
sk stakingkeeper.Keeper, vk vpnkeeper.Keeper, wk wasmkeeper.Keeper) upgradetypes.UpgradeHandler {
func Handler(
mm *module.Manager,
configurator module.Configurator,
paramsStoreKey sdk.StoreKey,
ak authkeeper.AccountKeeper,
bk bankkeeper.Keeper,
cmk custommintkeeper.Keeper,
mk mintkeeper.Keeper,
sk stakingkeeper.Keeper,
vk vpnkeeper.Keeper,
wk wasmkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
var (
controllerParams = ibcicacontrollertypes.Params{}
Expand Down Expand Up @@ -141,6 +152,35 @@ func Handler(mm *module.Manager, configurator module.Configurator, paramsStoreKe
}
}

cmk.IterateInflations(ctx, func(_ int, item customminttypes.Inflation) (stop bool) {
cmk.DeleteInflation(ctx, item.Timestamp)
return false
})

inflations := []customminttypes.Inflation{
{
Max: sdk.NewDecWithPrec(37, 2),
Min: sdk.NewDecWithPrec(25, 2),
RateChange: sdk.NewDecWithPrec(12, 2),
Timestamp: time.Date(2022, 9, 27, 12, 0, 0, 0, time.UTC),
},
{
Max: sdk.NewDecWithPrec(25, 2),
Min: sdk.NewDecWithPrec(13, 2),
RateChange: sdk.NewDecWithPrec(12, 2),
Timestamp: time.Date(2023, 3, 27, 12, 0, 0, 0, time.UTC),
},
}

for _, inflation := range inflations {
if err := inflation.Validate(); err != nil {
return nil, err
}
}
for _, inflation := range inflations {
cmk.SetInflation(ctx, inflation)
}

return newVM, nil
}
}
Expand Down Expand Up @@ -206,7 +246,7 @@ func createContinuousVestingAccountFromBaseAccount(
)
)

fmt.Println(address.String(), balances, bonded, unbonding, delegation, total, bonus)
ctx.Logger().Info("creating a continuous vesting account", "address", address, "total", total, "bonus", bonus)

if bonus.IsPositive() {
if err := mk.MintCoins(ctx, sdk.NewCoins(bonus)); err != nil {
Expand Down
23 changes: 3 additions & 20 deletions x/mint/abci.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
package mint

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
abcitypes "github.com/tendermint/tendermint/abci/types"

"github.com/sentinel-official/hub/x/mint/keeper"
"github.com/sentinel-official/hub/x/mint/types"
)

const (
fix1Height = 2_642_500
)

func BeginBlock(ctx sdk.Context, k keeper.Keeper) []abcitypes.ValidatorUpdate {
if ctx.BlockHeight() == fix1Height {
k.SetInflation(ctx, types.Inflation{
Max: sdk.NewDecWithPrec(49, 2),
Min: sdk.NewDecWithPrec(43, 2),
RateChange: sdk.NewDecWithPrec(6, 2),
Timestamp: time.Date(2021, 9, 27, 12, 0, 0, 0, time.UTC),
})
}

k.IterateInflations(ctx, func(_ int, inflation types.Inflation) bool {
if inflation.Timestamp.After(ctx.BlockTime()) {
return true
Expand All @@ -35,11 +20,9 @@ func BeginBlock(ctx sdk.Context, k keeper.Keeper) []abcitypes.ValidatorUpdate {
params.InflationRateChange = inflation.RateChange
k.SetParams(ctx, params)

if ctx.BlockHeight() >= fix1Height {
minter := k.GetMinter(ctx)
minter.Inflation = inflation.Min
k.SetMinter(ctx, minter)
}
minter := k.GetMinter(ctx)
minter.Inflation = inflation.Min
k.SetMinter(ctx, minter)

k.DeleteInflation(ctx, inflation.Timestamp)
return false
Expand Down

0 comments on commit 29d4099

Please sign in to comment.