rewards

package
v0.0.0-...-589da53 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Send(event events.Event)
	SendBatch(events []events.Event)
}

Broker for sending events.

type Collateral

type Collateral interface {
	GetAccountByID(id string) (*types.Account, error)
	TransferRewards(ctx context.Context, rewardAccountID string, transfers []*types.Transfer) ([]*types.LedgerMovement, error)
	GetRewardAccountsByType(rewardAcccountType types.AccountType) []*types.Account
}

Collateral engine provides access to account data and transferring rewards.

type Config

type Config struct {
	Level encoding.LogLevel `long:"log-level"`
}

Config represent the configuration of the collateral engine.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type Delegation

type Delegation interface {
	ProcessEpochDelegations(ctx context.Context, epoch types.Epoch) []*types.ValidatorData
	GetValidatorData() []*types.ValidatorData
}

Delegation engine for getting validation data

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the reward engine handling reward payouts.

func New

func New(log *logging.Logger, config Config, broker Broker, delegation Delegation, epochEngine EpochEngine, collateral Collateral, ts TimeService, marketActivityTracker MarketActivityTracker, topology Topology) *Engine

New instantiate a new rewards engine.

func (*Engine) OnEpochEvent

func (e *Engine) OnEpochEvent(ctx context.Context, epoch types.Epoch)

OnEpochEvent calculates the reward amounts parties get for available reward schemes.

func (*Engine) OnEpochRestore

func (e *Engine) OnEpochRestore(ctx context.Context, epoch types.Epoch)

func (*Engine) UpdateAssetForStakingAndDelegation

func (e *Engine) UpdateAssetForStakingAndDelegation(ctx context.Context, asset string) error

func (*Engine) UpdateCompetitionLevelForStakingRewardScheme

func (e *Engine) UpdateCompetitionLevelForStakingRewardScheme(ctx context.Context, compLevel num.Decimal) error

UpdateCompetitionLevelForStakingRewardScheme is called when the competition level has changed.

func (*Engine) UpdateDelegatorShareForStakingRewardScheme

func (e *Engine) UpdateDelegatorShareForStakingRewardScheme(ctx context.Context, delegatorShare num.Decimal) error

UpdateDelegatorShareForStakingRewardScheme is a callback for changes in the network param for delegator share.

func (*Engine) UpdateErsatzRewardFactor

func (e *Engine) UpdateErsatzRewardFactor(ctx context.Context, ersatzRewardFactor num.Decimal) error

UpdateErsatzRewardFactor updates the ratio of staking and delegation reward that goes to ersatz validators.

func (*Engine) UpdateMaxPayoutPerParticipantForStakingRewardScheme

func (e *Engine) UpdateMaxPayoutPerParticipantForStakingRewardScheme(ctx context.Context, maxPayoutPerParticipant num.Decimal) error

UpdateMaxPayoutPerParticipantForStakingRewardScheme is a callback for changes in the network param for max payout per participant.

func (*Engine) UpdateMinValidatorsStakingRewardScheme

func (e *Engine) UpdateMinValidatorsStakingRewardScheme(ctx context.Context, minValidators int64) error

UpdateMinValidatorsStakingRewardScheme is called when the the network parameter for min validator has changed.

func (*Engine) UpdateMinimumValidatorStakeForStakingRewardScheme

func (e *Engine) UpdateMinimumValidatorStakeForStakingRewardScheme(ctx context.Context, minValStake num.Decimal) error

UpdateMinimumValidatorStakeForStakingRewardScheme updaates the value of minimum validator stake for being considered for rewards.

func (*Engine) UpdateOptimalStakeMultiplierStakingRewardScheme

func (e *Engine) UpdateOptimalStakeMultiplierStakingRewardScheme(ctx context.Context, optimalStakeMultiplier num.Decimal) error

UpdateOptimalStakeMultiplierStakingRewardScheme updaates the value of optimal stake multiplier.

type EpochEngine

type EpochEngine interface {
	NotifyOnEpoch(f func(context.Context, types.Epoch), r func(context.Context, types.Epoch))
}

TimeService notifies the reward engine at the end of an epoch.

type MarketActivityTracker

type MarketActivityTracker interface {
	GetAllMarketIDs() []string
	GetProposer(market string) string
	GetFeePartyScores(asset string, feeType types.TransferType) []*types.PartyContibutionScore
}

type TimeService

type TimeService interface {
	GetTimeNow() time.Time
}

TimeService notifies the reward engine on time updates

type Topology

type Topology interface {
	GetRewardsScores(ctx context.Context, epochSeq string, delegationState []*types.ValidatorData, stakeScoreParams types.StakeScoreParams) (*types.ScoreData, *types.ScoreData)
	RecalcValidatorSet(ctx context.Context, epochSeq string, delegationState []*types.ValidatorData, stakeScoreParams types.StakeScoreParams)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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