Deep Diving Into Marginfi!

Deep Diving Into Marginfi!

TL;DR

  • Marginfi is a decentralised lending protocol on Solana that puts risk management first in order to give users who want to access leverage and optimise capital efficiency a dependable and secure option.

  • Few people are aware that, although risk management is its main priority, behind-the-scenes Squads play a crucial role in safeguarding the resources of the marginfi protocol.

  • Margin trading across Solana perpetual exchanges was marginfi's primary focus until the advent of "mrgnlend," a new decentralised and overcollateralized lending protocol for the Solana ecosystem

What is Marginfi?

Marginfi has been one of the main drivers of the recent spike in activity surrounding Solana DeFi, which has been observed over the previous few months. Few people are aware that, although risk management is its main priority, behind-the-scenes Squads play a crucial role in safeguarding the resources of the marginfi protocol.

This article delves into the definition of marginfi and explains how Squads were used to protect the protocol's main resources, including its programs. It also acts as a manual for other projects looking to adopt similar security procedures.

Margin trading across Solana perpetual exchanges was marginfi's primary focus until the advent of "mrgnlend," a new decentralised and overcollateralized lending protocol for the Solana ecosystem, earlier this year. Following the introduction of its point-based reward system, it quickly garnered significant traction.

One of the first significant applications of DeFi in the cryptocurrency arena was lending and borrowing, together with AMMs. It first appeared with protocols like AAVE and Compound, which are currently the most popular on Ethereum and EVM chains. Following FTX's demise, a gap on Solana emerged, prompting marginfi to create its own borrow/lend protocol to cover it.

Lending protocols such as marginfi have a very basic notion. On the site, users deposit their tokens in order to earn interest on their cryptocurrency. Then, borrowers who are prepared to pay interest are given access to this cash because -

  • Lenders take a risk when they lose their capital and can lose out on opportunities;

  • This rate is paid by borrowers in order to get funds for a variety of strategies, including hedging, shorting, and leverage.

Working of Marginfi

The assets that users lend are combined to provide borrowers with more liquidity. The demand on both sides determines the lending and borrowing rates; higher lending rates result from aggressive borrowers. On the other hand, if lending exceeds borrowing by a significant amount, the lending rate will be low since borrowers will have ample liquidity.

Lending money without security precautions could be risky as DeFi users are not linked to real identities and borrowers might stop making loan payments. Overcollateralized borrow/lend protocols, like marginfi, mandate collateral deposits from each borrower in exchange for the ability to borrow assets deposited on the platform, in order to avoid such circumstances. This implies that before a marginfi user may borrow BONK, they must first deposit an accepted asset as collateral, such as JitoSOL or mSOL.

Liquidators may automatically seize a user's collateral and sell it on the open market to pay off the debt and make a profit if the user's debt (for example, BONK) rises sufficiently in comparison to their collateral, or if the price of the collateral falls too much in relation to the debt. Lenders' positions would be in risk in the absence of liquidators since they would not be able to close loans and reclaim their assets if the collateral given by borrowers fell short of the obligation.

Why there is a Need of Marginfi?

Many cryptocurrency borrow/lend protocols have had bad debt in the past as a result of accepting collateral that, because of excessive slippage and poor on-chain liquidity, liquidators were unable to sell for a profit. Due to this situation, lenders were unable to withdraw their initial deposits and the protocol was left with bad debt.

Here's where marginfi excels. A risk engine and risk tiers are two of the risk management tools that marginfi main contributors put in place to stop bad debt from happening on the protocol. To establish appropriate risk parameters, the mrgnlend risk engine considers three primary factors -

  • Execution Capacity of Liquidators: The rate at which liquidators can complete liquidations.

  • Market Depth: The amount of liquidity that is on-chain that allows liquidators to continue making money.

  • Market Depth Recovery Time: The amount of time needed following significant market orders for the liquidity depth imbalance to stabilise.

Additionally, marginfi offers a separate pool for dangerous SPL assets that may only be borrowed and not used as collateral, keeping the main loan pool free from assets with limited liquidity that might potentially result in bad debt. If the market falls sharply, there is a good probability that low-liquid assets will see severe slippage and not be able to cover the liquidators' obligations. In other words, the isolated pool reduces the likelihood of bad debt for the protocol and users by ensuring liquidators only have to liquidate assets with strong on-chain liquidity.

With its Points program, which rewards protocol usage, marginfi has also led the way among DeFi protocols. Lenders, borrowers, and referrers accrue points that can be redeemed for benefits and prizes in the future. Furthermore, marginfi is working on its stableswap AMM and overcollateralized stablecoin, mUSD, to create a virtuous circle for DeFi strategies within the marginfi “ecosystem”.

Why Marginfi Implement Squads?

Marginfi is one of the top lending protocols on Solana, so it must maintain the greatest security requirements. As we've seen, this calls for the implementation of robust risk management procedures along with a serious approach to program management.

On Solana, each protocol has an authority key that regulates modifications to its program (s). This key can be held by a private key in a hot/cold wallet or a CLI wallet, just like any other standard SPL asset. However, teams find it extremely dangerous and inconvenient to manage this program authority key with a single, basic wallet for a number of reasons -

  • It places program ownership under one person's control, making group decision-making impossible. The team as a whole is powerless to stop this individual from initiating a harmful upgrade;

  • The program's whole security is dependent on a single key. There is no further security layer, and if it is compromised, it is too late.

Marginfi hence made the decision to assign a multisig the authority over their mrgnlend programs using Squads. With a multisig, Squads can add all of the key players and establish a limit on the amount of approvals required to carry out program upgrades. The team members share control over the program, thwarting any malevolent updates. Furthermore, because an upgrade of the mrgnlend program needs the consent of many members, even the compromising of one member's key won't be sufficient.

Founding Story

With experience in both technology and high finance, Edgar and Mac, the company's founders, introduced the world to marginfi. Mac began his career at Morgan Stanley, but Edgar started his at Goldman Sachs. They gained significant knowledge about the inner workings of traditional finance and the possibilities for technological advancement from their experiences working for these titans of the financial industry.

Edgar and Mac's paths crossed in Miami for Art Basel. They were introduced by their mutual friend Ami, who saw their enthusiasm for DeFi. Edgar describes the incident; "You know, I remember entering the flat when we first met. Mac was bathed in a golden glow that seemed to emanate from the Miami sun. He is also wearing spectacles. He gives me a complete look as he glances up.

Tokenomics

Similar to Aave and Compound, marginfi has a governance token.

  • 1,000,000,000 MRGN Investors (vested tokens): 15%

  • Existing and future core contributors, milestones-based (vested tokens): 20%

  • Airdrop for the community: 10%

  • Community DAO reserves: 52.5%

  • Day 1 grant scheme for core needs: 2.5%

The community DAO reserves could include:

  • Growth incentives (for liquidity providers (LPs) and protocol participants)

  • Future development and operations support

  • The grant program

  • Anything the DAO will vote on

Summary

Marginfi is a decentralized lending protocol on Solana that prioritizes risk management, offering users a secure way to access leverage and optimize capital efficiency. Initially focused on margin trading across Solana perpetual exchanges, Marginfi has introduced "mrgnlend," a new overcollateralized lending protocol.

Marginfi addresses the risk of bad debt, a common issue in other borrow/lend protocols, by implementing a robust risk management system. This includes requiring collateral from borrowers and using liquidators to manage defaults. Marginfi also offers a separate pool for high-risk assets to protect the main lending pool from bad debt.

To enhance security, Marginfi uses Squads, a multisig solution, to manage program authority, preventing any single point of failure. This ensures that any updates to the protocol require multiple approvals, adding an extra layer of security.

Founded by Edgar and Mac, who have backgrounds in traditional finance, Marginfi also features a governance token (MRGN) with a total supply of 1 billion, allocated for investors, contributors, and the community.

Marginfi has also implemented a Points program to reward users for participating in the ecosystem and is developing additional features like a stableswap AMM and an overcollateralized stablecoin, mUSD, to further enhance its DeFi offerings.

FAQs

Q1) Can I earn points on The Arena?

No, traders cannot earn points for the activity they conduct on The Arena.

Q2) Are there fees on flashloans?

No, flashloans do not incur fees. Flashloans bundle multiple borrow and lend instructions into a single transaction, but the borrows that occur within the flashloan get paid back immediately so no interested can be accrued.

Q3) Are there fees on LST?

There are no fees for holding or acquiring LST. marginfi does not profit from LST withdrawals.

Q4) What are marginfi points?

Marginfi points are earned by lending, borrowing, and referring new users, they quantify your contribution to the marginfi ecosystem.

Q5) How do health factors work?

Health factors indicate how well-collateralized your account is. A value below 0% exposes you to liquidation.