# Rebalancing the Position (Liquidation Brake)

## The rebalancing mechanism

After a position is opened, the protocol employs an automated rebalancing mechanism to maintain stability and ensure the leverage ratio stays within predefined safe limits.

Rebalance is an automatic operation triggered when the leverage of a position reaches a predefined threshold (rebalance line). The protocol adjusts the leverage to bring it back to the rebalance line instead of liquidating a significant portion of the position.\
\
During this operation for xPOSITIONs:

* fxUSD is first redeemed from the Stability Pool.
* The underlying TOKEN is swapped for USDC to maintain system stability.

sPOSITIONs:

* Borrowed asset is first paid back by keepers
* The keeper gets fxUSD in return

**1. Continuous Monitoring**

External keepers continuously monitor market conditions and the leverage ratios of all open positions. If market fluctuations cause a position to drift outside safe leverage thresholds, the rebalancing mechanism is activated.

**2. Reducing Leverage**&#x20;

1. **xPOSITION & fxMINT - Via fxUSD Burning**

If leverage exceeds the safe limits—such as when ETH or BTC prices drop—the protocol automatically burns a portion of the fxUSD associated with the xPOSITION. The collateral backing the burned fxUSD is sold for fxUSD or USDC and returned to the Stability Pool. This adjustment reduces the leverage ratio while maintaining the user’s exposure to the underlying asset, effectively avoiding liquidation.

This automated rebalancing process eliminates the need for manual interventions and prevents forced liquidations, offering users a more secure and reliable way to manage positions in volatile markets.

2. **sPOSITION - Via debt repayment**

If leverage exceeds the safe limits—such as when ETH or BTC prices surge—the protocol automatically repay a portion of the debt associated with the sPOSITION. The fxUSD backing the repaid debt is given to the keeper processing the operation. This adjustment reduces the leverage ratio while maintaining the user’s exposure to the underlying asset, effectively avoiding liquidation.

This automated rebalancing process eliminates the need for manual interventions and prevents forced liquidations, offering users a more secure and reliable way to manage positions in volatile markets.

## Example of a rebalancing operation

Alice opens a 5x position with 1ETH when ETH trades at $3000. She will be rebalanced when ETH price falls 9.09%, which is $2727 (LTV=88% - see [Risk parameters](/fx-docs/risk-management/risk-parameters.md)).\
\
This is how her position looks at the opening.

| ETH Price | xPosition size (USD) | Position size (USD) | Real time Leverage | fxUSD debt | LTV    |
| --------- | -------------------- | ------------------- | ------------------ | ---------- | ------ |
| $3000     | $3000                | $15000              | 5.00               | $12000     | 80.00% |

Lousy luck, ETH price collapsed by 10% and reached $2700: Alice's xPOSITION will be rebalanced.<br>

Before rebalancing, this is how her position now looks:

| ETH Price | xPosition size (USD) | Position size (USD) | Real time Leverage | fxUSD debt | LTV    |
| --------- | -------------------- | ------------------- | ------------------ | ---------- | ------ |
| $2700     | $1500                | $13500              | 9.00               | $12000     | 88.89% |

The rebalancing process must burn enough fxUSD from her debt to bring her LTV back to 88%.\
\
The needed amount to burn can be calculated using the following formula.

$$
fxUSDtoBurn = ( Debt - PositionSize \* TargetLTV)/(1-TargetLTV)
$$

The redeeming bounty (see [Risk parameters](/fx-docs/risk-management/risk-parameters.md)) is added to this amount.

This is how the rebalancing process occurs:

1. $1000 worth of fxUSD are burnt from the stability pool and deducted from Alice’s debt
2. The corresponding amount of wsETH collateral + the keeper bounty is redeemed by the keeper.
3. The equivalent amount of fxUSD or USDC is returned to the Stability Pool.

Alice'sAfter the rebalancing process, Alice's position looks like this:

| ETH Price | xPosition size (USD) | Position size (USD) | Real time Leverage | fxUSD debt | LTV |
| --------- | -------------------- | ------------------- | ------------------ | ---------- | --- |
| $2700     | $1500                | $12500              | 8.33               | $11000     | 88% |

Her real-time leverage was stabilized to prevent her from liquidation. She kept market exposure.\
\
If the market recovers back to $3000:

| ETH Price | xPosition size (USD) | Position size (USD) | Real time Leverage | fxUSD debt | LTV    |
| --------- | -------------------- | ------------------- | ------------------ | ---------- | ------ |
| $3000     | $2889                | $13889              | 4.81               | $11000     | 79.20% |

Read More:

{% content-ref url="/pages/hT4QBrZHmnEFExq3Ac1L" %}
[What price drop would it require for my fxMINT or xPOSITION to be rebalanced/liquidated?](/fx-docs/faq/what-price-drop-would-it-require-for-my-fxmint-or-xposition-to-be-rebalanced-liquidated.md)
{% endcontent-ref %}


---

# 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://fxprotocol.gitbook.io/fx-docs/f-x-protocol-mechanisms/rebalancing-the-position-liquidation-brake.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.
