> For the complete documentation index, see [llms.txt](https://documentation.ivx.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.ivx.fi/0dtes-market-dynamics/editor.md).

# Portfolio creation and Collateral

IVX pioneers the start of option portfolio margin trading on-chain by implementing self-custodial smart contract wallets for users. This approach enables users where they can deposit any whitelisted asset by IVX, utilizing the entire portfolio as collateral, to write and purchase option positions on IVX.&#x20;

Each EVM wallet is permitted to create a single smart contract portfolio to interact with the IVX protocol.

### Margin Trading Overview

Margin trading is the possibility to buy and sell option positions using the trading portfolio as collateral, eliminating the need to sell any deposited asset. This mechanism enhances the traders' buying power, enabling interconnected positions on cross margin, and the ability to perform selling positions on leverage.

IVX protocol mandates the following steps for every trade interacting in margin trading:

* Create a portfolio account on IVX
* Deposit one or more whitelisted assets as collateral
* Interact with IVX Diem to open or close option positions

#### Effective Balance <a href="#effective-balance" id="effective-balance"></a>

Each smart contract account accepts whitelisted assets as collateral determined by the IVX risk engine. For each asset, there is a specific collateral factor that describes how much a trader can use from the tokens deposited as collateral.

The effective balance of the account is calculated as follows:

$$
\text{Effective Balance} = \sum\_{i=1}^{n} \text{Balance}\_i \times \text{Price}\_i \times \text{Collateral Factor}\_i
$$

IVX uses Redstone oracle price feeds to fetch token prices into the effective balance.

The collateral factor of each asset is a decimal percentage between 0.0 and 1.0 that determines how much of the asset’s notional value can be used as collateral.

| Asset | Collateral Factor |
| ----- | ----------------- |
|       |                   |
| $HNY  | 1.0               |
| $HYPE | 0.99              |
| $wETH | 0.99              |
| $wBTC | 0.99              |
| $SOL  | 0.99              |

{% hint style="info" %}
Example

Bob wants to deposit 2 $wETH and 5 $wBTC into the margin model. The collateral factors for each asset are 0.97 and 0.96, $wETH and $wBTC are trading at $1,600 and $22,000 respectively. We can calculate Alice’s margin balance as follows:

$$\text{Margin Balance} = \sum\_{i=1}^{n} \text{Balance}\_i \times \text{Price}\_i \times \text{Collateral Factor}\_i$$ &#x20;

$$= 2 \times 1,600 \times 0.95 + 5 \times 22,000 \times 0.925$$&#x20;

$$= 3,040 + 101,750$$&#x20;

$$= 104,790$$
{% endhint %}

#### Unrealized Profit and Loss <a href="#unrealized-profit-and-loss" id="unrealized-profit-and-loss"></a>

Unrealized profits and losses of the trading portfolio are stored within each account, affecting the account value calculation. This architecture will allow IVX to support cross-margin accounting between opened positions, facilitating the offsetting of profits and losses to reduce margin requirements, and protect from liquidation events. In addition, traders can leverage cross-margin to perform complex strategies with exotic payoff positions as it can free more capital to be used on other trades.

#### Debt <a href="#debt" id="debt"></a>

In cross-margin mode, the portfolio account allows traders to open and close positions even when they don't meet the capital requirement, as long as the total unrealized profit and loss exceed the amount and the fees required to open or close a position. The required value is stored in the portfolio status as debt and will be reduced from portfolio assets under specific conditions such as:

* Closing profitable positions
* Expiration of option positions
* The portfolio is liquidatable
* Additional assets deposited into the account

Trading on margin offers flexibility in trading by:

* Minimising capital requirements to trade due to the necessity to provide only the maintenance margin to keep the position opened.
* Reduce liquidation risks through the ability to cover losing positions using the portfolio’s assets
* Utilzing unrealized profits in the portfolio account to open extra additional positions
* Enabling the creation of complex strategies involving different option positions


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://documentation.ivx.fi/0dtes-market-dynamics/editor.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
