execution

package
v0.76.7 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: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMarketDoesNotExist is returned when the market does not exist.
	ErrMarketDoesNotExist = errors.New("market does not exist")

	// ErrNoMarketID is returned when invalid (empty) market id was supplied during market creation.
	ErrNoMarketID = errors.New("no valid market id was supplied")

	// ErrInvalidOrderCancellation is returned when an incomplete order cancellation request is used.
	ErrInvalidOrderCancellation = errors.New("invalid order cancellation")

	// ErrSuccessorMarketDoesNotExists is returned when SucceedMarket call is made with an invalid successor market ID.
	ErrSuccessorMarketDoesNotExist = errors.New("successor market does not exist")

	// ErrParentMarketNotEnactedYet is returned when trying to enact a successor market that is still in proposed state.
	ErrParentMarketNotEnactedYet = errors.New("parent market in proposed state, can't enact successor")

	// ErrInvalidStopOrdersCancellation is returned when an incomplete stop orders cancellation request is used.
	ErrInvalidStopOrdersCancellation = errors.New("invalid stop orders cancellation")

	// ErrMarketIDRequiredWhenOrderIDSpecified is returned when a stop order cancellation is emitted without an order id.
	ErrMarketIDRequiredWhenOrderIDSpecified = errors.New("market id required when order id specified")

	// ErrStopOrdersNotAcceptedDuringOpeningAuction is returned if a stop order is submitted when the market is in the opening auction.
	ErrStopOrdersNotAcceptedDuringOpeningAuction = errors.New("stop orders are not accepted during the opening auction")
)

Functions

This section is empty.

Types

type Config

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

	Matching   matching.Config   `group:"Matching"    namespace:"matching"`
	Risk       risk.Config       `group:"Risk"        namespace:"risk"`
	Position   positions.Config  `group:"Position"    namespace:"position"`
	Settlement settlement.Config `group:"Settlement"  namespace:"settlement"`
	Fee        fee.Config        `group:"Fee"         namespace:"fee"`
	Liquidity  liquidity.Config  `group:"LiquidityV2" namespace:"liquidityV2"`
}

Config is the configuration of the execution package.

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 Engine

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

Engine is the execution engine.

func NewEngine

func NewEngine(
	log *logging.Logger,
	executionConfig Config,
	ts common.TimeService,
	collateral common.Collateral,
	oracle common.OracleEngine,
	broker common.Broker,
	stateVarEngine common.StateVarEngine,
	marketActivityTracker *common.MarketActivityTracker,
	assets common.Assets,
	referralDiscountRewardService fee.ReferralDiscountRewardService,
	volumeDiscountService fee.VolumeDiscountService,
	banking common.Banking,
) *Engine

NewEngine takes stores and engines and returns a new execution engine to process new orders, etc.

func (*Engine) AmendLiquidityProvision

func (e *Engine) AmendLiquidityProvision(ctx context.Context, lpa *types.LiquidityProvisionAmendment, party string, deterministicID string) error

func (*Engine) AmendOrder

func (e *Engine) AmendOrder(ctx context.Context, amendment *types.OrderAmendment, party string, idgen common.IDGenerator) (*types.OrderConfirmation, error)

AmendOrder takes order amendment details and attempts to amend the order if it exists and is in a editable state.

func (*Engine) BeginBlock added in v0.73.0

func (e *Engine) BeginBlock(ctx context.Context)

func (*Engine) BlockEnd added in v0.63.0

func (e *Engine) BlockEnd(ctx context.Context)

func (*Engine) CancelLiquidityProvision

func (e *Engine) CancelLiquidityProvision(ctx context.Context, cancel *types.LiquidityProvisionCancellation, party string) error

func (*Engine) CancelOrder

func (e *Engine) CancelOrder(
	ctx context.Context,
	cancel *types.OrderCancellation,
	party string,
	idgen common.IDGenerator,
) (_ []*types.OrderCancellationConfirmation, returnedErr error)

CancelOrder takes order details and attempts to cancel if it exists in matching engine, stores etc.

func (*Engine) CancelStopOrders added in v0.72.0

func (e *Engine) CancelStopOrders(ctx context.Context, cancel *types.StopOrdersCancellation, party string, idgen common.IDGenerator) error

func (*Engine) Checkpoint added in v0.72.0

func (e *Engine) Checkpoint() ([]byte, error)

func (*Engine) GetEquityLikeShareForMarketAndParty

func (e *Engine) GetEquityLikeShareForMarketAndParty(market, party string) (num.Decimal, bool)

GetEquityLikeShareForMarketAndParty return the equity-like shares of the given party in the given market. If the market doesn't exist, it returns false.

func (*Engine) GetFillPriceForMarket added in v0.75.0

func (e *Engine) GetFillPriceForMarket(marketID string, volume uint64, side types.Side) (*num.Uint, error)

func (*Engine) GetMarket

func (e *Engine) GetMarket(market string, settled bool) (types.Market, bool)

func (*Engine) GetMarketCounters added in v0.63.0

func (e *Engine) GetMarketCounters() map[string]*types.MarketCounters

GetMarketCounters returns the per-market counts used for gas estimation.

func (*Engine) GetMarketData

func (e *Engine) GetMarketData(mktID string) (types.MarketData, error)

func (*Engine) GetMarketState

func (e *Engine) GetMarketState(mktID string) (types.MarketState, error)

func (*Engine) GetMarketStats added in v0.73.0

func (e *Engine) GetMarketStats() map[string]*types.MarketStats

func (*Engine) GetState

func (e *Engine) GetState(_ string) ([]byte, []types.StateProvider, error)

func (*Engine) Hash

func (e *Engine) Hash() []byte

func (*Engine) IsEligibleForProposerBonus

func (e *Engine) IsEligibleForProposerBonus(marketID string, value *num.Uint) bool

IsEligibleForProposerBonus checks if the given value is greater than that market quantum * quantum_multiplier.

func (*Engine) IsSucceeded added in v0.72.0

func (e *Engine) IsSucceeded(mktID string) bool

func (*Engine) Keys

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

func (*Engine) Load added in v0.72.0

func (e *Engine) Load(ctx context.Context, data []byte) error

func (*Engine) LoadState

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

func (*Engine) MarketExists

func (e *Engine) MarketExists(market string) bool

func (*Engine) Name added in v0.72.0

func (e *Engine) Name() types.CheckpointName

func (*Engine) Namespace

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

func (*Engine) OnChainIDUpdate added in v0.74.0

func (e *Engine) OnChainIDUpdate(cID uint64) error

func (*Engine) OnEpochEvent added in v0.73.0

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

func (*Engine) OnEpochRestore added in v0.73.0

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

func (*Engine) OnInternalCompositePriceUpdateFrequency added in v0.74.0

func (e *Engine) OnInternalCompositePriceUpdateFrequency(ctx context.Context, d time.Duration) error

func (*Engine) OnMarkPriceUpdateMaximumFrequency added in v0.63.0

func (e *Engine) OnMarkPriceUpdateMaximumFrequency(ctx context.Context, d time.Duration) error

func (*Engine) OnMarketAuctionMaximumDurationUpdate added in v0.73.0

func (e *Engine) OnMarketAuctionMaximumDurationUpdate(ctx context.Context, d time.Duration) error

func (*Engine) OnMarketAuctionMinimumDurationUpdate

func (e *Engine) OnMarketAuctionMinimumDurationUpdate(ctx context.Context, d time.Duration) error

func (*Engine) OnMarketCreationQuantumMultipleUpdate

func (e *Engine) OnMarketCreationQuantumMultipleUpdate(ctx context.Context, d num.Decimal) error

func (*Engine) OnMarketFeeFactorsInfrastructureFeeUpdate

func (e *Engine) OnMarketFeeFactorsInfrastructureFeeUpdate(ctx context.Context, d num.Decimal) error

func (*Engine) OnMarketFeeFactorsMakerFeeUpdate

func (e *Engine) OnMarketFeeFactorsMakerFeeUpdate(ctx context.Context, d num.Decimal) error

func (*Engine) OnMarketLiquidityMaximumLiquidityFeeFactorLevelUpdate

func (e *Engine) OnMarketLiquidityMaximumLiquidityFeeFactorLevelUpdate(_ context.Context, d num.Decimal) error

to be removed and replaced by its v2 counterpart. in use only for future.

func (*Engine) OnMarketLiquidityV2BondPenaltyUpdate added in v0.72.0

func (e *Engine) OnMarketLiquidityV2BondPenaltyUpdate(_ context.Context, d num.Decimal) error

OnMarketLiquidityV2BondPenaltyUpdate stores net param on execution engine and applies to markets at the start of new epoch.

func (*Engine) OnMarketLiquidityV2EarlyExitPenaltyUpdate added in v0.72.0

func (e *Engine) OnMarketLiquidityV2EarlyExitPenaltyUpdate(_ context.Context, d num.Decimal) error

OnMarketLiquidityV2EarlyExitPenaltyUpdate stores net param on execution engine and applies to markets at the start of new epoch.

func (*Engine) OnMarketLiquidityV2MaximumLiquidityFeeFactorLevelUpdate added in v0.72.0

func (e *Engine) OnMarketLiquidityV2MaximumLiquidityFeeFactorLevelUpdate(_ context.Context, d num.Decimal) error

OnMarketLiquidityV2MaximumLiquidityFeeFactorLevelUpdate stores net param on execution engine and applies at the start of new epoch.

func (*Engine) OnMarketLiquidityV2ProvidersFeeCalculationTimeStep added in v0.73.0

func (e *Engine) OnMarketLiquidityV2ProvidersFeeCalculationTimeStep(_ context.Context, d time.Duration) error

OnMarketLiquidityV2ProvidersFeeCalculationTimeStep stores net param on execution engine and applies to markets at the start of new epoch.

func (*Engine) OnMarketLiquidityV2SLANonPerformanceBondPenaltyMaxUpdate added in v0.72.0

func (e *Engine) OnMarketLiquidityV2SLANonPerformanceBondPenaltyMaxUpdate(_ context.Context, d num.Decimal) error

OnMarketLiquidityV2SLANonPerformanceBondPenaltyMaxUpdate stores net param on execution engine and applies to markets at the start of new epoch.

func (*Engine) OnMarketLiquidityV2SLANonPerformanceBondPenaltySlopeUpdate added in v0.72.0

func (e *Engine) OnMarketLiquidityV2SLANonPerformanceBondPenaltySlopeUpdate(_ context.Context, d num.Decimal) error

OnMarketLiquidityV2SLANonPerformanceBondPenaltySlopeUpdate stores net param on execution engine and applies to markets at the start of new epoch.

func (*Engine) OnMarketLiquidityV2StakeToCCYVolumeUpdate added in v0.73.0

func (e *Engine) OnMarketLiquidityV2StakeToCCYVolumeUpdate(_ context.Context, d num.Decimal) error

OnMarketLiquidityV2StakeToCCYVolumeUpdate stores net param on execution engine and applies to markets at the start of new epoch.

func (*Engine) OnMarketMarginScalingFactorsUpdate

func (e *Engine) OnMarketMarginScalingFactorsUpdate(ctx context.Context, v interface{}) error

func (*Engine) OnMarketMinProbabilityOfTradingForLPOrdersUpdate

func (e *Engine) OnMarketMinProbabilityOfTradingForLPOrdersUpdate(ctx context.Context, d num.Decimal) error

func (*Engine) OnMarketPartiesMaximumStopOrdersUpdate added in v0.72.0

func (e *Engine) OnMarketPartiesMaximumStopOrdersUpdate(ctx context.Context, u *num.Uint) error

func (*Engine) OnMarketProbabilityOfTradingTauScalingUpdate

func (e *Engine) OnMarketProbabilityOfTradingTauScalingUpdate(ctx context.Context, d num.Decimal) error

func (*Engine) OnMarketValueWindowLengthUpdate

func (e *Engine) OnMarketValueWindowLengthUpdate(_ context.Context, d time.Duration) error

func (*Engine) OnMaxPeggedOrderUpdate added in v0.63.0

func (e *Engine) OnMaxPeggedOrderUpdate(ctx context.Context, max *num.Uint) error

func (*Engine) OnMinLpStakeQuantumMultipleUpdate

func (e *Engine) OnMinLpStakeQuantumMultipleUpdate(ctx context.Context, d num.Decimal) error

func (*Engine) OnStateLoaded

func (e *Engine) OnStateLoaded(ctx context.Context) error

func (*Engine) OnSuccessorMarketTimeWindowUpdate added in v0.72.0

func (e *Engine) OnSuccessorMarketTimeWindowUpdate(ctx context.Context, window time.Duration) error

func (*Engine) OnTick

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

func (*Engine) RejectMarket

func (e *Engine) RejectMarket(ctx context.Context, marketID string) error

RejectMarket will stop the execution of the market and refund into the general account any funds in margins accounts from any parties This works only if the market is in a PROPOSED STATE.

func (*Engine) ReloadConf

func (e *Engine) ReloadConf(cfg Config)

ReloadConf updates the internal configuration of the execution engine and its dependencies.

func (*Engine) RestoreMarket

func (e *Engine) RestoreMarket(ctx context.Context, marketConfig *types.Market) error

RestoreMarket restores a new market from proposal checkpoint.

func (*Engine) StartOpeningAuction

func (e *Engine) StartOpeningAuction(ctx context.Context, marketID string) error

StartOpeningAuction will start the opening auction of the given market. This will work only if the market is currently in a PROPOSED state.

func (*Engine) Stopped

func (e *Engine) Stopped() bool

func (*Engine) SubmitLiquidityProvision

func (e *Engine) SubmitLiquidityProvision(ctx context.Context, sub *types.LiquidityProvisionSubmission, party, deterministicID string) error

func (*Engine) SubmitMarket

func (e *Engine) SubmitMarket(ctx context.Context, marketConfig *types.Market, proposer string, oos time.Time) error

SubmitMarket submits a new market configuration to the network.

func (*Engine) SubmitOrder

func (e *Engine) SubmitOrder(ctx context.Context, submission *types.OrderSubmission, party string, idgen common.IDGenerator, orderID string) (*types.OrderConfirmation, error)

SubmitOrder checks the incoming order and submits it to a Vega market.

func (*Engine) SubmitSpotMarket added in v0.73.0

func (e *Engine) SubmitSpotMarket(ctx context.Context, marketConfig *types.Market, proposer string, oos time.Time) error

SubmitSpotMarket submits a new spot market configuration to the network.

func (*Engine) SubmitStopOrders added in v0.72.0

func (e *Engine) SubmitStopOrders(
	ctx context.Context,
	submission *types.StopOrdersSubmission,
	party string,
	idgen common.IDGenerator,
	fallsBelowID *string,
	risesAboveID *string,
) (*types.OrderConfirmation, error)

func (*Engine) SucceedMarket added in v0.72.0

func (e *Engine) SucceedMarket(ctx context.Context, successor, parent string) error

func (*Engine) UpdateMarginMode added in v0.74.0

func (e *Engine) UpdateMarginMode(ctx context.Context, party, marketID string, marginMode types.MarginMode, marginFactor num.Decimal) error

func (*Engine) UpdateMarket

func (e *Engine) UpdateMarket(ctx context.Context, marketConfig *types.Market) error

UpdateMarket will update an existing market configuration.

func (*Engine) UpdateMarketState added in v0.73.0

func (e *Engine) UpdateMarketState(ctx context.Context, changes *types.MarketStateUpdateConfiguration) error

func (*Engine) UpdateSpotMarket added in v0.73.0

func (e *Engine) UpdateSpotMarket(ctx context.Context, marketConfig *types.Market) error

UpdateSpotMarket will update an existing market configuration.

func (*Engine) VerifyUpdateMarketState added in v0.73.0

func (e *Engine) VerifyUpdateMarketState(changes *types.MarketStateUpdateConfiguration) error

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
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