Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToUint64(bz []byte) uint64
- func GetClaimPeriodPrefix(denom string, id uint64) []byte
- func GetClaimPrefix(addr sdk.AccAddress, denom string, id uint64) []byte
- func GetTotalVestingPeriodLength(periods vesting.Periods) int64
- func NewPeriod(amount sdk.Coins, length int64) vesting.Period
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- type AccountKeeper
- type CdpKeeper
- type Claim
- type ClaimPeriod
- type ClaimPeriods
- type Claims
- type GenesisClaimPeriodID
- type GenesisClaimPeriodIDs
- type GenesisState
- type MsgClaimReward
- type Params
- type PostClaimReq
- type QueryClaimsParams
- type Reward
- type RewardPeriod
- type RewardPeriods
- type Rewards
- type SupplyKeeper
Constants ¶
const ( EventTypeClaim = "claim_reward" EventTypeRewardPeriod = "new_reward_period" EventTypeClaimPeriod = "new_claim_period" EventTypeClaimPeriodExpiry = "claim_period_expiry" AttributeValueCategory = ModuleName AttributeKeyClaimedBy = "claimed_by" AttributeKeyClaimAmount = "claim_amount" AttributeKeyRewardPeriod = "reward_period" AttributeKeyClaimPeriod = "claim_period" )
Events emitted by the incentive module
const ( // ModuleName The name that will be used throughout the module ModuleName = "incentive" // StoreKey Top level store key where all module items will be stored StoreKey = ModuleName // RouterKey Top level router key RouterKey = ModuleName // DefaultParamspace default name for parameter store DefaultParamspace = ModuleName // QuerierRoute route used for abci queries QuerierRoute = ModuleName )
const ( QueryGetClaims = "claims" RestClaimOwner = "owner" RestClaimDenom = "denom" QueryGetParams = "parameters" QueryGetRewardPeriods = "reward-periods" QueryGetClaimPeriods = "claim-periods" )
Querier routes for the incentive module
Variables ¶
var ( ErrClaimNotFound = sdkerrors.Register(ModuleName, 1, "no claim with input id found for owner and denom") ErrClaimPeriodNotFound = sdkerrors.Register(ModuleName, 2, "no claim period found for id and denom") ErrInvalidAccountType = sdkerrors.Register(ModuleName, 3, "account type not supported") ErrNoClaimsFound = sdkerrors.Register(ModuleName, 4, "no claims with denom found for address") ErrInsufficientModAccountBalance = sdkerrors.Register(ModuleName, 5, "module account has insufficient balance to pay claim") )
var ( RewardPeriodKeyPrefix = []byte{0x01} // prefix for keys that store reward periods ClaimPeriodKeyPrefix = []byte{0x02} // prefix for keys that store claim periods ClaimKeyPrefix = []byte{0x03} // prefix for keys that store claims NextClaimPeriodIDPrefix = []byte{0x04} // prefix for keys that store the next ID for claims periods PreviousBlockTimeKey = []byte{0x05} // prefix for key that stores the previous blocktime )
Key Prefixes
var ( KeyActive = []byte("Active") KeyRewards = []byte("Rewards") DefaultActive = false DefaultRewards = Rewards{} DefaultPreviousBlockTime = tmtime.Canonical(time.Unix(0, 0)) GovDenom = cdptypes.DefaultGovDenom PrincipalDenom = "eurx" IncentiveMacc = stakedistTypes.ModuleName )
Parameter keys and default values
var ModuleCdc *codec.Codec
ModuleCdc generic sealed codec to be used throughout module
Functions ¶
func BytesToUint64 ¶
BytesToUint64 returns uint64 format from a byte array
func GetClaimPeriodPrefix ¶
GetClaimPeriodPrefix returns the key (denom + id) for a claim prefix
func GetClaimPrefix ¶
func GetClaimPrefix(addr sdk.AccAddress, denom string, id uint64) []byte
GetClaimPrefix returns the key (denom + id + address) for a claim
func GetTotalVestingPeriodLength ¶
GetTotalVestingPeriodLength returns the summed length of all vesting periods
func ParamKeyTable ¶
ParamKeyTable Key declaration for parameters
func RegisterCodec ¶
RegisterCodec registers the necessary types for incentive module
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) authexported.Account SetAccount(ctx sdk.Context, acc authexported.Account) }
AccountKeeper defines the expected keeper interface for interacting with account
type CdpKeeper ¶
type CdpKeeper interface { IterateCdpsByDenom(ctx sdk.Context, denom string, cb func(cdp cdptypes.CDP) (stop bool)) GetTotalPrincipal(ctx sdk.Context, collateralDenom string, principalDenom string) (total sdk.Int) }
CdpKeeper defines the expected cdp keeper for interacting with cdps
type Claim ¶
type Claim struct { Owner sdk.AccAddress `json:"owner" yaml:"owner"` Reward sdk.Coin `json:"reward" yaml:"reward"` Denom string `json:"denom" yaml:"denom"` ClaimPeriodID uint64 `json:"claim_period_id" yaml:"claim_period_id"` }
Claim stores the rewards that can be claimed by owner
type ClaimPeriod ¶
type ClaimPeriod struct { Denom string `json:"denom" yaml:"denom"` ID uint64 `json:"id" yaml:"id"` End time.Time `json:"end" yaml:"end"` TimeLock time.Duration `json:"time_lock" yaml:"time_lock"` }
ClaimPeriod stores the state of an ongoing claim period
func NewClaimPeriod ¶
NewClaimPeriod returns a new ClaimPeriod
func (ClaimPeriod) Validate ¶
func (cp ClaimPeriod) Validate() error
Validate performs a basic check of a ClaimPeriod fields.
type ClaimPeriods ¶
type ClaimPeriods []ClaimPeriod
ClaimPeriods array of ClaimPeriod
func (ClaimPeriods) Validate ¶
func (cps ClaimPeriods) Validate() error
Validate checks if all the ClaimPeriods are valid and there are no duplicated entries.
type GenesisClaimPeriodID ¶
type GenesisClaimPeriodID struct { Denom string `json:"denom" yaml:"denom"` ID uint64 `json:"id" yaml:"id"` }
GenesisClaimPeriodID stores the next claim id and its corresponding denom
func (GenesisClaimPeriodID) Validate ¶
func (gcp GenesisClaimPeriodID) Validate() error
Validate performs a basic check of a GenesisClaimPeriodID fields.
type GenesisClaimPeriodIDs ¶
type GenesisClaimPeriodIDs []GenesisClaimPeriodID
GenesisClaimPeriodIDs array of GenesisClaimPeriodID
func (GenesisClaimPeriodIDs) Validate ¶
func (gcps GenesisClaimPeriodIDs) Validate() error
Validate checks if all the GenesisClaimPeriodIDs are valid and there are no duplicated entries.
type GenesisState ¶
type GenesisState struct { Params Params `json:"params" yaml:"params"` PreviousBlockTime time.Time `json:"previous_block_time" yaml:"previous_block_time"` RewardPeriods RewardPeriods `json:"reward_periods" yaml:"reward_periods"` ClaimPeriods ClaimPeriods `json:"claim_periods" yaml:"claim_periods"` Claims Claims `json:"claims" yaml:"claims"` NextClaimPeriodIDs GenesisClaimPeriodIDs `json:"next_claim_period_ids" yaml:"next_claim_period_ids"` }
GenesisState is the state that must be provided at genesis.
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState returns a default genesis state
func NewGenesisState ¶
func NewGenesisState(params Params, previousBlockTime time.Time, rp RewardPeriods, cp ClaimPeriods, c Claims, ids GenesisClaimPeriodIDs) GenesisState
NewGenesisState returns a new genesis state
func (GenesisState) Equal ¶
func (gs GenesisState) Equal(gs2 GenesisState) bool
Equal checks whether two gov GenesisState structs are equivalent
func (GenesisState) IsEmpty ¶
func (gs GenesisState) IsEmpty() bool
IsEmpty returns true if a GenesisState is empty
func (GenesisState) Validate ¶
func (gs GenesisState) Validate() error
Validate performs basic validation of genesis data returning an error for any failed validation criteria.
type MsgClaimReward ¶
type MsgClaimReward struct { Sender sdk.AccAddress `json:"sender" yaml:"sender"` Denom string `json:"denom" yaml:"denom"` }
MsgClaimReward message type used to claim rewards
func NewMsgClaimReward ¶
func NewMsgClaimReward(sender sdk.AccAddress, denom string) MsgClaimReward
NewMsgClaimReward returns a new MsgClaimReward.
func (MsgClaimReward) GetSignBytes ¶
func (msg MsgClaimReward) GetSignBytes() []byte
GetSignBytes gets the canonical byte representation of the Msg.
func (MsgClaimReward) GetSigners ¶
func (msg MsgClaimReward) GetSigners() []sdk.AccAddress
GetSigners returns the addresses of signers that must sign.
func (MsgClaimReward) Route ¶
func (msg MsgClaimReward) Route() string
Route return the message type used for routing the message.
func (MsgClaimReward) Type ¶
func (msg MsgClaimReward) Type() string
Type returns a human-readable string for the message, intended for utilization within tags.
func (MsgClaimReward) ValidateBasic ¶
func (msg MsgClaimReward) ValidateBasic() error
ValidateBasic does a simple validation check that doesn't require access to state.
type Params ¶
type Params struct { Active bool `json:"active" yaml:"active"` // top level governance switch to disable all rewards Rewards Rewards `json:"rewards" yaml:"rewards"` }
Params governance parameters for the incentive module
func DefaultParams ¶
func DefaultParams() Params
DefaultParams returns default params for stakedist module
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
type PostClaimReq ¶
type PostClaimReq struct { BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` Sender sdk.AccAddress `json:"sender" yaml:"sender"` Denom string `json:"denom" yaml:"denom"` }
PostClaimReq defines the properties of claim transaction's request body.
type QueryClaimsParams ¶
type QueryClaimsParams struct { Owner sdk.AccAddress Denom string }
QueryClaimsParams params for query /incentive/claims
func NewQueryClaimsParams ¶
func NewQueryClaimsParams(owner sdk.AccAddress, denom string) QueryClaimsParams
NewQueryClaimsParams returns QueryClaimsParams
type Reward ¶
type Reward struct { Active bool `json:"active" yaml:"active"` // governance switch to disable a period Denom string `json:"denom" yaml:"denom"` // the collateral denom rewards apply to, must be found in the cdp collaterals AvailableRewards sdk.Coin `json:"available_rewards" yaml:"available_rewards"` // the total amount of coins distributed per period Duration time.Duration `json:"duration" yaml:"duration"` // the duration of the period TimeLock time.Duration `json:"time_lock" yaml:"time_lock"` // how long rewards for this period are timelocked ClaimDuration time.Duration `json:"claim_duration" yaml:"claim_duration"` // how long users have after the period ends to claim their rewards }
Reward stores the specified state for a single reward period.
type RewardPeriod ¶
type RewardPeriod struct { Denom string `json:"denom" yaml:"denom"` Start time.Time `json:"start" yaml:"start"` End time.Time `json:"end" yaml:"end"` Reward sdk.Coin `json:"reward" yaml:"reward"` // per second reward payouts ClaimEnd time.Time `json:"claim_end" yaml:"claim_end"` ClaimTimeLock time.Duration `json:"claim_time_lock" yaml:"claim_time_lock"` // the amount of time rewards are timelocked once they are sent to users }
RewardPeriod stores the state of an ongoing reward
func NewRewardPeriod ¶
func NewRewardPeriod(denom string, start time.Time, end time.Time, reward sdk.Coin, claimEnd time.Time, claimTimeLock time.Duration) RewardPeriod
NewRewardPeriod returns a new RewardPeriod
func NewRewardPeriodFromReward ¶
func NewRewardPeriodFromReward(reward Reward, blockTime time.Time) RewardPeriod
NewRewardPeriodFromReward returns a new reward period from the input reward and block time
func (RewardPeriod) Validate ¶
func (rp RewardPeriod) Validate() error
Validate performs a basic check of a RewardPeriod fields.
type RewardPeriods ¶
type RewardPeriods []RewardPeriod
RewardPeriods array of RewardPeriod
func (RewardPeriods) Validate ¶
func (rps RewardPeriods) Validate() error
Validate checks if all the RewardPeriods are valid and there are no duplicated entries.
type SupplyKeeper ¶
type SupplyKeeper interface { GetModuleAccount(ctx sdk.Context, name string) supplyexported.ModuleAccountI SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error }
SupplyKeeper defines the expected supply keeper for module accounts