types

package
v0.8.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

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

View Source
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
)
View Source
const (
	QueryGetClaims = "claims"
	RestClaimOwner = "owner"
	RestClaimDenom = "denom"
	QueryGetParams = "parameters"
)

Querier routes for the incentive module

Variables

View Source
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")
)
View Source
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

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

View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func BytesToUint64

func BytesToUint64(bz []byte) uint64

BytesToUint64 returns uint64 format from a byte array

func GetClaimPeriodPrefix

func GetClaimPeriodPrefix(denom string, id uint64) []byte

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

func GetTotalVestingPeriodLength(periods vesting.Periods) int64

GetTotalVestingPeriodLength returns the summed length of all vesting periods

func NewPeriod

func NewPeriod(amount sdk.Coins, length int64) vesting.Period

NewPeriod returns a new vesting period

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable Key declaration for parameters

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

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

func NewClaim

func NewClaim(owner sdk.AccAddress, reward sdk.Coin, denom string, claimPeriodID uint64) Claim

NewClaim returns a new Claim

func (Claim) String

func (c Claim) String() string

String implements fmt.Stringer

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

func NewClaimPeriod(denom string, id uint64, end time.Time, timeLock time.Duration) ClaimPeriod

NewClaimPeriod returns a new ClaimPeriod

func (ClaimPeriod) String

func (cp ClaimPeriod) String() string

String implements fmt.Stringer

type ClaimPeriods

type ClaimPeriods []ClaimPeriod

ClaimPeriods array of ClaimPeriod

type Claims

type Claims []Claim

Claims array of Claim

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

type GenesisClaimPeriodIDs

type GenesisClaimPeriodIDs []GenesisClaimPeriodID

GenesisClaimPeriodIDs array of GenesisClaimPeriodID

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

func NewParams

func NewParams(active bool, rewards Rewards) Params

NewParams returns a new params object

func (*Params) ParamSetPairs

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

ParamSetPairs implements the ParamSet interface and returns all the key/value pairs

func (Params) String

func (p Params) String() string

String implements fmt.Stringer

func (Params) Validate

func (p Params) Validate() error

Validate checks that the parameters have valid values.

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.

func NewReward

func NewReward(active bool, denom string, reward sdk.Coin, duration time.Duration, timelock time.Duration, claimDuration time.Duration) Reward

NewReward returns a new Reward

func (Reward) String

func (r Reward) String() string

String implements fmt.Stringer

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

func (rp RewardPeriod) String() string

String implements fmt.Stringer

type RewardPeriods

type RewardPeriods []RewardPeriod

RewardPeriods array of RewardPeriod

type Rewards

type Rewards []Reward

Rewards array of Reward

func (Rewards) String

func (rs Rewards) String() string

String implements fmt.Stringer

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

Jump to

Keyboard shortcuts

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