Skip to main content

Advanced Concepts

Morpho Blue is built as a singleton contract, meaning every market lives in one single smart contract instead of each market having a different contract. This design pattern simplifies the protocol and reduces gas consumption when users interact with multiple markets of Morpho Blue.

Singleton Contract

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, and liquidate.
  • 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 Blue (e.g., supply, supplyCollateral, repay, and liquidate) 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 Blue. These are covered in the IRM and Oracles sections.
note

Oracles and IRMs are integral to Morpho Blue 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 Blue achieves higher efficiency, reduced gas costs, and simplified user interactions, making it a robust and scalable solution for DeFi lending.