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!
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:
- Permissionless — anyone can create a new vault and deploy strategies to manage it;
- Strategist friendly — strategists should be incentivized to create new strategies by earning fees;
- Multitoken — strategies can manage multiple ERC-20 tokens at once;
- Cross-protocol — liquidity can be routed to different DeFi protocols on Etheruem mainnet and on L2/sidechains;
- Liquidity-mining enabled — liquidity in the Vault could be used to participate in liquidity mining programs thus earning additional yield for Mellow liquidity providers;
- 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;
- 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:
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:
- Liquidity provider deposits ERC-20 tokens into LP Issuer;
- LP Issuer mints LP tokens to the liquidity provider;
- ERC-20 tokens get transferred into the Gateway Vault, then it redistributes them into Integration layer vaults on a pro-rata basis;
- 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
There are two types of contracts on the diagram:
- Protocol contracts (pink color) — these are the protocol contracts that are deployed in one instance;
- 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:
- Deploy a new vault via a VaultGovernance#deployVault method
- Manage governance params for specific vaults
Upon Vault creation, the Vault Registry contract mints a new ERC-721 token that represents that Vault.
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.
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.