# Fees & Spread

## Introduction

In line with industry standard, **fees are calculated on the value of the total position size** (leverage x collateral).

## Fees Distribution

In the LeverageX ecosystem, trading fees are distributed across three key categories, ensuring sustainability, governance, and token value appreciation. Here’s how the fees are allocated:

1. **Protocol Fees**
   1. Purpose: To cover trading-related operations and ensure seamless platform functionality.
   2. Utilization: Paid to liquidity providers and traders profit.
2. **Governance Fees**
   1. Purpose: To fund the governance and development of the Javsphere ecosystem.
   2. Utilization: Directed to the Javsphere treasury to support platform improvements and long-term sustainability.
3. **Buyback and Burn Fees**
   1. Purpose: To maintain a deflationary tokenomics model for the $JAV token.
   2. Utilization: Fees are used to buy back $JAV tokens and burn them.

### Fee Allocation Example

**Borrowing Fees** are going 100% to liquidity providers and are applied per block as long as trades are open.

**Total Fees**  = 0.06% for every open, close and update (delta) trade

Total Fees are distributed:&#x20;

* 26% Governance&#x20;
* 54% Protocol Fees  and Liquidity Provider
* 20% Buy and Burn

**Total Fees $100,000.00 (= 100%)**

* Protocol Fees: $54,000.00 (= 54%\*)
* Governance Fees: $26,000.00 (= 26%\*)
* Buy Back and Burn JAV: $20,000.00 (= 20%\*)

\*Percentages can vary is depending on trading activities.

## Detailed Fee Structure

### Cryptocurrencies

Spreads on BTC and ETH pairs are fixed at 0%.

Spreads on other pairs are dynamically calculated depending on 1% market depth.

1. **Opening a trade: 0.06%**
2. **Closing a trade: 0.06%**

### Crypto Indices

Spreads on all stocks incidices are fixed at 0%.

1. **Opening a trade: 0.06%**
2. **Closing a trade: 0.06%**

## Stocks

Spreads on all stocks pairs are fixed at 0.01%.

* **Opening a trade: 0.06%**
* **Closing a trade: 0.06%**

## Forex

Spreads on all forex pairs are fixed at 0.01%.

* **Opening a trade: 0.012%**
* **Closing a trade: 0.012%**

## Commodities&#x20;

Spreads on all commodities pairs are fixed at 0.01%.

1. **Opening a trade: 0.05%**
2. **Closing a trade: 0.05%**

***

## Lifecycle of a Trade

### Opening Fee

Let's say we use **250 USDT** at **10x** leverage to long ETH/USD. The fee is applied to leveraged amount: **2,500 USDT**.

2,500 \* (0.06/100) = **1,5 USDT fee**

**248.5 USDT** is the total collateral value of your newly opened trade, and therefore its total position size is **2,480.5 USDT**.

### Fixed Spread

When opening a trade the Pyth oracle returns a price for the asset, for instance 3,003.19. The spread is then taken into account (0.04%), so the open price would be **3004.39** before consideration of the dynamic spread (see section below).

That is: 3,003.19 + (3,003.19 \* 0.04 / 100) = **3004.39**

Please make note that the spread is different for each pair — smaller pairs with lower liquidity have a higher spread. It is displayed on the front end next to the Price in the Trade Parameters box, and can be confirmed in the pair storage contract by searching for the relevant pair index

## Dynamic Spread

Dynamic Spread, formerly known as 'Price Impact' is added on top of the fixed spread (if the pair has one). It depends on the open interest of the pair, the position size of the trade being opened, and on the direction of the trade (long / short).

***Dynamic Spread (%) =** (Open interest {long/short} + New trade position size / 2) / 1% depth {above/below}.*

**Cryptocurrencies**

Dynamic spreads using the 1% depth in each direction (long: 1% depth above / short: 1% depth below) from Binance.

**Forex**

Fixed spreads.

**Commodities**

Fixed spreads.

## ETH/USD Example

So using our above price example with a position size of 2,480 after fees, if the "1% depth above price" parameter for ETH/USD is 8m and there is 100,000 USDT of open long interest:

**(100,000 + 2,480 / 2) / 8,000,000 = 0.0126% dynamic spread**

This percentage is then applied to the opening price including the Fixed Spread. In the case of crypto, as there is no Fixed Spread, this is just 3,003.19:

**Final opening price =** 3003.19 + (3003.19 \* 0.0126 / 100) = 3003.57

So in this case if the median spot price was 3003.19, the opening price would be 3003.57.

## Borrowing Fees

Borrowing fees are applied to trades while they are open.

Borrowing fees treat open trades of the dominant side as vault borrowers. The fee is determined by a pair's (or the group the pair is part of) net OI relative to the overall vault TVL, meaning pairs (or groups) with more lopsided OI will charge more than pairs with balanced OI.

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

```
borrowingFeePercent = feePerBlock * (abs(longOi - shortOi) / maxOi) ** feeExponent
```

Example:

```
feePerBlock = 0.0000100236
longOi = 22876.198079
shortOi = 5990.4
maxOi = 880666

pairFeePerBlock% = 0.0000100236 * Math.abs(22876.198079 - 5990.4) / 880666 ** 1 = 1.9219146149012726e-7
```

For this example, on **Base** (1800 blocks per hour), the estimated borrowing fee per hour is:

`0.00034976% = 1800 * Math.max(1.9219146149012726e-7, 1.9431296324610092e-7)`&#x20;

For this example, Position is 10000 USDT:&#x20;

`0.034976USDT per Hour = 0.00034976% / 100 * 10000 USDT`

## Liquidations Prices

Trades liquidation prices can **get closer** over time if you **pay borrowing fees**.

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

**Liquidation price =** If Long: Open Price - Liquidation Price Distance Else (Short): Open Price + Liquidation Price Distance.

For example, let's say that you have opened a long on BTC/USD at 20,000 USD using 100x leverage and 50 USDT collateral, the liquidation threshold would be 67%, the closing fee would be 16 USDT (20,000\*(0.08/100) and that you have paid 1 USDT in borrowing fees:

**Liquidation Price =** 20,000 - 20,000 \* (50 \* 0.67 - 16 - 1) / 50 / 100 = 19,888 USD.

## Liquidation Thresholds

The liquidation threshold depends on asset class and leverage used. The values can be found in the following table, for *Cryptocurrencies, Stocks, Forex, Commodities (gold), Commodities (other)*

### Liquidation Parameters

• startLiqThresholdP: The liquidation threshold percentage when leverage is at the starting point.

• endLiqThresholdP: The liquidation threshold percentage when leverage reaches the maximum (end) value.

• startLeverage: The leverage value where the liquidation threshold starts to decline.

• endLeverage: The leverage value where the liquidation threshold stops declining and stabilizes at its minimum.

• Leverage: The current leverage of the system or user, which influences the liquidation risk.

Examples:

Three Example Scenarios:

```json
{
 "startLiqThresholdP": 0.9,
 "endLiqThresholdP": 0.75,
 "startLeverage": 25,
 "endLeverage": 60
}
```

**1. Leverage Before Start Leverage (e.g., Leverage = 20):**

• Since the leverage (20) is below the start leverage (25), the function returns the start liquidation threshold, which is 0.9.

• This means the liquidation threshold remains at 90%, indicating a higher liquidation risk at lower leverage levels.

**2. Leverage Between Start and End Leverage (e.g., Leverage = 40):**

• In this case, leverage is between 25 and 60. The function performs linear interpolation to calculate the threshold.

• The liquidation threshold will be approximately 0.825 (based on the relative position between 25 and 60).

• This shows that as leverage increases, the liquidation threshold gradually decreases, indicating reduced liquidation risk as leverage moves toward the maximum.

**3. Leverage Beyond End Leverage (e.g., Leverage = 70):**

• Since the leverage (70) is greater than the end leverage (60), the function returns the end liquidation threshold, which is 0.75.

• This indicates that for very high leverage values, the liquidation threshold plateaus at 75%, meaning no further reduction in liquidation risk occurs beyond this point.

<table><thead><tr><th>Crypto</th><th>Stocks</th><th>Forex</th><th>Commodities</th></tr></thead><tbody><tr><td><pre class="language-json"><code class="lang-json">{
"startLiqThresholdP": 0.9,
"endLiqThresholdP": 0.75,
"startLeverage": 25,
"endLeverage": 60
},
</code></pre></td><td><pre><code>{
"startLiqThresholdP": 0.9,
"endLiqThresholdP": 0.75,
"startLeverage": 25,
"endLeverage": 60
},
</code></pre></td><td><p></p><pre class="language-json"><code class="lang-json">{
<strong>"startLiqThresholdP": 0.9,
</strong>"endLiqThresholdP": 0.75,
"startLeverage": 100,
"endLeverage": 300
},
</code></pre></td><td><p></p><pre class="language-json"><code class="lang-json">{
<strong>"startLiqThresholdP": 0.9,
</strong>"endLiqThresholdP": 0.75,
"startLeverage": 25,
"endLeverage": 100
}
</code></pre></td></tr></tbody></table>

## Closing Fee

Let's say ETH/USD **went up 1%** from the open price, and we close the trade at **3,033.6**. The pending profit (PnL) will be 1% of 2480 (our leveraged collateral), which is **24.8 USDT**.

Now, we close the trade, and therefore pay the closing fee. Please note that the fees are always applied on the initial position size (without PnL).

2480 \* (0.06/100) = 1.488 **USDT** closing fee

-> 24.8 - 1.488 = **23.312 USDT PnL**

Now let's also say that the trade **paid 0.5 USDT** of **borrowing fees**:

23.312 - 0.5 = **22.812 USDT final PnL**

Therefore, you would receive **270.812 USDT** (248 **USDT** collateral + 22.812 PnL) to your wallet after closing your trade.


---

# 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.javsphere.com/products/leveragex/trader/fees-and-spread.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.
