Ensure the security of your smart contracts

Dealing with Utilization in Lending Protocols

Author: Daniil Ogurtsov
Security researcher at MixBytes
This research article delves into an intriguing product direction in DeFi - P2P lending. We have examined this topic in detail through internal research and wish to share our findings. We will delve into why the industry shifted towards P2P lending and provide a comprehensive overview of the mechanics, using Morpho as a prominent example of such projects.

We also have an article on the common vulnerabilities of lending protocols, which provides a general overview of how they work.
Key obstacles of modern lending protocols
A perfect lending protocol would aim to address three key obstacles:

  1. High Utilization: Funds should not sit idle;
  2. Flexibility: New borrowers and depositors should always come and leave;
  3. Borrower-Lender Interest Alignment: Debt interest and APY should be aligned in a manner that benefits both borrowers and lenders, with minimal spread between rates.

However, achieving all three of these goals simultaneously can be challenging in practice.
The conflict between full utilization and flexibility
Achieving full utilization can be challenging as it requires borrowers to take exactly as much liquidity as the lenders have provided.

However, high utilization can result in low flexibility within the protocol, as new borrowers may face difficulties in obtaining debt, and current lenders may encounter obstacles when trying to exit their positions.
The conflict between full utilization and low spread in rates
For key users of lending protocols, only two metrics are critical - the debt interest rate for borrowers and the APY for lenders.
The lending protocol itself algorithmically sets only the debt interest rate for borrowers. Additionally, all lending protocols employ their own Interest Rate Model, which determines the interest rate for borrowers. In most cases, this rate is variable, meaning that the interest rate on a borrower’s debt fluctuates continuously. As a result, borrowers need to know the exact interest rate for their debt tomorrow, adding uncertainty to the borrowing process.
The background of the spread
Non-full utilization immediately affects the profitability of lenders.

The concept is straightforward. To illustrate this, let’s consider a scenario where lenders provided $100, but borrowers only took $50. After a year, borrowers are charged 20% interest on the debt, resulting in $10 in interest on the amount borrowed. However, this income is evenly distributed among all lenders, resulting in a total return of $110 on their initial investment of $100, or a 10% return.

The 50% utilization created a spread between the rates for borrowers and lenders: 20% for borrowers and 10% for lenders.

This difference in rates is purely mathematical and results in an obvious inefficiency. Reducing the spread would have satisfied both parties.
For instance, if there were no spread and rates set at 15% for borrowers and lenders, it would be mutually beneficial. However, due to utilization constraints, achieving this mathematically is not possible.
The compromise chosen by modern lending protocols
Modern lending protocols have chosen to maintain some idle liquidity, typically 10-30%, to provide flexibility to new borrowers and lenders. As a trade-off, they accept the spread between rates.

Generally, the debt interest rate should not be too high or too low. If it is too low, borrowers may take up all the liquidity, leaving none for new borrowers and hindering the project’s core functionality. Additionally, a low rate would result in minimal APY for lenders. On the other hand, if the rate is set too high, borrowers may be unwilling to take on such an expensive debt.

Thus, the interest rate must be set at a fair value based on market participants’ activity, with utilization being a key measure of this activity. High utilization indicates increased borrower activity and demand for debt, which may justify a higher interest rate.

The Interest Rate Model is used to automatically search for such a rate based on utilization, often represented by a common curve, as seen in the example provided by Aave in the graph:

Source: https://docs.aave.com/risk/liquidity-risk/borrow-interest-rate

Typically, there is a current fair market rate on the curve where both borrowers and lenders are satisfied. At this point, in theory, borrowers do not take on new debt, and lenders do not provide additional liquidity to avoid diluting their APY.

The purpose of this mechanism is to maintain some idle liquidity while ensuring that the spread between rates is not too large.
Most existing lending protocols commonly follow this compromise, as it results from the impossibility of solving all conflicting tasks simultaneously.

In the next section, we will explore new directions in the industry where this model may be changed.
How else can we find a balance between these conflicting tasks?
One alternative idea is P2P lending, which directly connects borrowers and lenders, with accrued interest on the debt going directly to the lender, based on the principal amount of the debt. In this case, full utilization is achieved by definition, as there is no pool where funds would sit idle.

This idea was tested back in 2017, when Aave was known as ETHLend and originally offered this P2P lending model:

  • Potential borrowers could come to the platform, deposit collateral, and “apply” to borrow, specifying the terms of their debt.
  • Lenders could review such applications and provide liquidity to those borrowers whose terms they found attractive.

However, this system was not atomic and required several transactions for the full transaction cycle, and it implied the absence of any matching mechanism, as everything happened manually. Such a model sacrificed a lot of flexibility.

The P2P lending model did not find its market at that time, as the DeFi space was still narrow. New Peer-To-Pool models turned out to be more attractive, as anyone could instantly interact with the pool by depositing liquidity or borrowing. Flexibility was prioritized over ensuring a minimum spread between rates for lending protocols.

Subsequently, ETHLend turned into Aave and adopted a new model already successfully tested at Compound.

After that, the P2P lending model disappeared from the radar, but it remained tempting to reduce the spread between rates and overcome the obvious inefficiencies.

Now, Morpho reintroduces this idea, and we will further explore how they have managed to create P2P lending and what nuances are involved.
How Morpho achieves full utilization
Morpho and ETHLend have some differences.

From the user’s perspective, the interactions with Morpho are similar to any other lending protocol.

  • Lenders can provide liquidity into the pool and withdraw it at their discretion.
  • Borrowers can access funds from the pool and repay the debt when they choose to.

However, two extreme situations may arise.
If there are more lenders than borrowers
In theory, there may not be full utilization. However, the funds are not idle and are deposited into Compound/Aave. As a result, some lenders receive APY directly from the borrowers, achieving full utilization. Other lenders earn APY from Compound/Aave for supplying liquidity.
If there are more borrowers than lenders
In this case, some funds will be taken directly from the lenders, achieving full utilization for these lenders and borrowers. However, the remaining borrowers’ collateral will be sent to Compound/Aave. Morpho will then transfer debt from Compound/Aave to borrowers.
There are two important conclusions to be drawn
1. For P2P lending to operate, there must be a base lending protocol such as Compound or Aave, where excess liquidity can be deposited or missing liquidity can be borrowed from. Morpho is not a replacement for modern lending protocols; rather, it serves as an add-on to them.

2. In reality, full utilization is not achieved for all Morpho users. Users are divided into two groups. The first group experiences formal full utilization, while the second group has their interactions redirected to Compound/Aave.

This can be illustrated using the example of Morpho’s own numbers.
Source: https://www.morpho.xyz/

At the time of writing, lenders have deposited $460M and borrowers have taken $220M.

These numbers may not indicate full utilization. However, the lenders of $220 million did achieve full utilization as exactly $220 million was issued as debt. The remaining surplus of $240 million went to Compound/Aave, where funds earn interest rates and contribute to the utilization of these base protocols.
How Morpho reduces the spread between rates
Morpho has a unique approach to reducing the spread between rates. Some of its funds achieve full utilization, and Morpho calculates its own interest rate for these funds. This calculated interest rate is the average between the debt interest rate and APY for lenders obtained from the base lending protocols (although the actual formula is more complex, we will omit it for now). As a result, for borrowers on Morpho, the rate becomes lower, making debt cheaper, while for lenders, the rate becomes higher, resulting in a higher APY.

This artificial nullification of the spread between rates is achieved only for the funds that are “matched” according to Morpho’s Matching Engine, a smart contract that calculates the amount of such funds (we will discuss this in a separate section).

However, it’s important to note that unmatched funds are also present in Morpho, which are redirected to Compound/Aave. Morpho does not set special rates for these unmatched funds, and they are charged the current market rate of these lending protocols.

Excess liquidity in Morpho accrues a lower yield, which is taken from Compound/Aave, while excess debt is subject to an increased interest rate, which is charged from Compound/Aave.
Inspiration for improvement to other developers
Matched rates are not socialized
Let’s illustrate this with an example of excess liquidity in Morpho. In Morpho, there is a distinct division of funds into two groups that earn different returns. One group earns a higher return, while the other group earns a lower return. There are no intermediate states, except for some users who may experience partial matching, dividing their funds into two groups.

However, there is an unresolved issue of having a group of users who earn the same returns as Compound/Aave as they wait in a queue for matching with new borrowers.

This creates inequality between the groups, a conscious design decision by Morpho. While a typical liquidity provider would prefer to be in the high-income group, achieving this in Morpho’s implementation takes work. This issue is further compounded by the challenges associated with the Matching Engine.
Matching Engine
Morpho monitors the funds deposited/borrowed by different users and ranks them from the largest to the smallest based on their size. Users at the top of the list, which includes the largest lenders and borrowers, fall into the category with higher income.

However, this approach has its problems, and the implementation of the Matching Engine still needs to be improved due to gas restrictions. It scans and sorts users each time, which may leave some users unsorted due to gas limitations.

In addition, the implementation of the Matching Engine itself is not yet quite perfect due to gas restrictions. It scans and sorts users each time, and leaves some users unsorted due to gas restrictions.
Source: https://dune.com/morpholabs/morpho-aave-dashboard

As a result, despite the excess liquidity in Morpho, not all borrowers can match with lenders, as seen in the provided graphs. Only a fraction of the borrowers were able to find matches, while the remaining funds were borrowed from Aave, even though there is a queue of lenders expected to match with them.
The base protocol does not have to be a lending
Since DeFi offers multiple sources of revenue, P2P lending protocols are not required to redirect excess liquidity to another lending protocol. Some implementations may deposit such liquidity in yield aggregators like Yearn, as seen with projects like Sturdy. This is also one of the ways to effectively utilize excess liquidity and increase capital utilization.
Conclusion
P2P lending protocols are gaining momentum in the industry, and in the future, we may see updates to Morpho itself, as well as new projects that aim to overcome its limitations.

We hope that we have thoroughly addressed the issue of utilization in lending protocols and potentially highlighted an interesting niche for new developers.
Related articles
Who is MixBytes?
MixBytes is a team of expert blockchain auditors and security researchers specializing in providing comprehensive smart contract audits and technical advisory services for EVM-compatible and Substrate-based projects. Join us on Twitter to stay up-to-date with the latest industry trends and insights.
Disclaimer
The information contained in this Website is for educational and informational purposes only and shall not be understood or construed as financial or investment advice.
Other posts