{"id":26054871,"url":"https://github.com/morpho-org/morpho-optimizers","last_synced_at":"2025-04-05T14:03:02.462Z","repository":{"id":65027024,"uuid":"384546699","full_name":"morpho-org/morpho-optimizers","owner":"morpho-org","description":"Core contracts of Morpho Optimizers.","archived":false,"fork":false,"pushed_at":"2025-03-02T22:34:08.000Z","size":13550,"stargazers_count":138,"open_issues_count":5,"forks_count":24,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-29T13:04:48.578Z","etag":null,"topics":["blockchain","decentralized","defi","finance"],"latest_commit_sha":null,"homepage":"https://app.morpho.org","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morpho-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audits/ChainSecurity_Morpho_Labs_Morpho_Aave_v3_audit.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-09T20:42:34.000Z","updated_at":"2025-03-04T18:58:36.000Z","dependencies_parsed_at":"2023-12-05T17:31:02.607Z","dependency_job_id":"78152ed4-e0fa-42e9-8ff2-b7dc141a337d","html_url":"https://github.com/morpho-org/morpho-optimizers","commit_stats":{"total_commits":3030,"total_committers":26,"mean_commits":"116.53846153846153","dds":0.6557755775577558,"last_synced_commit":"fbb5b1324f5dc2dd5963ba0bfc1fdff885fb582b"},"previous_names":["morpho-dao/morpho-v1"],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fmorpho-optimizers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fmorpho-optimizers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fmorpho-optimizers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fmorpho-optimizers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morpho-org","download_url":"https://codeload.github.com/morpho-org/morpho-optimizers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345848,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","decentralized","defi","finance"],"created_at":"2025-03-08T10:00:27.087Z","updated_at":"2025-04-05T14:03:02.442Z","avatar_url":"https://github.com/morpho-org.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Morpho Optimizers\n\n[![Morpho-Compound-Optimizer](https://github.com/morpho-dao/morpho-v1/actions/workflows/ci-foundry-compound.yml/badge.svg)](https://github.com/morpho-dao/morpho-v1/actions/workflows/ci-foundry-compound.yml)\n[![Morpho-AaveV2-Optimizer](https://github.com/morpho-dao/morpho-v1/actions/workflows/ci-foundry-aave-v2.yml/badge.svg)](https://github.com/morpho-dao/morpho-v1/actions/workflows/ci-foundry-aave-v2.yml)\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://i.imgur.com/uLq5V14.png\"\u003e\n  \u003cimg alt=\"\" src=\"https://i.imgur.com/ZiL1Lr2.png\"\u003e\n\u003c/picture\u003e\n\n---\n\n## What are Morpho Optimizers?\n\nMorpho Optimizers improve the capital efficiency of positions on existing lending pools by seamlessly matching users peer-to-peer.\n\n- 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.\n- Morpho also preserves the same experience, the same liquidity, and the same parameters (collateral factors, oracles, …) as the underlying pool.\n\nTL;DR: Instead of borrowing or lending on your favorite pool like Compound or Aave, you would be better off using Morpho Optimizers.\n\n---\n\n## Contracts overview\n\nMorpho Optimizers are designed at their core with a set of contracts delegating calls to implementation contracts (to overcome the contract size limit).\n\nHere is a brief overview of the Morpho Optimizers' contracts interactions:\n\n![image](https://user-images.githubusercontent.com/3147812/187162991-d9e94841-0f23-4f25-86d4-a495917b70e7.png)\n\nThe 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:\n\n- `PositionsManager`: logic of basic supply, borrow, withdraw, repay, and liquidate functions. The Morpho-AaveV2 Optimizer is separated into two contracts, `EntryPositionsManager` and `ExitPositionsManager`. These contracts inherit from `MatchingEngine`, which contains the matching engine's internal functions.\n- `InterestRatesManager`: logic of indexes computation.\n\nIt also interacts with `RewardsManager`, which manages the underlying pool's rewards, if any.\n\n---\n\n## Documentation\n\n- [White Paper](https://whitepaper.morpho.org)\n- [Yellow Paper](https://yellowpaper.morpho.org/)\n- [Morpho Documentation](https://docs.morpho.org/concepts/morpho-optimizers)\n\n---\n\n## Audits\n\nAll audits are stored in the [audits](./audits/)' folder.\n\n---\n\n## Bug bounty\n\nA bug bounty is open on Immunefi. The rewards and scope are defined [here](https://immunefi.com/bounty/morpho/).\nYou can email [security@morpho.org](mailto:security@morpho.org) if you find something worrying.\n\n---\n\n## Deployment Addresses\n\n### Morpho-Compound Optimizer on Ethereum\n\n- Morpho Proxy: [0x8888882f8f843896699869179fb6e4f7e3b58888](https://etherscan.io/address/0x8888882f8f843896699869179fb6e4f7e3b58888)\n- Morpho Implementation: [0xe3d7a242614174ccf9f96bd479c42795d666fc81](https://etherscan.io/address/0xe3d7a242614174ccf9f96bd479c42795d666fc81)\n- PositionsManager: [0x79a1b5888009bB4887E00EA27CF52551aAf2A004](https://etherscan.io/address/0x79a1b5888009bB4887E00EA27CF52551aAf2A004)\n- InterestRatesManager: [0xD9B7209eD2936b5c06990A8356D155c3665d43Ab](https://etherscan.io/address/0xD9B7209eD2936b5c06990A8356D155c3665d43Ab)\n- RewardsManager Proxy: [0x78681e63b6f3ad81ecd64aecc404d765b529c80d](https://etherscan.io/address/0x78681e63b6f3ad81ecd64aecc404d765b529c80d)\n- RewardsManager Implementation: [0x581c3816589ad0de7f9c76bc242c97fe96c9f100](https://etherscan.io/address/0x581c3816589ad0de7f9c76bc242c97fe96c9f100)\n- Lens Proxy: [0x930f1b46e1d081ec1524efd95752be3ece51ef67](https://etherscan.io/address/0x930f1b46e1d081ec1524efd95752be3ece51ef67)\n- Lens Implementation: [0x834632a7c70ddd7badd3d21ba9d885a9da66b0de](https://etherscan.io/address/0x834632a7c70ddd7badd3d21ba9d885a9da66b0de)\n- Lens Extension: [0xc5c3bB32c70d1d547023346BD1E32a6c5BC7FD1e](https://etherscan.io/address/0xc5c3bB32c70d1d547023346BD1E32a6c5BC7FD1e)\n- CompRewardsLens: [0x9e977f745d5ae26c6d47ac5417ee112312873ba7](https://etherscan.io/address/0x9e977f745d5ae26c6d47ac5417ee112312873ba7)\n\n### Morpho-AaveV2 Optimizer on Ethereum\n\n- Morpho Proxy: [0x777777c9898d384f785ee44acfe945efdff5f3e0](https://etherscan.io/address/0x777777c9898d384f785ee44acfe945efdff5f3e0)\n- Morpho Implementation: [0xFBc7693f114273739C74a3FF028C13769C49F2d0](https://etherscan.io/address/0xFBc7693f114273739C74a3FF028C13769C49F2d0)\n- EntryPositionsManager: [0x029Ee1AF5BafC481f9E8FBeD5164253f1266B968](https://etherscan.io/address/0x029Ee1AF5BafC481f9E8FBeD5164253f1266B968)\n- ExitPositionsManager: [0xfd9b1Ad429667D27cE666EA800f828B931A974D2](https://etherscan.io/address/0xfd9b1Ad429667D27cE666EA800f828B931A974D2)\n- InterestRatesManager: [0x22a4ecf5195c87605ae6bad413ae79d5c4170ff1](https://etherscan.io/address/0x22a4ecf5195c87605ae6bad413ae79d5c4170ff1)\n- Lens Proxy: [0x507fa343d0a90786d86c7cd885f5c49263a91ff4](https://etherscan.io/address/0x507fa343d0a90786d86c7cd885f5c49263a91ff4)\n- Lens Implementation: [0x4bf26012b64312b462bf70f2e42d1be8881d0f84](https://etherscan.io/address/0x4bf26012b64312b462bf70f2e42d1be8881d0f84)\n\n### Common Ethereum\n\n- ProxyAdmin: [0x99917ca0426fbc677e84f873fb0b726bb4799cd8](https://etherscan.io/address/0x99917ca0426fbc677e84f873fb0b726bb4799cd8)\n\n---\n\n## Importing package\n\nUsing npm:\n\n```bash\nnpm install @morpho-dao/morpho-v1\n```\n\nUsing forge:\n\n```bash\nforge install @morpho-dao/morpho-v1@v2.0.0\n```\n\nUsing git submodules:\n\n```bash\ngit submodule add @morpho-dao/morpho-v1@v2.0.0 lib/morpho-v1\n```\n\n---\n\n## Testing with [Foundry](https://github.com/foundry-rs/foundry) 🔨\n\nTests 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.\n\nFor testing, make sure `yarn` and `foundry` are installed and install dependencies (node_modules, git submodules) with:\n\n```bash\nmake install\n```\n\nAlternatively, if you only want to set up\n\nRefer to the `env.example` for the required environment variable.\n\nTo run tests on different protocols, navigate a Unix terminal to the root folder of the project and run the command of your choice:\n\nTo run every test of a specific protocol (e.g. for the Morpho-Compound Optimizer):\n\n```bash\nmake test PROTOCOL=compound\n```\n\nor to run only a specific set of tests of a specific protocol (e.g. for the Morpho-AaveV2 Optimizer):\n\n```bash\nmake c-TestBorrow PROTOCOL=aave-v2\n```\n\nor to run an individual test of a specific protocol (e.g. for the Morpho-AaveV2 Optimizer):\n\n```bash\nmake test-testBorrow1 PROTOCOL=aave-v2\n```\n\nFor the other commands, check the [Makefile](./Makefile).\n\nIf 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`.\n\n:warning: The `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:\n\n- use `( . ./export_env.sh \u0026\u0026 forge test )` if the command you want to run is `forge test`\n- use `bash` and then `. ./export_env.sh` followed by your commands and then `exit` to return to the parent shell and clear the environment variables.\n\n---\n\n## Testing with Hardhat\n\nOnly tests for the [RewardsDistributor](./src/common/rewards-distribution/RewardsDistributor.sol) are run with Hardhat.\n\nJust run:\n\n```bash\nyarn test\n```\n\n---\n\n## Storage seatbelt\n\nA CI pipeline [foundry-storage-check](https://github.com/Rubilmax/foundry-storage-diff) 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.\n\n---\n\n## Deployment \u0026 Upgrades\n\n### Network mode (default)\n\nRun the Foundry deployment script with:\n\n```bash\nmake script-Deploy PROTOCOL=compound NETWORK=goerli\n```\n\n### Local mode\n\nFirst start a local EVM:\n\n```bash\nmake anvil NETWORK=goerli\n```\n\nThen run the Foundry deployment script in a separate shell, using `SMODE=local`:\n\n```bash\nmake script-Deploy PROTOCOL=compound NETWORK=goerli SMODE=local\n```\n\n---\n\n## Questions \u0026 Feedback\n\nFor any questions or feedback, you can send an email to [merlin@morpho.org](mailto:merlin@morpho.org).\n\n---\n\n## Licensing\n\nThe code is under the GNU AFFERO GENERAL PUBLIC LICENSE v3.0, see [`LICENSE`](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fmorpho-optimizers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorpho-org%2Fmorpho-optimizers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fmorpho-optimizers/lists"}