Giter Site home page Giter Site logo

experimental-4626's Introduction

Experimental ERC-4626 Repository

Introduction - MultiVault Extension

MultiVault extends original ERC4626 functions with minimal additions to the original interface. The ERC4626 architectual approach to the standarization of single Vaults is translated onto a MultiVault design by introducing ERC1155 as LP (shares) managment token and as a tool for embedding multiple ERC4626 underlying(s) within one MultiVault contract. This contract maintains high modularity with an encoded vaultData variable, presented through sample implementation in MultiCore.sol, allowing for each vaultId to have it's own modules, additional interfaces or metadata. Current sample implementation is suppose to demonstrate usage of MultiVault.sol interface for yield aggregator contract. This repository is not proudction ready

Inspired by: https://github.com/z0r0z/MultiVault

Rationale

ERC4626 currently only operates on one underlying token, minting in return one ERC20 shares token, all within one - single - Vault contract, and needs to be redeployed for each new underlying asset with it's separate accounting logic. Often requested functionality is the ability to operate on multiple assets with separate accounting still within single Vault contract. The ERC4626 standard was designed to be inherited and overriden (and such is the expectation) through parent contracts, initialized by other contract or made to use as an instance allowing for quick extending. Despite this underlying flexibility, arguments for a potential standardized extension exist.

Found reccuring patterns hold true across many non-4626 Vaults and can be accomodated with small logical changes to the existing ERC4626 interface while still keeping extension intuitive for developers already working with ERC4626. To that, we demonstrate alpha version of MultiCore.sol implementation contract, utilizing our proposed MultiVault.sol extension of the ERC4626.

Changes to ERC4626:

  • ERC1155 as shares / lp token for Vault
    • access to batch operations and one time approval
  • totalSupply of vaultIds (ERC1155 id)
  • separate operation logic for each underlying within one MultiVault
    • each vaultId has it's own underlying and additional data params (vaultData is suppose to be very flexible without breaking)
  • create(ERC20 asset) function to add new vault within core vault contract
  • struct Vault data structure to hold vital information for vaultId (Vault)
    • ERC20 asset underlying token for vaultId
    • uint256 totalSupply total supply of shares for vaultId. can be left at 0 if not used by implementation.
    • bytes vaultData additional data held for vaultId, e.g interface of contract for use inside of afterDeposit(). Or, any other value. Idea is to map additional logic, implemented by inheriting contract to vaultId of MultiVault. for clarity, it should decode to single variable and implementer should take care of providing appropriate getters.

Disclaimer: Exploratory work and designs. Interface standarization is work in progress

Common Patterns

Three reccuring patterns for all currently researched multiVaults, warranting one common interface:

  1. Reccuring uint256 indexOfAssets variable for any sort of id tracking (here, totalSupply of ERC1155 ids). True for underlying assets, shares, supplies & balances or even whole Vaults (ERC1155 MultiVault)
  2. Reccuring pattern of addition of another token interface through initialization in existing contract - create() function
  3. Reccuring pattern of creation of separate accounting calculations for different types of assets/shares. MultiVault preserves original function on ERC4626 standard Vault, namley - managmend of assets. With MultiVault it's now possible to manage all of those assets within one contract.

Sample Implementation

MultiCore.sol is an example implementation of inherited MultiVault.sol extension. It serves as a scaffold for multiple assets strategy manager contract (uff...). Accepts multiple underlying tokens and can route to multiple Strategy contracts (In sample implementation this are ERC4626 Vaults, free to be changed to Yearn-like BaseStrategy). It centralizes accounting and holds yield bearing assets under managment, effectivley becoming a MetaVault (Vault of Vaults).

Features:

  • Multiple underlying tokens accepted
  • Holds all LP position inside of one ERC1155 token
    • Access to batch operations
    • Index-like token for basket of shares
  • Manage multiple yield generating strategies for each vaultId
  • WIP: exchangeRate between MultiVault managed LP-shares

Install

npm install

npx hardhat test

Example tasks:

npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
npx hardhat help
REPORT_GAS=true npx hardhat test
npx hardhat coverage
npx hardhat run scripts/deploy.ts
TS_NODE_FILES=true npx ts-node scripts/deploy.ts
npx eslint '**/*.{js,ts}'
npx eslint '**/*.{js,ts}' --fix
npx prettier '**/*.{json,sol,md}' --check
npx prettier '**/*.{json,sol,md}' --write
npx solhint 'contracts/**/*.sol'
npx solhint 'contracts/**/*.sol' --fix

experimental-4626's People

Contributors

shortdoom avatar sg1-ra avatar

Stargazers

Andreas Brekken avatar Jose Abraham Garcia avatar justin avatar  avatar Darpit Rangari avatar Suthan Somadeva avatar neodaoist avatar mz7 avatar @askCasmir  avatar Weston Nelson avatar Jake Sung avatar Alfred Gaillard avatar John C avatar Surfacing8671 avatar Elvis avatar  avatar Zach Mead avatar TJ VanSlooten avatar Lisandro Fernández avatar Chinmay Sai Vemuri avatar Koda avatar Care Water avatar  avatar  avatar Michael Smyers avatar SnakePoison avatar Sandy Bradley avatar Marcelo Morgado avatar Hamzah Khan  avatar Brian Le avatar Michael Demarais avatar Adediran Tofunmi avatar felyn avatar 0xBA5ED.eth avatar mortem avatar Sarang Parikh avatar chirag-bgh avatar  avatar Cache Monet avatar Etch avatar Sparx avatar  avatar  avatar sudo rm -rf --no-preserve-root / avatar 0xKitetsu avatar Alex Lane avatar kaden avatar Shun Kakinoki avatar t11s avatar  avatar bageltoes avatar

Watchers

Sergey Beresnev avatar Michael Demarais avatar Lisandro Fernández avatar  avatar Sujith Somraaj avatar Care Water avatar

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.