# Fee, Spread, Liquidation

This mechanism applies exclusively to the Perp DEX launched on the Mitosis Testnet and does not apply to the DVX Perp Aggregator.

## 1. Spread

Spread is applied to eight assets: LBTC, miLBTC, ETH, miETH, USDT, miUSDT, USDe, and miUSDe, and is provided in a basic form on the Testnet.

## 2. Fee

DVX's fees consist of opening fee, borrowing fee, closing fee,

### Opening Fee

**0.06% on Collateral**

### Borrowing Fees

<mark style="color:purple;">**Borrowing Fee**</mark>

Borrowing fees are charged on the dominant side, where most of the open interest is. If there is, for example, $3m long open interest and $1m short open interest on a pair, longs will pay the borrowing fee, and shorts won’t pay anything.

The fee is charged per block on a trade's total position size.

<mark style="color:purple;">**Borrowing APR**</mark>

The borrowing APR represents the borrowing fee charged for a specific trading pair or group of correlated pairs at 100% vault utilization (net OI = vault TVL).

It is calculated using the following methodology:

> Borrowing APR = volFactor / Max vault exposure % \* marketFactor

1. **volFactor:** volatility coefficient (more volatility = more expensive).
2. **Max vault exposure %:** This parameter is set depending on how much maximum vault exposure is targeted ideally.
3. **marketFactor:** The coefficient allows for adjusting costs for groups of pairs (between 0 and 1).

volFactor is calculated as follows:

> volFactor = (dailyVolatility \* 365) ^ 1.25 / 150
>
> *dailyVolatility = (3 \* Avg\_Daily\_ATR%\_1\_Days + 2 \* Avg\_Daily\_ATR%\_7\_Days + Avg\_Daily\_ATR%\_30\_Days ) / 6*

The daily ATR % is a technical indicator measuring an asset’s daily volatility in percentage. For groups, the average value for all pairs is used instead. The weighted average of recent and older volatility allows us to consider short-term and longer-term volatility.

The max vault exposure % is set at 20% based on historical trading data collected until now.

The market factor is 1 on all pairs (no effect on the APR), and for groups, it will be proportional to the correlation of all pairs it contains (low correlation 0 = closer to 0, higher correlation = closer to 1). This leads to a lower cost on the group level, which allows for more activity on popular pairs of the group without increasing the fees on all its other pairs too fast.\\

Example calculations:

* BTC/USD (volFactor = 60, max vault exposure % = 20%, marketFactor = 1) → 60 / 0.2 \* 1 = 300%
* Crypto group (volFactor = 70, max vault exposure % = 20%, marketFactor = 0.5) → 70 / 0.2 \* 0.5 = 175%

Finally, the 300% and 175% borrowing APRs of the example above respectively represent 60% and 35% APR at 20% vault exposure (= the max targeted vault exposure).

*Please note that the examples above do not represent the exact values that will be set as the volatility changes all the time, they are just examples.*

#### <mark style="color:purple;">**Pair Borrowing**</mark>

Pair borrowing refers to the holding fee associated with each trading pair. It is calculated based on the net OI and borrowing APR for a specific pair and on the vault TVL.

The APR charged at any point in time is calculated using the formula:

> ***Borrowing APR \* Net OI / Vault TVL***

Let’s break down the calculation using the following set of values for a specific pair:

* Borrowing APR: 40%
* Net OI: $5 million
* Vault TVL: $50 million

**Pair Borrowing APR:** 40% \* *($5 million / $50 million) = 4%\\*

<mark style="color:purple;">**Group Borrowing**</mark>

In the updated system, trading pairs that are closely related are organized into groups, and a group borrowing fee is applied to these groups.

The APR for the group borrowing fee is calculated in the same way as for individual pairs. It takes into account the total net Open Interest (OI) of all pairs in the group, the group borrowing APR, and the vault's Total Value Locked (TVL).

For example, consider a group of related cryptocurrency pairs:

* **Borrowing APR:** 25%
* **Net OI:** $10 million (total for all pairs in the group)
* **Vault TVL:** $60 million
* **Group Borrowing APR Calculation:** 25% \* ($10 million / $60 million) = 4.17%

It's important to note that each trading pair can only be part of one group. If a pair isn't closely related to other assets, it won't be included in any group and won't incur a group borrowing fee.

<mark style="color:purple;">**Final Borrowing Fee Calculation**</mark>

At any time, the borrowing fee a user pays is the maximum of the 'Pair Borrowing' or the 'Group Borrowing Fee.'   This method allows DVX to manage the overall risk of the platform efficiently.

### Closing Fee

0.06% on Initial position size without PnL.&#x20;

## 3. Liquidation&#x20;

### Liquidation Prices&#x20;

Trades liquidation prices can get closer over time if you pay borrowing fees.&#x20;

***Liquidation Price Threshold =** Open Price \* (Collateral \* Liquidation Threshold - Closing Fee - Borrowing Fees) / Collateral / Leverage.*

**Liquidation price**

* **For Long Positions:**
  * Liquidation Price=Open Price−Liquidation Price Distance
* **For Short Positions:**
  * Liquidation Price=Open Price+Liquidation Price Distance

### Liquidation Threshold

The liquidation threshold is the minimum margin ratio required to keep a leveraged position open. If the margin falls below this threshold due to losses, the position is automatically liquidated to prevent further losses.

| Leverage | Liquidation Threshold (%) |
| -------- | ------------------------- |
| 2x       | 89.84%                    |
| 5x       | 89.60%                    |
| 10x      | 89.20%                    |
| 15x      | 88.80%                    |
| 20x      | 88.40%                    |
| 25x      | 88.00%                    |
| 30x      | 85.46%                    |
| 35x      | 82.91%                    |
| 40x      | 80.37%                    |
| 45x      | 77.83%                    |
| 50x      | 75.29%                    |
