forked from GalloDaSballo/badger-vaults-mix-v1.5
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path3_production_setup.py
180 lines (135 loc) · 5.63 KB
/
3_production_setup.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import time
from brownie import accounts, network, MyStrategy, TheVault, BadgerRegistry
from config import WANT, REWARD_TOKEN, LP_COMPONENT, REGISTRY
from helpers.constants import AddressZero
import click
from rich.console import Console
console = Console()
sleep_between_tx = 1
def main():
"""
TO BE RUN BEFORE PROMOTING TO PROD
Checks and Sets all Keys for Vault and Strategy Against the Registry
1. Checks all Keys
2. Sets all Keys
In case of a mismatch, the script will execute a transaction to change the parameter to the proper one.
Notice that, as a final step, the script will change the governance address to Badger's Governance Multisig;
this will effectively relinquish the contract control from your account to the Badger Governance.
Additionally, the script performs a final check of all parameters against the registry parameters.
"""
# Get deployer account from local keystore
dev = connect_account()
# Add deployed Strategy and Vault contracts here:
STRAT = "123"
VAULT = "123"
assert STRAT != "123"
assert VAULT != "123"
strategy = MyStrategy.at(STRAT)
vault = TheVault.at(VAULT)
assert strategy.paused() == False
assert vault.paused() == False
console.print("[blue]Strategy: [/blue]", strategy.getName())
console.print("[blue]Vault: [/blue]", vault.name())
# Get production addresses from registry
registry = BadgerRegistry.at(REGISTRY)
governance = registry.get("governance")
guardian = registry.get("guardian")
keeper = registry.get("keeper")
controller = registry.get("controller")
badgerTree = registry.get("badgerTree")
assert governance != AddressZero
assert guardian != AddressZero
assert keeper != AddressZero
assert controller != AddressZero
assert badgerTree != AddressZero
# Check production parameters and update any mismatch
set_parameters(
dev,
strategy,
vault,
governance,
guardian,
keeper,
controller,
)
# Confirm all productions parameters
check_parameters(
strategy, vault, governance, guardian, keeper, controller, badgerTree
)
def set_parameters(dev, strategy, vault, governance, guardian, keeper, controller):
# Set Controller (deterministic)
if strategy.controller() != controller:
strategy.setController(controller, {"from": dev})
time.sleep(sleep_between_tx)
if vault.controller() != controller:
vault.setController(controller, {"from": dev})
time.sleep(sleep_between_tx)
console.print("[green]Controller existing or set at: [/green]", controller)
# Set Fees
if strategy.performanceFeeGovernance() != 0:
strategy.setPerformanceFeeGovernance(0, {"from": dev})
time.sleep(sleep_between_tx)
if strategy.performanceFeeStrategist() != 0:
strategy.setPerformanceFeeStrategist(0, {"from": dev})
time.sleep(sleep_between_tx)
if strategy.withdrawalFee() != 10:
strategy.setWithdrawalFee(10, {"from": dev})
time.sleep(sleep_between_tx)
console.print("[green]Fees existing or set at: [/green]", "0, 0, 10")
# Set permissioned accounts
if strategy.keeper() != keeper:
strategy.setKeeper(keeper, {"from": dev})
time.sleep(sleep_between_tx)
if vault.keeper() != keeper:
vault.setKeeper(keeper, {"from": dev})
time.sleep(sleep_between_tx)
console.print("[green]Keeper existing or set at: [/green]", keeper)
if strategy.guardian() != guardian:
strategy.setGuardian(guardian, {"from": dev})
time.sleep(sleep_between_tx)
if vault.guardian() != guardian:
vault.setGuardian(guardian, {"from": dev})
time.sleep(sleep_between_tx)
console.print("[green]Guardian existing or set at: [/green]", guardian)
if strategy.strategist() != governance:
strategy.setStrategist(governance, {"from": dev})
time.sleep(sleep_between_tx)
console.print("[green]Strategist existing or set at: [/green]", governance)
if strategy.governance() != governance:
strategy.setGovernance(governance, {"from": dev})
time.sleep(sleep_between_tx)
if vault.governance() != governance:
vault.setGovernance(governance, {"from": dev})
time.sleep(sleep_between_tx)
console.print("[green]Governance existing or set at: [/green]", governance)
def check_parameters(
strategy, vault, governance, guardian, keeper, controller, badgerTree
):
assert strategy.want() == WANT
assert vault.token() == WANT
assert strategy.lpComponent() == LP_COMPONENT
assert strategy.reward() == REWARD_TOKEN
assert strategy.controller() == controller
assert vault.controller() == controller
assert strategy.performanceFeeGovernance() == 0
assert strategy.performanceFeeStrategist() == 0
assert strategy.withdrawalFee() == 10
assert strategy.keeper() == keeper
assert vault.keeper() == keeper
assert strategy.guardian() == guardian
assert vault.guardian() == guardian
assert strategy.strategist() == governance
assert strategy.governance() == governance
assert vault.governance() == governance
# Not all strategies use the badgerTree
try:
if strategy.badgerTree() != AddressZero:
assert strategy.badgerTree() == badgerTree
except:
pass
console.print("[blue]All Parameters checked![/blue]")
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