Giter Club home page Giter Club logo

metamorpho's People

Contributors

adhusson avatar cratiu222 avatar jean-grimal avatar jhoenicke avatar julien-devatom avatar makcandrov avatar mathisgd avatar merlinegalite avatar nnsw3 avatar omahs avatar pakim249cal avatar qgarchery avatar rubilmax avatar tomrpl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metamorpho's Issues

Role update

  • The owner should have the power of risk managers and allocators
  • Risk managers should have the power of allocators

Use only `id` as argument?

It could ease vault manager's life you'll need to store somewhere the bytes32 only and not the whole market config.

Add timelocks

Add a timelock to:

  • update the timelock
  • sets the performance fee
  • list/delist a market

Fee questions

I have some questions about the fee mechanism:

  1. When setting a fee, should revert if the fee recipient is not set? and also do the opposite, revert if there's a fee but we try to remove the fee recipient?
  2. A somehow related question. On fee accrual we skip the update if the fee recipient is zero. I feel that we should skip only if fee is 0.
    https://github.com/morpho-labs/morpho-blue-metamorpho/blob/4c7b5d69bc9d2e2a8eac801e30c0b53af3906388/contracts/SupplyVault.sol#L459
    Else, we could set a fee and a fee recipient, updating lastTotalAssets, remove the fee recipient so that lastTotalAssets is not updated for a while. Then, add a new fee recipient so that lastTotalAssets is the totalInterest generated is very (very) big. This needs to be clarified on my side but I think the fee recipient could basically steal users' funds.

`set` wording is unclear

When first reading the code, I'd argue that understanding what functions named setParameter are used for because in the case parameters require a pending submission first, these functions don't expect any input parameter
Moreover, it may be not very clear with other functions named alike for parameters that don't require a pending submission

Perhaps acceptParameter is a better name

Error message when withdrawing too much

When withdrawing too much, 2 errors can be raised depending on how much is withdrawn:

  • withdraw order failed
  • ERC20: burn amount exceeds balance

We should harmonize this behavior.

The vault should be connectable with the rewards distributor

Problem

How to redistribute tokens transferred to the vaults (claim on Blue, for example) to the users ?

Offchain distribution

The easiest way to redistribute tokens is to use a Merkle tree, with an offchain distribution

Use the URD

The Universal Rewards Distributor is using ERC20 allowance and a treasury transaction to redistribute the tokens.

The flow is as following

  • a distribution owner is creating a new distribution on the URD (permisionless). The owner can request a treasury to approve the distribution to use his allowance, by calling this function. In our case, the treasury is the Vault itself.

The vault has to accept the treasury. We can do it in the constructor or, if the vault is owned, by adding an owner function.

contract Vault {
  address constant URD = 0x0000;
  uint256 immutable distributionId;
  constructor(uint256 _distributionId) {
    distributionId = _distributionId;
  }

  /// can be called by everyone, the distributionId is immutable
  function acceptTreasuryRole() public {
   IURD(URD).acceptAsTreasury(distributionId);
  }
}

Then, the vault has to set the allowance to the rewards distributor.
Usually, the vault must not contain any ERC20. So we can create this public function:

function setURDAllowance(address token) public {
  uint256 balance = ERC20(token).balanceOf(address(this));
  if(token == VAULT_UNDERLYING) 
    balance = balance - idle

  ERC20(token).approve(URD, balance);
}

Use OZ Access Control?

OZ has contracts for access control management that we could use.

There's a DEFAULT_ADMIN_ROLE (a sort of master admin) having the power to grant or revoke other roles (in our case RISK_MANAGER and ALLOCATOR).

Pros:

  • removes onlyRiskManager and onlyAllocator modifiers
  • removes setIsRiskManager and setIsAllocator functions
  • removes isRiskManager and isAllocator from storage

Cons:

  • adds a little bit of gas
  • ?

There's AccessControlDefaultAdminRules adding a delay for changing DEFAULT_ADMIN_ROLE. This can be interesting for legal reasons (to be discussed in a product call).

Strategies update

Following last product discussion, we'll remove supply and withdraw strategies. Instead, we'll have setters to set ordered list of whitelisted markets for the supply and withdraw side.

The allocator can still allocate arbitrarily the funds among the whitelisted markets.

`totalAssets` relies on `balanceOf(address(this))` that can be voluntarily increased

In totalAssets we use balanceOf(address(this)) to get access to the idle balance of the vault.

Because of passed events we know that it can be an attack vector for integrators on top. Thus, I'd advocate for tracking the idle liquidity instead even if it implies losing some money when someone donates to the vault.

https://github.com/morpho-labs/morpho-stack/blob/bc0ca6784997f7c67882ee0404dcf01d61470fda/contracts/meta-morpho/SupplyVault.sol#L234

Fix remapping issue

I tried to remove the remapping in morpho-blue but it still fails when running yarn test:hardhat

Handle idle supply

Idle supply is not tracked yet but it's necessary for allocations and the URD

Withdrawal queue can be missing a market

Context

There is no constraint on the withdrawal queue pushed by the allocator, so in the case users withdraw all liquidity available from all markets of the withdrawal queue and from the idle supply, there may be available liquidity on markets that are not in the withdrawal queue... which makes the vault illiquid whereas it should be

Fix

A way to fix this is to check that all enabled markets are part of the withdrawal queue upon change

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.