# Margin Model

### Initial margin

Initial margin is the minimum amount required for executing a position

* Buy option call/put : `Buy maintenance margin($)*(1+k) + open fees`
* Sell put option : `Maintenance margin * IMR factor`
* Sell call option :`Maintenance margin * IMR factor`

### Maintenance margin

Maintenance margin is the minimum amount required to be maintained in the portfolio to keep the position opened

* Buy option call/put : `Initial premium price($) + close fees (0 for liquidation calculation)`
* Sell put option : `Max(b * spot, b * Mark Price of the premium) + Mark Price of the premium`
* Sell call option:`b* Spot price + Mark Price of the premium`

Where a and b are margin variables defined per asset :&#x20;

<table><thead><tr><th>Market</th><th>Initial margin factor (a)</th><th width="182.1796875">Main. margin factor (b)</th></tr></thead><tbody><tr><td>$wETH</td><td>1.25</td><td>0.075</td></tr><tr><td>$wBTC</td><td>1.25</td><td>0.075</td></tr><tr><td>$HYPE</td><td>1.25</td><td>0.1</td></tr><tr><td>$SOL</td><td>1.25</td><td>0.1</td></tr></tbody></table>

<br>

### Open position margin checking

In order to open a position, we have to check and make sure that the current financial value of user portfolio is above or equal to the **new position initial margin** added, following the formula below:

**a\* token amount in portfolio \* CF + max\_pnl\_factor\* total unrealized Profit - total unrealized loss - debt - current position sell MM - current position buy MM - liquidation fee >= new position IM**

### Liquidation margin checking

In order to check if the user is liquidatable or not, the current account balance - losses - guaranteed maintenance margin should be always above 0 , **which means he’s able to pay his full deb**t, so in order to define a user as not liquidatable he must maintain the formula below:

**b\*Token\*CF** + **max\_pnl\_factor\* total unrealized Profit - total unrealized loss - debt - current position sell MM - liq fees >= 0**

### Withdrawal margin checking

In order to allow user to get withdraw money from portfolio, we need to make sure that the new portfolio balances of his portfolio - the losses and the guaranteed margin is above 0 , or else we need to revert the transaction, so this formula must be always maintained :

**c\*new token dollar amount after withdraw\*CF + max\_pnl\_factor\* total unrealized Profit - total unrealized loss - debt - current position sell MM - current position buy MM - liquidation fee >= 0**

| Paramater   | Value |   |
| ----------- | ----- | - |
| a           | 1     |   |
| b           | 1     |   |
| c           | 0.85  |   |
| pnl\_factor | 0.4   |   |


---

# 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://documentation.ivx.fi/images-and-media/margin-model.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.
