https://github.com/morpho-org/morpho-aavev3-optimizer
Core contracts of Morpho Optimizers on AaveV3
https://github.com/morpho-org/morpho-aavev3-optimizer
blockchain decentralized defi finance protocol
Last synced: about 1 month ago
JSON representation
Core contracts of Morpho Optimizers on AaveV3
- Host: GitHub
- URL: https://github.com/morpho-org/morpho-aavev3-optimizer
- Owner: morpho-org
- License: agpl-3.0
- Created: 2022-11-17T11:11:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-25T13:58:54.000Z (7 months ago)
- Last Synced: 2024-10-25T14:15:40.399Z (7 months ago)
- Topics: blockchain, decentralized, defi, finance, protocol
- Language: Solidity
- Homepage:
- Size: 4.82 MB
- Stars: 38
- Watchers: 7
- Forks: 12
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Audit: audits/runtime-verification-morpho-aave-v3-report.pdf
Awesome Lists containing this project
README
# 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`](./src/Morpho.sol) contract. It inherits from [`MorphoGetters`](./src/MorphoGetters.sol), which contains all the functions used to query Morpho-AaveV3, [`MorphoSetters`](./src/MorphoSetters.sol), which contains all the functions used by the governance to manage the protocol, [`MorphoInternal`](./src/MorphoInternal.sol), and [`MorphoStorage`](./src/MorphoStorage.sol), where the protocol's internal logic & storage is located. This contract delegates call to the [`PositionsManager`](./src/PositionsManager.sol), that has the same storage layout: this contract inherits from [`PositionsManagerInternal`](./src/PositionsManagerInternal.sol), which contains all the internal accounting logic and in turn inherits from [`MatchingEngine`](./src/MatchingEngine.sol), which contains the matching engine internal functions.
It also interacts with [`RewardsManager`](./src/RewardsManager.sol), which manages AaveV3's rewards, if any.
---
## Documentation
- [White Paper](https://whitepaper.morpho.org)
- [Yellow Paper](https://yellowpaper.morpho.org/)
- [Morpho Documentation](https://docs.morpho.org/concepts/morpho-optimizers)---
## Audits
All audits are stored in the [audits](./audits/)' folder.
---
## Bug bounty
A bug bounty is open on Immunefi. The rewards and scope are defined [here](https://immunefi.com/bounty/morpho/).
You can also email [[email protected]](mailto:[email protected]) if you find something worrying.---
## Deployment Addresses
### Morpho-Aave-V3 Optimizer (Ethereum)
- Morpho Proxy: [0x33333aea097c193e66081e930c33020272b33333](https://etherscan.io/address/0x33333aea097c193e66081e930c33020272b33333)
- Morpho Implementation: [0xf835456cb1de3e39ab50a8a9fbb07ebec3a8ff67](https://etherscan.io/address/0xf835456cb1de3e39ab50a8a9fbb07ebec3a8ff67)
- PositionsManager: [0xcecc755730904b3a6c20ce9aaba181aa4593f869](https://etherscan.io/address/0xcecc755730904b3a6c20ce9aaba181aa4593f869)### Common (Ethereum)
- ProxyAdmin: [0x99917ca0426fbc677e84f873fb0b726bb4799cd8](https://etherscan.io/address/0x99917ca0426fbc677e84f873fb0b726bb4799cd8)
---
## Importing contracts
Using forge:
```bash
forge install morpho-dao/morpho-aave-v3
```---
## Development
### Getting Started
- Install [Foundry](https://github.com/foundry-rs/foundry).
- Run `make install` to initialize the repository.
- Create a `.env` file according to the [`.env.example`](./.env.example) file.### Testing with [Foundry](https://github.com/foundry-rs/foundry) 🔨
Tests are run against a fork of Ethereum, which allows us to interact directly with AaveV3. Note that you need an RPC provider with access to Ethereum.
For testing, make sure `foundry` is installed and install dependencies (git submodules) with:
```bash
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:
```bash
make test
```Or to run only tests matching an input:
```bash
make test-Borrow
```Or to run only unit, internal, integration, or invariant tests:
```bash
make test-[unit/internal/integration/invariant]
```For the other commands, check the [Makefile](./Makefile).
### VSCode setup
Configure your VSCode to automatically format a file on save, using `forge fmt`:
- Install [emeraldwalk.runonsave](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave)
- Update your `settings.json`:```json
{
"[solidity]": {
"editor.formatOnSave": false
},
"emeraldwalk.runonsave": {
"commands": [
{
"match": ".sol",
"isAsync": true,
"cmd": "forge fmt ${file}"
}
]
}
}
```---
## Test coverage
Test coverage is reported using [foundry](https://github.com/foundry-rs/foundry) coverage with [lcov](https://github.com/linux-test-project/lcov) report formatting (and optionally, [genhtml](https://manpages.ubuntu.com/manpages/xenial/man1/genhtml.1.html) transformer).
To generate the `lcov` report, run:
```bash
make coverage
```The report is then usable either:
- via [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) following [this tutorial](https://mirror.xyz/devanon.eth/RrDvKPnlD-pmpuW7hQeR5wWdVjklrpOgPCOA-PJkWFU)
- via html, using `make lcov-html` to transform the report and opening `coverage/index.html`---
## Storage seatbelt
[foundry-storage-check](https://github.com/Rubilmax/foundry-storage-diff) 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 [[email protected]](mailto:[email protected]).
---
## Licensing
The code is under the GNU AFFERO GENERAL PUBLIC LICENSE v3.0, see [`LICENSE`](./LICENSE).