Mellow protocol Vaults design

Mellow Protocol
5 min readNov 12, 2021

Lately, we discussed the basics of liquidity providing mechanics on Uniswap V3 in our medium post. It was part of broader research on optimal liquidity provision on Uniswap V3 and other DeFi protocols we’ve been doing for the last months. The research brought us new insights into active liquidity routing strategies and system design, which will be covered in the next articles. Today, we’re going to show how we can actually implement the system for active liquidity balancing between protocols on the blockchain.

Key results of our research led us to the design of Mellow Permissionless Vaults — a system that allows flexible liquidity provision and liquidity management. In this article, we’d like to provide key highlights and encourage the community to have a design discussion on our Twitter and Discord.

If you want to dive into details and contract API check out our docs.

Let’s get started!

Featured highlights

There’re a lot of different aspects that should be considered when designing a vault system. We decided that we want to have the following features in Mellow Vaults:

  1. Permissionless — anyone can create a new vault and deploy strategies to manage it;
  2. Strategist friendly — strategists should be incentivized to create new strategies by earning fees;
  3. Multitoken — strategies can manage multiple ERC-20 tokens at once;
  4. Cross-protocol — liquidity can be routed to different DeFi protocols on Etheruem mainnet and on L2/sidechains;
  5. Liquidity-mining enabled — liquidity in the Vault could be used to participate in liquidity mining programs thus earning additional yield for Mellow liquidity providers;
  6. Strategy trustless — strategy should only be able to perform minimal actions that only allow to rebalance liquidity between protocols and tokens, not diverge it somewhere else. Thus it’s possible to deploy the Strategy both as a smart contract and as an off-chain management system;
  7. Oracle adverse — reduce the number of oracles to a minimum since many DeFi hacks used oracle manipulation.

How it works

A typical vault and strategy setup would be made by using Mellow Permissioless Vaults deployVault function. As a result, the following set of smart contracts (called Vault System) would be established for every strategy and token pair:

Fig. 2 Deposit / Rebalance / Withdraw flow

For each DeFi protocol, a separate Vault contract is deployed. This allows depositing/withdrawing funds and tracking earnings for that protocol. These vaults are aggregated using Gateway Vault.

On top of that, there’s an LP Issuer contract that issues LP ERC-20 tokens to liquidity providers or NFT Issuer that issues ERC-721 tokens (Vault System configuration defines the type of contract/token).

The flow of the tokens between the contracts:

  1. Liquidity provider deposits ERC-20 tokens into LP Issuer;
  2. LP Issuer mints LP tokens to the liquidity provider;
  3. ERC-20 tokens get transferred into the Gateway Vault, then it redistributes them into Integration layer vaults on a pro-rata basis;
  4. Integration layer vaults put liquidity into DeFi protocols.

Strategy contract is a separate entity that is only allowed to redistribute liquidity between vaults and collect liquidity mining rewards (if any) from the underlying DeFi protocols. Technically, the Strategy is not required to be a contract but can also be an off-chain management system.

Vault system architecture

Mellow Permissionless Vaults smart contracts architecture

There are two types of contracts on the diagram:

  1. Protocol contracts (pink color) — these are the protocol contracts that are deployed in one instance;
  2. Vault contracts (purple color) — these are the contracts deployed by users (vault owners/strategists) by using protocol contracts. Essentially everyone can create a set of Vault contracts.

We can logically separate contracts into Vault Groups. Each Vault Group is a set of contracts that allows managing and creating a vault of a specific Vault Kind. Vault Governance is a contract that can:

  1. Deploy a new vault via a VaultGovernance#deployVault method
  2. Manage governance params for specific vaults

Upon Vault creation, the Vault Registry contract mints a new ERC-721 token that represents that Vault.

Strategists unite!

Mellow Protocol Vaults are permissionless by design. We believe in the power of builders and community and we welcome everyone to build liquidity management strategies with Mellow.

New Vault System can be easily created and deployed.

There are 3 core functions applicable to liquidity in the Vault contracts:

  • Vault#push — pushes the ERC-20 tokens from the Vault balance to the underlying DeFi protocol;
  • Vault#pull — pulls the ERC-20 tokens from the Underlying DeFi protocol to some other Vault of the Vault System;
  • Vault#claimRewards — claim liquidity mining rewards for the Vault (if any are assumed by the underlying DeFi protocol). Note that contracts with the liquidity mining rewards should be whitelisted in the Protocol Governance.

For more details on managing Vaults and managing the liquidity check Strategist guide section in our docs.

After we finish the beta phase, we’re considering special incentives for Strategists who will actively build effective liquidity management strategies.

Next steps

We’re preparing for the launch and here’s our plan for the following months:

Nov’ 21: Finalize the design of the vaults, finish the development, release the first version of the protocol for internal testing on mainnet;

Dec’ 21: Code423n4 contest and first audit, guarded launch with cap limits;

Feb’22: Final audit, uncapped vaults launch, L2 experiments.

Join our Twitter and Discord to discuss Vaults design with the team and stay in the loop.

Twitter | Discord | Gitbook | Website

--

--

Mellow Protocol

Exploring the depths of math on LPing, AMMs and trading strategies.