types

package
v0.0.0-...-f498596 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: Apache-2.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

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 (
	ManageTreasuresProposalName = "fibochain/mint/ManageTreasuresProposal"
)
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")
)
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

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

func RegisterCodec(cdc *codec.Codec)

func SortTreasures

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

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

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

GovKeeper defines the expected gov Keeper

type ManageTreasuresProposal

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

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

NewManageTreasuresProposal creates a new instance of ManageTreasuresProposal

func (ManageTreasuresProposal) GetDescription

func (mp ManageTreasuresProposal) GetDescription() string

GetDescription returns description of a manage treasures proposal object

func (ManageTreasuresProposal) GetTitle

func (mp ManageTreasuresProposal) GetTitle() string

GetTitle returns title of a manage treasures proposal object

func (ManageTreasuresProposal) ProposalRoute

func (mp ManageTreasuresProposal) ProposalRoute() string

ProposalRoute returns route key of a manage treasures proposal object

func (ManageTreasuresProposal) ProposalType

func (mp ManageTreasuresProposal) ProposalType() string

ProposalType returns type of a manage treasures proposal object

func (ManageTreasuresProposal) String

func (mp ManageTreasuresProposal) String() string

String returns a human readable string representation of a ManageTreasuresProposal

func (ManageTreasuresProposal) ValidateBasic

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

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

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

func InsertAndUpdateTreasures

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

func NewTreasure

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

func (Treasure) ValidateBasic

func (t Treasure) ValidateBasic() error

Jump to

Keyboard shortcuts

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