reward

package
v0.0.0-...-6519026 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const PercentDenominator = 1_000_000

PercentDenominator is the denominator used to calculate percentages

Variables

This section is empty.

Functions

func Split

func Split(totalAmount uint64, shares uint32) (uint64, uint64)

Split [totalAmount] into [totalAmount * shares percentage] and the remainder.

Invariant: [shares] <= PercentDenominator

Types

type Calculator

type Calculator interface {
	Calculate(stakedDuration time.Duration, currentTime time.Time, stakedAmount uint64) uint64
}

func NewCalculator

func NewCalculator(c Config) Calculator

type Config

type Config struct {
	// MinStakePeriod is the minimal stake duration.
	MinStakePeriod time.Duration
	// MaxStakePeriod is the maximum stake duration.
	MaxStakePeriod time.Duration
	// StakePeriodRewardShare is the maximum period reward given for a
	// stake period equal to MaxStakePeriod.
	StakePeriodRewardShare uint64
	// StartRewardShare is the starting share of rewards given to validators.
	// Restrictions:
	// - Must be > 0
	// - Must be <= [reward.PercentDenominator]
	StartRewardShare uint64 `serialize:"true" json:"startRewardShare"`
	// StartRewardTime is the starting timestamp that will be used to calculate
	// the remaining percentage of rewards given to validators.
	// Restrictions:
	// - Must be > 0
	// - Must be <= [TargetRewardTime]
	StartRewardTime uint64 `serialize:"true" json:"startRewardTime"`
	// DiminishingRewardShare is the share of rewards given to validators at the start of diminishing year.
	// Restrictions:
	// - Must be > 0
	// - Must be <= [StartRewardShare]
	DiminishingRewardShare uint64 `serialize:"true" json:"diminishingRewardShare"`
	// DiminishingRewardTime is the target timestamp that will be used to calculate
	// the remaining percentage of rewards given to validators.
	// Restrictions:
	// - Must be >= [StartRewardTime]
	DiminishingRewardTime uint64 `serialize:"true" json:"diminishingRewardTime"`
	// TargetRewardShare is the target final share of rewards given to validators.
	// Restrictions:
	// - Must be > 0
	// - Must be <= [DiminishingRewardShare]
	TargetRewardShare uint64 `serialize:"true" json:"targetRewardShare"`
	// TargetRewardTime is the target timestamp that will be used to calculate
	// the remaining percentage of rewards given to validators.
	// Restrictions:
	// - Must be >= [DiminishingRewardTime]
	TargetRewardTime uint64 `serialize:"true" json:"targetRewardTime"`
}

Jump to

Keyboard shortcuts

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