-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathconftest.py
More file actions
184 lines (128 loc) · 4.39 KB
/
Copy pathconftest.py
File metadata and controls
184 lines (128 loc) · 4.39 KB
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
181
182
183
184
import pytest
from brownie import config, Contract, ZERO_ADDRESS
from eth_abi import encode_single
@pytest.fixture(scope="function", autouse=True)
def isolate(fn_isolation):
pass
@pytest.fixture
def gov(accounts):
yield accounts.at("0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52", force=True)
@pytest.fixture
def user(accounts):
yield accounts[0]
@pytest.fixture
def rewards(accounts):
yield accounts[1]
@pytest.fixture
def guardian(accounts):
yield accounts[2]
@pytest.fixture
def management(accounts):
yield accounts[3]
@pytest.fixture
def strategist(accounts):
yield accounts[4]
@pytest.fixture
def keeper(accounts):
yield accounts[5]
@pytest.fixture
def yvweth_032():
yield Contract("0xa9fE4601811213c340e850ea305481afF02f5b28")
@pytest.fixture
def yvweth_042():
yield Contract("0xa258C4606Ca8206D8aA700cE2143D7db854D168c")
@pytest.fixture
def origin_vault():
# origin vault of the route
yield Contract("0xa9fE4601811213c340e850ea305481afF02f5b28")
@pytest.fixture
def destination_vault():
# destination vault of the route
yield Contract("0xa258C4606Ca8206D8aA700cE2143D7db854D168c")
@pytest.fixture
def origin_vault():
# origin vault of the route
yield Contract("0xa9fE4601811213c340e850ea305481afF02f5b28")
@pytest.fixture
def destination_vault():
# destination vault of the route
yield Contract("0xa258C4606Ca8206D8aA700cE2143D7db854D168c")
@pytest.fixture
def weth_whale(accounts):
yield accounts.at("0xc1aae9d18bbe386b102435a8632c8063d31e747c", True)
@pytest.fixture
def token():
token_address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" # this should be the address of the ERC-20 used by the strategy/vault (DAI)
yield Contract(token_address)
@pytest.fixture
def amount(accounts, token, user):
amount = 10_000 * 10 ** token.decimals()
# In order to get some funds for the token you are about to use,
# it impersonate an exchange address to use it's funds.
reserve = accounts.at("0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643", force=True)
token.transfer(user, amount, {"from": reserve})
yield amount
@pytest.fixture
def weth():
yield Contract("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
@pytest.fixture
def weth_amout(user, weth):
weth_amout = 10 ** weth.decimals()
user.transfer(weth, weth_amout)
yield weth_amout
@pytest.fixture
def health_check():
yield Contract("0xddcea799ff1699e98edf118e0629a974df7df012")
@pytest.fixture
def vault(pm, gov, rewards, guardian, management, token):
Vault = pm(config["dependencies"][0]).Vault
vault = guardian.deploy(Vault)
vault.initialize(token, gov, rewards, "", "", guardian, management)
vault.setDepositLimit(2 ** 256 - 1, {"from": gov})
vault.setManagement(management, {"from": gov})
yield vault
yield Contract("0xa9fE4601811213c340e850ea305481afF02f5b28")
@pytest.fixture
def strategy(
strategist,
keeper,
origin_vault,
destination_vault,
RouterStrategy,
gov,
health_check,
):
strategy = strategist.deploy(
RouterStrategy, origin_vault, destination_vault, "Route yvWETH 042"
)
strategy.setKeeper(keeper)
for i in range(0, 20):
strat_address = origin_vault.withdrawalQueue(i)
if ZERO_ADDRESS == strat_address:
break
origin_vault.updateStrategyDebtRatio(strat_address, 0, {"from": gov})
strategy.setHealthCheck(health_check, {"from": origin_vault.governance()})
origin_vault.addStrategy(strategy, 10_000, 0, 2 ** 256 - 1, 0, {"from": gov})
yield strategy
@pytest.fixture
def unique_strategy(
strategist, keeper, yvweth_032, yvweth_042, RouterStrategy, gov, health_check
):
strategy = strategist.deploy(
RouterStrategy, yvweth_032, yvweth_042, "Route yvWETH 042"
)
strategy.setKeeper(keeper)
strategy.setHealthCheck(health_check, {"from": yvweth_032.governance()})
for i in range(0, 20):
strat_address = yvweth_032.withdrawalQueue(i)
if ZERO_ADDRESS == strat_address:
break
yvweth_032.updateStrategyDebtRatio(strat_address, 0, {"from": gov})
yvweth_032.setPerformanceFee(0, {"from": gov})
yvweth_032.setManagementFee(0, {"from": gov})
yvweth_032.addStrategy(strategy, 10_000, 0, 2 ** 256 - 1, 0, {"from": gov})
yvweth_032.setDepositLimit(0, {"from": gov})
yield strategy
@pytest.fixture(scope="session")
def RELATIVE_APPROX():
yield 1e-5