Skip to main content

Morpho Blue Contracts

Morpho Blue has been developed to be an unopinionated and trustless protocol for lending, similar to SMTP for emails. This means that some software engineering's common “good practices” have been traded for security, minimalism, readability, and efficiency. As a result, all the main logic is contained in one single file (Morpho.sol), and the whole protocol is about 600 lines of code.

The contract implements all the obvious user-facing entry points: supply / withdraw, borrow / repay, supplyCollateral / withdrawCollateral, and liquidate. It also has a flashloan entrypoint and contains the governance gated functions: enabling new IRM/LLTVs and the fee switch capped at 25%. The code carries several useful features for integrations::

  • Singleton: Morpho Blue’s contract is a singleton, meaning all markets of a given chain live in one smart contract. This pattern simplifies interactions and drastically reduces the gas consumption of lending aggregation layers built on top of Morpho Blue.
  • Account management: Blue has an authorization system that enables users to grant any address the permission to borrow and withdraw on their behalf, using their position. This can be done by calling setAuthorization or by signing a message (similar to permit in ERC20 tokens). In particular, this system greatly simplifies bundling transactions for externally owned accounts (EOAs) and can simplify the implementation of tailored granular management systems.
  • Free flash loans: Morpho Blue’s singleton has a free flash loan function allowing one to borrow from all markets simultaneously, as long as they are repaid in the same transaction. This is typically useful in DeFi for liquidations, setting up leverage positions, and onchain arbitrages.
  • Callbacks: Each entry-point in which tokens go from the user to Blue, namely supply, supplyCollateral, repay and liquidate, allows the latter to do a callback with arbitrary data before sending the tokens. For example, this removes the dependency on external flash loans to leverage or liquidate and significantly reduces gas costs for integrators.

The contract comes with a set of Interest Rate Models and Oracle adapters to work with. These are described in the IRM and Oracles sections.


Oracles and IRM are a part of Morpho Blue since the core contract needs IRM and oracles to function correctly. However, you can use any oracle you want to create your own market.