npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@morpho-dao/morpho-v1

v2.0.0

Published

Core contracts of the Morpho Protocol V1.

Downloads

26

Readme

Morpho Core Protocol V1

Morpho-Compound Morpho-AaveV2


What is Morpho?

Morpho is a lending pool optimizer: it improves 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 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.
  • 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-Compound or Morpho-Aave.


Contracts overview

The Morpho protocol is designed at its 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 protocol's contracts interactions:

image

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:

  • 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.
  • InterestRatesManager: logic of indexes computation.

It also interacts with RewardsManager, which manages the underlying pool'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 send an email to [email protected] if you find something worrying.


Deployment Addresses

Morpho-Compound Ethereum

Morpho-Aave-V2 Ethereum

Common Ethereum


Importing package

Using npm:

npm install @morpho-dao/morpho-v1

Using forge:

forge install @morpho-dao/[email protected]

Using git submodules:

git submodule add @morpho-dao/[email protected] lib/morpho-v1

Testing with Foundry 🔨

Tests are run against a forks of real networks, which allows us to interact directly with liquidity pools of Compound or Aave. Note that you need to have an RPC provider that have access to Ethereum or Polygon.

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

make install

Alternatively, 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 Morpho-Compound):

make test PROTOCOL=compound

or to run only a specific set of tests of a specific protocol (e.g. for Morpho-Aave V2):

make c-TestBorrow PROTOCOL=aave-v2

or to run an individual test of a specific protocol (e.g. for Morpho-Aave V2):

make test-testBorrow1 PROTOCOL=aave-v2

For the other commands, check the Makefile.


Testing with Hardhat

Only tests for the RewardsDistributor are run with Hardhat.

Just run:

yarn test

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:

:warning: Test coverage is not available on Morpho-AaveV2 for this reason


Storage seatbelt

2 CI pipelines are 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:

  • storage-layout.sh checks that the latest foundry storage layout snapshot is identical to the committed storage layout snapshot
  • foundry-storage-check is in test phase and will progressively replace the snapshot check

In the case the storage layout snapshots checked by storage-layout.sh are not identical, the developer must commit the updated storage layout snapshot stored under snapshots/ by running:

  • make storage-layout-generate with the appropriate protocol parameters

Deployment & Upgrades

Network mode (default)

Run the Foundry deployment script with:

make script-Deploy PROTOCOL=compound NETWORK=goerli

Local mode

First start a local EVM:

make anvil NETWORK=goerli

Then run the Foundry deployment script in a separate shell, using SMODE=local:

make script-Deploy PROTOCOL=compound NETWORK=goerli SMODE=local

Questions & Feedback

For any question or feedback you can send an email to [email protected].


Licensing

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