forked from GalloDaSballo/badger-vaults-mix-v1.5
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path1_production_deploy.py
166 lines (128 loc) · 4.06 KB
/
1_production_deploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import time
from brownie import (
accounts,
network,
MyStrategy,
TheVault,
AdminUpgradeabilityProxy,
interface,
)
from _setup.config import (
WANT,
REGISTRY,
PERFORMANCE_FEE_GOVERNANCE,
PERFORMANCE_FEE_STRATEGIST,
WITHDRAWAL_FEE,
MANAGEMENT_FEE,
)
from helpers.constants import AddressZero
import click
from rich.console import Console
console = Console()
sleep_between_tx = 1
def main():
"""
FOR STRATEGISTS AND GOVERNANCE
Deploys a Controller, a TheVault and your strategy under upgradable proxies and wires them up.
Note that it sets your deployer account as the governance for the three contracts so that
the setup and production tests are simpler and more efficient. The rest of the permissioned actors
are set based on the latest entries from the Badger Registry.
"""
# Get deployer account from local keystore
dev = connect_account()
# Get actors from registry
registry = interface.IBadgerRegistry(REGISTRY)
strategist = registry.get("governance")
badgerTree = registry.get("badgerTree")
guardian = registry.get("guardian")
keeper = registry.get("keeper")
proxyAdmin = registry.get("proxyAdminTimelock")
name = "FTM STRAT" ## In vaults 1.5 it's the full name
symbol = "bFRM-STrat" ## e.g The full symbol (remember to add symbol from want)
assert strategist != AddressZero
assert guardian != AddressZero
assert keeper != AddressZero
assert proxyAdmin != AddressZero
assert name != "Name Prefix Here"
assert symbol != "bveSymbolHere"
# Deploy Vault
vault = deploy_vault(
dev.address, # Deployer will be set as governance for testing stage
keeper,
guardian,
dev.address,
badgerTree,
proxyAdmin,
name,
symbol,
dev
)
# Deploy Strategy
strategy = deploy_strategy(
vault,
proxyAdmin,
dev
)
dev_setup = vault.setStrategy(strategy, {"from": dev})
console.print("[green]Strategy was set was deployed at: [/green]", dev_setup)
def deploy_vault(governance, keeper, guardian, strategist, badgerTree, proxyAdmin, name, symbol, dev):
args = [
WANT,
governance,
keeper,
guardian,
governance,
strategist,
badgerTree,
name,
symbol,
[
PERFORMANCE_FEE_GOVERNANCE,
PERFORMANCE_FEE_STRATEGIST,
WITHDRAWAL_FEE,
MANAGEMENT_FEE,
],
]
print("Vault Arguments: ", args)
vault_logic = TheVault.deploy(
{"from": dev}
) # TheVault Logic ## TODO: Deploy and use that
vault_proxy = AdminUpgradeabilityProxy.deploy(
vault_logic,
proxyAdmin,
vault_logic.initialize.encode_input(*args),
{"from": dev}
)
time.sleep(sleep_between_tx)
## We delete from deploy and then fetch again so we can interact
AdminUpgradeabilityProxy.remove(vault_proxy)
vault_proxy = TheVault.at(vault_proxy.address)
console.print("[green]Vault was deployed at: [/green]", vault_proxy.address)
return vault_proxy
def deploy_strategy(
vault, proxyAdmin, dev
):
args = [
vault,
[WANT]
]
print("Strategy Arguments: ", args)
strat_logic = MyStrategy.deploy({"from": dev})
time.sleep(sleep_between_tx)
strat_proxy = AdminUpgradeabilityProxy.deploy(
strat_logic,
proxyAdmin,
strat_logic.initialize.encode_input(*args),
{"from": dev}
)
time.sleep(sleep_between_tx)
## We delete from deploy and then fetch again so we can interact
AdminUpgradeabilityProxy.remove(strat_proxy)
strat_proxy = MyStrategy.at(strat_proxy.address)
console.print("[green]Strategy was deployed at: [/green]", strat_proxy.address)
return strat_proxy
def connect_account():
click.echo(f"You are using the '{network.show_active()}' network")
dev = accounts.load(click.prompt("Account", type=click.Choice(accounts.load())))
click.echo(f"You are using: 'dev' [{dev.address}]")
return dev