keeper

package
v1.5.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeInflationParams added in v1.2.0

func MergeInflationParams(
	partial inflationtypes.MsgEditInflationParams,
	inflationParams inflationtypes.Params,
) (inflationtypes.Params, error)

MergeInflationParams: Performs a partial struct update using [partial] and merges its params into the existing [inflationParams], keeping any existing values that are not set in the partial. For use with [Keeper.EditInflationParams].

func NewMsgServerImpl added in v1.2.0

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the inflation MsgServer interface for the provided Keeper.

func NewQuerier added in v1.2.0

func NewQuerier(keeper Keeper) types.QueryServer

NewQuerier returns an implementation of the types.QueryServer interface for the provided Keeper.

Types

type Hooks

type Hooks struct {
	K Keeper
}

Hooks implements module-specific calls (epochstypes.EpochHooks) that will occur at the end of every epoch. Hooks is meant for use with with `EpochsKeeper.SetHooks`. These functions run outside of the normal body of transactions.

func (Hooks) AfterEpochEnd

func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber uint64)

AfterEpochEnd is a hook that runs just prior to the first block whose timestamp is after the end of an epoch duration. AfterEpochEnd mints and allocates coins at the end of each epoch. If inflation is disabled as a module parameter, the state for "NumSkippedEpochs" increments.

func (Hooks) BeforeEpochStart

func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber uint64)

BeforeEpochStart is a hook that runs just prior to the start of a new epoch.

type Keeper

type Keeper struct {

	// CurrentPeriod: Strictly increasing counter for the inflation "period".
	CurrentPeriod collections.Sequence

	// NumSkippedEpochs: Strictly increasing counter for the number of skipped
	// epochs. Inflation epochs are skipped when [types.Params.InflationEnabled]
	// is false so that gaps in the active status of inflation don't mess up the
	// polynomial computation. It allows inflation to smoothly be toggled on and
	// off.
	NumSkippedEpochs collections.Sequence

	// Params stores module-specific parameters that specify the blockchain token
	// economics, token release schedule, maximum supply, and whether or not
	// inflation is enabled on the network.
	Params collections.Item[types.Params]
	// contains filtered or unexported fields
}

Keeper of the inflation module. Keepers are module-specific "gate keepers" responsible for encapsulating access to the key-value stores (state) of the network. The functions on the Keeper contain all of the business logic for reading and modifying state.

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey storetypes.StoreKey,
	paramspace paramstypes.Subspace,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	distributionKeeper types.DistrKeeper,
	stakingKeeper types.StakingKeeper,
	sudoKeeper types.SudoKeeper,
	feeCollectorName string,
) Keeper

NewKeeper creates a new mint Keeper instance

func (Keeper) AllocatePolynomialInflation added in v1.1.0

func (k Keeper) AllocatePolynomialInflation(
	ctx sdk.Context,
	mintedCoin sdk.Coin,
	params types.Params,
) (
	staking, strategic, community sdk.Coin,
	err error,
)

AllocatePolynomialInflation allocates coins from the inflation to external modules according to proportions proportions:

Returns:

  • staking: Tokens minted for staking inflation that go to the decentralized validator set and delegators. This is handled by the `auth` module fee collector.
  • strategic: Tokens minted to the Strategic Reserve, the root account fo the x/sudo module.
  • community: Tokens minted to the Community Pool, which is managed strictly by on-chain governance.

func (Keeper) CirculatingSupply

CirculatingSupply returns the total supply in circulation excluding the team allocation in the first year

func (Keeper) EpochMintProvision

EpochMintProvision returns the EpochMintProvision of the inflation module.

func (Keeper) GetCirculatingSupply

func (k Keeper) GetCirculatingSupply(ctx sdk.Context, mintDenom string) sdkmath.Int

GetCirculatingSupply returns the bank supply of the mintDenom excluding the team allocation in the first year

func (Keeper) GetEpochMintProvision

func (k Keeper) GetEpochMintProvision(ctx sdk.Context) sdk.Dec

GetEpochMintProvision retrieves necessary params KV storage and calculate EpochMintProvision

func (Keeper) GetEpochsPerPeriod added in v1.2.0

func (k Keeper) GetEpochsPerPeriod(ctx sdk.Context) (res uint64)

func (Keeper) GetInflationDistribution added in v1.2.0

func (k Keeper) GetInflationDistribution(ctx sdk.Context) (res types.InflationDistribution)

func (Keeper) GetInflationEnabled added in v1.2.0

func (k Keeper) GetInflationEnabled(ctx sdk.Context) (res bool)

func (Keeper) GetInflationRate

func (k Keeper) GetInflationRate(ctx sdk.Context, mintDenom string) sdk.Dec

GetInflationRate returns the inflation rate for the current period.

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) types.Params

func (Keeper) GetPeriodsPerYear added in v1.2.0

func (k Keeper) GetPeriodsPerYear(ctx sdk.Context) (res uint64)

func (Keeper) GetPolynomialFactors added in v1.2.0

func (k Keeper) GetPolynomialFactors(ctx sdk.Context) (res []sdk.Dec)

func (Keeper) GetProportions

func (k Keeper) GetProportions(
	_ sdk.Context,
	coin sdk.Coin,
	proportion sdk.Dec,
) sdk.Coin

GetAllocationProportion calculates the proportion of coins that is to be allocated during inflation for a given distribution.

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Hooks implements module-speecific calls that will occur in the ABCI BeginBlock logic.

func (Keeper) InflationRate

InflationRate returns the inflation rate for the current period.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) MintAndAllocateInflation

func (k Keeper) MintAndAllocateInflation(
	ctx sdk.Context,
	coins sdk.Coin,
	params types.Params,
) (
	staking, strategic, community sdk.Coin,
	err error,
)

MintAndAllocateInflation mints and allocates tokens based on the polynomial inflation coefficients and current block height.

Args:

  • coins: Tokens to be minted.
  • params:

Returns:

  • staking: Tokens minted for staking inflation that go to the decentralized validator set and delegators. This is handled by the `auth` module fee collector.
  • strategic: Tokens minted to the Strategic Reserve, the root account fo the x/sudo module.
  • community: Tokens minted to the Community Pool, which is managed strictly by on-chain governance.

func (Keeper) MintCoins

func (k Keeper) MintCoins(ctx sdk.Context, coin sdk.Coin) error

MintCoins calls the underlying [BankKeeper] mints tokens "coin".

func (Keeper) Period

Period returns the current period of the inflation module.

func (Keeper) SkippedEpochs

SkippedEpochs returns the number of skipped Epochs of the inflation module.

func (Keeper) Sudo added in v1.2.0

func (k Keeper) Sudo() sudoExtension

Sudo extends the Keeper with sudo functions. See x/sudo.

These sudo functions should: 1. Not be called in other methods in the module. 2. Only be callable by the x/sudo root or sudo contracts.

The intention behind "Keeper.Sudo" is to make it more obvious to the developer that an unsafe function is being used when it's called. x/sudo: https://pkg.go.dev/github.com/NibiruChain/nibiru@v1.1.0/x/sudo/keeper

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL