generated from GalloDaSballo/badger-vaults-mix-v1.5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_production_wireup.py
84 lines (64 loc) · 2.35 KB
/
4_production_wireup.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
import time
from brownie import (
accounts,
network,
Controller,
BadgerRegistry,
)
import click
from rich.console import Console
from config import REGISTRY
from helpers.constants import AddressZero
console = Console()
sleep_between_tx = 1
def main():
"""
GOVERNANCE ONLY
Connects the Strategies to the Vaults via the Production Controller
This script is enabled to handle multiple sets of strategy + vault + want. It must be
called from the controller's governance account.
"""
# dev must be the controller's governance (get from keystore)
dev = connect_account()
# NOTE: Add the strategies, vaults and their corresponding wants
# to the arrays below. It is very important that indexes are the
# same for corresponding contracts. Example: to wire SettA, the
# address of strategyA, vaultA and wantA must all be position at
# the same index within their respective arrays.
# Strategies to wire up
strategies = [
"0x1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a",
]
# Vaults to wire up
vaults = [
"0x1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a",
]
# Wants related to strategies and vaults
wants = [
"0x1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a",
]
# Get production controller from registry
registry = BadgerRegistry.at(REGISTRY)
controllerAddr = registry.get("controller")
assert controllerAddr != AddressZero
controller = Controller.at(controllerAddr)
# Wire up strategies
for strat in strategies:
want = wants[strategies.index(strat)]
controller.approveStrategy(want, strat, {"from": dev})
time.sleep(sleep_between_tx)
assert controller.approvedStrategies(want, strat) == True
controller.setStrategy(want, strat, {"from": dev})
time.sleep(sleep_between_tx)
assert controller.strategies(want) == strat
# Wire up vaults
for vault in vaults:
want = wants[vaults.index(vault)]
controller.setVault(want, vault, {"from": dev})
time.sleep(sleep_between_tx)
assert controller.vaults(want) == vault
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