This spec describes the lifecycle of a market. The market lifecycle begins at acceptance of a proposal and is driven by the market's status
. Each status and the entry and exit criteria are described below.
Markets on Vega are proposed, permissionless, using the governance mechanism. If a market passes the governance vote, it undergoes various state changes throughout its lifecycle. Aspects of the state that change include:
- trading mode
- whether the market is open for trading
- status of settlement
Markets proposed via governance proposals undergo certain additional validations. Note the distinctions between a proposal that is valid
or accepted
and a proposal that is sucessful
. A valid
proposal has passed or will pass validation checks; an accepted
proposal has been received in a Vega transaction and passed validation checks; and a successful
proposal has been voted for and won. The proposal becomes enacted
when the action specified (i.e. for the purposes of this spec, market creation/update/close).
All markets are proposed without any liquidity commitment.
If the proposal is successful the market will go into opening auction at least until the proposed enactment
date. If the enactment date is passed by more than the maximum opening auction extension duration Network Parameter (market.auction.maximumDuration
) and the opening auction hasn't uncrossed, then the market is automatically cancelled.
A market can progress through a number of statuses through its life. The overall market status flow is shown in the diagram below. A market is created in a proposed
state when a valid market creation governance proposal is accepted
.
Status | Accepting LPs[1] | Trading Mode | Condition for entry | Condition for exit |
---|---|---|---|---|
Proposed | Yes | No trading | Governance proposal valid and accepted | Governance proposal voting period ends |
Rejected | No | No trading | Outcome of governance votes is to reject the market | N/A |
Pending | Yes | Opening auction | Governance vote passes/wins | Governance vote (to close) OR enactment date reached |
Cancelled | No | No trading | Market triggers cancellation condition | N/A |
Active | Yes | Normal trading | Enactment date reached and usual auction exit checks pass | Governance vote (to close) OR trigger for trading terminated for of market |
Suspended | Yes | Exceptional auction | Price monitoring trigger, or product lifecycle trigger | Exit conditions met per monitoring spec. that triggered it, no other monitoring triggered or governance vote if allowed (see below) |
Closed | No | No trading | Governance vote (to close) | N/A |
Trading Terminated | No | No trading | Defined by the product (i.e. from a product parameter, specified in market definition, giving close date/time) | Settlement event commences |
Settled | No | No trading | Settlement triggered and completed as defined by product | N/A |
[1] Accepting LPs: it is possible to make or amend Liquidity Provision Commitments.
Note that there is no governance proposal to cancel a market. However it is possible to submit a market change proposal which will change the trading terminated trigger and the settlement price source. Thus, via governance, it is possible to get market into a cancelled state if it never left Pending state (opening auction) or settle a market immediately (if any positions were ever created on the market). Either of these effectively removes the market.
All Markets are first proposed via the governance mechanism. Once the valid Market Proposal is accepted the Market (see market framework) is created and can accept Liquidity Provision Commitments, voting begins and its state is proposed
.
Entry:
- Valid governance proposal submitted and accepted.
Exit:
-
Market Proposal voting period ends
- Passed (yes votes win & thresholds met) β Pending
- Failed (no votes win or thresholds not met) β Rejected
Behaviour:
- Participants can vote for or against the Market Proposal
- Liquidity Providers can make, change, or exit Liquidity Commitments
- No trading is possible, no orders can be placed (except the buy/sell order shapes that form part of a Liquidity Commitment)
- No market data (price, etc.) is emitted, no positions exist on the market, and no risk management occurs
When a Market Proposal is not successful, see governance proposal, Market state is Rejected.
Entry:
- Voting period ends
- Failed (no votes win or thresholds not met) β Rejected
Exit:
- No exit. End state.
Behaviour:
- Nothing can happen to the market with this status - it does not exist (Vega core has no need to keep any information about this market proposal). Any collateral locked to liquidity commitments is returned to the general account of the party that submitted the liquidity commitment.
When a Market Proposal is successful at the end of the voting period, the Market state becomes "Pending". Currently a Pending Market is always in an auction call period that ends at the enactment date as specified in the Market Proposal if the other conditions for exiting auction period are met (liquidity committed, best static bid / ask present). If, initially, at the specified enactment date it was not possible to leave the auction period, the auction will conclude as soon as possible once the conditions for auction exit are met.
Note: this state represents any market that will be created, which currently means a Market Proposal vote has concluded successfully.
Entry:
- Valid Market Proposal was successful (yes votes win & thresholds met)
Exit:
Auction period ends when any of the following occur:
- Enactment date is reached and the conditions for exiting an auction are met and at least one trade will be generated when uncrossing the auction β Active (the auction is uncrossed during this transition)
- Enactment date is passed and the product would trigger the Trading Terminated status β Cancelled (the market ceases to exist, auction orders are cancelled, and no uncrossing occurs)
- Enactment date is passed by more than the maximum opening auction extension duration Network Parameter β Cancelled (the market ceases to exist, auction orders are cancelled, and no uncrossing occurs)
- Market change governance vote approves closure of market β Cancelled (the market ceases to exist, auction orders are cancelled, and no uncrossing occurs)
Behaviour:
- Liquidity providers can make, change, or exit commitments
- Auction orders are accepted as per any regular auction period.
- Margins on orders as per auction margin instructions in margin calculator spec.
A market becomes Cancelled when a Market Proposal is successful and conditions are not met to transition the Market to the Active state during the Pending period, and the trading terminated data source input is triggered, see data sourcing.
When a market transitions to a cancelled state all orders should be cancelled and collateral returned to respective parties general account for the relevant asset, all LP commitments should be cancelled and their bond returned to the general account for the relevant asset. After market.liquidity.successorLaunchWindowLength
has elapsed since cancellation any insurance pool balance should get transferred into the global insurance pool using the same settlement asset.
Once "cancelled" there must be no open positions tracked by the protocol for the market and any open positions must have been closed including returning all margin and other related collateral if necessary and also notifying downstream event consumers that the positions are closed. Specific position related actions may be unnecessary if the cancelled state is being entered from a state in which there cannot possibly have been any open positions. All data sources that are only referenced by this market should be unregistered.
Entry:
- Enactment date is passed and the product would trigger the Trading Terminated status β Cancelled (the market ceases to exist, auction orders are cancelled, and no uncrossing occurs)
- Enactment date is passed by more than the maximum opening auction extension duration Network Parameter β Cancelled (the market ceases to exist, auction orders are cancelled, and no uncrossing occurs)
- Market change governance vote approves closure of market β Cancelled (the market ceases to exist, auction orders are cancelled, and no uncrossing occurs)
Exit:
- No exit. End state.
Behaviour:
- Nothing can happen to the market with this status - it does not exist (Vega core has no need to keep any information about this market proposal).
Once the enactment date is reached and the other conditions specified to exit the Pending state are met, the market becomes Active on conclusion of uncrossing of the opening auction. This status indicates it is trading via its normally configured trading mode according to the market framework (continuous trading, frequent batch auction, RFQ, block only, etc.). The specification for the trading mode should describe which orders are accepted and how trading proceeds. The market will terminate trading according to a product trigger (for futures, if the trading termination date is reached) and can be temporarily suspended automatically by (price monitoring. The market can also be closed via a governance vote (market parameter update) to change the status to closed see the governance spec.
Entry:
- From Pending: enactment date reached and conditions to transition from Pending state to Active as detailed above are met
- From Suspended: conditions specified in price monitoring are met for the market to exit the suspended status back to Active.
Exit:
- Price, liquidity or other monitoring system triggers suspension β Suspended
- Trading termination, settlement, or suspension is triggered by a product trigger (for futures, if the trading termination date, set by a market parameter, is reached) β Trading Terminated | Settled | Suspended
- Market change governance vote approves closure of market β Closed
Behaviour:
- Liquidity Providers can make, change, or exit Liquidity Commitments, as per conditions specified in the liquidity mechanics spec.
- Orders can be placed into the market, trading occurs according to normal trading mode rules
- Market data is emitted
- Positions and margins are managed as per the specs
A Suspended market occurs when an Active market is temporarily stopped from trading to protect the market or the network from various types of risk. Suspension is used when the system has determined it is either not safe or not reasonable to operate the market at the current time, for example due to extremely low liquidity. No trades may be created while a market is Suspended.
Suspension currently always operates as an auction call period. Depending on the type of suspension, the auction call period may have a defined end (which can also be subject to extension) or may be indefinite in which case the auction will end once the required conditions are met. The auction is uncrossed as part of the transition back to the Active state and normal trading. Alternatively, a Suspended market may become closed in which case the auction does not uncross and the orders are discarded.
Entry:
- Price, liquidity or other monitoring system triggers suspension β Suspended
Exit:
- Conditions specified in price monitoring and the usual ending of auction checks pass β Active
- Governance vote to close a market passes β Closed
- Market was suspended by governance vote of product lifecycle trigger and a governance vote passes to set the status to ACTIVE β Active
Behaviour:
- Liquidity providers can make, change, or exit commitments.
- Auction orders are accepted as per any regular auction period.
- Margins on orders as per auction based instructions in margin calculator spec.
Market goes into a closed state if a governance vote to close it passes and its enactment date is reached.
Entry:
- Governance vote to close a market passes β Closed
Exit:
No exit. This is a terminal state.
Behaviour:
- If market is in auction that auction gets uncrossed and any orders matched within it result in trades. All other orders get cancelled, no new orders are accepted, liquidity commitments cannot be modified, final settlement is carried out using the price supplied by the governance vote.
A market may terminate trading if the product is one that expires or if the market is otherwise configured to have a finite lifetime. In the case of futures, termination occurs at some point prior to the settlement of the product and is triggered by the trading terminated data source configured on the market. Markets in this state accept no trading, but retain the positions and margin balances that were in place after processing the trading terminated trigger (which may itself generate MTM cashflows, though for futures it doesn't).
A market moves from this termination state to Settled when enough information exists and the triggers are reached to settle the market. This could happen instantly upon trading termination if the data source message also contains the required settlement data, though usually there will be a delay, for instance, to wait for receipt and acceptance of data from a data source (oracle). An example of an instant transition would be where the trigger for terminating trading and the settlement are the publishing of a specific price from another market on the Vega network itself (same shard), or in the rare case of extremely delayed blocks meaning that the settlement data is available before the trigger is activated (note that market creators would be expected to allow enough of a buffer that this should effectively never happen).
Entry:
- Triggered by the product (in the case of futures, there is a product parameter that specifies when this will be triggered).
Exit:
- Settlement dependencies met (i.e. oracle data received) β Settled
Behaviour:
- No trading occurs, no orders are accepted
- Mark to market settlement is performed, if required, after termination is triggered, then never again
- A single set of market data may be emitted for the final settlement data (e.g. settlement mark price), after which no market data are emitted.
- During the transition out of this state:
- All final settlement cashflows are calculated and applied (settled)
- Margins are transferred back to general accounts
- No risk management or price occurs
Once the required data to calculate the settlement cashflows is provided by oracle input for a market in status Trading Terminated, these cashflows are calculated and applied to all traders with an open position (settlement).
The positions are then closed and all orders cleared.
All money held in margin accounts after final settlement is returned to traders' general accounts.
LP fees that have been cumulated but not yet paid out are distributed to the market LPs as per the LP spec.
After market.liquidity.successorLaunchWindowLength
has elapsed since the settlement time
- Insurance pool funds are transferred (after window for successor creation elapsed) into the global insurance pool using the same settlement asset. For markets that have a named successor market the appropriate fraction of the insurance pool balance is transferred to the insurance pool of the successor market.
- The market can be deleted entirely at this point, from a core perspective.
Entry:
- Trading is Terminated
- Triggered by product logic and inputs (i.e. required data source/oracle data is received)
Exit:
- No exit. End state.
Behaviour:
- No trading occurs, no orders are accepted
- During the transition into this state:
- All final settlement cashflows are calculated and applied (settled)
- Margins are transferred back to general accounts
- All fees are distributed (after a delay/at the next relevant epoch if needed - this means the market may continue to need to be "tracked" by the core until this step is complete)
- Market is over and can be removed from core data, nothing happens after the final settlement above is complete.
Market is proposed but rejected (0043-MKTL-001)
- Market
m1
is proposed with an internal trading terminated oracle set for some time in the future. Price monitoring is configured (e.g. like2668-price-monitoring.feature
). Market state isproposed
. - Parties vote against the market proposal.
The LP bond of the party that proposed the market is transferred to the general account.
It is not possible to submit orders to the market.
No parties have margin account balances that are non-zero for the market.
Market state is
rejected
.
Lifecycle happy path (0043-MKTL-002)
- Market
m1
is proposed with an internal trading terminated oracle set for some time in the future. Price monitoring is configured (e.g. like2668-price-monitoring.feature
). Market state isproposed
. The LP bond of the party that proposed the market is transferred from general to bond account. - Market
m1
is accepted and enters opening auction. Market state ispending
. - Parties place orders and at least one trade happens in continuous trading mode.
Market state is
active
. - Parties place orders so that a price monitoring auction is triggered.
Market state is
suspended
. - Price monitoring auction ends and the market is in continuous trading again.
The market state is
active
. - Make sure that trades happen so that at least two parties have open positions.
The mark price is
p
. - The time specified at market proposal by the internal time oracle is reached.
Any orders that parties submit get rejected.
The parties with open position in the immediately preceding step still have open positions.
Parties with open positions still have non-zero margin account balances.
The market state is
trading terminated
. - A final market-to-market happens with the last mark price.
- The settlement price oracle transaction is sent and it is not equal to
p
. Parties that had open positions see settlement cash-flows happen. Margin account balances are transferred to the general account. The market state issettled
. Aftermarket.liquidity.successorLaunchWindowLength
has passed since market settlement, any insurance pool balance is transferred into the global insurance pool using the same settlement asset.
Lifecycle happy path in Spot market (0043-MKTL-006)
- Market
m1
is proposed. Price monitoring is configured (e.g. like2668-price-monitoring.feature
). Market state isproposed
. The LP bond of the party that proposed the market is transferred from general to bond account. - Market
m1
is accepted and enters opening auction. Market state ispending
. - Parties place orders and at least one trade happens in continuous trading mode.
Market state is
active
. - Parties place orders so that a price monitoring auction is triggered.
Market state is
suspended
. - Price monitoring auction ends and the market is in continuous trading again.
The market state is
active
. - When a new governance proposal for "closing" the Spot market, then market state is
trading terminated
.
Lifecycle happy path in Perpetual market(0043-MKTL-009)
-
Market
m1
is proposed with an internal trading terminated oracle set for some time in the future. Price monitoring is configured (e.g. like2668-price-monitoring.feature
). Market state isproposed
. The LP bond of the party that proposed the market is transferred from general to bond account. -
Market
m1
is accepted and enters opening auction. Market state ispending
. -
Parties place orders and at least one trade happens in continuous trading mode. Market state is
active
. -
Parties place orders so that a price monitoring auction is triggered. Market state is
suspended
. -
Price monitoring auction ends and the market is in continuous trading again. The market state is
active
. -
Make sure that trades happen so that at least two parties have open positions.
-
An oracle event arrives which triggers the perpetual market's interim settlement logic, causing cashflow transfers but the market remains open.
-
Further trades happen, with parties still having different positions to previously. The mark price is
p
. -
A market state change proposal is created to terminate the market at a given price that is not equal to
p
. When this is approved and enacted the market state isclosed
. Parties that had open positions see settlement cash-flows happen to settle positions. Margin account balances are transferred to the general account. Aftermarket.liquidity.successorLaunchWindowLength
has passed since market settlement, any insurance pool balance is transferred into the global insurance pool using the same settlement asset.
Market never leaves opening auction, trading terminated triggered, market cancelled (0043-MKTL-010)
- A market is proposed, approved by governance process and enters the opening auction (Pending state).
- Trading terminated data source triggers before the market leaves the opening auction (so market never left Pending state so far).
- All orders should be cancelled and collateral returned to respective parties general account for the relevant asset.
- All LP commitments should be cancelled and their bond returned to the general account for the relevant asset.
- After
market.liquidity.successorLaunchWindowLength
has elapsed since market cancellation, any insurance pool balance should be transferred into the global insurance pool using the same settlement asset. - All data sources that are only referenced by that market are unregistered.
- The market state is set to cancelled.
Market (Spot) never leaves opening auction, market cancelled by governance proposal(0043-MKTL-007)
- A market is proposed, approved by governance process and enters the opening auction (Pending state).
- Market cancelled before the market leaves the opening auction (so market never left Pending state so far).
- All orders should be cancelled and holdings returned to respective parties general account for the relevant asset.
- All LP commitments should be cancelled and their bond returned to the general account for the relevant asset.
- The market state is set to cancelled.
Market never leaves opening auction, trading terminated triggered, market cancelled (0043-MKTL-012)
- A market is proposed, approved by governance process and enters the opening auction (Pending state).
- Market stays in opening auction till time passes
market.auction.maximumDuration
, the market should be cancelled. - All orders should be cancelled and collateral returned to respective parties general account for the relevant asset.
- All LP commitments should be cancelled and their bond returned to the general account for the relevant asset.
- After
market.liquidity.successorLaunchWindowLength
has elapsed since market cancellation, any insurance pool balance should be transferred into the global insurance pool using the same settlement asset. - All data sources that are only referenced by that market are unregistered.
- The market state is set to cancelled.
Market (Spot) never leaves opening auction, market cancelled by governance proposal(0043-MKTL-013)
- A market is proposed, approved by governance process and enters the opening auction (Pending state).
- Market stays in opening auction till time passes
market.auction.maximumDuration
, then the market should be cancelled. - All orders should be cancelled and holdings returned to respective parties general account for the relevant asset.
- All LP commitments should be cancelled and their bond returned to the general account for the relevant asset.
- The market state is set to cancelled.
Market gets closed via a governance proposal (0043-MKTL-004)
- Once the governance proposal to close the market gets enacted any auction that the market may be in gets uncrossed and trades get generated.
- All the other orders are cancelled and no further trades get generated.
- Any new orders get rejected.
- Liquidity commitments cannot be modified or cancelled.
- Final settlement is carried out and the transfers reflect the difference in the last mark price and the final settlement price supplied by the governance proposal.
- All the funds from market specific accounts get released to appropriate accounts; the insurance pool perhaps after the delay to allow for transfer into a successor market.
- Market gets deleted.
Market (Spot) gets closed via a governance proposal (0043-MKTL-008)
- Once the governance proposal to close the market gets enacted any auction that the market may be in gets uncrossed and trades get generated.
- All the other orders are cancelled and no further trades get generated.
- Any new orders get rejected.
- Liquidity commitments cannot be modified or cancelled.
- All the funds from market specific accounts get released to appropriate accounts.
- Market gets deleted.
- Once the governance proposal to suspend the market gets enacted the market gets immediately put into auction mode, if market was already in auction mode it remains in it.
- No cashflows are exchanged when market has been suspended via a governance proposal.
- Parties cannot modify their open interest
- The prerequisite for a market to go out of auction mode is now a successful enactment of a governance proposal to resume that market.
- Once the governance proposal to resumed the market gets enacted the market can now leave the auction.
- If no other auction triggers are active the market goes back into its default trading mode immediately (auction gets uncrossed and trades get generated).
- If other auction triggers are active the market remains in auction mode until these allow it to leave it.
Market gets suspended and resumed before it has been enacted (0043-MKTL-011)
- A market cannot be suspended if the proposal to enact the market is open