All code in this repository is meant for instructional purposes only. Is not audited or considered safe for production.
This repository is fa hardhat fork of storming0x ystarter-foundry-kit you can find it here
-
Basic example Solidity Smart Contracts for integrating with Yearn Vaults. Both V2 and ERC4626 interfaces.
-
ERC4626 adapter to wrap yearn vaults.
-
Example Contracts (
examples
) -
Sample test suite. (
tests
)
VaultWrapper is an ERC4626 adapter interface that makes v2 vaults compatible with the standard. A wrapper is needed per deployed vault. Contracts can interact with the wrapper as they would with any ERC4626 since it adapts the standard completely.
NOTE: This adapter makes all V2 vault operations more gas expensive since its doing additional calls to normal vault methods like deposit/operations to wrap the vault tokens into the ERC4626 adapter.
Given the flexibility, the gas increase tradeoff may be good for integrators using multiple ERC4626 to keep code cohesive for all yield sources.
Also future proofs integrations since V3 vaults will be ERC4626 compatible on launch.
(contracts/examples/SugarVault.sol
)
(contracts/examples/SugarYvault.sol
)
SugarVault is an example contract that works internally with any ERC4626 compatible yield token. SugarYvault has the same functionality but uses Yearn V2 interfaces.
- These contracts accepts donators underlying tokens and deposits it into yield source and configures a receiver.
- The receiver can claim as stream the yield generated by the donator deposits when available.
- The donator can stop yield sharing at any moment and retrieve the underlying token capital deposited plus any unclaimed yields from receiver.
- Tokenized the contract as NFT for donations. Could use two linked NFTs by id, one for donator and one for receiver that can be transfered to claim each part of their funds.
- Add support for migrating yield sources to other ERC4626. Requires same underlying token.
- typescript support enabled
- typechain plugin installed (typescript type bindings are generated from smart contracts)/check Typechain docs
- hardhat-deploy plugin enabled (use deployments from
deploy
folder, order and tag them; multi-network) - hardhat console enabled - to allow console.log usage within solidity code
- testing environment configured and operational
-
Fork this repository.
-
Clone your newly created repository recursively to include modules.
git clone --recursive https://github.com/AlexNi245/ystarter-hardhat-kit
cd ystarter-hardhat-kit
NOTE: if you create from template you may need to run the following command to fetch the git submodules (.gitmodules for exact releases) git submodule init && git submodule update
- Install Dependencies
yarn install
-
Sign up for Infura and generate an API key and copy your RPC url. Store it in the
RINKEBY_RPC_URL
environment variable. NOTE: you can use other services. -
Use .env file
-
Make a copy of
.env.example
-
Add the values for
RINKEBY_RPC_URL
and other example vars NOTE: If you set up a global environment variable, that will take precedence. -
Run tests
yarn test
Run yarn install
and then:
hh compile
- to compile smart contract and generate typechain ts bindingshh test
- to run testshh deploy
- to deploy to local network (see options for more)hh TABTAB
- to use autocompletehh node
- to run a localhost node
Check package.json
scripts for more options.
Use .env.example
file and adapt it to you values and settings.
Tests run in fork environment, you need to complete Installation and Setup step 6 to be able to run these commands.
yarn test
- Yearn Discord channel
- Hardhat Docs