|
1 | | -# Morpho Protocol V1 🦋 |
| 1 | +# Morpho Core Protocol V1 |
2 | 2 |
|
3 | 3 | [](https://github.com/morpho-labs/morpho-contracts/actions/workflows/ci-foundry.yml) |
4 | 4 |
|
5 | | -This repository contains the core smart contracts for the Morpho Protocol V1 🦋. |
| 5 | +<picture> |
| 6 | + <source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/uLq5V14.png"> |
| 7 | + <img alt="" src="https://i.imgur.com/ZiL1Lr2.png"> |
| 8 | +</picture> |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## What is Morpho? |
| 13 | + |
| 14 | +Morpho is a lending pool optimizer: it improves the capital efficiency of positions on existing lending pools by seamlessly matching users peer-to-peer. |
| 15 | + |
| 16 | +- Morpho's rates stay between the supply rate and the borrow rate of the pool, reducing the interests paid by the borrowers while increasing the interests 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. |
| 17 | +- Morpho also preserves the same experience, the same liquidity and the same parameters (collateral factors, oracles, …) as the underlying pool. |
| 18 | + |
| 19 | +TL;DR: Instead of borrowing or lending on your favorite pool like Compound or Aave, you would be better off using Morpho-Compound or Morpho-Aave. |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Contracts overview |
| 24 | + |
| 25 | +In this repository. |
| 26 | + |
| 27 | +The Morpho protocol is designed at its core with a set of contracts delegating calls to implementation contracts (to overcome the contract size limit). |
| 28 | + |
| 29 | +Here is a brief overview of the Morpho protocol's contracts interactions: |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +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 exact same storage layout: |
| 34 | + |
| 35 | +- `PositionsManager`: logic of basic supply, borrow, withdraw, repay and liquidate functions. In Morpho-Aave, it is separated into two contracts, `EntryPositionsManager` and `ExitPositionsManager`. These contracts inherit from `MatchingEngine`, which contains the matching engine internal functions. |
| 36 | +- `InterestRatesManager`: logic of indexes computation. |
| 37 | + |
| 38 | +It also interacts with `RewardsManager`, which manages the underlying pool's rewards if any. |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## Documentation |
| 43 | + |
| 44 | +- [White Paper](https://whitepaper.morpho.xyz) |
| 45 | +- [Morpho Documentation](https://docs.morpho.xyz) |
| 46 | +- Yellow Paper (coming soon) |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Audits |
| 51 | + |
| 52 | +All audits are stored in the [audits](./audits/)' folder. |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## Bug bounty |
| 57 | + |
| 58 | +A bug bounty is open on Immunefi. The rewards and scope are defined [here](https://immunefi.com/bounty/morpho/). |
| 59 | +You can also send an email to [security@morpho.xyz](mailto:security@morpho.xyz) if you find something worrying. |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## Deployment Addresses |
| 64 | + |
| 65 | +### Morpho-Compound Ethereum |
| 66 | + |
| 67 | +- Morpho Proxy: [0x8888882f8f843896699869179fb6e4f7e3b58888](https://etherscan.io/address/0x8888882f8f843896699869179fb6e4f7e3b58888) |
| 68 | +- Morpho Implementation: [0xf29cc0319679b54bd25a8666fc0830b023c6a272](https://etherscan.io/address/0xf29cc0319679b54bd25a8666fc0830b023c6a272) |
| 69 | +- PositionsManager: [0x082bf6702e718483c85423bd279088c215a21302](https://etherscan.io/address/0x082bf6702e718483c85423bd279088c215a21302) |
| 70 | +- InterestRatesManager: [0x2f2d51f4d68a96859d4f69672cbeefd854bd8289](https://etherscan.io/address/0x2f2d51f4d68a96859d4f69672cbeefd854bd8289) |
| 71 | +- RewardsManager Proxy: [0x78681e63b6f3ad81ecd64aecc404d765b529c80d](https://etherscan.io/address/0x78681e63b6f3ad81ecd64aecc404d765b529c80d) |
| 72 | +- RewardsManager Implementation: [0x70c59877f5358d8d6f2fc90f53813eb2b2698ab7](https://etherscan.io/address/0x70c59877f5358d8d6f2fc90f53813eb2b2698ab7) |
| 73 | +- Lens: [0xe8cfa2edbdc110689120724c4828232e473be1b2](https://etherscan.io/address/0xe8cfa2edbdc110689120724c4828232e473be1b2) |
| 74 | +- CompRewardsLens: [0x9e977f745d5ae26c6d47ac5417ee112312873ba7](https://etherscan.io/address/0x9e977f745d5ae26c6d47ac5417ee112312873ba7) |
| 75 | + |
| 76 | +### Morpho-Aave-V2 Ethereum |
| 77 | + |
| 78 | +- Morpho Proxy: [0x299ff2534c6f11624d6a65463b8b40c958ab668f](https://etherscan.io/address/0x299ff2534c6f11624d6a65463b8b40c958ab668f) |
| 79 | +- Morpho Implementation: [0x299ff2534c6f11624d6a65463b8b40c958ab668f](https://etherscan.io/address/0x299ff2534c6f11624d6a65463b8b40c958ab668f) |
| 80 | +- EntryPositionsManager: [0xdf93cf1ca3acf96bc26783e6fab89400d362d0b4](https://etherscan.io/address/0xdf93cf1ca3acf96bc26783e6fab89400d362d0b4) |
| 81 | +- ExitPositionsManager: [0xf6998f72b92b81c8f683d30ed8678d348fe9754b](https://etherscan.io/address/0xf6998f72b92b81c8f683d30ed8678d348fe9754b) |
| 82 | +- InterestRatesManager: [0x91b23044d4a8089670309852c7f0a93e5ca8efb7](https://etherscan.io/address/0x91b23044d4a8089670309852c7f0a93e5ca8efb7) |
| 83 | +- Lens Proxy: [0x507fa343d0a90786d86c7cd885f5c49263a91ff4](https://etherscan.io/address/0x507fa343d0a90786d86c7cd885f5c49263a91ff4) |
| 84 | +- Lens: [0x8706256509684e9cd93b7f19254775ce9324c226](https://etherscan.io/address/0x8706256509684e9cd93b7f19254775ce9324c226) |
| 85 | + |
| 86 | +### Common Ethereum |
| 87 | + |
| 88 | +- ProxyAdmin: [0x99917ca0426fbc677e84f873fb0b726bb4799cd8](https://etherscan.io/address/0x99917ca0426fbc677e84f873fb0b726bb4799cd8) |
6 | 89 |
|
7 | 90 | --- |
8 | 91 |
|
@@ -51,7 +134,7 @@ Only tests for the [RewardsDistributor](./contracts/common/rewards-distribution/ |
51 | 134 | Just run: |
52 | 135 |
|
53 | 136 | ```bash |
54 | | -yarn test:hardhat |
| 137 | +yarn test |
55 | 138 | ``` |
56 | 139 |
|
57 | 140 | --- |
@@ -82,94 +165,12 @@ make script-Deploy PROTOCOL=compound NETWORK=goerli SMODE=local |
82 | 165 |
|
83 | 166 | --- |
84 | 167 |
|
85 | | -## Style guide 💅 |
86 | | - |
87 | | -### Code Formatting |
88 | | - |
89 | | -We use prettier with the default configuration mentionned in the [Solidity Prettier Plugin](https://github.com/prettier-solidity/prettier-plugin-solidity). |
90 | | -We recommend developers using VS Code to set their local config as below: |
91 | | - |
92 | | -```json |
93 | | -{ |
94 | | - "editor.formatOnSave": true, |
95 | | - "solidity.formatter": "prettier", |
96 | | - "editor.defaultFormatter": "esbenp.prettier-vscode" |
97 | | -} |
98 | | -``` |
99 | | - |
100 | | -In doing so the code will be formatted on each save. |
101 | | - |
102 | | -We use Husky hook to format code before being pushed to any remote branch to enforce coding style among all developers. |
103 | | - |
104 | | -### Code Style |
| 168 | +## Questions & Feedback |
105 | 169 |
|
106 | | -We follow the Solidity style guide from the [Solidity Documentation](https://docs.soliditylang.org/en/latest/style-guide.html) and the [NatSpec format](https://docs.soliditylang.org/en/latest/natspec-format.html) using this pattern `///`. |
107 | | -Comments should begin with a capital letter and end with a period. You can check the current code to have an overview of what is expected. |
| 170 | +For any question or feedback you can send an email to [merlin@morpho.xyz](mailto:merlin@morpho.xyz). |
108 | 171 |
|
109 | 172 | --- |
110 | 173 |
|
111 | | -## Contributing 💪 |
112 | | - |
113 | | -In this section, you will find some guidelines to read before contributing to the project. |
114 | | - |
115 | | -### Creating issues and PRs |
116 | | - |
117 | | -Guidelines for creating issues and PRs: |
118 | | - |
119 | | -- Issues must be created and labelled with relevant labels (type of issues, high/medium/low priority, etc.). |
120 | | -- Nothing should be pushed directly to the `main` branch. |
121 | | -- Pull requests must be created before and branch names must follow this pattern: `feat/<feature-name>`, `test/<test-name>` or `fix/<fix-name>`. `docs`, `ci` can also be used. The goal is to have clear branches names and make easier their management. |
122 | | -- PRs must be labelled with the relevant labels. |
123 | | -- Issues must be linked to PRs so that once the PR is merged related issues are closed at the same time. |
124 | | -- Reviewers must be added to the PR. |
125 | | -- For commits, install the gitmoji VS Code extension and use the appropriate emoji for each commit. It should match this pattern: `<emoji> (<branch-name>) <commit-message>`. For a real world example: `✨ (feat/new-feature) Add new feature`. |
126 | | - |
127 | | -### Before merging a PR |
128 | | - |
129 | | -Before merging a PR: |
130 | | - |
131 | | -- PR must have been reviewed by reviewers. The must deliver a complete report on the smart contracts (see the section below). |
132 | | -- Comments and requested changes must have been resolved. |
133 | | -- PR must have been approved by every reviewers. |
134 | | -- CI must pass. |
135 | | - |
136 | | -For smart contract reviews, a complete report must have been done, not just a reading of the changes in the code. This is very important as a simple change on one line of code can bring dramatic consequences on a smart contracts (bad copy/paste have already lead to hacks). |
137 | | -For the guidelines on "How to review contracts and write a report?", you can follow this [link](https://morpho-labs.notion.site/How-to-do-a-Smart-Contract-Review-81d1dc692259463993cc7d81544767d1). |
138 | | - |
139 | | -By default, PR are rebased with `dev` before merging to keep a clean historic of commits and the branch is deleted. The same process is done from `dev` to `main`. |
140 | | - |
141 | | -## Deploying a contract on a network 🚀 |
142 | | - |
143 | | -You can run the following command to deploy Morpho-Aave's contracts on Mumbai by using foundry: |
144 | | - |
145 | | -```bash |
146 | | -make script-DeployMorphoAaveV2 PROTOCOL=aave-v2 NETWORK=polygon-mumbai |
147 | | -``` |
148 | | - |
149 | | -## Publishing and verifying a contract on Etherscan 📡 |
150 | | - |
151 | | -An etherscan API key is required to verify the contract and placed into your `.env.local` file. |
152 | | -The right arguments of the constructor of the smart contract to verify must be write inside `arguments.js`. Then you can run the following command to verify a contract: |
153 | | - |
154 | | -```bash |
155 | | -npx hardhat verify --network <network-name> --constructor-args scripts/arguments.js <contract-address> |
156 | | -npx hardhat verify --network <network-name> --constructor-args scripts/arguments.js --contract contracts/Example.sol:ExampleContract <contract-address> |
157 | | -``` |
158 | | - |
159 | | -The second is necessary if contracts with different names share the same ABI. |
160 | | - |
161 | | -## Verification on Tenderly 📡 |
162 | | - |
163 | | -In your `env.local` file, put your tenderly private key. Then you can deploy and directly verify contracts on your tenderly dashboard. |
164 | | - |
165 | | -## External resources & documentation 📚 |
166 | | - |
167 | | -- [General documentation](https://morpho-labs.gitbook.io/morpho-documentation/) |
168 | | -- [Developer documentation](https://morpho-labs.gitbook.io/technical-documentation/) |
169 | | -- [Whitepaper](https://whitepaper.morpho.best) |
170 | | -- [Foundry](https://github.com/gakonst/foundry) |
171 | | -- [Solidity Prettier Plugin](https://github.com/prettier-solidity/prettier-plugin-solidity) |
172 | | - |
173 | | -## Questions & Feedback 💬 |
| 174 | +## Licensing |
174 | 175 |
|
175 | | -For any question you can send an email to [merlin@mopho.best](mailto:merlin@morpho.best) 😊 |
| 176 | +The code is under the GNU General Public License v3.0 license, see [`LICENSE`](https://github.com/morphodao/morpho-core-v1/blob/main/LICENSE). |
0 commit comments