v0_11

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

func NewClaim

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

NewClaim returns a new Claim

func (Claim) String

func (c Claim) String() string

String implements fmt.Stringer

func (Claim) Validate

func (c Claim) Validate() error

Validate performs a basic check of a Claim fields.

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

func (cp ClaimPeriod) GetMultiplier(name MultiplierName) (Multiplier, bool)

GetMultiplier returns the named multiplier from the input claim period

func (ClaimPeriod) String

func (cp ClaimPeriod) String() string

String implements fmt.Stringer

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 Claims

type Claims []Claim

Claims array of Claim

func (Claims) Validate

func (cs Claims) Validate() error

Validate checks if all the claims 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 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) Validate

func (gs GenesisState) Validate() error

Validate performs basic validation of genesis data returning an error for any failed validation criteria.

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

func (m Multiplier) String() string

String implements fmt.Stringer

func (Multiplier) Validate

func (m Multiplier) Validate() error

Validate multiplier param

type MultiplierName

type MultiplierName string

MultiplierName name for valid multiplier

const (
	Small      MultiplierName = "small"
	Medium     MultiplierName = "medium"
	Large      MultiplierName = "large"
	ModuleName                = "incentive"
)

Valid reward multipliers

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

func (Multipliers) String

func (ms Multipliers) String() string

String implements fmt.Stringer

func (Multipliers) Validate

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 NewParams

func NewParams(active bool, rewards Rewards) Params

NewParams returns a new params object

func (Params) Validate

func (p Params) Validate() error

Validate checks that the parameters have valid values.

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.

func NewReward

func NewReward(active bool, collateralType string, reward sdk.Coin, duration time.Duration, multiplier Multipliers, claimDuration time.Duration) Reward

NewReward returns a new Reward

func (Reward) String

func (r Reward) String() string

String implements fmt.Stringer

func (Reward) Validate

func (r Reward) Validate() error

Validate performs a basic check of a reward fields.

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

func (rp RewardPeriod) String() string

String implements fmt.Stringer

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 Rewards

type Rewards []Reward

Rewards array of Reward

func (Rewards) String

func (rs Rewards) String() string

String implements fmt.Stringer

func (Rewards) Validate

func (rs Rewards) Validate() error

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

Jump to

Keyboard shortcuts

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