Margin Model
Link to code: https://github.com/IVX-FI/ivx-diem/blob/c01b385948c67b04ccc54f65fc08d58cbdada189/src/margin/IVXMarginManager.sol#L247
The trade flow on Diem is bi-directional and permissionless, facilitated by the Diem AMM smart contract. When a user trades on Diem, the Diem AMM takes the other side of the user’s position and at the point of expiry will settle the option payoff in cash. The Diem AMM ingests market data through reading an IVX volatility oracle, which provide methods for pricing assets and calculating the implied volatility estimate for an underlying asset. Users are able to buy and sell options from the Diem AMM, as illustrated below:

Trading Fees determined here.
In addition, all trading on Diem is facilitated on margin, meaning that each user has a separate margin account which is used to collateralize all leveraged trading on Diem including long option positions.
Example: wETH and wBTC Margin Account
Alice wants to deposit 2 wETH and 5 wBTC into the margin model. The collateral factors for each asset are 0.8 and 0.9, wETH and wBTC are trading at $1,600 and $22,000 respectively. We can calculate Alice’s margin balance as follows:

Therefore, Alice’s margin balance is $101,560. These funds can be used for trading on the platform, including paying borrow fees on leveraged positions and collateralizing positions. Premia paid to the Diem AMM will be subtracted from the user’s margin balance at the point of purchase of an option, and premia paid to the user will be added at the point of sale of an option. We can express the margin breakdown of Alice’s account as comprised of both assets visually as follows:

Since this margin account is comprised of assets which fluctuate with market movements, the notional value of Alice’s margin balance will change over time, meaning that market movements can change the leverage factor of Alice’s book. As an example, suppose that the price of wETH increases to $2,200 while the price of wBTC reduces to $18,000. In addition, Alice decides to compensate for the reduction in her margin balance by adding $10,000 of USDC.
The new balance of margin in Alice’s account is now represented by the following composition:

Last updated