generated from Badger-Finance/badger-strategy-mix-v1
-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy.py
144 lines (121 loc) · 3.58 KB
/
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
from brownie import *
from brownie import interface, accounts, Contract, StrategySushiBadgerIbBTC, Controller, SettV3
import time
from helpers.time import days
from config import (
BADGER_DEV_MULTISIG,
WANT,
LP_COMPONENT,
REWARD_TOKEN,
PROTECTED_TOKENS,
FEES
)
from dotmap import DotMap
def main():
return deploy()
def deploy():
"""
Deploys, vault, controller and strats and wires them up for you to test
"""
deployer = accounts[0]
strategist = deployer
keeper = deployer
guardian = deployer
governance = accounts.at(BADGER_DEV_MULTISIG, force=True)
controller = Controller.deploy({"from": deployer})
controller.initialize(
BADGER_DEV_MULTISIG,
strategist,
keeper,
BADGER_DEV_MULTISIG
)
sett = SettV3.deploy({"from": deployer})
sett.initialize(
WANT,
controller,
BADGER_DEV_MULTISIG,
keeper,
guardian,
False,
"prefix",
"PREFIX"
)
sett.unpause({"from": governance})
controller.setVault(WANT, sett)
## TODO: Add guest list once we find compatible, tested, contract
# guestList = VipCappedGuestListWrapperUpgradeable.deploy({"from": deployer})
# guestList.initialize(sett, {"from": deployer})
# guestList.setGuests([deployer], [True])
# guestList.setUserDepositCap(100000000)
# sett.setGuestList(guestList, {"from": governance})
## Start up Strategy
strategy = StrategySushiBadgerIbBTC.deploy({"from": deployer})
strategy.initialize(
BADGER_DEV_MULTISIG,
strategist,
controller,
keeper,
guardian,
PROTECTED_TOKENS,
FEES
)
## Tool that verifies bytecode (run independetly) <- Webapp for anyone to verify
## Set up tokens
want = interface.IERC20(WANT)
lpComponent = interface.IERC20(LP_COMPONENT)
rewardToken = interface.IERC20(REWARD_TOKEN)
## Wire up Controller to Strart
## In testing will pass, but on live it will fail
controller.approveStrategy(WANT, strategy, {"from": governance})
controller.setStrategy(WANT, strategy, {"from": deployer})
WBTC = strategy.wBTC_TOKEN()
wbtc = interface.IERC20(WBTC)
IBBTC = strategy.ibBTC_TOKEN()
ibBTC = interface.IERC20(IBBTC)
## Uniswap some tokens here
router = interface.IUniswapRouterV2(strategy.SUSHISWAP_ROUTER())
wbtc.approve(router.address, 999999999999999999999999999999, {"from": deployer})
ibBTC.approve(router.address, 999999999999999999999999999999, {"from": deployer})
# Buy WBTC with path MATIC -> WETH -> WBTC
router.swapExactETHForTokens(
0,
["0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619", WBTC],
deployer,
9999999999999999,
{"from": deployer, "value": 5000 * 10**18}
)
# Buy WBTC with path MATIC -> WETH -> WBTC -> ibBTC
router.swapExactETHForTokens(
0,
["0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619", WBTC, IBBTC],
deployer,
9999999999999999,
{"from": deployer, "value": 5000 * 10**18}
)
# Add ibBTC-wBTC liquidity
router.addLiquidity(
WBTC,
IBBTC,
wbtc.balanceOf(deployer),
ibBTC.balanceOf(deployer),
wbtc.balanceOf(deployer) * 0.005,
ibBTC.balanceOf(deployer) * 0.005,
deployer,
int(time.time()) + 1200, # Now + 20mins
{"from": deployer}
)
assert want.balanceOf(deployer) > 0
print("Initial Want Balance: ", want.balanceOf(deployer.address))
return DotMap(
deployer=deployer,
controller=controller,
vault=sett,
sett=sett,
strategy=strategy,
# guestList=guestList,
want=want,
lpComponent=lpComponent,
rewardToken=rewardToken
)