Skip to content

morpho-org/morpho-aavev3-optimizer

Repository files navigation

Morpho-AaveV3 Optimizer


What are Morpho Optimizers?

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 AaveV3 pool, you would be better off using Morpho-AaveV3.


Contracts overview

The Morpho protocol is designed at its core, with the main Morpho contract delegating calls to the PositionsManager implementation contract (to overcome the contract size limit).

The main user's entry points are exposed in the Morpho contract. It inherits from MorphoGetters, which contains all the functions used to query Morpho-AaveV3, MorphoSetters, which contains all the functions used by the governance to manage the protocol, MorphoInternal, and MorphoStorage, where the protocol's internal logic & storage is located. This contract delegates call to the PositionsManager, that has the same storage layout: this contract inherits from PositionsManagerInternal, which contains all the internal accounting logic and in turn inherits from MatchingEngine, which contains the matching engine internal functions.

It also interacts with RewardsManager, which manages AaveV3's rewards, if any.


Documentation


Audits

All audits are stored in the audits' folder.


Bug bounty

A bug bounty is open on Immunefi. The rewards and scope are defined here. You can also email security@morpho.org if you find something worrying.


Deployment Addresses

Morpho-Aave-V3 Optimizer (Ethereum)

Common (Ethereum)


Importing contracts

Using forge:

forge install morpho-dao/morpho-aave-v3

Development

Getting Started

  • Install Foundry.
  • Run make install to initialize the repository.
  • Create a .env file according to the .env.example file.

Testing with Foundry 🔨

Tests are run against a fork of real networks, which allows us to interact directly with the liquidity pools of AaveV3. Note that you need an RPC provider with access to Ethereum or Avalanche.

For testing, make sure foundry is installed and install dependencies (git submodules) with:

make install

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 the whole test suite:

make test

Or to run only tests matching an input:

make test-Borrow

Or to run only unit, internal, integration, or invariant tests:

make test-[unit/internal/integration/invariant]

For the other commands, check the Makefile.

VSCode setup

Configure your VSCode to automatically format a file on save, using forge fmt:

{
  "[solidity]": {
    "editor.formatOnSave": false
  },
  "emeraldwalk.runonsave": {
    "commands": [
      {
        "match": ".sol",
        "isAsync": true,
        "cmd": "forge fmt ${file}"
      }
    ]
  }
}

Test coverage

Test coverage is reported using foundry coverage with lcov report formatting (and optionally, genhtml transformer).

To generate the lcov report, run:

make coverage

The report is then usable either:


Storage seatbelt

foundry-storage-check is currently running on every PR to check that the changes introduced are not modifying the storage layout of proxied smart contracts in an unsafe way.


Questions & Feedback

For any questions or feedback, you can send an email to contact@morpho.org.


Licensing

The code is under the GNU AFFERO GENERAL PUBLIC LICENSE v3.0, see LICENSE.