Back to godoc.org

Package types

v0.3.7
Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module: github.com/terra-project/core

Overview

noalias

Index

Constants

const (
	DefaultCodespace sdk.CodespaceType = "treasury"

	CodeInvalidEpoch sdk.CodeType = 1
)

Treasury error codes

const (
	EventTypePolichUpdate = "policy_update"

	AttributeKeyTaxRate      = "tax_rate"
	AttributeKeyRewardWeight = "reward_weight"
	AttributeKeyTaxCap       = "tax_cap"
)

Treasury module event types

const (
	// ModuleName is the module name constant used in many places
	ModuleName = "treasury"

	// StoreKey is the string store representation
	StoreKey = ModuleName

	// RouterKey is the message route for treasury
	RouterKey = ModuleName

	// QuerierRoute is the querier route for treasury
	QuerierRoute = ModuleName
)
const (
	// ProposalTypeTaxRateUpdate defines the type for a TaxRateUpdateProposal
	ProposalTypeTaxRateUpdate = "TaxRateUpdate"

	// ProposalTypeRewardWeightUpdate defines the type for a RewardWeightUpdateProposal
	ProposalTypeRewardWeightUpdate = "RewardWeightUpdate"
)
const (
	QueryTaxRate             = "taxRate"
	QueryTaxCap              = "taxCap"
	QueryRewardWeight        = "rewardWeight"
	QuerySeigniorageProceeds = "seigniorageProceeds"
	QueryTaxProceeds         = "taxProceeds"
	QueryParameters          = "parameters"
)

query endpoints supported by the auth Querier

const DefaultParamspace = ModuleName

DefaultParamspace defines default space for treasury params

Variables

var (
	// Keys for store prefixes
	TaxRateKey              = []byte{0x01} // a key for a tax-rate
	RewardWeightKey         = []byte{0x02} // a key for a reward-weight
	TaxCapKey               = []byte{0x03} // prefix for each key to a tax-cap
	TaxProceedsKey          = []byte{0x04} // a key for a tax-proceeds
	EpochInitialIssuanceKey = []byte{0x05} // a key for a initial epoch issuance

	// Keys for store prefixes of internal purpose variables
	TRKey  = []byte{0x06} // prefix for each key to a TR
	SRKey  = []byte{0x07} // prefix for each key to a SR
	TSLKey = []byte{0x08} // prefix for each key to a TSL
)

Keys for treasury store Items are stored with the following key: values

- 0x01: sdk.Dec

- 0x02: sdk.Dec

- 0x03<denom_Bytes>: sdk.Int

- 0x04: sdk.Coins

- 0x05: sdk.Coins

- 0x06<epoch_Bytes>: sdk.Dec

- 0x07<epoch_Bytes>: sdk.Dec

- 0x08<epoch_Bytes>: sdk.Int

var (
	ParamStoreKeyTaxPolicy               = []byte("taxpolicy")
	ParamStoreKeyRewardPolicy            = []byte("rewardpolicy")
	ParamStoreKeySeigniorageBurdenTarget = []byte("seigniorageburdentarget")
	ParamStoreKeyMiningIncrement         = []byte("miningincrement")
	ParamStoreKeyWindowShort             = []byte("windowshort")
	ParamStoreKeyWindowLong              = []byte("windowlong")
	ParamStoreKeyWindowProbation         = []byte("windowprobation")
)

Parameter keys

var (
	DefaultTaxPolicy = PolicyConstraints{
		RateMin:       sdk.NewDecWithPrec(5, 4),
		RateMax:       sdk.NewDecWithPrec(1, 2),
		Cap:           sdk.NewCoin(core.MicroSDRDenom, sdk.OneInt().MulRaw(core.MicroUnit)),
		ChangeRateMax: sdk.NewDecWithPrec(25, 5),
	}
	DefaultRewardPolicy = PolicyConstraints{
		RateMin:       sdk.NewDecWithPrec(5, 2),
		RateMax:       sdk.NewDecWithPrec(50, 2),
		ChangeRateMax: sdk.NewDecWithPrec(25, 3),
		Cap:           sdk.NewCoin("unused", sdk.ZeroInt()),
	}
	DefaultSeigniorageBurdenTarget = sdk.NewDecWithPrec(67, 2)  // 67%
	DefaultMiningIncrement         = sdk.NewDecWithPrec(107, 2) // 1.07 mining increment; exponential growth
	DefaultWindowShort             = int64(4)                   // a month
	DefaultWindowLong              = int64(52)                  // a year
	DefaultWindowProbation         = int64(12)                  // 3 month
	DefaultTaxRate                 = sdk.NewDecWithPrec(1, 3)   // 0.1%
	DefaultRewardWeight            = sdk.NewDecWithPrec(5, 2)   // 5%
)

Default parameter values

var ModuleCdc *codec.Codec

ModuleCdc defines generic sealed codec to be used throughout module

func ErrInvalidEpoch

func ErrInvalidEpoch(codespace sdk.CodespaceType, curEpoch, epoch int64) sdk.Error

ErrInvalidEpoch called when the epoch exceeds the current epoch

func GetSRKey

func GetSRKey(epoch int64) []byte

GetSRKey - stored by *epoch*

func GetSubkeyByEpoch

func GetSubkeyByEpoch(prefix []byte, epoch int64) []byte

GetSubkeyByEpoch - stored by *epoch*

func GetTRKey

func GetTRKey(epoch int64) []byte

GetTRKey - stored by *epoch*

func GetTSLKey

func GetTSLKey(epoch int64) []byte

GetTSLKey - stored by *epoch*

func GetTaxCapKey

func GetTaxCapKey(denom string) []byte

GetTaxCapKey - stored by *denom*

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the provided oracle genesis state to ensure the expected invariants holds. (i.e. params in correct bounds, no duplicate validators)

type DistributionKeeper

type DistributionKeeper interface {
	GetFeePool(ctx sdk.Context) (feePool distrtypes.FeePool)
	SetFeePool(ctx sdk.Context, feePool distrtypes.FeePool)
}

DistributionKeeper expected keeper for distribution module

type GenesisState

type GenesisState struct {
	Params               Params             `json:"params" yaml:"params"` // market params
	TaxRate              sdk.Dec            `json:"tax_rate" yaml:"tax_rate"`
	RewardWeight         sdk.Dec            `json:"reward_weight" yaml:"reward_weight"`
	TaxCaps              map[string]sdk.Int `json:"tax_caps" yaml:"tax_caps"`
	TaxProceed           sdk.Coins          `json:"tax_proceed" yaml:"tax_proceed"`
	EpochInitialIssuance sdk.Coins          `json:"epoch_initial_issuance" yaml:"epoch_initial_issuance"`
	TRs                  []sdk.Dec          `json:"TRs" yaml:"TRs"`
	SRs                  []sdk.Dec          `json:"SRs" yaml:"SRs"`
	TSLs                 []sdk.Int          `json:"TSLs" yaml:"TSLs"`
}

GenesisState - all treasury state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState gets raw genesis raw message for testing

func NewGenesisState

func NewGenesisState(params Params, taxRate sdk.Dec, rewardWeight sdk.Dec,
	taxCaps map[string]sdk.Int, taxProceed sdk.Coins,
	epochInitialIssuance sdk.Coins, TRs []sdk.Dec, SRs []sdk.Dec, TSLs []sdk.Int) GenesisState

NewGenesisState creates a new GenesisState object

func (GenesisState) Equal

func (data GenesisState) Equal(data2 GenesisState) bool

Equal checks whether 2 GenesisState structs are equivalent.

func (GenesisState) IsEmpty

func (data GenesisState) IsEmpty() bool

IsEmpty returns if a GenesisState is empty or has data in it

type MarketKeeper

type MarketKeeper interface {
	ComputeInternalSwap(ctx sdk.Context, offerCoin sdk.DecCoin, askDenom string) (sdk.DecCoin, sdk.Error)
}

MarketKeeper expected market keeper

type Params

type Params struct {
	TaxPolicy               PolicyConstraints `json:"tax_policy" yaml:"tax_policy"`
	RewardPolicy            PolicyConstraints `json:"reward_policy" yaml:"reward_policy"`
	SeigniorageBurdenTarget sdk.Dec           `json:"seigniorage_burden_target" yaml:"seigniorage_burden_target"`
	MiningIncrement         sdk.Dec           `json:"mining_increment" yaml:"mining_increment"`
	WindowShort             int64             `json:"window_short" yaml:"window_short"`
	WindowLong              int64             `json:"window_long" yaml:"window_long"`
	WindowProbation         int64             `json:"window_probation" yaml:"window_probation"`
}

Params treasury parameters

func DefaultParams

func DefaultParams() Params

DefaultParams creates default treasury module parameters

func (*Params) ParamSetPairs

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

ParamSetPairs implements the ParamSet interface and returns all the key/value pairs pairs of treasury module's parameters. nolint

func (Params) String

func (params Params) String() string

String implements fmt.Stringer interface

func (Params) Validate

func (params Params) Validate() error

Validate params

type PolicyConstraints

type PolicyConstraints struct {
	RateMin       sdk.Dec  `json:"rate_min"`
	RateMax       sdk.Dec  `json:"rate_max"`
	Cap           sdk.Coin `json:"cap"`
	ChangeRateMax sdk.Dec  `json:"change_max"`
}

PolicyConstraints wraps constraints around updating a key Treasury variable

func (PolicyConstraints) Clamp

func (pc PolicyConstraints) Clamp(prevRate sdk.Dec, newRate sdk.Dec) (clampedRate sdk.Dec)

Clamp constrains a policy variable update within the policy constraints

func (PolicyConstraints) String

func (pc PolicyConstraints) String() string

String implements fmt.Stringer interface

type QueryTaxCapParams

type QueryTaxCapParams struct {
	Denom string
}

QueryTaxCapParams for query - 'custom/treasury/taxRate

func NewQueryTaxCapParams

func NewQueryTaxCapParams(denom string) QueryTaxCapParams

NewQueryTaxCapParams returns new QueryTaxCapParams instance

type RewardWeightUpdateProposal

type RewardWeightUpdateProposal struct {
	Title        string  `json:"title" yaml:"title"`                 // Title of the Proposal
	Description  string  `json:"description" yaml:"description"`     // Description of the Proposal
	RewardWeight sdk.Dec `json:"reward_weight" yaml:"reward_weight"` // target RewardWeight
}

RewardWeightUpdateProposal update treasury tax-rate

func NewRewardWeightUpdateProposal

func NewRewardWeightUpdateProposal(title, description string, taxRate sdk.Dec) RewardWeightUpdateProposal

NewRewardWeightUpdateProposal creates an RewardWeightUpdateProposal.

func (RewardWeightUpdateProposal) GetDescription

func (p RewardWeightUpdateProposal) GetDescription() string

GetDescription returns the description of an RewardWeightUpdateProposal.

func (RewardWeightUpdateProposal) GetTitle

func (p RewardWeightUpdateProposal) GetTitle() string

GetTitle returns the title of an RewardWeightUpdateProposal.

func (RewardWeightUpdateProposal) ProposalRoute

func (RewardWeightUpdateProposal) ProposalRoute() string

ProposalRoute returns the routing key of an RewardWeightUpdateProposal.

func (RewardWeightUpdateProposal) ProposalType

func (p RewardWeightUpdateProposal) ProposalType() string

ProposalType returns the type of an RewardWeightUpdateProposal.

func (RewardWeightUpdateProposal) String

func (p RewardWeightUpdateProposal) String() string

String implements the Stringer interface.

func (RewardWeightUpdateProposal) ValidateBasic

func (p RewardWeightUpdateProposal) ValidateBasic() sdk.Error

ValidateBasic runs basic stateless validity checks

type StakingKeeper

type StakingKeeper interface {
	TotalBondedTokens(sdk.Context) sdk.Int // total bonded tokens within the validator set
}

StakingKeeper expected keeper for staking module

type SupplyKeeper

type SupplyKeeper interface {
	GetSupply(ctx sdk.Context) (supply supplyexported.SupplyI)
	MintCoins(ctx sdk.Context, name string, amt sdk.Coins) sdk.Error
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) sdk.Error
}

SupplyKeeper expected supply keeper

type TaxRateUpdateProposal

type TaxRateUpdateProposal struct {
	Title       string  `json:"title" yaml:"title"`             // Title of the Proposal
	Description string  `json:"description" yaml:"description"` // Description of the Proposal
	TaxRate     sdk.Dec `json:"tax_rate" yaml:"tax_rate"`       // target TaxRate
}

TaxRateUpdateProposal updates treasury tax-rate

func NewTaxRateUpdateProposal

func NewTaxRateUpdateProposal(title, description string, taxRate sdk.Dec) TaxRateUpdateProposal

NewTaxRateUpdateProposal creates an TaxRateUpdateProposal.

func (TaxRateUpdateProposal) GetDescription

func (p TaxRateUpdateProposal) GetDescription() string

GetDescription returns the description of an TaxRateUpdateProposal.

func (TaxRateUpdateProposal) GetTitle

func (p TaxRateUpdateProposal) GetTitle() string

GetTitle returns the title of an TaxRateUpdateProposal.

func (TaxRateUpdateProposal) ProposalRoute

func (TaxRateUpdateProposal) ProposalRoute() string

ProposalRoute returns the routing key of an TaxRateUpdateProposal.

func (TaxRateUpdateProposal) ProposalType

func (p TaxRateUpdateProposal) ProposalType() string

ProposalType returns the type of an TaxRateUpdateProposal.

func (TaxRateUpdateProposal) String

func (p TaxRateUpdateProposal) String() string

String implements the Stringer interface.

func (TaxRateUpdateProposal) ValidateBasic

func (p TaxRateUpdateProposal) ValidateBasic() sdk.Error

ValidateBasic runs basic stateless validity checks

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier