Documentation ¶
Index ¶
- Constants
- Variables
- func BeginBlocker(ctx sdk.Context, k Keeper)
- func GetMineToken(curBlkHeight int64, totalSupply sdk.Int, curAmplitude int64, curCycle int64, ...) (sdk.Dec, sdk.Dec, sdk.Dec)
- func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
- func NewQuerier(k Keeper) sdk.Querier
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type FeeCollectionKeeper
- type GenesisState
- type Keeper
- func (k Keeper) GetMinter(ctx sdk.Context) (minter Minter)
- func (k Keeper) GetParamSet(ctx sdk.Context) Params
- func (k Keeper) GetParams(ctx sdk.Context) Params
- func (k Keeper) SetMinter(ctx sdk.Context, minter Minter)
- func (k Keeper) SetParamSet(ctx sdk.Context, params Params)
- func (k Keeper) SetParams(ctx sdk.Context, params Params)
- type Minter
- type Params
- type StakingKeeper
Constants ¶
const ( BlkTime = 5 AvgDaysPerMonth = 30 DayinSecond = 24 * 3600 AvgBlksPerMonth = AvgDaysPerMonth * DayinSecond / BlkTime Period = AvgBlksPerMonth TotalMinableBlks = 40 * 12 * AvgBlksPerMonth BlkRadianIntv = 2.0 * math.Pi / float64(Period) MonthProvisions = float64(75000) // 75000 per month AnnualProvisions = 12 * MonthProvisions // 900000 per year TotalProvisions = 40 * AnnualProvisions // 36,000,000 for 40 years CurrentProvisions = float64(60000000) // 60,000,000 at genesis CurrentProvisionsAsSatoshi = int64(CurrentProvisions * htdf2satoshi) // 60,000,000 at genesis TotalLiquid = TotalProvisions + CurrentProvisions // 96,000,000 TotalLiquidAsSatoshi = int64(TotalLiquid * htdf2satoshi) // 96,000,000 * 100,000,000 // junying-todo, 2019-12-05 AvgBlkReward = MonthProvisions / AvgBlksPerMonth AvgBlkRewardAsSatoshi = htdf2satoshi * AvgBlkReward RATIO = 0.5 // junying-todo, 2019-12-06 MAX_AMPLITUDE = AvgBlkReward MIN_AMPLITUDE = 0.001 MAX_CYCLE = 3000 MIN_CYCLE = 100 )
const ( // ModuleName is the name of the module ModuleName = "minting" // default paramspace for params keeper DefaultParamspace = "mint" // StoreKey is the default store key for mint StoreKey = "mint" // QuerierRoute is the querier route for the minting store. QuerierRoute = StoreKey )
const ( QueryParameters = "parameters" QueryInflation = "inflation" QueryAnnualProvisions = "annual_provisions" )
Query endpoints supported by the minting querier
Variables ¶
var ( // params store for inflation params ParamStoreKeyParams = []byte("params") )
Functions ¶
func BeginBlocker ¶
Inflate every block, update inflation parameters once per hour
func GetMineToken ¶ added in v0.2.0
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
new mint genesis
func NewQuerier ¶
NewQuerier returns a minting Querier handler.
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the provided genesis state to ensure the expected invariants holds.
Types ¶
type FeeCollectionKeeper ¶
expected fee collection keeper interface
type GenesisState ¶
type GenesisState struct { Minter Minter `json:"minter"` // minter object Params Params `json:"params"` // inflation params }
GenesisState - minter state
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState creates a default GenesisState object
func ExportGenesis ¶
func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState
ExportGenesis returns a GenesisState for a given context and keeper.
func NewGenesisState ¶
func NewGenesisState(minter Minter, params Params) GenesisState
NewGenesisState creates a new GenesisState object
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
keeper of the staking store
func NewKeeper ¶
func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace, sk StakingKeeper, fck FeeCollectionKeeper) Keeper
func (Keeper) GetParamSet ¶
get inflation params from the global param store
func (Keeper) SetParamSet ¶
set inflation params from the global param store
type Minter ¶
type Minter struct { Inflation sdk.Dec `json:"inflation"` // current annual inflation rate AnnualProvisions sdk.Dec `json:"annual_provisions"` // current annual expected provisions }
Minter represents the minting state.
func DefaultInitialMinter ¶
func DefaultInitialMinter() Minter
DefaultInitialMinter returns a default initial Minter object for a new chain which uses an inflation rate of 13%.
func InitialMinter ¶
InitialMinter returns an initial Minter object with a given inflation value.
func NewMinter ¶
NewMinter returns a new Minter object with the given inflation and annual provisions values.
func (Minter) BlockProvision ¶
BlockProvision returns the provisions for a block based on the annual provisions rate.
func (Minter) NextAnnualProvisions ¶
NextAnnualProvisions returns the annual provisions based on current total supply and inflation rate.
type Params ¶
type Params struct { MintDenom string `json:"mint_denom"` // type of coin to mint InflationRateChange sdk.Dec `json:"inflation_rate_change"` // maximum annual change in inflation rate InflationMax sdk.Dec `json:"inflation_max"` // maximum inflation rate InflationMin sdk.Dec `json:"inflation_min"` // minimum inflation rate GoalBonded sdk.Dec `json:"goal_bonded"` // goal of percent bonded atoms BlocksPerYear uint64 `json:"blocks_per_year"` // expected blocks per year }
mint parameters
func (*Params) GetParamSpace ¶
Implements params.ParamStruct
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
func (*Params) StringFromBytes ¶
type StakingKeeper ¶
type StakingKeeper interface { TotalTokens(ctx sdk.Context) sdk.Int BondedRatio(ctx sdk.Context) sdk.Dec InflateSupply(ctx sdk.Context, newTokens sdk.Int) // junying-todo, 2019-12-06 Amplitude(ctx sdk.Context) int64 Cycle(ctx sdk.Context) int64 LastIndex(ctx sdk.Context) int64 SetAmplitude(ctx sdk.Context, amp int64) SetCycle(ctx sdk.Context, cycle int64) SetLastIndex(ctx sdk.Context, index int64) }
expected staking keeper