Margin

The Margin system on Aftermath Perpetuals ensures the solvency of the protocol and governs the collateral requirements for opening and maintaining positions.

Margin is the collateral deposited by a trader to cover their positions and potential losses. On Aftermath, margin is used to back your leverage. If the value of your account falls below the required margin level, your positions may be subject to Liquidations.

Margin Ratio Formula

The Margin Ratio is the primary metric for account health. It is calculated as the ratio of your Account Value (Equity) to your Position Exposure (adjusted by MaxNetBase).

MarginRatio(p)=Collateral(p)β‹…CollateralPrice+UnrealizedFundings(p)+Pnl(p)Β MaxNetBase(p)β‹…BasePrice{\small \begin{align*} MarginRatio(p) &= \frac{ Collateral(p) \cdot CollateralPrice + UnrealizedFundings(p) + Pnl(p)\ }{ MaxNetBase(p) \cdot BasePrice } \end{align*} }%

Understanding MaxNetBase

The exposure of a position is determined by MaxNetBase.

MaxNetBase(p)=max⁑{∣BaseAmount(p)+PendingBids(p)∣,∣BaseAmount(p)βˆ’PendingAsks(p)∣}\small MaxNetBase(p) = \max \{ | BaseAmount(p) + PendingBids(p) | , | BaseAmount(p) - PendingAsks(p) | \}
circle-info

π‘€π‘Žπ‘₯π‘π‘’π‘‘π΅π‘Žπ‘ π‘’(𝑝) is motivated as follows: Instead of taking |π΅π‘Žπ‘ π‘’π΄π‘šπ‘œπ‘’π‘›π‘‘(𝑝) + 𝑃𝑒𝑛𝑑𝑖𝑛𝑔𝐡𝑖𝑑𝑠(𝑝) βˆ’ π‘ƒπ‘’π‘›π‘‘π‘–π‘›π‘”π΄π‘ π‘˜π‘ (𝑝)| , we take the max above, since otherwise a user could place equivalent bids and asks without raising its leverage, thus artificially deepening the order book.

Initial and Maintenance Margin Ratio (IMR/MMR)

The IMR (Initial Margin Ratio) and MMR (Maintenance Margin Ratio) are fundamental risk parameters set at market creation. They represent the inverse of leverage:

  • IMR (Initial): Determines the maximum leverage for opening a position.

    • Example: An IMR of 0.1 allows a maximum leverage of 10x ($1 / 0.1$).

  • MMR (Maintenance): Determines the liquidation threshold.

    • Example: An MMR of 0.05 means a position will be liquidated once its effective leverage reaches 20x ($1 / 0.05$).

Governance

The owner of the AdminCapability may change these parameters to adapt to market conditions. However, for user safety:

  1. The smart contract stores the new values on-chain first.

  2. The update is time-delayed; it only takes effect after a sufficient waiting period (a few days), ensuring users have time to adjust their positions.

Position Margin Requirements

The absolute margin required for a specific position is calculated as:

MarginRequirements(p)=MaxNetBase(p)β‹…BasePriceβ‹…IMRΒ {\small \begin{align} MarginRequirements(p) &= MaxNetBase(p) \cdot BasePrice \cdot IMR\ \end{align} }%

Solvency Check

To verify that a position is solvent (i.e., the margin ratio is healthy), the protocol checks that the Margin Ratio is greater than the IMR. This is mathematically equivalent to checking if your Equity covers the Requirement:

circle-info

To get the Maintenance Margin Requirements of a position, simply replace 𝐼𝑀𝑅 with 𝑀𝑀𝑅 .

Last updated