Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme #195

Merged
merged 13 commits into from
Oct 17, 2023
77 changes: 76 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
# Morpho Blue MetaMorpho

[Morpho Blue](https://github.com/morpho-org/morpho-blue) is a new lending primitive that offers better rates, high capital efficiency and extended flexibility to lenders & borrowers.
[Morpho Blue](https://github.com/morpho-org/morpho-blue) is a trustless lending primitive that offers unparalleled efficiency and flexibility.

MetaMorpho is a protocol for noncustodial risk management built on top of Morpho Blue.
It enables anyone to create a vault depositing liquidity into multiple Morpho Blue markets.
It offers a seamless experience similar to Aave and Compound.

Users of MetaMorpho are liquidity providers that want to earn from borrowing interest whithout having to actively manage the risk of their position.
The active management of the deposited assets is the responsibility of a set of different roles (owner, risk manager and allocators).
These roles are primarily responsible for enabling and disabling markets on Morpho Blue and managing the allocation of users’ funds.

## Specifications

### MetaMorpho

MetaMorpho vaults are ERC-4626 compliant vault with the permit feature (ERC-2612). One MetaMorpho vault is dedicated to one loan asset on Morpho Blue.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved

Users can supply or withdraw assets at any time, depending on the available liquidity on Morpho Blue.
A maximum of 30 markets can be enabled on a given MetaMorpho vault.

There are 4 different roles for a MetaMorpho vault (owner, risk manager, guardian & allocators).
All actions that are against the interest of the users (e.g. enabling a market with a high liquidation risk, increasing the fee) are subject to a timelock of minimum 12 hours.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved
During this timelock, users can withdraw their funds from the vault if they don't agree or the guardian (if set) can revoke the action. After the timelock, the action can be executed by anyone until the `TIMELOCK_EXPIRATION` is exceeded.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved

In case the vault receives rewards on Morpho Blue markets, the rewards can be redistributed by setting a rewards recipient. This rewards recipient can be [Universal Rewards Distributor (URD)](https://github.com/morpho-org/universal-rewards-distributor).
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved

Below is a more fine-grained description of the different roles.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved

The owner can:
- Do whatever the risk manager and allocators can do.
- Transfer or renounce the ownership.
- Set the risk manager.
- Set allocators.
- Set the rewards recipient.
- [Timelocked] Set the timelock.
- [Timelocked] Set the performance fee (capped to 50%).
- [Timelocked] Set the guardian.
- Set the fee recipient.

The risk manager can:
- Do whatever the allocators can do.
- [Timelocked] Enable or disable a market by setting a cap to a specific market.
- The cap can be set to 0 to disable the market.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved
- Disabling a market can only be done if there's the vault has no liquidity on the market.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved

The allocators can:
- Set the `supplyQueue` and `withdrawQueue`, ie decides on the order of the markets to supply/withdraw from.
- Upon a deposit, the vault will supply up to the cap of each Morpho Blue market in the supply queue in the order set. The remaining funds are left as idle supply on the vault (uncapped).
- Upon a withdrawal, the vault will first withdraw from the idle supply, then withdraw up to the liquidity of each Morpho Blue market in the withdrawal queue in the order set.
- The `supplyQueue` can only contain enabled markets.
- The `withdrawQueue` MUST contain all enabled and disabled markets on which the vault has still liquidity.
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved
- Reallocate funds among the enabled market at any moment.

The guardian can:
- Revoke any timelocked action.

Anyone can:
- Trigger the ERC-4626 entry points.
- Transfer rewards to the rewards recipient.

### MetaMorpho Factory

The MetaMorpho factory is permissionless factory contract that allows anyone to create a new MetaMorpho vault.

## Getting Started

Install dependencies: `yarn`

Run forge tests: `yarn test:forge`

Run hardhat tests: `yarn test:hardhat`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are gas tests right ? We should explain that if it's the case, otherwise we wonder why we use both hardhat and forge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do the same in blue then but there was that comment: morpho-org/morpho-blue#523 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I didn't know it was removed, it's fine if we want to not add that comment


You will find other useful commands in the [`package.json`](./package.json) file.

## License

Morpho Blue Oracles is licensed under `GPL-2.0-or-later`, see [`LICENSE`](./LICENSE).
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved