Margin Engine

marginfi has a comprehensive view of each margin accounts portfolio. With this in depth understanding we can bridge liquidity for traders that is otherwise siloed in individual protocols.
Any action that can negatively influence the health of your account is verified by our margining system. For example, when you open a trade, or deposit into a UTP our margining system makes sure that your account is still in a healthy state.
The margining process is completely unassuming and always verifies the portfolio health after an action has happened. This enables very flexible use of the margining system, for example, if you have $0 of balance in your margin account and a position with $10k PNL in Mango Markets, the margining engine allows you to directly deposit $10k of collateral into 01 Protocol, without you having to (1) close your Mango Markets positions, and (2) explicitly borrowing collateral before wanting to use it. As a general principle the margining engine allows any action to happen that keeps your account in a healthy state.

Portfolio Margining

marginfi aggregates data from your marginfi account and each activated UTP, and uses that to determine wether your satisfy one of the many margin requirement types given the action you want to perform.

Initialization Margin Requirement

An account has to satisfy this requirement if it wants to either trade or deposit collateral into UTPs. More broadly our margining engine ensures that this requirement is satisfied whenever an action happens that either lowers your account equity (opening new positions) or increases your initialization margin requirement (borrowing liquidity).
Your account satisfies the initialization margin requirement whenever your account margin adjusted equity (ME) is greater or equal to your initialization margin requirement.
MEimrME \ge imr
The initialization margin requirement is a calculated from the value of your liabilities and a initialization margin fraction (currently imf = 1).
imr=limf imr = l \cdot imf

Maintenance Margin Requirement

If your accounts margin adjusted equity falls under your maintenance margin requirement the system will liquidate your account in order to protect its obligations.


We look at two type of portfolio equity. The true equity (E) is a sum of your account balance and equity of your UTP accounts. The margin adjusted equity (ME) is a sum of your account balance and your UTP equity with discounted initialization margin requirements.
E=b+iutpeiE = b + \sum_i^{utp} e_i
ME=b+iutpmax(eiimri,0)ME = b + \sum_i^{utp}{max(e_i - imr_i, 0)}
UTP equity
Each UTP has a unique nuances on how they calculate equity and margin requirements. The margining engine mirrors exactly understanding of equity and margin requirements of each UTP supported.
Read more on how margining works in each UTP: