Using ERC-4626 as Vault (with yearn v2 strategy)
This repository is an example of Yearn V2 Vault architecture translated into new ERC-4626 proposed standard for Vaults. Yearn Vault contract is exchanged with minimal implementation of Rari's solmate ERC-4626. Controller and Strategy contracts are left untouched. Basic DAI/Compound stategy is used because of it's simplicity. Some functions from original Yearn Vault got rewritten to operate with underlying ERC-4626, that is usually noted through NatSpec's @notice tag. Contract is neither tested nor optimized.
All is run against forked network with real DAI used and actual compounding from Compound. Console.log will return internal balance sheet change (interests accrued) after depositing funds into strategy and waiting some blocks for profit.
This is by no means robust simulation but could be extended easily. As is, you can just verify that Yearn V2 works fine with ERC4626 through inspection of a small change in accured profits from Compound strategy.
Set .env.example
yarn install
First, start the hardhat network: npx hardhat node
To simulate deployment and deposits run: npx hardhat run scripts/simulate.ts --network localhost
There is currently no test beyond basic deployment of Vault + Strategy to a local hardhat network.
ERC4626 Proposal: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4626.md
Yearn V2 Contracts: https://github.com/yearn/yearn-starter-pack
ERC4626 Discussion: https://ethereum-magicians.org/t/eip-4626-yield-bearing-vault-standard/7900/45
Uses
This is a GitHub template, which means you can reuse it as many times as you want. You can do that by clicking the "Use this template" button at the top of the page.
Before running any command, make sure to install dependencies:
$ yarn install
Compile the smart contracts with Hardhat:
$ yarn compile
Run the Mocha tests:
$ yarn test
npx hardhat run --network rinkeby ./scripts/deploy.ts
npx hardhat verify --network <network> <DEPLOYED_CONTRACT_ADDRESS> "Constructor argument 1"
If you like it than you soulda put a start ⭐ on it