forked from yearn/brownie-wrapper-mix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconftest.py
186 lines (144 loc) · 4.63 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
175
176
177
178
179
180
181
182
183
184
185
186
import pytest
from brownie import accounts, config, Contract
from eth_account import Account
from eth_account.messages import encode_structured_data
@pytest.fixture
def gov(accounts):
yield accounts[0]
@pytest.fixture
def affiliate(accounts):
yield accounts[1]
@pytest.fixture
def guardian(accounts):
yield accounts[2]
@pytest.fixture
def management(accounts):
yield accounts[2]
@pytest.fixture
def rewards(accounts):
yield accounts[3]
@pytest.fixture
def rando(accounts):
yield accounts[3]
@pytest.fixture
def token(pm, gov):
Token = pm(config["dependencies"][0]).Token
yield gov.deploy(Token, 18)
@pytest.fixture
def affiliate_token(token, affiliate, registry, AffiliateToken):
# Affliate Wrapper
yield affiliate.deploy(
AffiliateToken,
token,
registry,
f"Affiliate {token.symbol()}",
f"af{token.symbol()}",
)
@pytest.fixture
def vault(create_vault, token):
yield create_vault(token=token)
@pytest.fixture
def create_vault(pm, gov, rewards, guardian, management):
def create_vault(token, releaseDelta=0, governance=gov):
liveRegistry = Contract("0x50c1a2eA0a861A967D9d0FFE2AE4012c2E053804")
Vault = pm(config["dependencies"][0]).Vault
tx = liveRegistry.newExperimentalVault(
token,
governance,
guardian,
rewards,
"vault",
"token",
releaseDelta,
{"from": governance},
)
vault = Vault.at(tx.return_value)
vault.setDepositLimit(2 ** 256 - 1, {"from": governance})
return vault
yield create_vault
@pytest.fixture
def registry(pm, gov):
Registry = pm(config["dependencies"][0]).Registry
yield gov.deploy(Registry)
@pytest.fixture
def new_registry(pm, gov):
Registry = pm(config["dependencies"][0]).Registry
yield gov.deploy(Registry)
@pytest.fixture
def sign_token_permit():
def sign_token_permit(
token,
owner: Account, # NOTE: Must be a eth_key account, not Brownie
spender: str,
allowance: int = 2 ** 256 - 1, # Allowance to set with `permit`
deadline: int = 0, # 0 means no time limit
override_nonce: int = None,
):
chain_id = 1 # ganache bug https://github.com/trufflesuite/ganache/issues/1643
if override_nonce:
nonce = override_nonce
else:
nonce = token.nonces(owner.address)
data = {
"types": {
"EIP712Domain": [
{"name": "name", "type": "string"},
{"name": "version", "type": "string"},
{"name": "chainId", "type": "uint256"},
{"name": "verifyingContract", "type": "address"},
],
"Permit": [
{"name": "owner", "type": "address"},
{"name": "spender", "type": "address"},
{"name": "value", "type": "uint256"},
{"name": "nonce", "type": "uint256"},
{"name": "deadline", "type": "uint256"},
],
},
"domain": {
"name": token.name(),
"version": "1",
"chainId": chain_id,
"verifyingContract": str(token),
},
"primaryType": "Permit",
"message": {
"owner": owner.address,
"spender": spender,
"value": allowance,
"nonce": nonce,
"deadline": deadline,
},
}
permit = encode_structured_data(data)
return owner.sign_message(permit)
return sign_token_permit
@pytest.fixture
def live_token(live_vault):
token_address = live_vault.token() # this will be the address of the Curve LP token
yield Contract(token_address)
@pytest.fixture
def live_vault():
yield Contract("0x986b4aff588a109c09b50a03f42e4110e29d353f") # yvseth
@pytest.fixture
def live_affiliate_token(AffiliateToken, affiliate, live_token, live_registry):
# Affliate Wrapper
yield affiliate.deploy(
AffiliateToken,
live_token,
live_registry,
f"Affiliate {live_token.symbol()}",
f"af{live_token.symbol()}",
)
@pytest.fixture
def live_registry():
yield Contract("v2.registry.ychad.eth")
@pytest.fixture
def live_whale(accounts):
whale = accounts.at(
"0x3c0ffff15ea30c35d7a85b85c0782d6c94e1d238", force=True
) # make sure this address holds big bags of want()
yield whale
@pytest.fixture
def live_gov(live_registry):
yield accounts.at(live_registry.governance(), force=True)