Location>code7788 >text

[Project Learning] Morpho Lending Agreement Simple Research

Popularity:290 ℃/2024-12-20 00:04:50

Project Background

Morpho blue (hereinafter Morpho) is an overcollateralized lending agreement. Unlike traditional lending agreements, Morpho does not require governance approval to create any customized lending marketplace. Users can create a standalone market by specifying parameters such as a loan asset, a collateral asset, a liquidated loan value (LLTV), a prognosticator and an interest rate model (IRM). Once a market is created, its parameters cannot be modified.

Advantages of Morpho over traditional lending agreements:

  1. Market creation without governance licenses: Morpho creates markets with any collateral and loan asset and any risk parameterization without a governance license.
  2. Higher borrowing ratios: Since Morpho's lending market is composed of one collateral and one lending item, unlike multi-asset pools, the clearing parameters for each market can be set without regard to the riskiest asset in the basket. As a result, providers can lend at a higher LLTV.
  3. Higher interest rates: Collateralized assets are not lent to borrowers. This reduces the liquidity requirements needed for the proper functioning of the lending platform and allows Morpho to offer higher capital utilization. In addition, Morpho is fully autonomous and does not charge platform fees (markets can charge fees).
  4. Low gas consumption: Morpho is a very refined protocol, which reduces Gas consumption by 50% compared to existing lending platforms.

code analysis

The Morpho protocol is really compact, counting only 1892 lines in the Mock contract and only 557 lines in the Master contract.

image

Key functions in Morpho contracts:

  1. createMarket: Deploy a new lending market by configuring core parameters such as borrowing assets, collateralized assets, interest rate models and clearing thresholds.
  2. Supply: Deposit assets into a designated lending market, where you can specify the amount or share of assets to be deposited, support proxy deposits, and receive a corresponding share voucher as a basis for future withdrawals after the deposit is made.
  3. Withdraw: Withdraw previously deposited assets from a designated lending market, redeem the corresponding amount of assets by destroying share certificates, support proxy operations and specify the receiving address.
  4. borrow: lending assets in a designated lending market, checking the health of a user's borrowing based on the value of his collateral, sending the lent assets to the receiving address, and recording the corresponding share of the debt.
  5. REPAY: Allows a user or agent to repay debt in a specified lending market, reduce the share of debt in a target account by transferring assets, support specifying the number or share of assets to be repaid, and update the market's total debit status upon completion of repayment.
  6. supplyCollateral: Allows users to deposit collateral into a specified lending market, supports proxy operations, directly increases the amount of collateral in the target account without generating a share, and eliminates the need to update the market interest rate since collateral does not participate in the calculation of interest on lending.
  7. withdrawCollateral: Allows users to withdraw collateral from a specified lending market, requires a check on the health of the borrowing after the withdrawal to ensure that the remaining collateral is sufficient to cover the current debt, supports proxy operations and specifies the receiving address.
  8. LIQUIDATE: Collateral that allows a liquidator to obtain a discount by paying off a borrower's debt if he or she is not healthy enough.
  9. flashLoan: Provides flash loan function.

Loans and collateral

The Morpho market is a single collateral and single borrower market. So only the Supplier, who provides the collateral, earns interest, while the Borrower, who provides the collateral, does not earn interest.

image

This is where it differs from a traditional lending agreement. In a traditional lending agreement, the collateral provided by the user is also lent to other borrowers as a loan, so the collateral incurs interest.
When Supplier passes thesupply When a function provides debits and credits, the function calls the_accrueInterest function to update its rate.

image

But when Borrower passessupplyCollateral When a function provides collateral, it only accumulates the amount of collateral and does not provide interest for it.

image

Morpho vs. AAVE V3 for mortgage lending

Let's say a user deposits an ETH on Lido and gets 10,000 U worth of wstETH, which he wants to use as collateral to lend USDC.

The following data are for 2024.12.16, assuming a USDC price of 1 U

Mortgage lending at AAVE V3

Suppose the user adds this wstETH to the AAVE V3 (/) on doing collateralized lending.

At this point, wstETH's deposit rate is 0.13%, and USDC's borrowing rate is 16.46%, which offsets the 16.33% interest still to be paid.

image

image

In addition, USDC may lend up to 75% of the value of the collateral, triggering a liquidation at 78% and liquidating up to 50% of the assets lent with a 4.5% liquidation bonus.

image

Receive 10 per cent of interest to fund the platform

image

Secured Lending on Morpho

Suppose a user puts this wstETH in the Morpho (/borrow?network=mainnet) on doing collateralized lending.

The interest rate for collateralizing wstETH on Morpho is 0 (the interest rate for collateralizing anything is 0), and the interest rate for borrowing USDC in the wstETH-USDC market is 12.03%, which includes a Morpho token bonus of -0.77%.

image

Its borrowing and liquidation ratios are equal, both at 86%, and when liquidation is triggered, it can liquidate 100% of the borrowed assets and receive a liquidation gain of 4.38%.

image

image

The creator of the market can set the fee parameter to get a commission from the interest (maximum 25%), for this market the fee parameter is set to 0, i.e. no commission is charged.

Comparison of mortgage lending results

10,000 U worth of wstETH for collateralized lending on AAVE V3 and Morpho, respectively.

It is possible to lend 7500 USDC on AAVE V3 with 16.33% interest. When the value of wstETH falls to 9615 U it will be liquidated.

The maximum amount that can be borrowed on Morpho is 8600 USDC with 12.03% interest. Considering that Morpho's maximum borrowing ratio is the same as the liquidation ratio, it is calculated that when the value of wstETH falls to 9615 U and will be liquidated (in line with AAVE's liquidation price), the maximum amount of money that can be borrowed is 8269 USDC.

The data above shows that Morpho outperforms AAVE V3 in terms of borrowing ratio, liquidation ratio, and interest rate on borrowing.

Morpho vs AAVE V3 Deposit Comparison

Let's say that the user has 10,000 USDC right now and he wants to lend USDC on a lending agreement to generate income.

Make a deposit at AAVE V3

Depositing on AAVE gives you a rate of 12.81%.

image

Make a deposit at Morpho

Morpho offers a variety of deposit options for USDC, with interest rates ranging from 34.39% to 7.69% for different programs.

image

View the Relend USDC strategy to see which Morpho markets the strategy invests in.

image

Comparison of deposit results

In terms of deposit features, AAVE offers a single deposit rate of 12.81%, where users offer USDC into the marketplace to be lent out by any user with any type of collateral. On the other hand, Morpho offers a variety of deposit programs, with different programs placing the user's funds in different markets to earn different interest rates. The overall interest rate performance is better than AAVE.

Comparison of Morpho and AAVE V3's Lightning Loan

Morpho flash loans no fees, win!

image

AAVE V3 will charge a 0.05% handling fee to lose!

image

shortcoming

Morpho outperforms AAVE V3 in terms of features such as secured lending, deposits, and flash loans, but no deal is perfect, and Morpho makes concessions in a few areas in order to improve the utilization of funds as well as to reduce the gap between deposit rates and borrowing rates.

Decentralized liquidity

Morpho uses a single collateral and a single debit to form a lending marketplace. In a traditional lending protocol, it is assumed that a user deposits WETH as collateral and lends USDC, USDT and other tokens from the protocol. However, in Morpho, users need to deposit WETH into the [WETH, USDC] and [WETH, USDT] markets, and then lend tokens separately. This spreads the liquidity of the tokens across the markets. If the same collateral is used to lend different tokens in succession, the collateral needs to be withdrawn from one market and deposited in the next market for collateralized lending.

collateral risk

Since the collateral offered in the Morpho marketplace does not generate interest rates, and Morpho allows users to create a marketplace by freely choosing the type of collateral and the type of lending. Therefore, users prefer to offer interest-bearing tokens as collateral. This allows them to generate their own interest income from the interest-bearing tokens during the collateralization process. You can see that markets with liquidity above 10M are using external DeFi protocol interest-bearing tokens as collateral.

image

But this behavior also introduces new risks. Using the interest-bearing tokens of the external DeFi protocol as collateral is equivalent to building a lending market on the basis of the external protocol. If the external protocol fails to pay the interest-bearing tokens rigidly due to security issues or a crash in the coin price, the value of the relevant collateral in the Morpho market will drop. Failure to liquidate in a timely manner may also result in the creation of bad debt, which may prevent the lending provider from recovering the borrowed funds.

If the original tokens (WETH, WBTC, etc.) are used, it can be assumed that no security risk of the protocol is introduced into the lending market, and there is only the risk of a flash crash in the price of the coin leading to a bad debt.

reference article

  1. Official Documentation:/morpho/overview
  2. Github:/morpho-org/morpho-blue/tree/main
  3. /posts/morpho-bule/

postscript

The Morpho project doesn't have a lot of code, and the biggest question in understanding the project is why it stands out. It's such a delicate project, and it doesn't have too many complicated mechanisms and strategies, but it has gained the favor of users. This is something that needs to be understood in terms of market segments and user needs, which is exactly what I lacked. It is also from the code that I could not understand why Morpho protocol was accepted by the market, so I added a comparison with AAVE V3 in the article, hoping to understand the advantages of the Morpho project from the data shown, and then I could know which advantages of Morpho would be favored by the users. Although this way of understanding is not as concrete as looking at the code implementation, it's still a confusing start, right?