Morpho Optimizers improve the capital efficiency of positions on existing lending pools by seamlessly matching users peer-to-peer.
- Morpho's rates stay between the supply rate and the borrow rate of the pool, reducing the interest paid by the borrowers while increasing the interest earned by the suppliers. It means that you are getting boosted peer-to-peer rates or, in the worst-case scenario, the APY of the pool.
- Morpho also preserves the same experience, the same liquidity, and the same parameters (collateral factors, oracles, …) as the underlying pool.
TL;DR: Instead of borrowing or lending on your favorite pool like Compound or Aave, you would be better off using Morpho Optimizers.
Morpho Optimizers are designed at their core with a set of contracts delegating calls to implementation contracts (to overcome the contract size limit).
Here is a brief overview of the Morpho Optimizers' contracts interactions:
The main user's entry points are exposed in the Morpho contract. It inherits from MorphoGovernance, which contains all the admin functions of the DAO, MorphoUtils, and MorphoStorage, where the protocol's storage is located. This contract delegates call to other contracts that have the same storage layout:
PositionsManager: logic of basic supply, borrow, withdraw, repay, and liquidate functions. The Morpho-AaveV2 Optimizer is separated into two contracts,EntryPositionsManagerandExitPositionsManager. These contracts inherit fromMatchingEngine, which contains the matching engine's internal functions.InterestRatesManager: logic of indexes computation.
It also interacts with RewardsManager, which manages the underlying pool's rewards, if any.
All audits are stored in the audits' folder.
A bug bounty is open on Immunefi. The rewards and scope are defined here. You can email [email protected] if you find something worrying.
- Morpho Proxy: 0x8888882f8f843896699869179fb6e4f7e3b58888
- Morpho Implementation: 0xe3d7a242614174ccf9f96bd479c42795d666fc81
- PositionsManager: 0x79a1b5888009bB4887E00EA27CF52551aAf2A004
- InterestRatesManager: 0xD9B7209eD2936b5c06990A8356D155c3665d43Ab
- RewardsManager Proxy: 0x78681e63b6f3ad81ecd64aecc404d765b529c80d
- RewardsManager Implementation: 0x581c3816589ad0de7f9c76bc242c97fe96c9f100
- Lens Proxy: 0x930f1b46e1d081ec1524efd95752be3ece51ef67
- Lens Implementation: 0x834632a7c70ddd7badd3d21ba9d885a9da66b0de
- Lens Extension: 0xc5c3bB32c70d1d547023346BD1E32a6c5BC7FD1e
- CompRewardsLens: 0x9e977f745d5ae26c6d47ac5417ee112312873ba7
- Morpho Proxy: 0x777777c9898d384f785ee44acfe945efdff5f3e0
- Morpho Implementation: 0xFBc7693f114273739C74a3FF028C13769C49F2d0
- EntryPositionsManager: 0x029Ee1AF5BafC481f9E8FBeD5164253f1266B968
- ExitPositionsManager: 0xfd9b1Ad429667D27cE666EA800f828B931A974D2
- InterestRatesManager: 0x22a4ecf5195c87605ae6bad413ae79d5c4170ff1
- Lens Proxy: 0x507fa343d0a90786d86c7cd885f5c49263a91ff4
- Lens Implementation: 0x4bf26012b64312b462bf70f2e42d1be8881d0f84
- ProxyAdmin: 0x99917ca0426fbc677e84f873fb0b726bb4799cd8
Using npm:
npm install @morpho-dao/morpho-v1Using forge:
forge install @morpho-dao/[email protected]Using git submodules:
git submodule add @morpho-dao/[email protected] lib/morpho-v1Testing with Foundry 🔨
Tests are run against a fork of real networks, allowing us to interact directly with Compound or Aave liquidity pools. Note that you need an RPC provider with access to Ethereum or Polygon.
For testing, make sure yarn and foundry are installed and install dependencies (node_modules, git submodules) with:
make installAlternatively, if you only want to set up
Refer to the env.example for the required environment variable.
To run tests on different protocols, navigate a Unix terminal to the root folder of the project and run the command of your choice:
To run every test of a specific protocol (e.g. for the Morpho-Compound Optimizer):
make test PROTOCOL=compoundor to run only a specific set of tests of a specific protocol (e.g. for the Morpho-AaveV2 Optimizer):
make c-TestBorrow PROTOCOL=aave-v2or to run an individual test of a specific protocol (e.g. for the Morpho-AaveV2 Optimizer):
make test-testBorrow1 PROTOCOL=aave-v2For the other commands, check the Makefile.
If you want to call a custom forge command and not have to edit the Makefile, you can source the export_env.sh script by calling . ./export_env.sh.
export_env.sh script exports environment variables in the current shell, meaning that subsequent calls to make or forge will use those variables. Variables defined in the .env.local file will still override those if you run make later. If you don't want to change variables in the current shell, you can always create a new shell in one of the following ways:
- use
( . ./export_env.sh && forge test )if the command you want to run isforge test - use
bashand then. ./export_env.shfollowed by your commands and thenexitto return to the parent shell and clear the environment variables.
Only tests for the RewardsDistributor are run with Hardhat.
Just run:
yarn testA CI pipeline foundry-storage-check is running on every PR to check that the changes introduced are not modifying the storage layout of proxied smart contracts in an unsafe way.
Run the Foundry deployment script with:
make script-Deploy PROTOCOL=compound NETWORK=goerliFirst start a local EVM:
make anvil NETWORK=goerliThen run the Foundry deployment script in a separate shell, using SMODE=local:
make script-Deploy PROTOCOL=compound NETWORK=goerli SMODE=localFor any questions or feedback, you can send an email to [email protected].
The code is under the GNU AFFERO GENERAL PUBLIC LICENSE v3.0, see LICENSE.