execution

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: 24 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")
)

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:"Liquidity" namespace:"liquidity"`
}

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,
) *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,
) (returnedErr error)

func (*Engine) AmendOrder

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

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

func (*Engine) BlockEnd

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

func (*Engine) CancelLiquidityProvision

func (e *Engine) CancelLiquidityProvision(ctx context.Context, cancel *types.LiquidityProvisionCancellation, party string) (returnedErr 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) Checkpoint

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

func (*Engine) GetAsset

func (e *Engine) GetAsset(assetID string) (types.Asset, bool)

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) GetMarket

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

func (*Engine) GetMarketCounters

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) 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) Keys

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

func (*Engine) Load

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

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

func (*Engine) Namespace

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

func (*Engine) OnMarkPriceUpdateMaximumFrequency

func (e *Engine) OnMarkPriceUpdateMaximumFrequency(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) OnMarketLiquidityBondPenaltyUpdate

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

func (*Engine) OnMarketLiquidityMaximumLiquidityFeeFactorLevelUpdate

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

func (*Engine) OnMarketLiquidityProvidersFeeDistributionTimeStep

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

func (*Engine) OnMarketLiquidityProvisionShapesMaxSizeUpdate

func (e *Engine) OnMarketLiquidityProvisionShapesMaxSizeUpdate(
	_ context.Context, v int64,
) error

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) 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

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

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

func (*Engine) OnSuppliedStakeToObligationFactorUpdate

func (e *Engine) OnSuppliedStakeToObligationFactorUpdate(_ context.Context, d num.Decimal) 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) SpotsMarketsEnabled

func (e *Engine) SpotsMarketsEnabled() bool

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,
) (returnedErr error)

func (*Engine) SubmitMarket

func (e *Engine) SubmitMarket(ctx context.Context, marketConfig *types.Market, proposer string) 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,
) (confirmation *types.OrderConfirmation, returnedErr error)

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

func (*Engine) SucceedMarket

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

func (*Engine) UpdateMarket

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

UpdateMarket will update an existing market configuration.

Directories

Path Synopsis
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