Margin Requirements for Leverage
@gradientdev June 14, 2023
Link to code: https://github.com/IVX-FI/ivx-diem/blob/c01b385948c67b04ccc54f65fc08d58cbdada189/src/margin/IVXMarginManager.sol#L183
Position Maintenance Margin
Each position requires a specific minimal amount of margin in order to keep the position well funded, this is called the Position Maintenance Margin for that position.
Note that this quantity is specific to the position itself, and can change over time as the position changes.
Suppose that the underlying price of the asset for which the option represents is given by X and the current price of the option is given by Y , then the Position Maintenance Margin is given by

(1) All of the numbers in (1) should be configured as parameters on the contract.
0.3 × max {0.032 X + 1.00 Y, 0.002 X + 1.03 Y}
Borrow Maintenance Margin
If I open a position on leverage, I need to borrow money from the AMM to finance my position. For instance, if I open a $50 position of long call options and pay $20 in premia (a leveraged long position), I have borrowed $30 in order to finance my position. This borrow accrues an interest from the user to the AMM which increases over time, this interest is charged on the margin balance of the user automatically. The interest rate of this borrow should depend continuously on the capital utilization of the AMM, such that a fully utilized AMM charges a lot more for leveraged positions than a relatively unutilized AMM. The quantity Borrow Maintenance Margin is defined as

Maintenance Margin for Open Positions
This is the required maintenance margin for all positions a user has open at any given time. If a user has a list of positions given by P = [p1, p2, . . . , pn], then this quantity is given by

where we have added the terms (1) and (2) for each position.
Maintenance Margin Rate
An account will become eligible for liquidation if its Maintenance Margin Rate crosses 100%. It will intially be below 100% but as positions become increasingly underwater, will move closer to 100%. The Maintenance Margin Rate is given by

where :
• Maintenance Margin is defined in (4);
• The quantity Effective Margin is a collateral factor-adjusted margin balance;
• The quantity Order Loss is equal to the negative net profit and loss of the user’s positions. For example, if the user is in profit, the quantity −Order Loss is a positive quantity;
• The quantity Shock Loss is a shock-scenario portfolio loss under some specific simulation.
Available Margin
This quantity is defined as

Last updated