# Force Matching

This feature is a risk management measure that allows the off-chain engine to close positions on a sub-account's behalf in order to protect the protocol and limit loss to unhealthy sub-accounts. It can only be invoked if one of the two following invariants are true:

1. Sub-account Core Collateral Debt < 0
2. Sub-account Maintenance Health < 0

In the event that one of these invariants is true for a given sub-account the off-chain engine will create a market order on a certain position (the position selection criteria are provided in the sections below). This will then be matched on the Order book and settled on-chain as a regular swap, this allows the user to avoid costly liquidation fees.&#x20;

### Sub-account Core Collateral Debt&#x20;

This will occur if the sub-account being force matched has accrued a negative core collateral debt but are still healthy from a margin perspective. If this is the case then the offchain engine will swap one of their other positions into core collateral in order to reduce their core collateral debt to 0 or a threshold above 0. The position that are force matched to retrieve core collateral are selected based on the liquidation order described in [Liquidations](/100x-exchange/liquidations.md)

### Sub-account Maintenance Health&#x20;

This will occur if the sub-account is below maintenance health and are deemed unhealthy. If this is the case then the offchain engine will swap one of their positions to improve their health so that it is above maintenance but below initial margin. The position that are force matched to improve health are selected based on the liquidation order described in [Liquidations](/100x-exchange/liquidations.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.100x.finance/100x-exchange/force-matching.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
