Documentation ¶
Index ¶
- Constants
- Variables
- type Assets
- type AuctionState
- type Broker
- type Collateral
- type EligibilityChecker
- type EpochEngine
- type EquityLikeShares
- type EquityShares
- func (es *EquityShares) AllShares() map[string]num.Decimal
- func (es *EquityShares) AvgEntryValuation(id string) num.Decimal
- func (es *EquityShares) AvgTradeValue(avg num.Decimal) *EquityShares
- func (es EquityShares) Changed() bool
- func (es *EquityShares) GetCPShares() []*types.ELSShare
- func (es *EquityShares) GetLPSCount() int
- func (es *EquityShares) GetMarketGrowth() num.Decimal
- func (es *EquityShares) GetState() *types.EquityShare
- func (es *EquityShares) GetTotalVStake() num.Decimal
- func (es *EquityShares) InheritELS(shares []*types.ELSShare)
- func (es *EquityShares) LpsToLiquidityProviderFeeShare(ls map[string]num.Decimal) []*types.LiquidityProviderFeeShare
- func (es *EquityShares) OpeningAuctionEnded()
- func (es *EquityShares) ResetAvgToLP(id string)
- func (es *EquityShares) RestoreELS(shares []*types.ELSShare)
- func (es *EquityShares) RollbackParentELS()
- func (es *EquityShares) SetCPShares(shares []*types.ELSShare)
- func (es *EquityShares) SetPartyStake(id string, newStakeU *num.Uint)
- func (es *EquityShares) SharesExcept(except map[string]struct{}) map[string]num.Decimal
- func (es *EquityShares) SharesFromParty(party string) num.Decimal
- func (es *EquityShares) UpdateVStake()
- type ExpiringOrders
- func (a ExpiringOrders) Changed() bool
- func (a *ExpiringOrders) Expire(ts int64) []string
- func (a *ExpiringOrders) GetExpiryingOrderCount() int
- func (a *ExpiringOrders) GetState() []*types.Order
- func (a *ExpiringOrders) Insert(orderID string, ts int64)
- func (a *ExpiringOrders) RemoveOrder(expiresAt int64, orderID string) bool
- type FeeSplitter
- func (fs *FeeSplitter) AddTradeValue(tv *num.Uint)
- func (fs *FeeSplitter) AvgTradeValue() num.Decimal
- func (fs *FeeSplitter) Changed() bool
- func (fs *FeeSplitter) Elapsed() time.Duration
- func (fs *FeeSplitter) GetState() *types.FeeSplitter
- func (fs *FeeSplitter) MarketValueProxy(mvwl time.Duration, totalStakeU *num.Uint) num.Decimal
- func (fs *FeeSplitter) SetCurrentTime(t time.Time) error
- func (fs *FeeSplitter) SetElapsed(e time.Duration)
- func (fs *FeeSplitter) SetTradeValue(tv *num.Uint)
- func (fs *FeeSplitter) TimeWindowStart(t time.Time)
- func (fs *FeeSplitter) TradeValue() *num.Uint
- type FeeTransfer
- type IDGenerator
- type LiquidityEngine
- type MarketActivityTracker
- func (mat *MarketActivityTracker) AddValueTraded(marketID string, value *num.Uint)
- func (mat *MarketActivityTracker) Checkpoint() ([]byte, error)
- func (mat *MarketActivityTracker) GetAllMarketIDs() []string
- func (mat *MarketActivityTracker) GetFeePartyScores(market string, feeType types.TransferType) []*types.PartyContibutionScore
- func (mat *MarketActivityTracker) GetMarketScores(asset string, markets []string, dispatchMetric vega.DispatchMetric) []*types.MarketContributionScore
- func (mat *MarketActivityTracker) GetMarketsWithEligibleProposer(asset string, markets []string, payoutAsset string, funder string) []*types.MarketContributionScore
- func (mat *MarketActivityTracker) GetProposer(market string) string
- func (mat *MarketActivityTracker) GetState(k string) ([]byte, []types.StateProvider, error)
- func (mat *MarketActivityTracker) IsMarketEligibleForBonus(market string, payoutAsset string, marketsInScope []string, funder string) bool
- func (mat *MarketActivityTracker) Keys() []string
- func (mat *MarketActivityTracker) Load(ctx context.Context, data []byte) error
- func (mat *MarketActivityTracker) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)
- func (mat *MarketActivityTracker) MarkPaidProposer(market, payoutAsset string, marketsInScope []string, funder string)
- func (mat *MarketActivityTracker) MarketProposed(asset, marketID, proposer string)
- func (mat *MarketActivityTracker) Name() types.CheckpointName
- func (mat *MarketActivityTracker) Namespace() types.SnapshotNamespace
- func (mat *MarketActivityTracker) RemoveMarket(marketID string)
- func (mat *MarketActivityTracker) SetEligibilityChecker(eligibilityChecker EligibilityChecker)
- func (mat *MarketActivityTracker) Stopped() bool
- func (mat *MarketActivityTracker) UpdateFeesFromTransfers(market string, transfers []*types.Transfer)
- type MarketLiquidity
- func (m *MarketLiquidity) AmendLiquidityProvision(ctx context.Context, lpa *types.LiquidityProvisionAmendment, party string, ...) error
- func (m *MarketLiquidity) EndBlock()
- func (m *MarketLiquidity) NewTransfer(partyID string, transferType types.TransferType, amount *num.Uint) *types.Transfer
- func (m *MarketLiquidity) OnEarlyExitPenalty(earlyExitPenalty num.Decimal)
- func (m *MarketLiquidity) OnEpochEnd(ctx context.Context, t time.Time)
- func (m *MarketLiquidity) OnEpochRestore(ctx context.Context, epoch types.Epoch)
- func (m *MarketLiquidity) OnEpochStart(ctx context.Context, now time.Time, markPrice, targetStake *num.Uint, ...)
- func (m *MarketLiquidity) OnFeeDistributionTimeStep(feeDistributionTimeStep time.Duration)
- func (m *MarketLiquidity) OnMinLPStakeQuantumMultiple(minLPStakeQuantumMultiple num.Decimal)
- func (m *MarketLiquidity) OnPriceRange(priceRange num.Decimal)
- func (m *MarketLiquidity) OnTick(ctx context.Context, t time.Time)
- func (m *MarketLiquidity) SubmitLiquidityProvision(ctx context.Context, sub *types.LiquidityProvisionSubmission, party string, ...) (err error)
- func (m *MarketLiquidity) TxProcessed(txCount int, markPrice *num.Uint, positionFactor num.Decimal)
- type OracleEngine
- type PeggedOrders
- func (p *PeggedOrders) AmendParked(amended *types.Order)
- func (p *PeggedOrders) Changed() bool
- func (p *PeggedOrders) EnterAuction(ctx context.Context) []events.Event
- func (p *PeggedOrders) GetAllParkedForParty(party string) (orders []*types.Order)
- func (p *PeggedOrders) GetParkedByID(id string) *types.Order
- func (p *PeggedOrders) GetParkedIDs() []string
- func (p *PeggedOrders) GetParkedOrdersCount() int
- func (p *PeggedOrders) GetState() *types.PeggedOrdersState
- func (p *PeggedOrders) IsParked(id string) bool
- func (p *PeggedOrders) Park(o *types.Order)
- func (p *PeggedOrders) Parked() []*types.Order
- func (p *PeggedOrders) RemoveAllForParty(ctx context.Context, party string, status types.OrderStatus) (orders []*types.Order, evts []events.Event)
- func (p *PeggedOrders) Settled() []*types.Order
- func (p *PeggedOrders) Unpark(oid string)
- type PriceMonitor
- type StateVarEngine
- type TimeService
Constants ¶
const InitialOrderVersion = 1
InitialOrderVersion is set on `Version` field for every new order submission read from the network.
Variables ¶
var ( // ErrMarketClosed signals that an action have been tried to be applied on a closed market. ErrMarketClosed = errors.New("market closed") // ErrPartyDoNotExists signals that the party used does not exists. ErrPartyDoNotExists = errors.New("party does not exist") // ErrMarginCheckFailed signals that a margin check for a position failed. ErrMarginCheckFailed = errors.New("margin check failed") // ErrMarginCheckInsufficient signals that a margin had not enough funds. ErrMarginCheckInsufficient = errors.New("insufficient margin") // ErrMissingGeneralAccountForParty ... ErrMissingGeneralAccountForParty = errors.New("missing general account for party") // ErrNotEnoughVolumeToZeroOutNetworkOrder ... ErrNotEnoughVolumeToZeroOutNetworkOrder = errors.New("not enough volume to zero out network order") // ErrInvalidAmendRemainQuantity signals incorrect remaining qty for a reduce by amend. ErrInvalidAmendRemainQuantity = errors.New("incorrect remaining qty for a reduce by amend") // ErrEmptyMarketID is returned if processed market has an empty id. ErrEmptyMarketID = errors.New("invalid market id (empty)") // ErrInvalidOrderType is returned if processed order has an invalid order type. ErrInvalidOrderType = errors.New("invalid order type") // ErrInvalidExpiresAtTime is returned if the expire time is before the createdAt time. ErrInvalidExpiresAtTime = errors.New("invalid expiresAt time") // ErrGFAOrderReceivedDuringContinuousTrading is returned is a gfa order hits the market when the market is in continuous trading state. ErrGFAOrderReceivedDuringContinuousTrading = errors.New("gfa order received during continuous trading") // ErrGFNOrderReceivedAuctionTrading is returned if a gfn order hits the market when in auction state. ErrGFNOrderReceivedAuctionTrading = errors.New("gfn order received during auction trading") // ErrIOCOrderReceivedAuctionTrading is returned if a ioc order hits the market when in auction state. ErrIOCOrderReceivedAuctionTrading = errors.New("ioc order received during auction trading") // ErrFOKOrderReceivedAuctionTrading is returned if a fok order hits the market when in auction state. ErrFOKOrderReceivedAuctionTrading = errors.New("fok order received during auction trading") // ErrUnableToReprice we are unable to get a price required to reprice. ErrUnableToReprice = errors.New("unable to reprice") // ErrOrderNotFound we cannot find the order in the market. ErrOrderNotFound = errors.New("unable to find the order in the market") // ErrTradingNotAllowed no trading related functionalities are allowed in the current state. ErrTradingNotAllowed = errors.New("trading not allowed") // ErrCommitmentSubmissionNotAllowed no commitment submission are permitted in the current state. ErrCommitmentSubmissionNotAllowed = errors.New("commitment submission not allowed") // ErrNotEnoughStake is returned when a LP update results in not enough commitment. ErrNotEnoughStake = errors.New("commitment submission rejected, not enough stake") // ErrPartyNotLiquidityProvider is returned when a LP update or cancel does not match an LP party. ErrPartyNotLiquidityProvider = errors.New("party is not a liquidity provider") // ErrPartyAlreadyLiquidityProvider is returned when a LP is submitted by a party which is already LP. ErrPartyAlreadyLiquidityProvider = errors.New("party is already a liquidity provider") // ErrCannotRejectMarketNotInProposedState. ErrCannotRejectMarketNotInProposedState = errors.New("cannot reject a market not in proposed state") // ErrCannotStateOpeningAuctionForMarketNotInProposedState. ErrCannotStartOpeningAuctionForMarketNotInProposedState = errors.New("cannot start the opening auction for a market not in proposed state") // ErrCannotRepriceDuringAuction. ErrCannotRepriceDuringAuction = errors.New("cannot reprice during auction") // ErrPartyInsufficientAssetBalance is returned when a party does not have sufficient balance of the required asset to perform an action. ErrPartyInsufficientAssetBalance = errors.New("party has insufficient balance in asset") ErrMaxStopOrdersPerPartyReached = errors.New("max stop orders per party reached") ErrStopOrderSubmissionNotAllowedWithoutExistingPosition = errors.New("stop order submission not allowed without existing position") ErrStopOrderSideNotClosingThePosition = errors.New("side used in stop order does not close the position") ErrStopOrderMustBeReduceOnly = errors.New("stop order must be reduce only") ErrStopOrderExpiryInThePast = errors.New("stop order expiry in the past") )
var ErrCommitmentAmountTooLow = errors.New("commitment amount is too low")
var (
ErrSnapshotKeyDoesNotExist = errors.New("unknown key for market activity tracker snapshot")
)
var One = num.UintOne()
Functions ¶
This section is empty.
Types ¶
type AuctionState ¶
type AuctionState interface { price.AuctionState lmon.AuctionState // are we in auction, and what auction are we in? InAuction() bool IsOpeningAuction() bool IsPriceAuction() bool IsLiquidityAuction() bool IsFBA() bool IsMonitorAuction() bool // is it the start/end of an auction AuctionStart() bool CanLeave() bool // when does the auction start/end ExpiresAt() *time.Time Start() time.Time // signal we've started/ended the auction AuctionStarted(ctx context.Context, time time.Time) *events.Auction AuctionExtended(ctx context.Context, time time.Time) *events.Auction ExtendAuction(delta types.AuctionDuration) Left(ctx context.Context, now time.Time) *events.Auction // get some data Mode() types.MarketTradingMode Trigger() types.AuctionTrigger ExtensionTrigger() types.AuctionTrigger // UpdateMinDuration works out whether or not the current auction period (if applicable) should be extended UpdateMinDuration(ctx context.Context, d time.Duration) *events.Auction // Snapshot GetState() *types.AuctionState Changed() bool }
AuctionState ...
type Collateral ¶
type Collateral interface { Deposit(ctx context.Context, party, asset string, amount *num.Uint) (*types.LedgerMovement, error) Withdraw(ctx context.Context, party, asset string, amount *num.Uint) (*types.LedgerMovement, error) EnableAsset(ctx context.Context, asset types.Asset) error GetPartyGeneralAccount(party, asset string) (*types.Account, error) GetPartyBondAccount(market, partyID, asset string) (*types.Account, error) BondUpdate(ctx context.Context, market string, transfer *types.Transfer) (*types.LedgerMovement, error) BondSpotUpdate(ctx context.Context, market string, transfer *types.Transfer) (*types.LedgerMovement, error) RemoveBondAccount(partyID, marketID, asset string) error MarginUpdateOnOrder(ctx context.Context, marketID string, update events.Risk) (*types.LedgerMovement, events.Margin, error) GetPartyMargin(pos events.MarketPosition, asset, marketID string) (events.Margin, error) GetPartyMarginAccount(market, party, asset string) (*types.Account, error) RollbackMarginUpdateOnOrder(ctx context.Context, marketID string, assetID string, transfer *types.Transfer) (*types.LedgerMovement, error) GetOrCreatePartyBondAccount(ctx context.Context, partyID, marketID, asset string) (*types.Account, error) CreatePartyMarginAccount(ctx context.Context, partyID, marketID, asset string) (string, error) FinalSettlement(ctx context.Context, marketID string, transfers []*types.Transfer, factor *num.Uint) ([]*types.LedgerMovement, error) ClearMarket(ctx context.Context, mktID, asset string, parties []string, keepInsurance bool) ([]*types.LedgerMovement, error) HasGeneralAccount(party, asset string) bool ClearPartyMarginAccount(ctx context.Context, party, market, asset string) (*types.LedgerMovement, error) CanCoverBond(market, party, asset string, amount *num.Uint) bool Hash() []byte TransferFeesContinuousTrading(ctx context.Context, marketID string, assetID string, ft events.FeesTransfer) ([]*types.LedgerMovement, error) TransferFees(ctx context.Context, marketID string, assetID string, ft events.FeesTransfer) ([]*types.LedgerMovement, error) TransferSpotFees(ctx context.Context, marketID string, assetID string, ft events.FeesTransfer) ([]*types.LedgerMovement, error) TransferSpotFeesContinuousTrading(ctx context.Context, marketID string, assetID string, ft events.FeesTransfer) ([]*types.LedgerMovement, error) MarginUpdate(ctx context.Context, marketID string, updates []events.Risk) ([]*types.LedgerMovement, []events.Margin, []events.Margin, error) MarkToMarket(ctx context.Context, marketID string, transfers []events.Transfer, asset string) ([]events.Margin, []*types.LedgerMovement, error) RemoveDistressed(ctx context.Context, parties []events.MarketPosition, marketID, asset string) (*types.LedgerMovement, error) GetMarketLiquidityFeeAccount(market, asset string) (*types.Account, error) GetAssetQuantum(asset string) (num.Decimal, error) GetInsurancePoolBalance(marketID, asset string) (*num.Uint, bool) AssetExists(string) bool CreateMarketAccounts(context.Context, string, string) (string, string, error) SuccessorInsuranceFraction(ctx context.Context, successor, parent, asset string, fraction num.Decimal) *types.LedgerMovement ClearInsurancepool(ctx context.Context, marketID string, asset string, clearFees bool) ([]*types.LedgerMovement, error) GetOrCreatePartyLiquidityFeeAccount(ctx context.Context, partyID, marketID, asset string) (*types.Account, error) GetPartyLiquidityFeeAccount(market, partyID, asset string) (*types.Account, error) GetLiquidityFeesBonusDistributionAccount(marketID, asset string) (*types.Account, error) CreateSpotMarketAccounts(ctx context.Context, marketID, quoteAsset string) error CreatePartyGeneralAccount(ctx context.Context, partyID, asset string) (string, error) GetOrCreateLiquidityFeesBonusDistributionAccount(ctx context.Context, marketID, asset string) (*types.Account, error) }
type EligibilityChecker ¶
type EpochEngine ¶
type EquityLikeShares ¶
type EquityLikeShares interface {}
type EquityShares ¶
type EquityShares struct {
// contains filtered or unexported fields
}
EquityShares module controls the Equity sharing algorithm described on the spec: https://github.com/vegaprotocol/product/blob/02af55e048a92a204e9ee7b7ae6b4475a198c7ff/specs/0042-setting-fees-and-rewarding-lps.md#calculating-liquidity-provider-equity-like-share
func NewEquityShares ¶
func NewEquityShares(mvp num.Decimal) *EquityShares
func NewEquitySharesFromSnapshot ¶
func NewEquitySharesFromSnapshot(state *types.EquityShare) *EquityShares
func (*EquityShares) AllShares ¶
func (es *EquityShares) AllShares() map[string]num.Decimal
AllShares returns the ratio of equity for each party on the market.
func (*EquityShares) AvgEntryValuation ¶
func (es *EquityShares) AvgEntryValuation(id string) num.Decimal
AvgEntryValuation returns the Average Entry Valuation for a given party.
func (*EquityShares) AvgTradeValue ¶
func (es *EquityShares) AvgTradeValue(avg num.Decimal) *EquityShares
func (EquityShares) Changed ¶
func (es EquityShares) Changed() bool
func (*EquityShares) GetCPShares ¶
func (es *EquityShares) GetCPShares() []*types.ELSShare
func (*EquityShares) GetLPSCount ¶
func (es *EquityShares) GetLPSCount() int
func (*EquityShares) GetMarketGrowth ¶
func (es *EquityShares) GetMarketGrowth() num.Decimal
func (*EquityShares) GetState ¶
func (es *EquityShares) GetState() *types.EquityShare
func (*EquityShares) GetTotalVStake ¶
func (es *EquityShares) GetTotalVStake() num.Decimal
func (*EquityShares) InheritELS ¶
func (es *EquityShares) InheritELS(shares []*types.ELSShare)
func (*EquityShares) LpsToLiquidityProviderFeeShare ¶
func (es *EquityShares) LpsToLiquidityProviderFeeShare(ls map[string]num.Decimal) []*types.LiquidityProviderFeeShare
func (*EquityShares) OpeningAuctionEnded ¶
func (es *EquityShares) OpeningAuctionEnded()
OpeningAuctionEnded signal to the EquityShare that the opening auction has ended.
func (*EquityShares) ResetAvgToLP ¶ added in v0.72.7
func (es *EquityShares) ResetAvgToLP(id string)
func (*EquityShares) RestoreELS ¶
func (es *EquityShares) RestoreELS(shares []*types.ELSShare)
func (*EquityShares) RollbackParentELS ¶
func (es *EquityShares) RollbackParentELS()
func (*EquityShares) SetCPShares ¶
func (es *EquityShares) SetCPShares(shares []*types.ELSShare)
func (*EquityShares) SetPartyStake ¶
func (es *EquityShares) SetPartyStake(id string, newStakeU *num.Uint)
SetPartyStake sets LP values for a given party.
func (*EquityShares) SharesExcept ¶
func (es *EquityShares) SharesExcept(except map[string]struct{}) map[string]num.Decimal
SharesExcept returns the ratio of equity for each party on the market, except the ones listed in parameter.
func (*EquityShares) SharesFromParty ¶
func (es *EquityShares) SharesFromParty(party string) num.Decimal
SharesFromParty returns the equity-like shares of a given party on the market.
func (*EquityShares) UpdateVStake ¶
func (es *EquityShares) UpdateVStake()
type ExpiringOrders ¶
type ExpiringOrders struct {
// contains filtered or unexported fields
}
func NewExpiringOrders ¶
func NewExpiringOrders() *ExpiringOrders
func NewExpiringOrdersFromState ¶
func NewExpiringOrdersFromState(orders []*types.Order) *ExpiringOrders
func (ExpiringOrders) Changed ¶
func (a ExpiringOrders) Changed() bool
func (*ExpiringOrders) Expire ¶
func (a *ExpiringOrders) Expire(ts int64) []string
func (*ExpiringOrders) GetExpiryingOrderCount ¶
func (a *ExpiringOrders) GetExpiryingOrderCount() int
func (*ExpiringOrders) GetState ¶
func (a *ExpiringOrders) GetState() []*types.Order
func (*ExpiringOrders) Insert ¶
func (a *ExpiringOrders) Insert( orderID string, ts int64, )
func (*ExpiringOrders) RemoveOrder ¶
func (a *ExpiringOrders) RemoveOrder(expiresAt int64, orderID string) bool
type FeeSplitter ¶
type FeeSplitter struct {
// contains filtered or unexported fields
}
func NewFeeSplitter ¶
func NewFeeSplitter() *FeeSplitter
func NewFeeSplitterFromSnapshot ¶
func NewFeeSplitterFromSnapshot(fs *types.FeeSplitter, now time.Time) *FeeSplitter
func (*FeeSplitter) AddTradeValue ¶
func (fs *FeeSplitter) AddTradeValue(tv *num.Uint)
func (*FeeSplitter) AvgTradeValue ¶
func (fs *FeeSplitter) AvgTradeValue() num.Decimal
func (*FeeSplitter) Changed ¶
func (fs *FeeSplitter) Changed() bool
func (*FeeSplitter) Elapsed ¶
func (fs *FeeSplitter) Elapsed() time.Duration
Elapsed returns the distance (in duration) from TimeWindowStart and CurrentTime.
func (*FeeSplitter) GetState ¶
func (fs *FeeSplitter) GetState() *types.FeeSplitter
func (*FeeSplitter) MarketValueProxy ¶
MarketValueProxy returns the market value proxy according to the spec: https://github.com/vegaprotocol/product/blob/master/specs/0042-setting-fees-and-rewarding-lps.md
func (*FeeSplitter) SetCurrentTime ¶
func (fs *FeeSplitter) SetCurrentTime(t time.Time) error
func (*FeeSplitter) SetElapsed ¶
func (fs *FeeSplitter) SetElapsed(e time.Duration)
func (*FeeSplitter) SetTradeValue ¶
func (fs *FeeSplitter) SetTradeValue(tv *num.Uint)
func (*FeeSplitter) TimeWindowStart ¶
func (fs *FeeSplitter) TimeWindowStart(t time.Time)
TimeWindowStart starts or restarts (if active) a current time window. This sets the internal timers to `t` and resets the accumulated trade values.
func (*FeeSplitter) TradeValue ¶
func (fs *FeeSplitter) TradeValue() *num.Uint
type FeeTransfer ¶
type FeeTransfer struct {
// contains filtered or unexported fields
}
func NewFeeTransfer ¶
func (FeeTransfer) TotalFeesAmountPerParty ¶
func (ft FeeTransfer) TotalFeesAmountPerParty() map[string]*num.Uint
func (FeeTransfer) Transfers ¶
func (ft FeeTransfer) Transfers() []*types.Transfer
type IDGenerator ¶
type IDGenerator interface {
NextID() string
}
type LiquidityEngine ¶
type LiquidityEngine interface { ResetSLAEpoch(t time.Time, markPrice *num.Uint, positionFactor num.Decimal) ApplyPendingProvisions(ctx context.Context, now time.Time) map[string]*types.LiquidityProvision PendingProvision() map[string]*types.LiquidityProvision PendingProvisionByPartyID(party string) *types.LiquidityProvision CalculateSLAPenalties(time.Time) liquidity.SlaPenalties ResetAverageLiquidityScores() UpdateAverageLiquidityScores(num.Decimal, num.Decimal, *num.Uint, *num.Uint) GetAverageLiquidityScores() map[string]num.Decimal SubmitLiquidityProvision(context.Context, *types.LiquidityProvisionSubmission, string, liquidity.IDGen) (bool, error) RejectLiquidityProvision(context.Context, string) error AmendLiquidityProvision(context.Context, *types.LiquidityProvisionAmendment, string) error ValidateLiquidityProvisionAmendment(*types.LiquidityProvisionAmendment) error IsLiquidityProvider(string) bool ProvisionsPerParty() liquidity.ProvisionsPerParty LiquidityProvisionByPartyID(string) *types.LiquidityProvision CalculateSuppliedStake() *num.Uint CalculateSuppliedStakeWithoutPending() *num.Uint UpdatePartyCommitment(string, *num.Uint) (*types.LiquidityProvision, error) EndBlock() TxProcessed(txCount int, markPrice *num.Uint, positionFactor num.Decimal) }
type MarketActivityTracker ¶
type MarketActivityTracker struct {
// contains filtered or unexported fields
}
MarketActivityTracker tracks how much fees are paid and received for a market by parties by epoch.
func NewMarketActivityTracker ¶
func NewMarketActivityTracker(log *logging.Logger, epochEngine EpochEngine) *MarketActivityTracker
NewFeesTracker instantiates the fees tracker.
func (*MarketActivityTracker) AddValueTraded ¶
func (mat *MarketActivityTracker) AddValueTraded(marketID string, value *num.Uint)
AddValueTraded records the value of a trade done in the given market.
func (*MarketActivityTracker) Checkpoint ¶
func (mat *MarketActivityTracker) Checkpoint() ([]byte, error)
func (*MarketActivityTracker) GetAllMarketIDs ¶
func (mat *MarketActivityTracker) GetAllMarketIDs() []string
GetAllMarketIDs returns all the current market IDs.
func (*MarketActivityTracker) GetFeePartyScores ¶
func (mat *MarketActivityTracker) GetFeePartyScores(market string, feeType types.TransferType) []*types.PartyContibutionScore
GetFeePartyScores returns the fraction each of the participants paid/received in the given fee of the market in the relevant period.
func (*MarketActivityTracker) GetMarketScores ¶
func (mat *MarketActivityTracker) GetMarketScores(asset string, markets []string, dispatchMetric vega.DispatchMetric) []*types.MarketContributionScore
GetMarketScores calculates the aggregate share of the asset/market in contribution to the metric out of either all the markets of the asset or the subset specified.
func (*MarketActivityTracker) GetMarketsWithEligibleProposer ¶
func (mat *MarketActivityTracker) GetMarketsWithEligibleProposer(asset string, markets []string, payoutAsset string, funder string) []*types.MarketContributionScore
GetMarketsWithEligibleProposer gets all the markets within the given asset (or just all the markets in scope passed as a parameter) that are eligible for proposer bonus.
func (*MarketActivityTracker) GetProposer ¶
func (mat *MarketActivityTracker) GetProposer(market string) string
GetProposer returns the proposer of the market or empty string if the market doesn't exist.
func (*MarketActivityTracker) GetState ¶
func (mat *MarketActivityTracker) GetState(k string) ([]byte, []types.StateProvider, error)
func (*MarketActivityTracker) IsMarketEligibleForBonus ¶
func (mat *MarketActivityTracker) IsMarketEligibleForBonus(market string, payoutAsset string, marketsInScope []string, funder string) bool
IsMarketEligibleForBonus returns true is the market proposer is eligible for market proposer bonus and has not been paid for the combination of payout asset and marketsInScope. The proposer is not market as having been paid until told to do so (if actually paid).
func (*MarketActivityTracker) Keys ¶
func (mat *MarketActivityTracker) Keys() []string
func (*MarketActivityTracker) Load ¶
func (mat *MarketActivityTracker) Load(ctx context.Context, data []byte) error
func (*MarketActivityTracker) LoadState ¶
func (mat *MarketActivityTracker) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)
func (*MarketActivityTracker) MarkPaidProposer ¶
func (mat *MarketActivityTracker) MarkPaidProposer(market, payoutAsset string, marketsInScope []string, funder string)
MarkProposerPaid marks the proposer of the market as having been paid proposer bonus.
func (*MarketActivityTracker) MarketProposed ¶
func (mat *MarketActivityTracker) MarketProposed(asset, marketID, proposer string)
MarketProposed is called when the market is proposed and adds the market to the tracker.
func (*MarketActivityTracker) Name ¶
func (mat *MarketActivityTracker) Name() types.CheckpointName
func (*MarketActivityTracker) Namespace ¶
func (mat *MarketActivityTracker) Namespace() types.SnapshotNamespace
func (*MarketActivityTracker) RemoveMarket ¶
func (mat *MarketActivityTracker) RemoveMarket(marketID string)
removeMarket is called when the market is removed from the network. It is not immediately removed to give a chance for rewards to be paid at the end of the epoch for activity during the epoch. Instead it is marked for removal and will be removed at the beginning of the next epoch.
func (*MarketActivityTracker) SetEligibilityChecker ¶
func (mat *MarketActivityTracker) SetEligibilityChecker(eligibilityChecker EligibilityChecker)
func (*MarketActivityTracker) Stopped ¶
func (mat *MarketActivityTracker) Stopped() bool
func (*MarketActivityTracker) UpdateFeesFromTransfers ¶
func (mat *MarketActivityTracker) UpdateFeesFromTransfers(market string, transfers []*types.Transfer)
UpdateFeesFromTransfers takes a slice of transfers and if they represent fees it updates the market fee tracker. market is guaranteed to exist in the mapping as it is added when proposed.
type MarketLiquidity ¶
type MarketLiquidity struct {
// contains filtered or unexported fields
}
func NewMarketLiquidity ¶
func NewMarketLiquidity( log *logging.Logger, liquidityEngine LiquidityEngine, collateral Collateral, broker Broker, orderBook liquidity.OrderBook, equityShares EquityLikeShares, marketActivityTracker *MarketActivityTracker, fee *fee.Engine, marketID string, asset string, minLPStakeQuantumMultiple num.Decimal, priceFactor *num.Uint, priceRange num.Decimal, earlyExitPenalty num.Decimal, feeDistributionTimeStep time.Duration, ) *MarketLiquidity
func (*MarketLiquidity) AmendLiquidityProvision ¶
func (m *MarketLiquidity) AmendLiquidityProvision( ctx context.Context, lpa *types.LiquidityProvisionAmendment, party string, deterministicID string, marketState types.MarketState, ) error
AmendLiquidityProvision forwards a LiquidityProvisionAmendment to the Liquidity Engine.
func (*MarketLiquidity) EndBlock ¶
func (m *MarketLiquidity) EndBlock()
func (*MarketLiquidity) NewTransfer ¶
func (m *MarketLiquidity) NewTransfer(partyID string, transferType types.TransferType, amount *num.Uint) *types.Transfer
func (*MarketLiquidity) OnEarlyExitPenalty ¶
func (m *MarketLiquidity) OnEarlyExitPenalty(earlyExitPenalty num.Decimal)
func (*MarketLiquidity) OnEpochEnd ¶
func (m *MarketLiquidity) OnEpochEnd(ctx context.Context, t time.Time)
func (*MarketLiquidity) OnEpochRestore ¶
func (m *MarketLiquidity) OnEpochRestore(ctx context.Context, epoch types.Epoch)
func (*MarketLiquidity) OnEpochStart ¶
func (*MarketLiquidity) OnFeeDistributionTimeStep ¶
func (m *MarketLiquidity) OnFeeDistributionTimeStep(feeDistributionTimeStep time.Duration)
func (*MarketLiquidity) OnMinLPStakeQuantumMultiple ¶
func (m *MarketLiquidity) OnMinLPStakeQuantumMultiple(minLPStakeQuantumMultiple num.Decimal)
func (*MarketLiquidity) OnPriceRange ¶
func (m *MarketLiquidity) OnPriceRange(priceRange num.Decimal)
func (*MarketLiquidity) OnTick ¶
func (m *MarketLiquidity) OnTick(ctx context.Context, t time.Time)
lp -> general per market fee account.
func (*MarketLiquidity) SubmitLiquidityProvision ¶
func (m *MarketLiquidity) SubmitLiquidityProvision( ctx context.Context, sub *types.LiquidityProvisionSubmission, party string, deterministicID string, marketState types.MarketState, ) (err error)
SubmitLiquidityProvision forwards a LiquidityProvisionSubmission to the Liquidity Engine.
func (*MarketLiquidity) TxProcessed ¶
type OracleEngine ¶
type OracleEngine interface { ListensToSigners(oracles.OracleData) bool Subscribe(context.Context, oracles.OracleSpec, oracles.OnMatchedOracleData) (oracles.SubscriptionID, oracles.Unsubscriber) Unsubscribe(context.Context, oracles.SubscriptionID) }
OracleEngine ...
type PeggedOrders ¶
type PeggedOrders struct {
// contains filtered or unexported fields
}
func NewPeggedOrders ¶
func NewPeggedOrders(log *logging.Logger, ts TimeService) *PeggedOrders
func NewPeggedOrdersFromSnapshot ¶
func NewPeggedOrdersFromSnapshot( log *logging.Logger, ts TimeService, state *types.PeggedOrdersState, ) *PeggedOrders
func (*PeggedOrders) AmendParked ¶
func (p *PeggedOrders) AmendParked(amended *types.Order)
func (*PeggedOrders) Changed ¶
func (p *PeggedOrders) Changed() bool
func (*PeggedOrders) EnterAuction ¶
func (p *PeggedOrders) EnterAuction(ctx context.Context) []events.Event
func (*PeggedOrders) GetAllParkedForParty ¶
func (p *PeggedOrders) GetAllParkedForParty(party string) (orders []*types.Order)
func (*PeggedOrders) GetParkedByID ¶
func (p *PeggedOrders) GetParkedByID(id string) *types.Order
func (*PeggedOrders) GetParkedIDs ¶
func (p *PeggedOrders) GetParkedIDs() []string
func (*PeggedOrders) GetParkedOrdersCount ¶
func (p *PeggedOrders) GetParkedOrdersCount() int
func (*PeggedOrders) GetState ¶
func (p *PeggedOrders) GetState() *types.PeggedOrdersState
func (*PeggedOrders) IsParked ¶
func (p *PeggedOrders) IsParked(id string) bool
func (*PeggedOrders) Park ¶
func (p *PeggedOrders) Park(o *types.Order)
func (*PeggedOrders) Parked ¶
func (p *PeggedOrders) Parked() []*types.Order
func (*PeggedOrders) RemoveAllForParty ¶
func (p *PeggedOrders) RemoveAllForParty( ctx context.Context, party string, status types.OrderStatus, ) (orders []*types.Order, evts []events.Event)
func (*PeggedOrders) Settled ¶
func (p *PeggedOrders) Settled() []*types.Order
func (*PeggedOrders) Unpark ¶
func (p *PeggedOrders) Unpark(oid string)
type PriceMonitor ¶
type PriceMonitor interface { OnTimeUpdate(now time.Time) CheckPrice(ctx context.Context, as price.AuctionState, trades []*types.Trade, persistent bool) bool GetCurrentBounds() []*types.PriceMonitoringBounds SetMinDuration(d time.Duration) GetValidPriceRange() (num.WrappedDecimal, num.WrappedDecimal) // Snapshot GetState() *types.PriceMonitor Changed() bool IsBoundFactorsInitialised() bool Initialised() bool UpdateSettings(risk.Model, *types.PriceMonitoringSettings) }
PriceMonitor interface to handle price monitoring/auction triggers @TODO the interface shouldn't be imported here.
type StateVarEngine ¶
type StateVarEngine interface { RegisterStateVariable(asset, market, name string, converter statevar.Converter, startCalculation func(string, statevar.FinaliseCalculation), trigger []statevar.EventType, result func(context.Context, statevar.StateVariableResult) error) error UnregisterStateVariable(asset, market string) NewEvent(asset, market string, eventType statevar.EventType) ReadyForTimeTrigger(asset, mktID string) }