Advanced Concepts
Singleton Contract
Morpho (formerly known as Morpho Blue) is designed as a singleton contract. This means all markets are contained within one single smart contract, rather than each market having a separate contract. This design simplifies the protocol and significantly reduces gas consumption when users interact with multiple markets.
Benefits of the Singleton Contract
- Simplified Interactions: Users can interact with multiple markets within a single transaction, saving on gas fees.
- Concentrated Liquidity: The singleton contract concentrates liquidity for flash loans, making it more efficient and accessible.
- Unified Logic: All core functionalities and user-facing entry points are contained within one file, Morpho.sol, making the protocol more readable and efficient.
Key Features
- User-Facing Entry Points: Includes functions like
supply
,withdraw
,borrow
,repay
,supplyCollateral
,withdrawCollateral
, andliquidate
. - Governance Functions: Includes functions for enabling new Interest Rate Models (IRMs), Loan-to-Value (LLTV) ratios, and a fee switch capped at 25%.
- Free Flash Loans: Allows borrowing from all markets simultaneously, provided they are repaid in the same transaction. This is useful for liquidations, leverage positions, and arbitrage.
- Callbacks: Each entry point where tokens move from the user to Morpho (e.g.,
supply
,supplyCollateral
,repay
, andliquidate
) supports callbacks with arbitrary data, removing dependencies on external flash loans and reducing gas costs.
Advanced Features
- Bad Debt Realization: Mechanisms to handle and realize bad debts within the protocol.
- Callbacks: Detailed explanation of how callbacks work within the entry points.
- Flash Loans: Overview of the free flash loan functionality.
- Account Management: Authorization system that allows users to grant permissions to other addresses for borrowing and withdrawing on their behalf.
Additional Information
- Interest Rate Models and Oracle Adapters: The contract includes various IRMs and Oracle adapters, which are crucial for the functioning of Morpho. These are covered in the IRM and Oracles sections.
Oracles and IRMs are integral to Morpho as the core contract needs them to function correctly. However, you can use any oracle you prefer to create your own market.
By consolidating all markets into a single contract, Morpho achieves higher efficiency, reduced gas costs, and simplified user interactions, making it a robust and scalable solution for DeFi lending.