# Platform Mechanics

## Liquidation                        &#x20;

The liquidation condition of the smart contract at which a liquidation event can be triggered takes into account accrued fees, collateral and PnL. It is as follows:

$$
accruedFees > liqThreshold \times collateral + PnL
$$

The price at which liquidation occurs is a function of position size, average entry price, collateral, accrued fees (which include closing/funding/borrowing), and a liquidation threshold which is defaulted to be 0.99 - this threshold is put in place to act as a built-in safety net to protect the protocol from losses on a position exceeding collateral.&#x20;

$$
deltaLiqPercent = \frac{(liqThreshold \times collateral) - accruedFees}{posSize}
$$

$$
liqPrice =\begin{cases} entryPrice \times (1-deltaLiqPercent) &\text{if } LONG \ entryPrice \times (1+deltaLiqPercent) &\text{if } SHORT\end{cases}
$$

If liquidated the trader will lose all of the collateral in their position.

For example, assume a 10,000 long position on BTC/USD with 1,000 USD collateral and an entry price of 28,000. Assume the trader has held this position for a few days and has accrued total fees of $30.00. The corresponding deltaLiqPercent is 9.60% and the liquidation price would be 25,312.

## Liquidation Bounty

Besides the Vela team's fee manager wallet, it is also possible for any 3rd party to trigger a qualifying liquidation. A bounty is put in place to incentivize liquidations to ensure they trigger in a timely matter (ie: liquidation is triggered before the remaining 1% of position collateral is lost due to rapid price movement).  The wallet to first liquidate the position will receive up to 10% of the total lost collateral if Vela's bot goes down or does not trigger in time. &#x20;

## Automated Open Interest

As a risk management tool, there are Open Interest (OI) limits per user as well as for each asset and direction. OI limits for both Longs and Shorts are established to protect the protocol from total OI exceeding TVL (in this case VLP backed liquidity). These limits, for each tradable asset, will be dynamically adjusted as follows:\
\
To ensure that traders can efficiently maximize on our available TVL, Vela Exchange has created an automated OI rebalancing solution, which adjusts the OI limit of each asset based on utility. Our new model compares previous and current asset trading demand in order to offer traders a broader opportunity to access OI on their favorite pairs. The components of this model come together to build the most innovative and strategic OI offerings in the perpetuals space.

{% hint style="info" %}
A snapshot of the Active OI will be recorded every 3h in order to dynamically update OI limits per asset. This method ensures that OI remains within the boundaries of our TVL and trader demand, and allocates new OI where it is needed most by traders.&#x20;
{% endhint %}

To ensure proper risk management, we have implemented a custom risk profile by asset, based on Average True Range (ATR) and then normalized by the volatility factor for BTC. This Volatility Factor is then used to determine the minimum and maximum OI limits per asset, based on available TVL.&#x20;

## Profit Limits

In order to further protect the vault, we have put limits (maxProfitPercent) into place per asset for how much any one trade can profit. The default is set to 1% of TVL, however this will likely be reduced over time as the TVL grows. In the event that one's profit exceeds 1% of TVL, then the position will be forced closed.<br>


---

# 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.vela.exchange/vela-knowledge-base/exchange/platform-mechanics.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.
