The Protocol
What problem is Morpho Optimizer solving?
On Aave or Compound, you may have noticed a large spread between the interests paid by borrowers and those earned by suppliers.
This spread exists because current lending protocols use a liquidity pool mechanism. In most cases, there is a significant mismatch between the number of suppliers and borrowers - pools have many suppliers and very few borrowers, causing poor capital efficiency.
In a liquidity pool, yields are socialized, meaning numerous lenders must share the interest paid by the limited amount of borrowers. Therefore, suppliers earn less while borrowers pay more to make up for low utilization. A large spread is the result of this mechanism.
Using Morpho Optimizer, rewards are no longer socialized. Instead, the supplied liquidity is dynamically and seamlessly matched peer-to-peer as borrowers come and go. For matched liquidity, lenders yield is the same as the borrowers rate: matched lenders don't share interests.
How Morpho Optimizer improves rates
When lenders and borrowers are matched peer-to-peer, Morpho Optimizer can freely choose the P2P rate but it must remain within the spread of the underlying protocol's pool (between lendingAPY
and borrowingAPY
) to be profitable for both parties.
Let's work through an example. Say Alice is the first lender to come to Morpho Optimizer. As she is alone, she will not find a match, so Morpho deposits her liquidity in the underlying pool.
Then, Bob, a borrower, comes in. Morpho Optimizer automatically removes Alice's liquidity from the pool to match Bob at the P2P rate. Both receive a better rate, a win-win for both parties.
If and when one of the two leaves, Morpho will tap into the liquidity of the underlying lending pool - also known as the fallback mechanism.
On this graph, one sees that Morpho Optimizer enables improved rates for both parties while ensuring that a user can break the peer-to-peer match to fall back on the pool at any moment.
To ensure Morpho Optimizer is an improvement for both suppliers and borrowers, the P2P APY is chosen by Morpho's DAO within the interval [lendingAPY; borrowingAPY]
of the underlying protocol's pool. This is done through the p2pIndexCursor
parameter set by governance, selected from within [0; 1]
, representing the position of the P2P APY within [lendingAPY; borrowingAPY]
.
How matching works
As a first approximation, one can see the matching engine as a priority queue. The Morpho Optimizer protocol uses this priority queue to match users according to the amount they want to lend or borrow. When a new lender supplies liquidity to the protocol, their liquidity is matched with the largest borrower first. Followed by the second, third, and so on, until the liquidity supplied is fully matched or there are no more borrowers to match.
Correspondingly, suppose a new borrower comes to the protocol for liquidity. In that case, their demand is matched with the most significant lender first, then the second, until the borrowed liquidity is fully matched or there are no more lenders to match.
The data-structure holding the priority queue onchain is chosen based on research led by Morpho Labs, a software development company contributing to the development of the Morpho protocol, which considers the most gas-efficient data-structure for this task. Note that a more complex data-structure, that do not necessarily match the largest user first, have been designed and implemented for Morpho AaveV3 Optimizer.
To be fully scalable, the Morpho DAO sets a maximum gas consumption for the matching process. This parameter is known as maxGasForMatching
.
Advanced users can customize this parameter when supplying or borrowing liquidity. If the matching gas consumption exceeds maxGasForMatching
, the remaining unmatched liquidity is deposited on the underlying protocol's pool.
How $COMP and MORPHO rewards work
The Morpho Optimizer protocol automatically accrues rewards distributed by the underlying protocol on behalf of its users. This means that all rewards from the underlying protocol accrued by a Morpho user can be claimed just as if the user was using the underlying protocol directly.
The Morpho Optimizer protocol also distributes its own MORPHO rewards to its users. Learn more in the Ages & Epochs section.