types

package
v0.11.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeHarvestDeposit               = "harvest_deposit"
	EventTypeHarvestDelegatorDistribution = "harvest_delegator_distribution"
	EventTypeHarvestLPDistribution        = "harvest_lp_distribution"
	EventTypeDeleteHarvestDeposit         = "delete_harvest_deposit"
	EventTypeHarvestWithdrawal            = "harvest_withdrawal"
	EventTypeClaimHarvestReward           = "claim_harvest_reward"
	AttributeValueCategory                = ModuleName
	AttributeKeyBlockHeight               = "block_height"
	AttributeKeyRewardsDistribution       = "rewards_distributed"
	AttributeKeyDeposit                   = "deposit"
	AttributeKeyDepositType               = "deposit_type"
	AttributeKeyDepositDenom              = "deposit_denom"
	AttributeKeyDepositor                 = "depositor"
	AttributeKeyClaimHolder               = "claim_holder"
	AttributeKeyClaimAmount               = "claim_amount"
	AttributeKeyClaimMultiplier           = "claim_multiplier"
)

Event types for harvest module

View Source
const (
	// ModuleName name that will be used throughout the module
	ModuleName = "harvest"

	// LPAccount LP distribution module account
	LPAccount = "harvest_lp_distribution"

	// DelegatorAccount delegator distribution module account
	DelegatorAccount = "harvest_delegator_distribution"

	// ModuleAccountName name of module account used to hold deposits
	ModuleAccountName = "harvest"

	// StoreKey Top level store key where all module items will be stored
	StoreKey = ModuleName

	// RouterKey Top level router key
	RouterKey = ModuleName

	// QuerierRoute Top level query string
	QuerierRoute = ModuleName

	// DefaultParamspace default name for parameter store
	DefaultParamspace = ModuleName
)
View Source
const (
	Small  MultiplierName = "small"
	Medium MultiplierName = "medium"
	Large  MultiplierName = "large"

	LP    DepositType = "lp"
	Stake DepositType = "stake"
)

Valid reward multipliers and reward types

View Source
const (
	QueryGetParams         = "params"
	QueryGetModuleAccounts = "accounts"
	QueryGetDeposits       = "deposits"
	QueryGetClaims         = "claims"
)

Querier routes for the harvest module

Variables

View Source
var (
	// ErrInvalidDepositDenom error for invalid deposit denoms
	ErrInvalidDepositDenom = sdkerrors.Register(ModuleName, 2, "invalid deposit denom")
	// ErrDepositNotFound error for deposit not found
	ErrDepositNotFound = sdkerrors.Register(ModuleName, 3, "deposit not found")
	// ErrInvaliWithdrawAmount error for invalid withdrawal amount
	ErrInvaliWithdrawAmount = sdkerrors.Register(ModuleName, 4, "withdrawal amount exceeds deposit amount")
	// ErrInvalidDepositType error for invalid deposit type
	ErrInvalidDepositType = sdkerrors.Register(ModuleName, 5, "invalid deposit type")
	// ErrClaimNotFound error for claim not found
	ErrClaimNotFound = sdkerrors.Register(ModuleName, 6, "claim not found")
	// ErrZeroClaim error for claim amount rounded to zero
	ErrZeroClaim = sdkerrors.Register(ModuleName, 7, "cannot claim - claim amount rounds to zero")
	// ErrLPScheduleNotFound error for liquidity provider rewards schedule not found
	ErrLPScheduleNotFound = sdkerrors.Register(ModuleName, 8, "no liquidity provider rewards schedule found")
	// ErrGovScheduleNotFound error for governance distribution rewards schedule not found
	ErrGovScheduleNotFound = sdkerrors.Register(ModuleName, 9, "no governance rewards schedule found")
	// ErrInvalidMultiplier error for multiplier not found
	ErrInvalidMultiplier = sdkerrors.Register(ModuleName, 10, "invalid rewards multiplier")
	// ErrInsufficientModAccountBalance error for module account with innsufficient balance
	ErrInsufficientModAccountBalance = sdkerrors.Register(ModuleName, 11, "module account has insufficient balance to pay reward")
	// ErrInvalidAccountType error for unsupported accounts
	ErrInvalidAccountType = sdkerrors.Register(ModuleName, 12, "receiver account type not supported")
	// ErrAccountNotFound error for accounts that are not found in state
	ErrAccountNotFound = sdkerrors.Register(ModuleName, 13, "account not found")
	// ErrClaimExpired error for expired claims
	ErrClaimExpired = sdkerrors.Register(ModuleName, 14, "claim period expired")
	// ErrInvalidReceiver error for when sending and receiving accounts don't match
	ErrInvalidReceiver = sdkerrors.Register(ModuleName, 15, "receiver account must match sender account")
)
View Source
var (
	DefaultPreviousBlockTime = tmtime.Canonical(time.Unix(0, 0))
	DefaultDistributionTimes = GenesisDistributionTimes{}
)

GenesisState default values

View Source
var (
	PreviousBlockTimeKey              = []byte{0x01}
	PreviousDelegationDistributionKey = []byte{0x02}
	DepositsKeyPrefix                 = []byte{0x03}
	ClaimsKeyPrefix                   = []byte{0x04}
)
View Source
var (
	DepositTypesDepositQuery = []DepositType{LP}
	DepositTypesClaimQuery   = []DepositType{LP, Stake}
)

Queryable deposit types

View Source
var (
	KeyActive                 = []byte("Active")
	KeyLPSchedules            = []byte("LPSchedules")
	KeyDelegatorSchedule      = []byte("DelegatorSchedule")
	DefaultActive             = true
	DefaultGovSchedules       = DistributionSchedules{}
	DefaultLPSchedules        = DistributionSchedules{}
	DefaultDelegatorSchedules = DelegatorDistributionSchedules{}
	GovDenom                  = cdptypes.DefaultGovDenom
)

Parameter keys and default values

View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func ClaimKey

func ClaimKey(depositType DepositType, denom string, owner sdk.AccAddress) []byte

ClaimKey key of a specific deposit in the store

func DepositKey

func DepositKey(depositType DepositType, denom string, depositor sdk.AccAddress) []byte

DepositKey key of a specific deposit in the store

func DepositTypeIteratorKey

func DepositTypeIteratorKey(depositType DepositType, denom string) []byte

DepositTypeIteratorKey returns an interator prefix for interating over deposits by deposit type and denom

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

type Claim struct {
	Owner        sdk.AccAddress `json:"owner" yaml:"owner"`
	DepositDenom string         `json:"deposit_denom" yaml:"deposit_denom"`
	Amount       sdk.Coin       `json:"amount" yaml:"amount"`
	Type         DepositType    `json:"type" yaml:"type"`
}

Claim defines an amount of coins that the owner can claim

func NewClaim

func NewClaim(owner sdk.AccAddress, denom string, amount sdk.Coin, dtype DepositType) Claim

NewClaim returns a new claim

type DelegatorDistributionSchedule

type DelegatorDistributionSchedule struct {
	DistributionSchedule DistributionSchedule `json:"distribution_schedule" yaml:"distribution_schedule"`

	DistributionFrequency time.Duration `json:"distribution_frequency" yaml:"distribution_frequency"`
}

DelegatorDistributionSchedule distribution schedule for delegators

func NewDelegatorDistributionSchedule

func NewDelegatorDistributionSchedule(ds DistributionSchedule, frequency time.Duration) DelegatorDistributionSchedule

NewDelegatorDistributionSchedule returns a new DelegatorDistributionSchedule

func (DelegatorDistributionSchedule) Validate

func (dds DelegatorDistributionSchedule) Validate() error

Validate performs a basic check of a reward fields.

type DelegatorDistributionSchedules

type DelegatorDistributionSchedules []DelegatorDistributionSchedule

DelegatorDistributionSchedules slice of DelegatorDistributionSchedule

func (DelegatorDistributionSchedules) Validate

func (dds DelegatorDistributionSchedules) Validate() error

Validate checks if all the LiquidityProviderSchedules are valid and there are no duplicated entries.

type Deposit

type Deposit struct {
	Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
	Amount    sdk.Coin       `json:"amount" yaml:"amount"`
	Type      DepositType    `json:"type" yaml:"type"`
}

Deposit defines an amount of coins deposited into a harvest module account

func NewDeposit

func NewDeposit(depositor sdk.AccAddress, amount sdk.Coin, dtype DepositType) Deposit

NewDeposit returns a new deposit

type DepositType

type DepositType string

DepositType type for valid deposit type strings

func (DepositType) IsValid

func (dt DepositType) IsValid() error

IsValid checks if the input is one of the expected strings

type DistributionSchedule

type DistributionSchedule struct {
	Active           bool        `json:"active" yaml:"active"`
	DepositDenom     string      `json:"deposit_denom" yaml:"deposit_denom"`
	Start            time.Time   `json:"start" yaml:"start"`
	End              time.Time   `json:"end" yaml:"end"`
	RewardsPerSecond sdk.Coin    `json:"rewards_per_second" yaml:"rewards_per_second"`
	ClaimEnd         time.Time   `json:"claim_end" yaml:"claim_end"`
	ClaimMultipliers Multipliers `json:"claim_multipliers" yaml:"claim_multipliers"`
}

DistributionSchedule distribution schedule for liquidity providers

func NewDistributionSchedule

func NewDistributionSchedule(active bool, denom string, start, end time.Time, reward sdk.Coin, claimEnd time.Time, multipliers Multipliers) DistributionSchedule

NewDistributionSchedule returns a new DistributionSchedule

func (DistributionSchedule) GetMultiplier

func (ds DistributionSchedule) GetMultiplier(name MultiplierName) (Multiplier, bool)

GetMultiplier returns the named multiplier from the input distribution schedule

func (DistributionSchedule) String

func (ds DistributionSchedule) String() string

String implements fmt.Stringer

func (DistributionSchedule) Validate

func (ds DistributionSchedule) Validate() error

Validate performs a basic check of a distribution schedule.

type DistributionSchedules

type DistributionSchedules []DistributionSchedule

DistributionSchedules slice of DistributionSchedule

func (DistributionSchedules) String

func (dss DistributionSchedules) String() string

String implements fmt.Stringer

func (DistributionSchedules) Validate

func (dss DistributionSchedules) Validate() error

Validate checks if all the LiquidityProviderSchedules are valid and there are no duplicated entries.

type GenesisDistributionTime

type GenesisDistributionTime struct {
	Denom                    string    `json:"denom" yaml:"denom"`
	PreviousDistributionTime time.Time `json:"previous_distribution_time" yaml:"previous_distribution_time"`
}

GenesisDistributionTime stores the previous distribution time and its corresponding denom

type GenesisDistributionTimes

type GenesisDistributionTimes []GenesisDistributionTime

GenesisDistributionTimes slice of GenesisDistributionTime

type GenesisState

type GenesisState struct {
	Params                    Params                   `json:"params" yaml:"params"`
	PreviousBlockTime         time.Time                `json:"previous_block_time" yaml:"previous_block_time"`
	PreviousDistributionTimes GenesisDistributionTimes `json:"previous_distribution_times" yaml:"previous_distribution_times"`
}

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, previousDistTimes GenesisDistributionTimes) 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"`
	Receiver       sdk.AccAddress `json:"receiver" yaml:"receiver"`
	DepositDenom   string         `json:"deposit_denom" yaml:"deposit_denom"`
	MultiplierName string         `json:"multiplier_name" yaml:"multiplier_name"`
	DepositType    string         `json:"deposit_type" yaml:"deposit_type"`
}

MsgClaimReward message type used to claim rewards

func NewMsgClaimReward

func NewMsgClaimReward(sender, receiver sdk.AccAddress, depositDenom, depositType, multiplier 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 MsgDeposit

type MsgDeposit struct {
	Depositor   sdk.AccAddress `json:"depositor" yaml:"depositor"`
	Amount      sdk.Coin       `json:"amount" yaml:"amount"`
	DepositType string         `json:"deposit_type" yaml:"deposit_type"`
}

MsgDeposit deposit collateral to the harvest module.

func NewMsgDeposit

func NewMsgDeposit(depositor sdk.AccAddress, amount sdk.Coin, depositType string) MsgDeposit

NewMsgDeposit returns a new MsgDeposit

func (MsgDeposit) GetSignBytes

func (msg MsgDeposit) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgDeposit) GetSigners

func (msg MsgDeposit) GetSigners() []sdk.AccAddress

GetSigners returns the addresses of signers that must sign.

func (MsgDeposit) Route

func (msg MsgDeposit) Route() string

Route return the message type used for routing the message.

func (MsgDeposit) String

func (msg MsgDeposit) String() string

String implements the Stringer interface

func (MsgDeposit) Type

func (msg MsgDeposit) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgDeposit) ValidateBasic

func (msg MsgDeposit) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgWithdraw

type MsgWithdraw struct {
	Depositor   sdk.AccAddress `json:"depositor" yaml:"depositor"`
	Amount      sdk.Coin       `json:"amount" yaml:"amount"`
	DepositType string         `json:"deposit_type" yaml:"deposit_type"`
}

MsgWithdraw withdraw from the harvest module.

func NewMsgWithdraw

func NewMsgWithdraw(depositor sdk.AccAddress, amount sdk.Coin, depositType string) MsgWithdraw

NewMsgWithdraw returns a new MsgWithdraw

func (MsgWithdraw) GetSignBytes

func (msg MsgWithdraw) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgWithdraw) GetSigners

func (msg MsgWithdraw) GetSigners() []sdk.AccAddress

GetSigners returns the addresses of signers that must sign.

func (MsgWithdraw) Route

func (msg MsgWithdraw) Route() string

Route return the message type used for routing the message.

func (MsgWithdraw) String

func (msg MsgWithdraw) String() string

String implements the Stringer interface

func (MsgWithdraw) Type

func (msg MsgWithdraw) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgWithdraw) ValidateBasic

func (msg MsgWithdraw) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type Multiplier

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

func NewMultiplier(name MultiplierName, lockup int64, factor sdk.Dec) Multiplier

NewMultiplier returns a new Multiplier

func (Multiplier) Validate

func (m Multiplier) Validate() error

Validate multiplier param

type MultiplierName

type MultiplierName string

MultiplierName name for valid multiplier

func (MultiplierName) IsValid

func (mn MultiplierName) IsValid() error

IsValid checks if the input is one of the expected strings

type Multipliers

type Multipliers []Multiplier

Multipliers slice of Multiplier

type Params

type Params struct {
	Active                         bool                           `json:"active" yaml:"active"`
	LiquidityProviderSchedules     DistributionSchedules          `json:"liquidity_provider_schedules" yaml:"liquidity_provider_schedules"`
	DelegatorDistributionSchedules DelegatorDistributionSchedules `json:"delegator_distribution_schedules" yaml:"delegator_distribution_schedules"`
}

Params governance parameters for harvest module

func DefaultParams

func DefaultParams() Params

DefaultParams returns default params for harvest module

func NewParams

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 QueryAccountParams

type QueryAccountParams struct {
	Page  int    `json:"page" yaml:"page"`
	Limit int    `json:"limit" yaml:"limit"`
	Name  string `json:"name" yaml:"name"`
}

QueryAccountParams is the params for a filtered module account query

func NewQueryAccountParams

func NewQueryAccountParams(page, limit int, name string) QueryAccountParams

NewQueryAccountParams returns QueryAccountParams

type QueryClaimParams

type QueryClaimParams struct {
	Page         int            `json:"page" yaml:"page"`
	Limit        int            `json:"limit" yaml:"limit"`
	DepositDenom string         `json:"deposit_denom" yaml:"deposit_denom"`
	Owner        sdk.AccAddress `json:"owner" yaml:"owner"`
	DepositType  DepositType    `json:"deposit_type" yaml:"deposit_type"`
}

QueryClaimParams is the params for a filtered claim query

func NewQueryClaimParams

func NewQueryClaimParams(page, limit int, depositDenom string, owner sdk.AccAddress, depositType DepositType) QueryClaimParams

NewQueryClaimParams creates a new QueryClaimParams

type QueryDepositParams

type QueryDepositParams struct {
	Page         int            `json:"page" yaml:"page"`
	Limit        int            `json:"limit" yaml:"limit"`
	DepositDenom string         `json:"deposit_denom" yaml:"deposit_denom"`
	Owner        sdk.AccAddress `json:"owner" yaml:"owner"`
	DepositType  DepositType    `json:"deposit_type" yaml:"deposit_type"`
}

QueryDepositParams is the params for a filtered deposit query

func NewQueryDepositParams

func NewQueryDepositParams(page, limit int, depositDenom string, owner sdk.AccAddress, depositType DepositType) QueryDepositParams

NewQueryDepositParams creates a new QueryDepositParams

type StakingKeeper

type StakingKeeper interface {
	IterateLastValidators(ctx sdk.Context, fn func(index int64, validator stakingexported.ValidatorI) (stop bool))
	IterateValidators(sdk.Context, func(index int64, validator stakingexported.ValidatorI) (stop bool))
	IterateAllDelegations(ctx sdk.Context, cb func(delegation stakingtypes.Delegation) (stop bool))
	GetBondedPool(ctx sdk.Context) (bondedPool exported.ModuleAccountI)
	BondDenom(ctx sdk.Context) (res string)
}

StakingKeeper defines the expected keeper interface for the staking keeper

type SupplyKeeper

type SupplyKeeper interface {
	GetModuleAddress(name string) sdk.AccAddress
	GetModuleAccount(ctx sdk.Context, name string) exported.ModuleAccountI
	GetSupply(ctx sdk.Context) (supply exported.SupplyI)
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
	MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error
}

SupplyKeeper defines the expected supply keeper

Jump to

Keyboard shortcuts

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