forked from Schlagonia/Yearn-V2-Generic-Lender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
174 lines (119 loc) · 4.05 KB
/
conftest.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
import pytest
from brownie import Wei, config
@pytest.fixture
def live_strat_usdc_1(Strategy):
yield Strategy.at("0xB7e9Bf9De45E1df822E97cA7E0C3D1B62798a4e0")
@pytest.fixture
def live_vault_usdc(pm):
Vault = pm(config["dependencies"][0]).Vault
yield Vault.at("0xD6b53d0f3d4e55fbAaADc140C0B0488293a433f8")
@pytest.fixture
def live_GenericCompound_usdc_1(GenericCompound):
yield GenericCompound.at("0x33D4c129586562adfd993ebb54E830481F31ef37")
@pytest.fixture
def live_GenericCream_usdc_1(GenericCream):
yield GenericCream.at("0x1bAaCef951d24c5d70a8cA88D89cE16B37472fB3")
@pytest.fixture
def live_GenericDyDx_usdc_1(GenericDyDx):
yield GenericDyDx.at("0x6C842746F21Ca34542EDC6895dFfc8D4e7D2bC1c")
# change these fixtures for generic tests
@pytest.fixture
def currency(dai, usdc, weth):
yield usdc
@pytest.fixture(autouse=True)
def isolation(fn_isolation):
pass
@pytest.fixture
def whale(accounts, web3, weth, gov):
# big binance7 wallet
# acc = accounts.at('0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8', force=True)
# big binance8 wallet
acc = accounts.at("0xf977814e90da44bfa03b6295a0616a897441acec", force=True)
# lots of weth account
wethAcc = accounts.at("0x767Ecb395def19Ab8d1b2FCc89B3DDfBeD28fD6b", force=True)
weth.approve(acc, 2 ** 256 - 1, {"from": wethAcc})
weth.transfer(acc, weth.balanceOf(wethAcc), {"from": wethAcc})
weth.approve(acc, 2 ** 256 - 1, {"from": acc})
weth.transfer(gov, Wei("100 ether"), {"from": acc})
assert weth.balanceOf(acc) > 0
yield acc
@pytest.fixture()
def strategist(accounts, whale, currency):
decimals = currency.decimals()
currency.transfer(accounts[1], 100_000 * (10 ** decimals), {"from": whale})
yield accounts[1]
@pytest.fixture
def samdev(accounts):
yield accounts.at("0xC3D6880fD95E06C816cB030fAc45b3ffe3651Cb0", force=True)
@pytest.fixture
def gov(accounts):
yield accounts[3]
@pytest.fixture
def rewards(gov):
yield gov # TODO: Add rewards contract
@pytest.fixture
def guardian(accounts):
# YFI Whale, probably
yield accounts[2]
@pytest.fixture
def keeper(accounts):
# This is our trusty bot!
yield accounts[4]
@pytest.fixture
def rando(accounts):
yield accounts[9]
# specific addresses
@pytest.fixture
def usdc(interface):
yield interface.ERC20("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
@pytest.fixture
def dai(interface):
yield interface.ERC20("0x6b175474e89094c44da98b954eedeac495271d0f")
@pytest.fixture
def weth(interface):
yield interface.IWETH("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
@pytest.fixture
def cdai(interface):
yield interface.CErc20I("0x5d3a536e4d6dbd6114cc1ead35777bab948e3643")
@pytest.fixture
def cUsdc(interface):
yield interface.CErc20I("0x39AA39c021dfbaE8faC545936693aC917d5E7563")
@pytest.fixture
def crUsdc(interface):
yield interface.CErc20I("0x44fbeBd2F576670a6C33f6Fc0B00aA8c5753b322")
@pytest.fixture(scope="module", autouse=True)
def shared_setup(module_isolation):
pass
@pytest.fixture
def vault(gov, rewards, guardian, currency, pm):
Vault = pm(config["dependencies"][0]).Vault
vault = Vault.deploy({"from": guardian})
vault.initialize(currency, gov, rewards, "", "")
yield vault
@pytest.fixture
def Vault(pm):
yield pm(config["dependencies"][0]).Vault
@pytest.fixture
def strategy(
strategist,
keeper,
vault,
crUsdc,
cUsdc,
Strategy,
GenericCompound,
GenericCream,
GenericDyDx,
):
strategy = strategist.deploy(Strategy, vault)
strategy.setKeeper(keeper)
compoundPlugin = strategist.deploy(GenericCompound, strategy, "Compound", cUsdc)
creamPlugin = strategist.deploy(GenericCream, strategy, "Cream", crUsdc)
dydxPlugin = strategist.deploy(GenericDyDx, strategy, "DyDx")
strategy.addLender(compoundPlugin, {"from": strategist})
assert strategy.numLenders() == 1
strategy.addLender(creamPlugin, {"from": strategist})
assert strategy.numLenders() == 2
strategy.addLender(dydxPlugin, {"from": strategist})
assert strategy.numLenders() == 3
yield strategy