Your one-stop-shop for writing a new vault ("crypt") and its associated strategy. Please follow the notes and checklist below carefully to ensure you're following our most up-to-date process guidance.
- Once forking is enabled, simply fork it. That way you can always pull new updates directly.
- Until then:
- Clone this repo
- Copy all the contents(
cp -R
to include hidden files) to a new directory - In your new folder, delete the
.git
directory and rungit init
to treat this like a new repo - Then push to your desired origin and get working :)
- Add your own
.env
file using the format described in.env.example
We're going for a least-surface-area-for-error approach. All IStrategy
functions have implementations within ReaperBaseStrategy
where access checks, valid-value checks, and state-checks happen. A developer really only needs to worry about business logic that goes inside the internal underscored functions (_deposit
for deposit
, _withdraw
for withdraw
and so on).
- Keep functions in roughly the same order as they appear in IStrategy.
- Keep internal functions close to their call site.
Note: during deployment, files will be created inside the .openzeppelin
folder that will be necessary when it comes time to upgrade the implementation. These files are specific for each deployment. So if you're going to deploy multiple instances of your crypt for different assets, use separate branches to keep track of the deployment files related to each crypt. DO commit these files to source control.
- BEFORE deploying:
- Ask for reviews. All deployed crypts must have at least one review.
- Unit test suite must pass in its entirety.
- APR reported in unit tests must reasonably match the expected APR.
- Deploying:
- Use the scripts in the
scripts/deploy
folder to deploy the vault, the strategy, and initialize the vault with the strategy. - Use solt or any other method of your choice to verify the vault and strategy implementation contracts on the network explorer. Remember to link your strategy proxy to its implementation.
- Follow the Beefy New Vault checklist.
- Run enough harvests to get the
averageAPRAcrossLastNHarvests(5)
matching what is reasonably expected. - Bump the
harvestLogCadence
to1 hours
. - Transfer ownership of vault to multisig. Add multisig as admin on the strategy. Leave your deployer account as admin for a few days.
- Use the scripts in the
- AFTER deploying:
- Make front-end PR and ask for reviews. All price metrics, analytics, and "More Info" must work as expected.
- Make harvester PR and ask for reviews. Remember that
master
branch needs to be deployed manually for the harvester. - Reach out to marketing to help with advertising for the crypt.
This project demonstrates an advanced Hardhat use case, integrating other tools commonly used alongside Hardhat in the ecosystem.
The project comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts. It also comes with a variety of other tools, preconfigured to work with the project code.
Try running some of the following 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.js
node scripts/deploy.js
npx eslint '**/*.js'
npx eslint '**/*.js' --fix
npx prettier '**/*.{json,sol,md}' --check
npx prettier '**/*.{json,sol,md}' --write
npx solhint 'contracts/**/*.sol'
npx solhint 'contracts/**/*.sol' --fix
To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan, such as Ropsten.
In this project, copy the .env.example file to a file named .env, and then edit it to fill in the details. Enter your Etherscan API key, your Ropsten node URL (eg from Alchemy), and the private key of the account which will send the deployment transaction. With a valid .env file in place, first deploy your contract:
hardhat run --network ropsten scripts/deploy.js
Then, copy the deployment address and paste it in to replace DEPLOYED_CONTRACT_ADDRESS
in this command:
npx hardhat verify --network ropsten DEPLOYED_CONTRACT_ADDRESS "Hello, Hardhat!"