Deploying a Vault and Strategy V2
Note: This private repo is encouraged to create multiple scripts for governance and dev multisig execution of complex transactions.
Requirements
Make sure you have the brownie environment set up before trying to deploy a vault. Check out the Readme MD in Yearn Vaults Repo for instructions.
The below instructions show some python commands that assume you are using the brownie console or a brownie script setup.
Deploying a new Experimental Vault
-
Clone the Yearn Vaults Repo and run
brownie run scripts/deploy.py --network <network-to-deploy-vault>
-
Choose the brownie account for deploying your vault. This account needs to have funds to pay for the deployment transaction.
-
Confirm the script is using the latest version of registry
v2.registry.ychad.eth
against the planned new release vault to be sure it's an updated version. (Can validate on Etherscan for latest address) -
Select the version of the vault to deploy or press enter to use the latest release.
-
Enter
Y
when prompt to deploy Proxy Vault -
Enter the checksummed address of the ERC20 token the vault will use.
-
Enter the vault Parameters (Below are some suggested values):
- Set your address or an address you control as governance.
- Set Treasury (
treasury.ychad.eth
) as the rewards address. - Set Core Dev multisig (
dev.ychad.eth
) as guardian. - Set Strategist multisig (
brain.ychad.eth
) as management. - Set name and symbol for vault or use suggested as default (can be changed on-chain later, but please check out our naming conventions).
-
Confirm the Parameters are correct and press
y
and ENTER to deploy the vault. -
Check new vault has ABI setup on Etherscan (Some vault versions from older releases may have verification issues with Vyper and proxy detection on Etherscan, consider using later releases >0.3.5 to ensure verification works).
-
Set deposit limit according to the table below
vault.setDepositLimit(limit)
- Set management fee to 0:
vault.setManagementFee(0)
- (Optional) Set governance to ychad.eth (
0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52
) if vault is planned to be endorsed soon:
- Note you can still make changes to the vault after setting governance up until governance is accepted
vault.setGovernance(ychad.eth)
Deploying a new Strategy
- Request access to a Core Dev strategist and create a new issue using the
Strategy Review
template in the strategies private repo Complete all the fields. - If the strategy targets a new protocol/new chain not currently approved by yearn (used in production) it may also require due diligence and path to production plan documents for the strategy to be considered for endorsement. Example(s) SNX
- Coordinate with Core Dev strategist for reviewing strategy, then follow the status on the private board.
- Have it peer-reviewed by at least two strategists.
- Check if
want
token has a deployed vault already (>=v0.3.0) and coordinate to use that first if possible. - Coordinate with a core developer to set a proper deposit limit and other settings for the new vault. See the table below: Limits per Stage.
- Deploy strategy and upload code to Etherscan for verification.
- Tag GitHub review issue with deployed version and attach mainnet address(es) to the strategy item in private board.
Make the Vault and Strategy work together
-
Add strategy to vault (for vault code v0.3.3+):
strategy = '' # Your strategy address
debt_ratio = 9800 # 98%
minDebtPerHarvest = 0 # Lower limit on debt add
maxDebtPerHarvest = 2 ** 256 - 1 # Upper limit on debt add
performance_fee = 1000 # Strategist perf fee: 10%
vault.addStrategy(
strategy,
debt_ratio,
minDebtPerHarvest,
maxDebtPerHarvest,
performance_fee
)debt_ratio
should be9800
if first strategy on vault.rate_limit
is0
unless there is reason for it to be different.
-
Set keeper:
strategy.setKeeper(keep3r_manager)
keep3r_manager
=0x736D7e3c5a6CB2CE3B764300140ABF476F6CFCCF
-
Set health check:
strategy.setHealthCheck(health_check)
health_check
=0xddcea799ff1699e98edf118e0629a974df7df012
NOTE: see section on health check for more details.
-
Set rewards:
strategy.setRewards(address)
- Read below if you want to use the sharer contract.
-
Run tests against "live" vault and strategy in mainnet-fork:
-
Harvest.
-
Profitable harvest.
-
Revoke strategy and check that funds return to the vault.
-
Increase/decrease debt + harvest, and check that the strategy is working well.
-
Migration.
-
Check that tokens in the strategy cannot be sweeped by dust collection.
-
Example: Hegic strat repo.
-
Test harvesting manually
You can coordinate with the strategists if you need a UI to test.
-
Deposit some
want
tokens into the vault. -
Do first
harvest
and make sure it worked correctly.strategy.harvest()
-
Monitor
harvest
andtend
triggers for first few days. Callharvest
/tend
manually. -
If this is a new vault deployment, test deposit, withdraw, and transfer to ensure functionality is as expected.
Scaling up / Moving to Endorse
In addition to the two strategist reviews, a Core Developer has to review the strategy before going into production.
-
Create an issue in yearn's web repo to ensure that the new vault won't create any problems with the API and that all necessary token/vault metadata is ready. Additionally, if this vault needs to go in the "labs" category, it must be manually added to the website.
-
Increase deposit limit according to the table below
-
Set management fee to production level:
vault.setManagementFee(200)
-
Set parameters for vault correctly before endorsement:
- Set Governance to (
ychad.eth
) - Set Treasury (
treasury.ychad.eth
) as the rewards address. - Set Core Dev multisig (
dev.ychad.eth
) as guardian. - Set Strategist multisig (
brain.ychad.eth
) as management. - Set description and symbol for vault or use suggested as default (can be changed on-chain later)
- Set Governance to (
-
Yearn's governance now must accept this vault's governance and endorse it:
strategy.acceptGovernance()
registry.endorseVault(vault)
- If using a curve voter stategy, make sure to approve the new strategy on yearn's voterProxy:
proxy.approveStrategy(gauge, strategy)
Endorsing a vault from a previous release
-
Check for the latest release number in the registry contract
-
Check the apiVersion of the vault you want to endorse to identify the target release
-
Calculate the releaseDelta from your target release. (see registry endorseVault param details) E.g: latestRelease = 0.3.3 and numReleases = 5. New vault apiVersion is 0.3.2
releaseDelta = numReleases - 1 - releaseTarget
-
Confirm using
registry.releases(uint256)
that yourtargetRelease
has the same apiVersion as your vault.releaseTarget = 3 # e.g vault api version 0.3.2
releaseDelta = registry.numReleases() - 1 - releaseTarget # (5-1-3) = 1
strategy.acceptGovernance() # from ychad.eth
registry.endorseVault(vault, releaseDelta) # from ychad.eth.
Publishing Your Strategy Description
The following steps are required for all strategies. These descriptions are pulled into the v3 website and used to generate strategy diagrams.
- Create a pull request at this link to add a new
.json
file with your strategy description and details. - Using other strategy files as a reference, create a 1-2 sentence description for your strategy.
- The author field is optional.
Setting up Keep3r
-
Adjust trigger variables until they are correct:
strategy.setProfitFactor()
strategy.setDebtThreshold()
strategy.setMaxReportDelay() -
Set strategy's Keep3r role to v2-keeper-contract:
strategy.setKeeper(0x736D7e3c5a6CB2CE3B764300140ABF476F6CFCCF)
-
Create an add-strategy PR in Keep3r repo (TBD)