referral

package
v0.75.8-fix.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaximumWindowLength uint64 = 100

Variables

View Source
var (
	ErrIsAlreadyAReferee = func(party types.PartyID) error {
		return fmt.Errorf("party %q has already been referred", party)
	}

	ErrIsAlreadyAReferrer = func(party types.PartyID) error {
		return fmt.Errorf("party %q is already a referrer", party)
	}

	ErrUnknownReferralCode = func(code types.ReferralSetID) error {
		return fmt.Errorf("no referral set for referral code %q", code)
	}

	ErrNotEligibleForReferralRewards = func(party string, balance, required *num.Uint) error {
		return fmt.Errorf("party %q not eligible for referral rewards, staking balance required of %s got %s", party, required.String(), balance.String())
	}

	ErrNotPartOfAReferralSet = func(party types.PartyID) error {
		return fmt.Errorf("party %q is not part of a referral set", party)
	}

	ErrPartyDoesNotOwnReferralSet = func(party types.PartyID) error {
		return fmt.Errorf("party %q does not own the referral set", party)
	}

	ErrUnknownSetID = errors.New("unknown set ID")
)

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Send(events.Event)
}

Broker is used to notify administrative actions on teams and members.

type Engine

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

func NewEngine

func NewEngine(broker Broker, timeSvc TimeService, mat MarketActivityTracker, staking StakingBalances) *Engine

func (*Engine) ApplyReferralCode

func (e *Engine) ApplyReferralCode(ctx context.Context, party types.PartyID, setID types.ReferralSetID) error

func (*Engine) CheckSufficientBalanceForApplyReferralCode

func (e *Engine) CheckSufficientBalanceForApplyReferralCode(party types.PartyID, balance *num.Uint) error

func (*Engine) CheckSufficientBalanceForCreateOrUpdateReferralSet added in v0.74.0

func (e *Engine) CheckSufficientBalanceForCreateOrUpdateReferralSet(party types.PartyID, balance *num.Uint) error

func (*Engine) CreateReferralSet

func (e *Engine) CreateReferralSet(ctx context.Context, party types.PartyID, deterministicSetID types.ReferralSetID) error

func (*Engine) GetReferrer

func (e *Engine) GetReferrer(referee types.PartyID) (types.PartyID, error)

func (*Engine) HasProgramEnded

func (e *Engine) HasProgramEnded() bool

func (*Engine) OnEpoch

func (e *Engine) OnEpoch(ctx context.Context, ep types.Epoch)

func (*Engine) OnEpochRestore

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

func (*Engine) OnMinBalanceForApplyReferralCodeUpdated

func (e *Engine) OnMinBalanceForApplyReferralCodeUpdated(_ context.Context, min *num.Uint) error

func (*Engine) OnMinBalanceForReferralProgramUpdated added in v0.74.0

func (e *Engine) OnMinBalanceForReferralProgramUpdated(_ context.Context, min *num.Uint) error

func (*Engine) OnReferralProgramMaxPartyNotionalVolumeByQuantumPerEpochUpdate

func (e *Engine) OnReferralProgramMaxPartyNotionalVolumeByQuantumPerEpochUpdate(_ context.Context, value *num.Uint) error

func (*Engine) OnReferralProgramMaxReferralRewardProportionUpdate

func (e *Engine) OnReferralProgramMaxReferralRewardProportionUpdate(_ context.Context, value num.Decimal) error

func (*Engine) OnReferralProgramMinStakedVegaTokensUpdate

func (e *Engine) OnReferralProgramMinStakedVegaTokensUpdate(_ context.Context, value *num.Uint) error

func (*Engine) PartyOwnsReferralSet added in v0.75.2

func (e *Engine) PartyOwnsReferralSet(referer types.PartyID, setID types.ReferralSetID) error

func (*Engine) ReferralDiscountFactorForParty

func (e *Engine) ReferralDiscountFactorForParty(party types.PartyID) num.Decimal

func (*Engine) RewardsFactorForParty

func (e *Engine) RewardsFactorForParty(party types.PartyID) num.Decimal

func (*Engine) RewardsFactorMultiplierAppliedForParty

func (e *Engine) RewardsFactorMultiplierAppliedForParty(party types.PartyID) num.Decimal

func (*Engine) RewardsMultiplierForParty

func (e *Engine) RewardsMultiplierForParty(party types.PartyID) num.Decimal

func (*Engine) UpdateProgram

func (e *Engine) UpdateProgram(newProgram *types.ReferralProgram)

type EpochEngine

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

EpochEngine is used to know when to apply the team switches.

type MarketActivityTracker

type MarketActivityTracker interface {
	NotionalTakerVolumeForParty(string) *num.Uint
}

MarketActivityTracker is used to retrieve the trading statistics about a party to compute referral program related data.

type SnapshottedEngine

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

func NewSnapshottedEngine

func NewSnapshottedEngine(broker Broker, timeSvc TimeService, mat MarketActivityTracker, staking StakingBalances) *SnapshottedEngine

func (*SnapshottedEngine) GetState

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

func (*SnapshottedEngine) Keys

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

func (*SnapshottedEngine) LoadState

func (*SnapshottedEngine) Namespace

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

func (*SnapshottedEngine) StopSnapshots

func (e *SnapshottedEngine) StopSnapshots()

func (*SnapshottedEngine) Stopped

func (e *SnapshottedEngine) Stopped() bool

type StakingBalances

type StakingBalances interface {
	GetAvailableBalance(party string) (*num.Uint, error)
}

type TimeService

type TimeService 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