Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToUint64(bz []byte) uint64
- func GetClaimPeriodPrefix(collateralType string, id uint64) []byte
- func GetClaimPrefix(addr sdk.AccAddress, collateralType 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 AugmentedClaim
- type AugmentedClaims
- type CdpKeeper
- type Claim
- type ClaimPeriod
- type ClaimPeriods
- type Claims
- type GenesisClaimPeriodID
- type GenesisClaimPeriodIDs
- type GenesisState
- type MsgClaimReward
- type Multiplier
- type MultiplierName
- type Multipliers
- 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" RestClaimCollateralType = "collateral_type" QueryGetParams = "parameters" QueryGetRewardPeriods = "reward-periods" QueryGetClaimPeriods = "claim-periods" )
Querier routes for the incentive module
Variables ¶
var ( ErrClaimNotFound = sdkerrors.Register(ModuleName, 2, "no claim with input id found for owner and collateral type") ErrClaimPeriodNotFound = sdkerrors.Register(ModuleName, 3, "no claim period found for id and collateral type") ErrInvalidAccountType = sdkerrors.Register(ModuleName, 4, "account type not supported") ErrNoClaimsFound = sdkerrors.Register(ModuleName, 5, "no claims with collateral type found for address") ErrInsufficientModAccountBalance = sdkerrors.Register(ModuleName, 6, "module account has insufficient balance to pay claim") ErrAccountNotFound = sdkerrors.Register(ModuleName, 7, "account not found") ErrInvalidMultiplier = sdkerrors.Register(ModuleName, 8, "invalid rewards multiplier") ErrZeroClaim = sdkerrors.Register(ModuleName, 9, "cannot claim - claim amount rounds to zero") )
Incentive module errors
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 = "usdx" IncentiveMacc = kavadistTypes.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 (collateral type + id) for a claim prefix
func GetClaimPrefix ¶
func GetClaimPrefix(addr sdk.AccAddress, collateralType string, id uint64) []byte
GetClaimPrefix returns the key (collateral type + 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 AugmentedClaim ¶ added in v0.11.0
type AugmentedClaim struct { Claim Claim `json:"claim" yaml:"claim"` Claimable bool `json:"claimable" yaml:"claimable"` }
AugmentedClaim claim type with information about whether the claim is currently claimable
func NewAugmentedClaim ¶ added in v0.11.0
func NewAugmentedClaim(claim Claim, claimable bool) AugmentedClaim
NewAugmentedClaim returns a new augmented claim struct
func (AugmentedClaim) String ¶ added in v0.11.0
func (ac AugmentedClaim) String() string
type AugmentedClaims ¶ added in v0.11.0
type AugmentedClaims []AugmentedClaim
AugmentedClaims array of AugmentedClaim
type CdpKeeper ¶
type CdpKeeper interface { IterateCdpsByCollateralType(ctx sdk.Context, collateralType string, cb func(cdp cdptypes.CDP) (stop bool)) GetTotalPrincipal(ctx sdk.Context, collateralType 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"` CollateralType string `json:"collateral_type" yaml:"collateral_type"` 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 { CollateralType string `json:"collateral_type" yaml:"collateral_type"` ID uint64 `json:"id" yaml:"id"` End time.Time `json:"end" yaml:"end"` ClaimMultipliers Multipliers `json:"claim_multipliers" yaml:"claim_multipliers"` }
ClaimPeriod stores the state of an ongoing claim period
func NewClaimPeriod ¶
func NewClaimPeriod(collateralType string, id uint64, end time.Time, multipliers Multipliers) ClaimPeriod
NewClaimPeriod returns a new ClaimPeriod
func (ClaimPeriod) GetMultiplier ¶ added in v0.11.0
func (cp ClaimPeriod) GetMultiplier(name MultiplierName) (Multiplier, bool)
GetMultiplier returns the named multiplier from the input claim period
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 { CollateralType string `json:"collateral_type" yaml:"collateral_type"` ID uint64 `json:"id" yaml:"id"` }
GenesisClaimPeriodID stores the next claim id and its corresponding collateral type
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"` CollateralType string `json:"collateral_type" yaml:"collateral_type"` MultiplierName string `json:"multiplier_name" yaml:"multiplier_name"` }
MsgClaimReward message type used to claim rewards
func NewMsgClaimReward ¶
func NewMsgClaimReward(sender sdk.AccAddress, collateralType, multiplierName 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 Multiplier ¶ added in v0.11.0
type Multiplier struct { Name MultiplierName `json:"name" yaml:"name"` MonthsLockup int64 `json:"months_lockup" yaml:"months_lockup"` Factor sdk.Dec `json:"factor" yaml:"factor"` }
Multiplier amount the claim rewards get increased by, along with how long the claim rewards are locked
func NewMultiplier ¶ added in v0.11.0
func NewMultiplier(name MultiplierName, lockup int64, factor sdk.Dec) Multiplier
NewMultiplier returns a new Multiplier
func (Multiplier) String ¶ added in v0.11.0
func (m Multiplier) String() string
String implements fmt.Stringer
func (Multiplier) Validate ¶ added in v0.11.0
func (m Multiplier) Validate() error
Validate multiplier param
type MultiplierName ¶ added in v0.11.0
type MultiplierName string
MultiplierName name for valid multiplier
const ( Small MultiplierName = "small" Medium MultiplierName = "medium" Large MultiplierName = "large" )
Valid reward multipliers
func (MultiplierName) IsValid ¶ added in v0.11.0
func (mn MultiplierName) IsValid() error
IsValid checks if the input is one of the expected strings
type Multipliers ¶ added in v0.11.0
type Multipliers []Multiplier
Multipliers slice of Multiplier
func (Multipliers) String ¶ added in v0.11.0
func (ms Multipliers) String() string
String implements fmt.Stringer
func (Multipliers) Validate ¶ added in v0.11.0
func (ms Multipliers) Validate() error
Validate validates each multiplier
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 incentive 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"` CollateralType string `json:"collateral_type" yaml:"collateral_type"` MultiplierName string `json:"multiplier_name" yaml:"multiplier_name"` }
PostClaimReq defines the properties of claim transaction's request body.
type QueryClaimsParams ¶
type QueryClaimsParams struct { Owner sdk.AccAddress CollateralType string }
QueryClaimsParams params for query /incentive/claims
func NewQueryClaimsParams ¶
func NewQueryClaimsParams(owner sdk.AccAddress, collateralType string) QueryClaimsParams
NewQueryClaimsParams returns QueryClaimsParams
type Reward ¶
type Reward struct { Active bool `json:"active" yaml:"active"` // governance switch to disable a period CollateralType string `json:"collateral_type" yaml:"collateral_type"` // the collateral type 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 ClaimMultipliers Multipliers `json:"claim_multipliers" yaml:"claim_multipliers"` // the reward multiplier and timelock schedule - applied at the time users claim rewards 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 { CollateralType string `json:"collateral_type" yaml:"collateral_type"` 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"` ClaimMultipliers Multipliers `json:"claim_multipliers" yaml:"claim_multipliers"` // the reward multiplier and timelock schedule - applied at the time users claim rewards }
RewardPeriod stores the state of an ongoing reward
func NewRewardPeriod ¶
func NewRewardPeriod(collateralType string, start time.Time, end time.Time, reward sdk.Coin, claimEnd time.Time, claimMultipliers Multipliers) 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