vesting

package
v0.79.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VestingKey = (&types.PayloadVesting{}).Key()

Functions

This section is empty.

Types

type ActivityStreakVestingMultiplier

type ActivityStreakVestingMultiplier interface {
	GetRewardsVestingMultiplier(party string) num.Decimal
}

type Assets

type Assets interface {
	Get(assetID string) (*assets.Asset, error)
}

type Broker

type Broker interface {
	Send(events events.Event)
	Stage(event events.Event)
}

type Collateral

type Collateral interface {
	TransferVestedRewards(ctx context.Context, transfers []*types.Transfer) ([]*types.LedgerMovement, error)
	GetVestingRecovery() map[string]map[string]*num.Uint
	GetAllVestingQuantumBalance(party string) num.Decimal
	GetAllVestingAndVestedAccountForAsset(asset string) []*types.Account
}

type Config

type Config struct {
	// logging level
	Level encoding.LogLevel
}

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration.

type Engine

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

func New

func New(
	log *logging.Logger,
	c Collateral,
	asvm ActivityStreakVestingMultiplier,
	broker Broker,
	assets Assets,
	parties Parties,
	t Time,
	stakeAccounting StakeAccounting,
) *Engine

func (*Engine) AddReward

func (e *Engine) AddReward(
	ctx context.Context,
	party, asset string,
	amount *num.Uint,
	lockedForEpochs uint64,
)

func (*Engine) GetSingleAndSummedRewardBonusMultipliers added in v0.77.0

func (e *Engine) GetSingleAndSummedRewardBonusMultipliers(party string) (MultiplierAndQuantBalance, MultiplierAndQuantBalance)

GetSingleAndSummedRewardBonusMultipliers returns a single and summed reward bonus multipliers and quantum balances for a party. The single multiplier is calculated based on the quantum balance of the party. The summed multiplier is calculated based on the quantum balance of the party and all derived keys. Caches the summed multiplier and quantum balance for the party.

func (*Engine) OnBenefitTiersUpdate

func (e *Engine) OnBenefitTiersUpdate(_ context.Context, v interface{}) error

func (*Engine) OnCheckpointLoaded

func (e *Engine) OnCheckpointLoaded()

func (*Engine) OnEpochEvent

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

func (*Engine) OnEpochRestore

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

func (*Engine) OnRewardVestingBaseRateUpdate

func (e *Engine) OnRewardVestingBaseRateUpdate(_ context.Context, baseRate num.Decimal) error

func (*Engine) OnRewardVestingMinimumTransferUpdate

func (e *Engine) OnRewardVestingMinimumTransferUpdate(_ context.Context, minimumTransfer num.Decimal) error

func (*Engine) OnStakingAssetUpdate added in v0.79.0

func (e *Engine) OnStakingAssetUpdate(_ context.Context, stakingAsset string) error

func (*Engine) OnTick added in v0.73.8

func (e *Engine) OnTick(ctx context.Context, _ time.Time)

OnTick is called on the beginning of the block. In here this is a post upgrade.

type MultiplierAndQuantBalance added in v0.77.0

type MultiplierAndQuantBalance struct {
	Multiplier     num.Decimal
	QuantumBalance num.Decimal
}

type Parties added in v0.77.0

type Parties interface {
	RelatedKeys(key string) (*types.PartyID, []string)
}

type PartyRewards

type PartyRewards struct {
	// the amounts per assets still being locked in the
	// account and not available to be released
	// this is a map of:
	// asset -> (remainingEpochLock -> Amount)
	Locked map[string]map[uint64]*num.Uint
	// the current part of the vesting account
	// per asset available for vesting
	Vesting map[string]*num.Uint
}

type SnapshotEngine

type SnapshotEngine struct {
	*Engine
}

func NewSnapshotEngine

func NewSnapshotEngine(
	log *logging.Logger,
	c Collateral,
	asvm ActivityStreakVestingMultiplier,
	broker Broker,
	assets Assets,
	parties Parties,
	t Time,
	stakeAccounting StakeAccounting,
) *SnapshotEngine

func (*SnapshotEngine) GetState

func (e *SnapshotEngine) GetState(k string) ([]byte, []types.StateProvider, error)

func (*SnapshotEngine) Keys

func (e *SnapshotEngine) Keys() []string

func (*SnapshotEngine) LoadState

func (e *SnapshotEngine) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)

func (*SnapshotEngine) Namespace

func (e *SnapshotEngine) Namespace() types.SnapshotNamespace

func (*SnapshotEngine) Stopped

func (e *SnapshotEngine) Stopped() bool

type StakeAccounting added in v0.79.0

type StakeAccounting interface {
	AddEvent(ctx context.Context, evt *types.StakeLinking)
}

type Time added in v0.79.0

type Time interface {
	GetTimeNow() time.Time
}

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