types

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManageTreasuresProposalName       = "okexchain/mint/ManageTreasuresProposal"
	ModifyNextBlockUpdateProposalName = "okexchain/mint/ModifyNextBlockUpdateProposal"
)
View Source
const (
	EventTypeMint = ModuleName

	AttributeKeyBondedRatio      = "bonded_ratio"
	AttributeKeyInflation        = "inflation"
	AttributeKeyAnnualProvisions = "annual_provisions"
)

Minting module event types

View Source
const (
	// ModuleName
	ModuleName = "mint"

	// DefaultParamspace params keeper
	DefaultParamspace = ModuleName

	// StoreKey is the default store key for mint
	StoreKey = ModuleName

	// QuerierRoute is the querier route for the minting store.
	QuerierRoute = StoreKey

	// Query endpoints supported by the minting querier
	QueryParameters       = "parameters"
	QueryInflation        = "inflation"
	QueryAnnualProvisions = "annual_provisions"
	QueryTreasures        = "treasures"
	QueryBlockRewards     = "block_rewards"
)

nolint

View Source
const (
	DefaultCodespace string = ModuleName
)

NOTE: We can't use 1 since that error code is reserved for internal errors.

View Source
const (

	// RouterKey uses module name for routing
	RouterKey = ModuleName
)

Variables

View Source
var (
	// ErrInvalidState returns an error resulting from an invalid Storage State.
	ErrEmptyTreasures = sdkerrors.Register(ModuleName, 2, "treasures is not empty")

	ErrDuplicatedTreasure      = sdkerrors.Register(ModuleName, 3, "treasures can not be duplicate")
	ErrUnexpectedProposalType  = sdkerrors.Register(ModuleName, 4, "unsupported proposal type of mint module")
	ErrProposerMustBeValidator = sdkerrors.Register(ModuleName, 5, "the proposal of proposer must be validator")
	ErrNotReachedVenus5Height  = sdkerrors.Register(ModuleName, 6, "venus5 block height has not been reached")
	ErrNextBlockUpdateTooLate  = sdkerrors.Register(ModuleName, 7, "the next block to update is too late")
	ErrCodeInvalidHeight       = sdkerrors.Register(ModuleName, 8, "height must be greater than current block")
)
View Source
var (
	// MinterKey is used for the keeper store
	MinterKey = []byte{0x00}
	// TreasuresKey is used for the keeper store
	TreasuresKey = []byte{0x01}
)
View Source
var (
	KeyMintDenom = []byte("MintDenom")
	//KeyInflationRateChange = []byte("InflationRateChange")
	//KeyInflationMax        = []byte("InflationMax")
	//KeyInflationMin        = []byte("InflationMin")
	//KeyGoalBonded          = []byte("GoalBonded")
	KeyBlocksPerYear = []byte("BlocksPerYear")

	KeyDeflationRate  = []byte("DeflationRate")
	KeyDeflationEpoch = []byte("DeflationEpoch")
	KeyFarmProportion = []byte("YieldFarmingProportion")
)

Parameter store keys

View Source
var ModuleCdc *codec.Codec

ModuleCdc is a generic sealed codec to be used throughout this module

Functions

func DefaultOriginalMintedPerBlock

func DefaultOriginalMintedPerBlock() sdk.Dec

func ErrTreasuresInternal added in v1.1.8

func ErrTreasuresInternal(err error) sdk.EnvelopedErr

ErrTreasuresInternal returns an error when the length of address list in the proposal is larger than the max limitation

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamTable for minting module.

func RegisterCodec added in v1.1.8

func RegisterCodec(cdc *codec.Codec)

func SortTreasures added in v1.1.8

func SortTreasures(treasures []Treasure)

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

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

func ValidateMinter

func ValidateMinter(minter Minter) error

validate minter

func ValidateMinterCustom

func ValidateMinterCustom(minter MinterCustom) error

ValidateMinterCustom validate minter

func ValidateTreasures added in v1.1.8

func ValidateTreasures(treasures []Treasure) error

Types

type GenesisState

type GenesisState struct {
	Minter    MinterCustom `json:"minter" yaml:"minter"`                           // minter object
	Params    Params       `json:"params" yaml:"params"`                           // inflation params
	Treasures []Treasure   `json:"treasures,omitempty" yaml:"treasures,omitempty"` // treasures

	OriginalMintedPerBlock sdk.Dec `json:"original_minted_per_block" yaml:"original_minted_per_block"`
}

GenesisState - minter state

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState creates a default GenesisState object

func NewGenesisState

func NewGenesisState(minter MinterCustom, params Params, originalMintedPerBlock sdk.Dec) GenesisState

NewGenesisState creates a new GenesisState object

type GovKeeper added in v1.1.8

type GovKeeper interface {
	GetDepositParams(ctx sdk.Context) govtypes.DepositParams
	GetVotingParams(ctx sdk.Context) govtypes.VotingParams
}

GovKeeper defines the expected gov Keeper

type ManageTreasuresProposal added in v1.1.8

type ManageTreasuresProposal struct {
	Title       string     `json:"title" yaml:"title"`
	Description string     `json:"description" yaml:"description"`
	Treasures   []Treasure `json:"treasures" yaml:"treasures"`
	IsAdded     bool       `json:"is_added" yaml:"is_added"`
}

ManageTreasuresProposal - structure for the proposal to add or delete treasures

func NewManageTreasuresProposal added in v1.1.8

func NewManageTreasuresProposal(title, description string, treasures []Treasure, isAdded bool,
) ManageTreasuresProposal

NewManageTreasuresProposal creates a new instance of ManageTreasuresProposal

func (ManageTreasuresProposal) GetDescription added in v1.1.8

func (mp ManageTreasuresProposal) GetDescription() string

GetDescription returns description of a manage treasures proposal object

func (ManageTreasuresProposal) GetTitle added in v1.1.8

func (mp ManageTreasuresProposal) GetTitle() string

GetTitle returns title of a manage treasures proposal object

func (ManageTreasuresProposal) ProposalRoute added in v1.1.8

func (mp ManageTreasuresProposal) ProposalRoute() string

ProposalRoute returns route key of a manage treasures proposal object

func (ManageTreasuresProposal) ProposalType added in v1.1.8

func (mp ManageTreasuresProposal) ProposalType() string

ProposalType returns type of a manage treasures proposal object

func (ManageTreasuresProposal) String added in v1.1.8

func (mp ManageTreasuresProposal) String() string

String returns a human readable string representation of a ManageTreasuresProposal

func (ManageTreasuresProposal) ValidateBasic added in v1.1.8

func (mp ManageTreasuresProposal) ValidateBasic() sdk.Error

ValidateBasic validates a manage treasures proposal

type Minter

type Minter struct {
	Inflation        sdk.Dec `json:"inflation" yaml:"inflation"`                 // current annual inflation rate
	AnnualProvisions sdk.Dec `json:"annual_provisions" yaml:"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.Dec) 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 MinterCustom

type MinterCustom struct {
	NextBlockToUpdate uint64         `json:"next_block_to_update" yaml:"next_block_to_update"` // record the block height for next year
	MintedPerBlock    types.DecCoins `json:"minted_per_block" yaml:"minted_per_block"`         // record the MintedPerBlock per block in this year
}

func DefaultInitialMinterCustom

func DefaultInitialMinterCustom() MinterCustom

DefaultInitialMinterCustom returns a default initial MinterCustom object for a new chain which uses an inflation rate of 1%.

func InitialMinterCustom

func InitialMinterCustom() MinterCustom

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

func NewMinterCustom

func NewMinterCustom(nextBlockToUpdate uint64, mintedPerBlock sdk.DecCoins) MinterCustom

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

type ModifyNextBlockUpdateProposal added in v1.7.0

type ModifyNextBlockUpdateProposal struct {
	Title       string `json:"title" yaml:"title"`
	Description string `json:"description" yaml:"description"`
	BlockNum    uint64 `json:"block_num" yaml:"block_num"`
}

ModifyNextBlockUpdateProposal - structure for the proposal modify next block update

func NewModifyNextBlockUpdateProposal added in v1.7.0

func NewModifyNextBlockUpdateProposal(title, description string, blockNum uint64) ModifyNextBlockUpdateProposal

NewModifyNextBlockUpdateProposal creates a new instance of ModifyNextBlockUpdateProposal

func (ModifyNextBlockUpdateProposal) GetDescription added in v1.7.0

func (mp ModifyNextBlockUpdateProposal) GetDescription() string

GetDescription returns description of proposal object

func (ModifyNextBlockUpdateProposal) GetTitle added in v1.7.0

func (mp ModifyNextBlockUpdateProposal) GetTitle() string

GetTitle returns title of the proposal object

func (ModifyNextBlockUpdateProposal) ProposalRoute added in v1.7.0

func (mp ModifyNextBlockUpdateProposal) ProposalRoute() string

ProposalRoute returns route key of the proposal object

func (ModifyNextBlockUpdateProposal) ProposalType added in v1.7.0

func (mp ModifyNextBlockUpdateProposal) ProposalType() string

ProposalType returns type of the proposal object

func (ModifyNextBlockUpdateProposal) String added in v1.7.0

String returns a human readable string representation of a ModifyNextBlockUpdateProposal

func (ModifyNextBlockUpdateProposal) ValidateBasic added in v1.7.0

func (mp ModifyNextBlockUpdateProposal) ValidateBasic() sdk.Error

ValidateBasic validates the proposal

type Params

type Params struct {
	MintDenom           string  `json:"mint_denom" yaml:"mint_denom"`                       // type of coin to mint
	InflationRateChange sdk.Dec `json:"inflation_rate_change" yaml:"inflation_rate_change"` // Deprecated: maximum annual change in inflation rate
	InflationMax        sdk.Dec `json:"inflation_max" yaml:"inflation_max"`                 // Deprecated: maximum inflation rate
	InflationMin        sdk.Dec `json:"inflation_min" yaml:"inflation_min"`                 // Deprecated: minimum inflation rate
	GoalBonded          sdk.Dec `json:"goal_bonded" yaml:"goal_bonded"`                     // Deprecated: goal of percent bonded atoms
	BlocksPerYear       uint64  `json:"blocks_per_year" yaml:"blocks_per_year"`             // blocks per year according to one block per 3s

	DeflationRate  sdk.Dec `json:"deflation_rate" yaml:"deflation_rate"`   // deflation rate every DeflationEpoch
	DeflationEpoch uint64  `json:"deflation_epoch" yaml:"deflation_epoch"` // block number to deflate
	FarmProportion sdk.Dec `json:"farm_proportion" yaml:"farm_proportion"` // proportion of minted for farm
}

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,
	deflationEpoch uint64, deflationRateChange, farmPropotion sdk.Dec,
) Params

func (*Params) ParamSetPairs

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

Implements params.ParamSet

func (Params) String

func (p Params) String() string

func (Params) Validate

func (p Params) Validate() error

validate params

type StakingKeeper

type StakingKeeper interface {
	StakingTokenSupply(ctx sdk.Context) sdk.Dec
	BondedRatio(ctx sdk.Context) sdk.Dec
	IsValidator(ctx sdk.Context, addr sdk.AccAddress) bool
}

StakingKeeper defines the expected staking keeper

type SupplyKeeper

type SupplyKeeper interface {
	GetModuleAddress(name string) sdk.AccAddress

	// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
	SetModuleAccount(sdk.Context, exported.ModuleAccountI)

	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
	MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error
}

SupplyKeeper defines the expected supply keeper

type Treasure added in v1.1.8

type Treasure struct {
	//Treasure Address
	Address sdk.AccAddress `json:"address" yaml:"address"`
	// proportion of minted for treasure
	Proportion sdk.Dec `json:"proportion" yaml:"proportion"`
}

Treasure is the struct which has address and proportion of mint reward.

func DeleteTreasures added in v1.1.8

func DeleteTreasures(src, dst []Treasure) ([]Treasure, error)

func InsertAndUpdateTreasures added in v1.1.8

func InsertAndUpdateTreasures(src, dst []Treasure) []Treasure

func NewTreasure added in v1.1.8

func NewTreasure(address sdk.AccAddress, proportion sdk.Dec) *Treasure

func (Treasure) ValidateBasic added in v1.1.8

func (t Treasure) ValidateBasic() error

type WrappedInflation added in v1.7.0

type WrappedInflation struct {
	Inflation sdk.Dec `json:"inflation" yaml:"inflation"`
}

WrappedInflation is used to wrap the Inflation, thus making the rest API response compatible with cosmos-sdk

func NewWrappedInflation added in v1.7.0

func NewWrappedInflation(inflation sdk.Dec) WrappedInflation

type WrappedParams added in v1.7.0

type WrappedParams struct {
	Params Params `json:"params" yaml:"params"`
}

WrappedParams is used to wrap the Params, thus making the rest API response compatible with cosmos-sdk

func NewWrappedParams added in v1.7.0

func NewWrappedParams(params Params) WrappedParams

NewWrappedParams creates a new instance of WrappedParams

Jump to

Keyboard shortcuts

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