Margin

Margin Ratio Formula

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*} }%

where

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

π‘€π‘Žπ‘₯π‘π‘’π‘‘π΅π‘Žπ‘ π‘’(𝑝) 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 and MMR are set at market creation. These are the inverse of leverage, e.g., an IMR of 0.1 equals a maximum leverage of 10x and an MMR of 0.05 means a position can get liquidated once its leverage reaches 20x.

The owner of the AdminCapability may change these parameters, but the smart contract first stores the new values, so they are visible on-chain, and only updates the actual market parameters after sufficient time has passed (a few days).

Position Margin Requirements

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

To check that the position's margin ratio is above the market's IMR:

{\small \begin{align} MarginRatio(p) &> IMR \\ &\equiv \\ \frac{ Coll(p) \cdot CollPrice + UF(p) + Pnl(p)\ }{ MaxNetBase(p) \cdot BasePrice } &> \frac{ MaxNetBase(p) \cdot BasePrice \cdot IMR\ }{ MaxNetBase(p) \cdot BasePrice } \\ &\equiv \\ \underbrace{ Coll(p) \cdot CollPrice + UF(p) + Pnl(p) }_{\text{margin}(p)} &> \underbrace{ MaxNetBase(p) \cdot BasePrice \cdot IMR }_{\text{margin_requirements}(p)} \end{align} }%

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

Last updated