future

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: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PriceMoveMid used to indicate that the mid price has moved.
	PriceMoveMid = 1

	// PriceMoveBestBid used to indicate that the best bid price has moved.
	PriceMoveBestBid = 2

	// PriceMoveBestAsk used to indicate that the best ask price has moved.
	PriceMoveBestAsk = 4

	// PriceMoveAll used to indicate everything has moved.
	PriceMoveAll = PriceMoveMid + PriceMoveBestBid + PriceMoveBestAsk
)

Variables

View Source
var ErrBondSlashing = errors.New("bond slashing")

ErrBondSlashing - just indicates that we had to penalize the party due to insufficient funds, and as such, we have to cancel their LP.

View Source
var ErrCommitmentAmountTooLow = errors.New("commitment amount is too low")

Functions

This section is empty.

Types

type LiquidityMonitor

type LiquidityMonitor interface {
	CheckLiquidity(as lmon.AuctionState, t time.Time, currentStake *num.Uint, trades []*types.Trade, rf types.RiskFactor, markPrice *num.Uint, bestStaticBidVolume, bestStaticAskVolume uint64, persistent bool) bool
	SetMinDuration(d time.Duration)
	UpdateTargetStakeTriggerRatio(ctx context.Context, ratio num.Decimal)
	UpdateParameters(*types.LiquidityMonitoringParameters)
}

LiquidityMonitor.

type Market

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

Market represents an instance of a market in fury and is in charge of calling the engines in order to process all transactions.

func NewMarket

func NewMarket(
	ctx context.Context,
	log *logging.Logger,
	riskConfig risk.Config,
	positionConfig positions.Config,
	settlementConfig settlement.Config,
	matchingConfig matching.Config,
	feeConfig fee.Config,
	liquidityConfig liquidity.Config,
	collateralEngine common.Collateral,
	oracleEngine products.OracleEngine,
	mkt *types.Market,
	timeService common.TimeService,
	broker common.Broker,
	as *monitor.AuctionState,
	stateVarEngine common.StateVarEngine,
	marketActivityTracker *common.MarketActivityTracker,
	assetDetails *assets.Asset,
	peggedOrderNotify func(int64),
) (*Market, error)

NewMarket creates a new market using the market framework configuration and creates underlying engines.

func NewMarketFromSnapshot

func NewMarketFromSnapshot(
	ctx context.Context,
	log *logging.Logger,
	em *types.ExecMarket,
	riskConfig risk.Config,
	positionConfig positions.Config,
	settlementConfig settlement.Config,
	matchingConfig matching.Config,
	feeConfig fee.Config,
	liquidityConfig liquidity.Config,
	collateralEngine common.Collateral,
	oracleEngine products.OracleEngine,
	timeService common.TimeService,
	broker common.Broker,
	stateVarEngine common.StateVarEngine,
	assetDetails *assets.Asset,
	marketActivityTracker *common.MarketActivityTracker,
	peggedOrderNotify func(int64),
) (*Market, error)

func (*Market) AmendLiquidityProvision

func (m *Market) AmendLiquidityProvision(ctx context.Context, lpa *types.LiquidityProvisionAmendment, party string, deterministicID string) (err error)

AmendLiquidityProvision forwards a LiquidityProvisionAmendment to the Liquidity Engine.

func (*Market) AmendOrder

func (m *Market) AmendOrder(
	ctx context.Context,
	orderAmendment *types.OrderAmendment,
	party string,
	deterministicID string,
) (oc *types.OrderConfirmation, _ error,
)

AmendOrder amend an existing order from the order book.

func (*Market) AmendOrderWithIDGenerator

func (m *Market) AmendOrderWithIDGenerator(
	ctx context.Context,
	orderAmendment *types.OrderAmendment,
	party string,
	idgen common.IDGenerator,
) (oc *types.OrderConfirmation, _ error,
)

func (*Market) BlockEnd

func (m *Market) BlockEnd(ctx context.Context)

BlockEnd notifies the market of the end of the block.

func (*Market) BondPenaltyFactorUpdate

func (m *Market) BondPenaltyFactorUpdate(ctx context.Context, d num.Decimal)

func (*Market) CanLeaveOpeningAuction

func (m *Market) CanLeaveOpeningAuction() bool

CanLeaveOpeningAuction checks if the market can leave the opening auction based on whether floating point consensus has been reached on all 3 vars.

func (*Market) CancelAllOrders

func (m *Market) CancelAllOrders(ctx context.Context, partyID string) ([]*types.OrderCancellationConfirmation, error)

func (*Market) CancelLiquidityProvision

func (m *Market) CancelLiquidityProvision(ctx context.Context, cancel *types.LiquidityProvisionCancellation, party string) (err error)

CancelLiquidityProvision forwards a LiquidityProvisionCancel to the Liquidity Engine.

func (*Market) CancelOrder

func (m *Market) CancelOrder(
	ctx context.Context,
	partyID, orderID string, deterministicID string,
) (oc *types.OrderCancellationConfirmation, _ error)

func (*Market) CancelOrderWithIDGenerator

func (m *Market) CancelOrderWithIDGenerator(
	ctx context.Context,
	partyID, orderID string,
	idgen common.IDGenerator,
) (oc *types.OrderCancellationConfirmation, _ error)

func (*Market) GetCPState

func (m *Market) GetCPState() *types.CPMarketState

func (*Market) GetEquityShares

func (m *Market) GetEquityShares() *common.EquityShares

func (*Market) GetID

func (m *Market) GetID() string

GetID returns the id of the given market.

func (*Market) GetMarketData

func (m *Market) GetMarketData() types.MarketData

func (*Market) GetMarketState

func (m *Market) GetMarketState() types.MarketState

func (*Market) GetNewStateProviders

func (m *Market) GetNewStateProviders() []types.StateProvider

func (*Market) GetNextMTM

func (m *Market) GetNextMTM() time.Time

func (*Market) GetSettlementAsset

func (m *Market) GetSettlementAsset() string

func (*Market) GetState

func (m *Market) GetState() *types.ExecMarket

func (*Market) GetTotalLPShapeCount

func (m *Market) GetTotalLPShapeCount() uint64

GetTotalLPShapeCount returns the total number of LP shapes.

func (*Market) GetTotalOpenPositionCount

func (m *Market) GetTotalOpenPositionCount() uint64

GetTotalOpenPositionCount returns the total number of open positions.

func (*Market) GetTotalOrderBookLevelCount

func (m *Market) GetTotalOrderBookLevelCount() uint64

GetTotalOrderBookLevelCount returns the total number of levels in the order book.

func (*Market) GetTotalPeggedOrderCount

func (m *Market) GetTotalPeggedOrderCount() uint64

GetTotalPeggedOrderCount returns the total number of pegged orders.

func (*Market) Hash

func (m *Market) Hash() []byte

func (*Market) InheritParent

func (m *Market) InheritParent(ctx context.Context, pstate *types.CPMarketState)

func (*Market) IntoType

func (m *Market) IntoType() types.Market

func (*Market) IsSucceeded

func (m *Market) IsSucceeded() bool

func (*Market) LoadCPState

func (m *Market) LoadCPState(state *types.CPMarketState)

func (*Market) Mkt

func (m *Market) Mkt() *types.Market

func (*Market) OnAuctionEnded

func (m *Market) OnAuctionEnded()

OnAuctionEnded is called whenever an auction is ended and emits an event to the state var engine.

func (*Market) OnFeeFactorsInfrastructureFeeUpdate

func (m *Market) OnFeeFactorsInfrastructureFeeUpdate(ctx context.Context, d num.Decimal) error

func (*Market) OnFeeFactorsMakerFeeUpdate

func (m *Market) OnFeeFactorsMakerFeeUpdate(ctx context.Context, d num.Decimal) error

func (*Market) OnMarginScalingFactorsUpdate

func (m *Market) OnMarginScalingFactorsUpdate(ctx context.Context, sf *types.ScalingFactors) error

func (*Market) OnMarkPriceUpdateMaximumFrequency

func (m *Market) OnMarkPriceUpdateMaximumFrequency(ctx context.Context, d time.Duration)

func (*Market) OnMarketAuctionMinimumDurationUpdate

func (m *Market) OnMarketAuctionMinimumDurationUpdate(ctx context.Context, d time.Duration)

func (*Market) OnMarketLiquidityMaximumLiquidityFeeFactorLevelUpdate

func (m *Market) OnMarketLiquidityMaximumLiquidityFeeFactorLevelUpdate(d num.Decimal)

func (*Market) OnMarketLiquidityProvidersFeeDistribitionTimeStep

func (m *Market) OnMarketLiquidityProvidersFeeDistribitionTimeStep(d time.Duration)

func (*Market) OnMarketLiquidityProvisionShapesMaxSizeUpdate

func (m *Market) OnMarketLiquidityProvisionShapesMaxSizeUpdate(v int64) error

func (*Market) OnMarketLiquidityTargetStakeTriggeringRatio

func (m *Market) OnMarketLiquidityTargetStakeTriggeringRatio(ctx context.Context, d num.Decimal)

func (*Market) OnMarketMinLpStakeQuantumMultipleUpdate

func (m *Market) OnMarketMinLpStakeQuantumMultipleUpdate(_ context.Context, d num.Decimal)

func (*Market) OnMarketMinProbabilityOfTradingLPOrdersUpdate

func (m *Market) OnMarketMinProbabilityOfTradingLPOrdersUpdate(_ context.Context, d num.Decimal)

func (*Market) OnMarketProbabilityOfTradingTauScalingUpdate

func (m *Market) OnMarketProbabilityOfTradingTauScalingUpdate(_ context.Context, d num.Decimal)

func (*Market) OnMarketTargetStakeScalingFactorUpdate

func (m *Market) OnMarketTargetStakeScalingFactorUpdate(d num.Decimal) error

func (*Market) OnMarketTargetStakeTimeWindowUpdate

func (m *Market) OnMarketTargetStakeTimeWindowUpdate(d time.Duration)

func (*Market) OnMarketValueWindowLengthUpdate

func (m *Market) OnMarketValueWindowLengthUpdate(d time.Duration)

func (*Market) OnOpeningAuctionFirstUncrossingPrice

func (m *Market) OnOpeningAuctionFirstUncrossingPrice()

OnOpeningAuctionFirstUncrossingPrice is triggered when the opening auction sees an uncrossing price for the first time and emits an event to the state variable engine.

func (*Market) OnSuppliedStakeToObligationFactorUpdate

func (m *Market) OnSuppliedStakeToObligationFactorUpdate(d num.Decimal)

func (*Market) OnTick

func (m *Market) OnTick(ctx context.Context, t time.Time) bool

OnTick notifies the market of a new time event/update. todo: make this a more generic function name e.g. OnTimeUpdateEvent

func (*Market) PostRestore

func (m *Market) PostRestore(ctx context.Context) error

func (*Market) Reject

func (m *Market) Reject(ctx context.Context) error

func (*Market) ReloadConf

func (m *Market) ReloadConf(
	matchingConfig matching.Config,
	riskConfig risk.Config,
	positionConfig positions.Config,
	settlementConfig settlement.Config,
	feeConfig fee.Config,
)

ReloadConf will trigger a reload of all the config settings in the market and all underlying engines this is required when hot-reloading any config changes, eg. logger level.

func (*Market) ResetParentIDAndInsurancePoolFraction

func (m *Market) ResetParentIDAndInsurancePoolFraction()

func (*Market) SetNextMTM

func (m *Market) SetNextMTM(tm time.Time)

func (*Market) SetSucceeded

func (m *Market) SetSucceeded()

func (*Market) SetSuccessorELS

func (m *Market) SetSuccessorELS(state *types.CPMarketState)

func (*Market) StartOpeningAuction

func (m *Market) StartOpeningAuction(ctx context.Context) error

func (*Market) StopSnapshots

func (m *Market) StopSnapshots()

func (*Market) SubmitLiquidityProvision

func (m *Market) SubmitLiquidityProvision(
	ctx context.Context,
	sub *types.LiquidityProvisionSubmission,
	party, deterministicID string,
) (err error,
)

SubmitLiquidityProvision forwards a LiquidityProvisionSubmission to the Liquidity Engine.

func (*Market) SubmitOrder

func (m *Market) SubmitOrder(
	ctx context.Context,
	orderSubmission *types.OrderSubmission,
	party string,
	deterministicID string,
) (oc *types.OrderConfirmation, _ error)

SubmitOrder submits the given order.

func (*Market) SubmitOrderWithIDGeneratorAndOrderID

func (m *Market) SubmitOrderWithIDGeneratorAndOrderID(
	ctx context.Context,
	orderSubmission *types.OrderSubmission,
	party string,
	idgen common.IDGenerator,
	orderID string,
) (oc *types.OrderConfirmation, _ error)

SubmitOrder submits the given order.

func (*Market) Update

func (m *Market) Update(ctx context.Context, config *types.Market, oracleEngine products.OracleEngine) error

type OrderReferenceCheck

type OrderReferenceCheck types.Order

func (OrderReferenceCheck) HasMoved

func (o OrderReferenceCheck) HasMoved(changes uint8) bool

type TargetStakeCalculator

type TargetStakeCalculator interface {
	types.StateProvider
	RecordOpenInterest(oi uint64, now time.Time) error
	GetTargetStake(rf types.RiskFactor, now time.Time, markPrice *num.Uint) *num.Uint
	GetTheoreticalTargetStake(rf types.RiskFactor, now time.Time, markPrice *num.Uint, trades []*types.Trade) *num.Uint
	UpdateScalingFactor(sFactor num.Decimal) error
	UpdateTimeWindow(tWindow time.Duration)
	StopSnapshots()
	UpdateParameters(types.TargetStakeParameters)
}

TargetStakeCalculator interface.

Jump to

Keyboard shortcuts

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