keeper

package
v0.1.0-mage.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecondsPerYear = uint64(31536000)
)

this is the same value used in the x/hard

Variables

This section is empty.

Functions

func CalculateInflationRate

func CalculateInflationRate(apy sdk.Dec, secondsPassed uint64) (sdk.Dec, error)

CalculateInflationRate converts an APY into the factor corresponding with that APY's accumulation over a period of secondsPassed seconds.

Types

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper of the magemint store

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
	sk types.StakingKeeper, ak types.AccountKeeper, bk types.BankKeeper,
	stakingRewardsFeeCollectorName string, communityPoolModuleAccountName string,
) Keeper

NewKeeper creates a new magemint Keeper instance

func (Keeper) AccumulateInflation

func (k Keeper) AccumulateInflation(
	ctx sdk.Context,
	rate sdk.Dec,
	basis sdk.Int,
	secondsSinceLastMint float64,
) (sdk.Coins, error)

AccumulateInflation calculates the number of coins that should be minted to match a yearly `rate` for interest compounded each second of the year over `secondsSinceLastMint` seconds. `basis` is the base amount of coins that is inflated.

func (Keeper) AddCollectedFees

func (k Keeper) AddCollectedFees(ctx sdk.Context, fees sdk.Coins) error

AddCollectedFees implements an alias call to the underlying supply keeper's AddCollectedFees to be used in BeginBlocker.

func (Keeper) BondDenom

func (k Keeper) BondDenom(ctx sdk.Context) string

BondDenom implements an alias call to the underlying staking keeper's BondDenom.

func (Keeper) CumulativeInflation

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

func (Keeper) FundCommunityPool

func (k Keeper) FundCommunityPool(ctx sdk.Context, funds sdk.Coins) error

FundCommunityPool implements an alias call to the underlying supply keeper's FundCommunityPool to be used in BeginBlocker.

func (Keeper) GetParams

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

GetParams returns the total set of minting parameters.

func (Keeper) GetPreviousBlockTime

func (k Keeper) GetPreviousBlockTime(ctx sdk.Context) (blockTime time.Time)

GetPreviousBlockTime get the blocktime for the previous block

func (Keeper) GetStakingApy

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

GetStakingApy returns the APY minted for staking rewards

func (Keeper) Inflation

Inflation returns minter.Inflation of the mint module.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MintCoins

func (k Keeper) MintCoins(ctx sdk.Context, newCoins sdk.Coins) error

MintCoins implements an alias call to the underlying supply keeper's MintCoins to be used in BeginBlocker.

func (Keeper) Params

Params returns params of the mint module.

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the total set of minting parameters.

func (Keeper) SetPreviousBlockTime

func (k Keeper) SetPreviousBlockTime(ctx sdk.Context, blockTime time.Time)

SetPreviousBlockTime set the time of the previous block

func (Keeper) TotalBondedTokens

func (k Keeper) TotalBondedTokens(ctx sdk.Context) sdk.Int

TotalBondedTokens implements an alias call to the underlying staking keeper's TotalBondedTokens to be used in BeginBlocker.

func (Keeper) TotalSupply

func (k Keeper) TotalSupply(ctx sdk.Context) sdk.Int

TotalSupply implements an alias call to the underlying supply keeper's GetSupply for the mint denom to be used in calculating cumulative inflation.

type KeeperI

type KeeperI interface {
	GetParams(ctx sdk.Context) (params types.Params)
	SetParams(ctx sdk.Context, params types.Params)

	BondDenom(ctx sdk.Context) string
	TotalSupply(ctx sdk.Context) sdk.Int
	TotalBondedTokens(ctx sdk.Context) sdk.Int

	MintCoins(ctx sdk.Context, newCoins sdk.Coins) error
	AddCollectedFees(ctx sdk.Context, fees sdk.Coins) error
	FundCommunityPool(ctx sdk.Context, funds sdk.Coins) error

	GetPreviousBlockTime(ctx sdk.Context) (blockTime time.Time)
	SetPreviousBlockTime(ctx sdk.Context, blockTime time.Time)

	CumulativeInflation(ctx sdk.Context) sdk.Dec
	AccumulateInflation(
		ctx sdk.Context,
		rate sdk.Dec,
		basis sdk.Int,
		secondsSinceLastMint float64,
	) (sdk.Coins, error)
}

type MintQueryServer

type MintQueryServer struct {
	// contains filtered or unexported fields
}

MintQueryServer implements cosmos sdk's x/mint querier. x/mint was removed from mage, but the standard inflation endpoint is still registered for easier third party integration and backwards compatibility.

func NewMintQueryServer

func NewMintQueryServer(magemintKeeper Keeper) MintQueryServer

NewMintQueryServer returns a service that implements x/mint's QueryServer

func (MintQueryServer) AnnualProvisions

AnnualProvisions is not implemented.

func (MintQueryServer) Inflation

Inflation returns an adjusted inflation rate. The `/cosmos/mint/v1beta1/inflation` endpoint is used by third parties to calculate staking APY. The usual staking APY calculation takes the inflation and determines the portion of it devoted to staking rewards after adjusting for the bonded ratio and x/distribution community_tax. staking_apy = (inflation - community_tax) * total_supply / total_bonded Staking APY is not set directly via the x/magemint staking_rewards_apy param. This endpoint returns the inflation that makes the above calculation equal to the param: inflation = staking_apy * total_bonded / total_supply NOTE: assumes x/distribution community_tax = 0

func (MintQueryServer) Params

Params is not implemented. There is no mint module.

Jump to

Keyboard shortcuts

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