diff --git a/app/app.go b/app/app.go index 32a7271d..17cb6e3c 100644 --- a/app/app.go +++ b/app/app.go @@ -101,7 +101,6 @@ import ( intertx "github.com/cosmos/interchain-accounts/x/inter-tx" intertxkeeper "github.com/cosmos/interchain-accounts/x/inter-tx/keeper" intertxtypes "github.com/cosmos/interchain-accounts/x/inter-tx/types" - okp4types "github.com/okp4/okp4d/pkg/mint" logicmodule "github.com/okp4/okp4d/x/logic" logicmodulekeeper "github.com/okp4/okp4d/x/logic/keeper" logicmoduletypes "github.com/okp4/okp4d/x/logic/types" @@ -647,7 +646,7 @@ func New( groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, okp4types.Okp4InflationCalculationFn), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), @@ -768,7 +767,7 @@ func New( capability.NewAppModule(appCodec, *app.CapabilityKeeper), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, minttypes.DefaultInflationCalculationFn), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), diff --git a/pkg/mint/okp4InflationCalculationFn.go b/pkg/mint/okp4InflationCalculationFn.go deleted file mode 100644 index 97e2ef13..00000000 --- a/pkg/mint/okp4InflationCalculationFn.go +++ /dev/null @@ -1,21 +0,0 @@ -package mint - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - minttypes "github.com/okp4/okp4d/x/mint/types" -) - -var initialInflation = sdk.NewDecWithPrec(75, 3) - -// Okp4InflationCalculationFn is the function used to calculate the inflation for the OKP4 network. -// Inflation is calculated in absolute terms, without taking into account previous inflation, on the basis of the current -// block height, knowing the total number of blocks for one year, using the formula: -// -// Inflation for year X = 0.15 * inflationRateChange^(X-1) -// -// See: https://docs.okp4.network/docs/whitepaper/tokenomics#staking-rewards -func Okp4InflationCalculationFn(ctx sdk.Context, minter minttypes.Minter, params minttypes.Params, _ sdk.Dec) sdk.Dec { - year := uint64(ctx.BlockHeight()) / params.BlocksPerYear - - return initialInflation.Mul(params.InflationRateChange.Power(year)) -} diff --git a/pkg/mint/okp4InflationCalculationFn_test.go b/pkg/mint/okp4InflationCalculationFn_test.go deleted file mode 100644 index 5bcf5451..00000000 --- a/pkg/mint/okp4InflationCalculationFn_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package mint - -import ( - "fmt" - "testing" - - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - minttypes "github.com/okp4/okp4d/x/mint/types" - . "github.com/smartystreets/goconvey/convey" -) - -func TestOkp4InflationCalculationFn(t *testing.T) { - Convey("Considering the Okp4InflationCalculationFn", t, func(c C) { - type args struct { - blockHeight uint64 - blocksPerYear uint64 - inflationRateChange float64 - } - tests := []struct { - name string - args args - want sdk.Dec - }{ - { - name: "Inflation for the first block of the first year", - args: args{ - blockHeight: 0, - blocksPerYear: 10, - inflationRateChange: .8, - }, want: sdk.NewDecWithPrec(75, 3), - }, - { - name: "Inflation for the last block of the first year", - args: args{ - blockHeight: 9, - blocksPerYear: 10, - inflationRateChange: .8, - }, want: sdk.NewDecWithPrec(75, 3), - }, - { - name: "Inflation for the first block of the second year", - args: args{ - blockHeight: 10, - blocksPerYear: 10, - inflationRateChange: .8, - }, want: sdk.NewDecWithPrec(6, 2), - }, - { - name: "Inflation for the second block of the third year", - args: args{ - blockHeight: 21, - blocksPerYear: 10, - inflationRateChange: .8, - }, want: sdk.MustNewDecFromStr("0.048"), - }, - { - name: "Inflation for a block in the 16th year", - args: args{ - blockHeight: 87899401, - blocksPerYear: 5256000, - inflationRateChange: .8, - }, want: sdk.MustNewDecFromStr("0.002111062325329920"), - }, - } - - for i, tt := range tests { - Convey(fmt.Sprintf("Given the context for test case %d (%s)", i, tt.name), func() { - mkey := sdk.NewKVStoreKey(fmt.Sprintf("test-%d", i)) - tkey := sdk.NewTransientStoreKey(fmt.Sprintf("transient_test_%d", i)) - ctx := testutil.DefaultContext(mkey, tkey).WithBlockHeight(int64(tt.args.blockHeight)) - minter := minttypes.DefaultInitialMinter() - params := minttypes.DefaultParams() - params.MintDenom = "uknow" - params.BlocksPerYear = tt.args.blocksPerYear - params.InflationRateChange = sdk.MustNewDecFromStr(fmt.Sprintf("%f", tt.args.inflationRateChange)) - - Convey("When calling testcase", func() { - got := Okp4InflationCalculationFn(ctx, minter, params, sdk.ZeroDec()) - - Convey(fmt.Sprintf("Then result should be '%d'", tt.want), func() { - So(got, ShouldEqual, tt.want) - }) - }) - }) - } - }) -}