Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquidation updates #900

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions docs/concepts/trading-on-vega/market-protections.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,35 +107,31 @@ If a market enters into a liquidity auction and never again attracts enough liqu
## Distressed traders
If a trader's available margin on a market is below the closeout level and cannot be replenished, that trader is considered distressed.

How a distressed trader's positions and orders are treated depends on if they're using isolated or cross margining.
How a distressed trader's positions and orders are treated depends on if they're using isolated or cross margining.

[Isolated margin](./margin.md#isolated-margin): An open position that drops below the maintenance margin level will be closed out. Any open orders will remain active, as the margin for each is calculated and funded separately.
If a distressed trader is using **isolated margin**, an *open position* that drops below the maintenance margin level will be closed out. Any open orders will remain active, as long as there's enough margin set aside to meet the [order margin](./margin.md#margin-order) requirement. The margin for each is calculated and funded separately.

[Cross margin](./margin.md#cross-margining): A distressed trader has all their open orders on that market cancelled. The network will then recalculate the margin requirement on the trader's remaining open position. If they then have sufficient collateral, they are no longer considered a distressed trader. However, if the trader doesn't have enough collateral, they are added to a list of traders that will then undergo position resolution to close out the position.
If the margin set aside for *orders* isn't enough, all of the trader's open orders on the market are cancelled and margin is returned to the general account. An open position in that market stays open, as it's margined separately.

### Closeouts
When a participant does not have enough collateral to hold their open positions, the protocol will automatically trigger a closeout.

The closeout process is a last resort for a position.
A distressed trader using **cross margining** has all their open orders on that market cancelled. The network will then recalculate the margin requirement on the trader's remaining open position. If they then have enough collateral, they are no longer considered a distressed trader. If the trader still does not have sufficient collateral, their position is closed out.

Cross margin and isolated margin positions have different closeout processes.
### Closeouts
When a participant does not have enough collateral to hold an open position, the protocol will automatically trigger a closeout. The closeout process is a last resort for a position.

**Isolated margin**: If the margin set aside for a *position* isn't enough to cover a mark to market settlement liability, the position is closed but open orders remain open. If the margin set aside for orders is no longer enough, all open orders on the market are cancelled and your margin is returned to your general account. An open position in that market stays open, as it's margined separately.
A position that's been closed out is transferred to the network, which can become a market participant in order to unload closed out positions.

**Cross margin**: If a trader's deployed margin on the market is insufficient to cover a mark to market settlement liability, first Vega will search the trader's available balance of the settlement asset. If this search is unable to cover the full liability, the trader will be considered distressed and undergo position resolution. Any margin balance remaining after closeout is transferred to the market's insurance pool. The insurance pool is then drawn from to make up the difference to cover the mark to market loss amount. If the funds in the insurance pool are insufficient for that, loss socialisation will be applied.
Any margin balance remaining after a closeout is transferred to the market's insurance pool.

### Position resolution
If there are distressed traders on a market, position resolution will be executed. Distressed trader(s) are ‘batched up’, and position resolution is run in one event, once the full set of traders is known.

The network calculates the overall net long or short positions in the batch that requires position resolution, which tells the network how much volume (either long or short) needs to be sourced from the order book. For example, if there are 3 distressed traders with +5, -4 and +2 positions respectively, then the net outstanding liability is +3.

The outstanding liability is sourced from the market's order book via a single market order executed by the network as a counterparty. In this example, a market order to sell 3 would be placed on the order book.

This is called a [network order](./orders.md#network-order). The network generates a set of trades with all the distressed traders, all at the volume weighted average price of the network's (new) open position. Network orders do not affect the market's mark price.
Once a trader is closed out, the position is taken over by the network. The network's open volume for the market increases, and the market's insurance pool acts as the network's margin account.

For those in **cross margin mode**, all of the remaining collateral in each distressed trader's margin account for that market is confiscated to the market's insurance pool.
The network party then submits an IOC limit order to unload the position - selling for a long position or buying for a short position. This is called a [network order](./orders.md#network-order). Network orders do not affect the market's mark price.

For those in **isolated margin mode**, a distressed position is closed out, but open orders will stay open as long as you have enough margin set aside to meet the [order margin](./margin.md#margin-order) requirement.
How much of the position the network party tries to offload depends on the liquidation parameters for disposal, set per market:
* Disposal time step: How often the network attempts to unload its position, as long as the market isn't in auction
* Disposal fraction: What fraction of network's current open volume it will try to reduce in one attempt
* Full disposal size: The lowest position size before the network will attempt to dispose the remaining amount in one order
* Max fraction of order book side that can be consumed: The max amount of the order book's total volume, within the liquidity bounds, that the network can use to close its position, as a fraction

### Loss socialisation
Loss socialisation occurs when there are traders that don't have sufficient collateral to handle the price moves of their open position(s), and the market's insurance pool cannot cover their shortfall.
Expand Down
10 changes: 10 additions & 0 deletions docs/tutorials/proposals/new-market-proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ The risk model uses the following properties:
| `param: r` | Annualised growth rate of the risk-free asset, it's used for discounting of future cash flows. Use 0.0 unless otherwise required. <br/><br/> Accepted values: any real number | 0.0 |
| `param: sigma` | Annualised historic volatility of the underlying asset. <br/><br/>Accepted values: any strictly non-negative real number; suggested value: asset dependent, should be derived from the historical time-series of prices. | 0.8 (converts to 80%) |

### Liquidation strategy
Set up the liquidation strategy to minimise the impact of distressed traders on the market. These parameters can balance between minimising the market impact of disposing of distressed positions and not holding a large open volume for a long time.

| Field | Description | Suggested value |
| ----------- | ----------- | ----------- |
| `disposalTimeStep` | Interval, in seconds, at which the network will attempt to close a position it's acquired from distressed traders. | 30 |
| `disposalFraction` | Fraction of the open position the market will try to close in a single attempt. Range 0 through 1 | 0.1 |
| `fullDisposalSize` | Size of the position that the network will try to close in a single attempt | 1 |
| `maxFractionConsumed` | Maximum fraction of the order book's total volume, within the liquidity bounds, that the network can use to close its position. Range 0 through 1 | 0.05 |

## Templates and submitting
In the tabs below you'll see:

Expand Down