mint

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlkTime             = 5
	AvgDaysPerMonth     = 30
	DayinSecond         = 24 * 3600
	AvgBlksPerMonth     = AvgDaysPerMonth * DayinSecond / BlkTime
	Period              = AvgBlksPerMonth
	DefaultMineableBlks = 40 * 12 * AvgBlksPerMonth // 40 years mining
	TestMineableBlks    = 2 * 3600 / BlkTime        // 2 hours mining
	TotalMineableBlks   = DefaultMineableBlks
	BlkRadianIntv       = 2.0 * math.Pi / float64(Period)

	ValidatorNumbers    = 7          // the number of validators
	ValidatorProvisions = float64(1) // 1 for each validator
	// Ignore validaotorProvisin because it is set as small as enough to be neglected.
	// if you want to set it bigger as your , you should care about this part again.
	// Including this part will decrease interoperability of the source code.
	// ValidatorTotalProvisions = ValidatorProvisions * ValidatorNumbers // 1 for each validator
	ValidatorTotalProvisions = 0

	// IssuerAmount = float64(1000000) // this is for test. 0 for production, 1000000 for test
	IssuerAmount = 0 // 0 for production

	FixedMineProvision       = float64(36000000)
	MineTotalProvisions      = FixedMineProvision - ValidatorTotalProvisions - IssuerAmount // ~36,000,000 for 40 years
	AnnualProvisions         = MineTotalProvisions / 40.0                                   // ~900000 per year
	AnnualProvisionAsSatoshi = int64(AnnualProvisions * htdf2satoshi)
	MonthProvisions          = AnnualProvisions / 12.0 // ~75000 per month

	// this is for export case,that's,this is activated if there exporting accounts exist.
	UserProvisions = float64(60000000) // if not, this should be set as zero

	CurrentProvisions          = UserProvisions + ValidatorTotalProvisions + IssuerAmount // ~60,000,000 at genesis
	CurrentProvisionsAsSatoshi = int64(CurrentProvisions * htdf2satoshi)                  // ~60,000,000 at genesis
	TotalLiquid                = MineTotalProvisions + CurrentProvisions                  // 96,000,000
	TotalLiquidAsSatoshi       = int64(TotalLiquid * htdf2satoshi)                        // 96,000,000 * 100,000,000

	// junying-todo, 2019-12-05
	AvgBlkReward          = MineTotalProvisions / TotalMineableBlks
	AvgBlkRewardAsSatoshi = htdf2satoshi * AvgBlkReward
	RATIO                 = 0.5
	// junying-todo, 2019-12-06
	MAX_AMPLITUDE = AvgBlkReward
	MIN_AMPLITUDE = 0.001
	MAX_CYCLE     = 3000
	MIN_CYCLE     = 100
)
View Source
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
)
View Source
const (
	QueryParameters       = "parameters"
	QueryInflation        = "inflation"
	QueryAnnualProvisions = "annual_provisions"
	QueryBlockRewards     = "rewards"
	QueryTotalProvisions  = "total_provisions"
)

Query endpoints supported by the minting querier

Variables

View Source
var (

	// params store for inflation params
	ParamStoreKeyParams = []byte("params")
)

Functions

func BeginBlocker

func BeginBlocker(ctx sdk.Context, k Keeper)

Inflate every block, update inflation parameters once per hour

func BytesToInt64 added in v1.0.0

func BytesToInt64(buf []byte) int64

func GetMineToken added in v0.2.0

func GetMineToken(curBlkHeight int64, totalSupply sdk.Int, curAmplitude int64, curCycle int64, curLastIndex int64) (sdk.Dec, sdk.Dec, sdk.Dec)

GetMineToken...

func InitGenesis

func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)

new mint genesis

func Int64ToBytes added in v1.0.0

func Int64ToBytes(i int64) []byte

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

NewQuerier returns a minting Querier handler.

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamTable for staking module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the provided genesis state to ensure the expected invariants holds.

Types

type BlockReward added in v1.1.0

type BlockReward struct {
	Reward int64
}

This is for block-reward query inferencing(cmd & rest)

func NewBlockReward added in v1.1.0

func NewBlockReward(r int64) BlockReward

func (BlockReward) String added in v1.1.0

func (br BlockReward) String() string

type FeeCollectionKeeper

type FeeCollectionKeeper interface {
	AddCollectedFees(sdk.Context, sdk.Coins) sdk.Coins
}

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) GetMinter

func (k Keeper) GetMinter(ctx sdk.Context) (minter Minter)

get the minter

func (Keeper) GetParamSet

func (k Keeper) GetParamSet(ctx sdk.Context) Params

get inflation params from the global param store

func (Keeper) GetParams

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

get inflation params from the global param store

func (Keeper) GetReward added in v1.0.0

func (k Keeper) GetReward(ctx sdk.Context, blkheight int64) int64

junying-todo, 2020-02-04 get the block rewards

func (Keeper) SetMinter

func (k Keeper) SetMinter(ctx sdk.Context, minter Minter)

set the minter

func (Keeper) SetParamSet

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

set inflation params from the global param store

func (Keeper) SetParams

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

set inflation params from the global param store

func (Keeper) SetReward added in v1.0.0

func (k Keeper) SetReward(ctx sdk.Context, blkheight int64, reward int64)

set the block reward

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

func InitialMinter(inflation sdk.Dec) Minter

InitialMinter returns an initial Minter object with a given inflation value.

func NewMinter

func NewMinter(inflation, annualProvisions sdk.Dec) Minter

NewMinter returns a new Minter object with the given inflation and annual provisions values.

func (Minter) BlockProvision

func (m Minter) BlockProvision(params Params) sdk.Coin

BlockProvision returns the provisions for a block based on the annual provisions rate.

func (Minter) NextAnnualProvisions

func (m Minter) NextAnnualProvisions(_ Params, totalSupply sdk.Int) sdk.Dec

NextAnnualProvisions returns the annual provisions based on current total supply and inflation rate.

func (Minter) NextInflationRate

func (m Minter) NextInflationRate(params Params, bondedRatio sdk.Dec) sdk.Dec

NextInflationRate returns the new inflation rate for the next hour.

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 DefaultParams

func DefaultParams() Params

default minting module parameters

func NewParams

func NewParams(mintDenom string, inflationRateChange, inflationMax,
	inflationMin, goalBonded sdk.Dec, blocksPerYear uint64) Params

func (*Params) GetParamSpace

func (p *Params) GetParamSpace() string

Implements params.ParamStruct

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

func (Params) String

func (p Params) String() string

func (*Params) StringFromBytes

func (p *Params) StringFromBytes(cdc *codec.Codec, key string, bytes []byte) (string, error)

func (*Params) Validate

func (p *Params) Validate(key string, value string) (interface{}, sdk.Error)

type QueryBlockRewardParams added in v1.0.0

type QueryBlockRewardParams struct {
	Height int64
}

defines the params for query: "custom/mint/rewards"

func NewQueryBlockRewardParams added in v1.0.0

func NewQueryBlockRewardParams(h int64) QueryBlockRewardParams

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

type TotalProvisions

type TotalProvisions struct {
	Provision sdk.Int
}

This is for block-reward query inferencing(cmd & rest)

func NewTotalProvisions added in v1.1.0

func NewTotalProvisions(p sdk.Int) TotalProvisions

func (TotalProvisions) String added in v1.1.0

func (tp TotalProvisions) String() string

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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