-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: staking -> saving * ci: remove parallel pytest to avoid hitting rate limits * feat: we can now cache in boa if we reject n=auto * chore: comments cleanup * feat: deployment script, dev_multisig * feat: deploy script * ci: notebooks cleanup on commit
- Loading branch information
Showing
17 changed files
with
1,561 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,290 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0", | ||
"metadata": {}, | ||
"source": [ | ||
"# s-crvUSD deployment\n", | ||
"This script deploys the scrvUSD vault contract to the Ethereum network. Additionally, RewardsHandler contract periphery is deployed to integrate the scrvUSD into the flow of crvUSD lending fees." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "1", | ||
"metadata": {}, | ||
"source": [ | ||
"## Setup" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"\n", | ||
"# importing scripting dependencies\n", | ||
"import boa\n", | ||
"from eth_account import Account\n", | ||
"from boa import NetworkEnv, Env" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# use address book for relevant addresses\n", | ||
"import sys\n", | ||
"\n", | ||
"if os.getcwd()[-7:] == \"scripts\":\n", | ||
" sys.path.append(\"..\") # to enable import from parent directory\n", | ||
"import tests.integration.address_book as ab\n", | ||
"\n", | ||
"from dotenv import load_dotenv\n", | ||
"\n", | ||
"load_dotenv()\n", | ||
"\n", | ||
"# get env vars\n", | ||
"ETHERSCAN_API_KEY = os.getenv(\"ETHERSCAN_API_KEY\")\n", | ||
"PINATA_API_KEY = os.getenv(\"PINATA_API_KEY\")\n", | ||
"RPC_URL = os.environ.get(\"ETH_RPC_URL\")\n", | ||
"PRIVATE_KEY = os.environ.get(\"PRIVATE_KEY\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4", | ||
"metadata": {}, | ||
"source": [ | ||
"## Select mode\n", | ||
"Production mode cell is intentionally executed first to avoid deploying things by accident. If one runs all the cells sequentially things will be executed in forking mode.\n", | ||
"\n", | ||
"To deploy in production mode, manually skip the execution of the fork mode cell." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# production mode (to deploy on ethereum)\n", | ||
"deployer = Account.from_key(PRIVATE_KEY)\n", | ||
"eth_env = NetworkEnv(RPC_URL)\n", | ||
"boa.set_env(eth_env)\n", | ||
"\n", | ||
"# this automatically sets the eoa as the deployer\n", | ||
"boa.env.add_account(deployer)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# fork mode (for testing)\n", | ||
"# we impersonate convex since they definitely have enough to push a vote\n", | ||
"CONVEX_VOTERPROXY = \"0x989aeb4d175e16225e39e87d0d97a3360524ad80\"\n", | ||
"\n", | ||
"forked_env = Env()\n", | ||
"boa.set_env(forked_env)\n", | ||
"\n", | ||
"boa.env.fork(RPC_URL, cache_file=None) # no cache because kernel locks access to the file\n", | ||
"boa.env.eoa = CONVEX_VOTERPROXY" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7", | ||
"metadata": {}, | ||
"source": [ | ||
"# I. Deployment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "8", | ||
"metadata": {}, | ||
"source": [ | ||
"### 1. Vault" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# I. First deploy the Vault\n", | ||
"vault_factory = boa.from_etherscan(\n", | ||
" ab.yearn_vault_factory, \"vault_factory\", api_key=ETHERSCAN_API_KEY\n", | ||
")\n", | ||
"\n", | ||
"deployer_address = boa.env.eoa\n", | ||
"vault_address = vault_factory.deploy_new_vault(\n", | ||
" ab.crvusd, # underlying token\n", | ||
" \"Savings crvUSD\", # vault name\n", | ||
" \"scrvUSD\", # vault symbol\n", | ||
" deployer_address, # initial role manager = deployer\n", | ||
" 86_400 * 7, # unlock time for rewards\n", | ||
")\n", | ||
"\n", | ||
"print(f\"Vault deployed at {vault_address}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "10", | ||
"metadata": {}, | ||
"source": [ | ||
"### 2. DepositLimitModule" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "11", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# II. Then deploy the DepositLimitModule\n", | ||
"DepositLimit_deployer = boa.load_partial(\"../contracts/DepositLimitModule.vy\")\n", | ||
"\n", | ||
"deposit_limit = DepositLimit_deployer(\n", | ||
" vault_address, # vault\n", | ||
" 5_000_000 * 10**18, # cap deposits to 5M crvUSD\n", | ||
" ab.dev_multisig, # admin\n", | ||
")\n", | ||
"\n", | ||
"print(f\"Deposit limit module deployed at {deposit_limit.address}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "12", | ||
"metadata": {}, | ||
"source": [ | ||
"### 3. RewardsHandler" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "13", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# III. Finally deploy the RewardsHandler\n", | ||
"RewardsHandler_deployer = boa.load_partial(\"../contracts/RewardsHandler.vy\")\n", | ||
"\n", | ||
"rewards_handler = RewardsHandler_deployer(\n", | ||
" ab.crvusd, # stablecoin\n", | ||
" vault_address, # vault\n", | ||
" 500, # minimum weight (5%)\n", | ||
" 10_000, # scaling factor (over MAX_BPS)\n", | ||
" ab.crvusd_controller_factory, # controller factory\n", | ||
" ab.dao_agent, # WE CERTAIN ABOUT THIS CONTRACT? [TODO]\n", | ||
")\n", | ||
"\n", | ||
"print(f\"Rewards handler deployed at {rewards_handler.address}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "14", | ||
"metadata": {}, | ||
"source": [ | ||
"# II. Post-deployment setup" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "15", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# I. Set the vault\n", | ||
"vault = boa.load_partial(\"../contracts/yearn/VaultV3.vy\").at(vault_address)\n", | ||
"# a. set the rewards handler roles in the vault\n", | ||
"vault.set_role(\n", | ||
" rewards_handler.address, 2**11 | 2**5\n", | ||
") # set RH as REPORTING_MANAGER and PROFIT_UNLOCK_MANAGER\n", | ||
"# b. set the deposit limit module in the vault\n", | ||
"vault.set_role(ab.dev_multisig, int(\"11111111111111\", 2)) # set dev_multisig megarole\n", | ||
"vault.transfer_role_manager(ab.dao_agent)\n", | ||
"\n", | ||
"# with boa.env.prank(ab.dev_multisig): ### TODO call from dev_multisig\n", | ||
"# vault.set_deposit_limit_module(deposit_limit.address, True)\n", | ||
"# c. relinquish the role manager role to DAO ### TODO propose acceptance of role by dao\n", | ||
"\n", | ||
"# II. Set the deposit limit module\n", | ||
"# use dev_multisig as admin at deploy time, then manually set the security agent to fuzzland (to avoid extra txns from deployer)\n", | ||
"# deposit_limit_address.set_security_agent(ab.fuzzland_address, True) # TODO dev_multisig txn\n", | ||
"\n", | ||
"# III. Finally set the rewards handler parameters\n", | ||
"# rewards_handler_contract = boa.load_partial(\"../contracts/RewardsHandler.vy\").at(rewards_handler_address)\n", | ||
"# here distribution_time must be set to match the vault's value, but why does RH have distribution_time at all? TODO: discuss" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "16", | ||
"metadata": {}, | ||
"source": [ | ||
"## 3. Vote in the DAO" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "17", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# ACTIONS = [(ab.controller_factory, \"set_fee_receiver\", fs)]\n", | ||
"# DESCRIPTION = \"Set the fee receiver to the fee splitter, to lay the foundation for autobribe, st-crvUSD and rebalancing donations. This vote **is not** about changing the fee distribution (100% of revenues will still go to veCRV holders).\"\n", | ||
"# curve_dao.create_vote(ab.dao, ACTIONS, DESCRIPTION, ETHERSCAN_API_KEY, PINATA_API_KEY)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "18", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.