-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathconfig.py
324 lines (245 loc) · 10.2 KB
/
config.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
import os
import sys
from typing import Any, Union, Optional, Dict, Tuple
from utils.brownie_prelude import *
from brownie import network, accounts
from brownie.utils import color
from brownie.network.account import Account, LocalAccount
MAINNET_VOTE_DURATION = 3 * 24 * 60 * 60
def network_name() -> Optional[str]:
if network.show_active() is not None:
return network.show_active()
cli_args = sys.argv[1:]
net_ind = next((cli_args.index(arg) for arg in cli_args if arg == "--network"), len(cli_args))
net_name = None
if net_ind != len(cli_args):
net_name = cli_args[net_ind + 1]
return net_name
if network_name() in ("goerli", "goerli-fork"):
print(f'Using {color("cyan")}config_goerli.py{color} addresses')
from configs.config_goerli import *
elif network_name() in ("holesky", "holesky-fork"):
print(f'Using {color("cyan")}config_holesky.py{color} addresses')
from configs.config_holesky import *
elif network_name() in ("sepolia", "sepolia-fork"):
print(f'Using {color("yellow")}config_sepolia.py{color} addresses')
from configs.config_sepolia import *
else:
print(f'Using {color("magenta")}config_mainnet.py{color} addresses')
from configs.config_mainnet import *
def get_is_live() -> bool:
dev_networks = [
"development",
"hardhat",
"hardhat-fork",
"goerli-fork",
"local-fork",
"mainnet-fork",
"holesky-fork",
"sepolia-fork",
]
return network.show_active() not in dev_networks
def get_priority_fee() -> str:
if "OMNIBUS_PRIORITY_FEE" in os.environ:
return os.environ["OMNIBUS_PRIORITY_FEE"]
else:
return "2 gwei"
def get_max_fee() -> str:
if "OMNIBUS_MAX_FEE" in os.environ:
return os.environ["OMNIBUS_MAX_FEE"]
else:
return "300 gwei"
def get_deployer_account() -> Union[LocalAccount, Account]:
is_live = get_is_live()
if is_live and "DEPLOYER" not in os.environ:
raise EnvironmentError("Please set DEPLOYER env variable to the deployer account name")
return accounts.load(os.environ["DEPLOYER"]) if (is_live or "DEPLOYER" in os.environ) else accounts[4]
def get_web3_storage_token(silent=False) -> str:
is_live = get_is_live()
if is_live and not silent and "WEB3_STORAGE_TOKEN" not in os.environ:
raise EnvironmentError(
"Please set WEB3_STORAGE_TOKEN env variable to the web3.storage API token to be able to "
"upload the vote description to IPFS by calling upload_vote_ipfs_description. Alternatively, "
"you can only calculate cid without uploading to IPFS by calling calculate_vote_ipfs_description"
)
return os.environ["WEB3_STORAGE_TOKEN"] if (is_live or "WEB3_STORAGE_TOKEN" in os.environ) else ""
def get_pinata_cloud_token(silent=False) -> str:
is_live = get_is_live()
if is_live and not silent and "PINATA_CLOUD_TOKEN" not in os.environ:
raise EnvironmentError(
"Please set PINATA_CLOUD_TOKEN env variable to the pinata.cloud API token to be able to "
"upload the vote description to IPFS by calling upload_vote_ipfs_description. Alternatively, "
"you can only calculate cid without uploading to IPFS by calling calculate_vote_ipfs_description"
)
return os.environ["PINATA_CLOUD_TOKEN"] if (is_live or "PINATA_CLOUD_TOKEN" in os.environ) else ""
def get_infura_io_keys(silent=False) -> Tuple[str, str]:
is_live = get_is_live()
if (
is_live
and not silent
and ("WEB3_INFURA_IPFS_PROJECT_ID" not in os.environ or "WEB3_INFURA_IPFS_PROJECT_SECRET" not in os.environ)
):
raise EnvironmentError(
"Please set WEB3_INFURA_IPFS_PROJECT_ID and WEB3_INFURA_IPFS_PROJECT_SECRET env variable "
"to the web3.storage api token"
)
project_id = (
os.environ["WEB3_INFURA_IPFS_PROJECT_ID"] if (is_live or "WEB3_INFURA_IPFS_PROJECT_ID" in os.environ) else ""
)
project_secret = (
os.environ["WEB3_INFURA_IPFS_PROJECT_SECRET"]
if (is_live or "WEB3_INFURA_IPFS_PROJECT_SECRET" in os.environ)
else ""
)
return project_id, project_secret
def prompt_bool() -> Optional[bool]:
choice = input().lower()
if choice in {"yes", "y"}:
return True
elif choice in {"no", "n"}:
return False
else:
sys.stdout.write("Please respond with 'yes' or 'no'")
class ContractsLazyLoader:
@property
def lido_v1(self) -> interface.LidoV1:
return interface.LidoV1(LIDO)
@property
def lido(self) -> interface.Lido:
return interface.Lido(LIDO)
@property
def ldo_token(self) -> interface.MiniMeToken:
return interface.MiniMeToken(LDO_TOKEN)
@property
def voting(self) -> interface.Voting:
return interface.Voting(VOTING)
@property
def token_manager(self) -> interface.TokenManager:
return interface.TokenManager(TOKEN_MANAGER)
@property
def finance(self) -> interface.Finance:
return interface.Finance(FINANCE)
@property
def acl(self) -> interface.ACL:
return interface.ACL(ACL)
@property
def agent(self) -> interface.Agent:
return interface.Agent(AGENT)
@property
def node_operators_registry(self) -> interface.NodeOperatorsRegistry:
return interface.NodeOperatorsRegistry(NODE_OPERATORS_REGISTRY)
@property
def simple_dvt(self) -> interface.SimpleDVT:
return interface.SimpleDVT(SIMPLE_DVT)
@property
def legacy_oracle(self) -> interface.LegacyOracle:
return interface.LegacyOracle(LEGACY_ORACLE)
@property
def deposit_security_module_v1(self) -> interface.DepositSecurityModule:
return interface.DepositSecurityModuleV1(DEPOSIT_SECURITY_MODULE_V1)
@property
def deposit_security_module(self) -> interface.DepositSecurityModule:
return interface.DepositSecurityModule(DEPOSIT_SECURITY_MODULE)
@property
def burner(self) -> interface.Burner:
return interface.Burner(BURNER)
@property
def execution_layer_rewards_vault(self) -> interface.LidoExecutionLayerRewardsVault:
return interface.LidoExecutionLayerRewardsVault(EXECUTION_LAYER_REWARDS_VAULT)
@property
def hash_consensus_for_accounting_oracle(self) -> interface.HashConsensus:
return interface.HashConsensus(HASH_CONSENSUS_FOR_AO)
@property
def accounting_oracle(self) -> interface.AccountingOracle:
return interface.AccountingOracle(ACCOUNTING_ORACLE)
@property
def hash_consensus_for_validators_exit_bus_oracle(self) -> interface.HashConsensus:
return interface.HashConsensus(HASH_CONSENSUS_FOR_VEBO)
@property
def validators_exit_bus_oracle(self) -> interface.ValidatorsExitBusOracle:
return interface.ValidatorsExitBusOracle(VALIDATORS_EXIT_BUS_ORACLE)
@property
def oracle_report_sanity_checker(self) -> interface.OracleReportSanityChecker:
return interface.OracleReportSanityChecker(ORACLE_REPORT_SANITY_CHECKER)
@property
def withdrawal_queue(self) -> interface.WithdrawalQueueERC721:
return interface.WithdrawalQueueERC721(WITHDRAWAL_QUEUE)
@property
def lido_locator(self) -> interface.LidoLocator:
return interface.LidoLocator(LIDO_LOCATOR)
@property
def eip712_steth(self) -> interface.EIP712StETH:
return interface.EIP712StETH(EIP712_STETH)
@property
def withdrawal_vault(self) -> interface.WithdrawalVault:
return interface.WithdrawalVault(WITHDRAWAL_VAULT)
@property
def staking_router(self) -> interface.StakingRouter:
return interface.StakingRouter(STAKING_ROUTER)
@property
def kernel(self) -> interface.Kernel:
return interface.Kernel(ARAGON_KERNEL)
@property
def apm_registry(self) -> interface.APMRegistry:
return interface.APMRegistry(APM_REGISTRY)
@property
def lido_app_repo(self) -> interface.Repo:
return interface.Repo(LIDO_REPO)
@property
def nor_app_repo(self) -> interface.Repo:
return interface.Repo(NODE_OPERATORS_REGISTRY_REPO)
@property
def voting_app_repo(self) -> interface.Repo:
return interface.Repo(VOTING_REPO)
@property
def oracle_app_repo(self) -> interface.Repo:
return interface.Repo(LEGACY_ORACLE_REPO)
@property
def easy_track(self) -> interface.EasyTrack:
return interface.EasyTrack(EASYTRACK)
@property
def relay_allowed_list(self) -> interface.MEVBoostRelayAllowedList:
return interface.MEVBoostRelayAllowedList(RELAY_ALLOWED_LIST)
@property
def dai_token(self) -> interface.ERC20:
return interface.ERC20(DAI_TOKEN)
@property
def usdt_token(self) -> interface.ERC20:
return interface.ERC20(USDT_TOKEN)
@property
def usdc_token(self) -> interface.ERC20:
return interface.ERC20(USDC_TOKEN)
@property
def weth_token(self) -> interface.WethToken:
return interface.WethToken(WETH_TOKEN)
@property
def oracle_daemon_config(self) -> interface.OracleDaemonConfig:
return interface.OracleDaemonConfig(ORACLE_DAEMON_CONFIG)
@property
def wsteth(self) -> interface.WstETH:
return interface.WstETH(WSTETH_TOKEN)
@property
def gate_seal(self) -> interface.GateSeal:
return interface.GateSeal(GATE_SEAL)
@property
def evm_script_registry(self) -> interface.EVMScriptRegistry:
return interface.EVMScriptRegistry(ARAGON_EVMSCRIPT_REGISTRY)
@property
def insurance_fund(self) -> interface.InsuranceFund:
return interface.InsuranceFund(INSURANCE_FUND)
@property
def anchor_vault(self) -> interface.InsuranceFund:
return interface.AnchorVault(ANCHOR_VAULT_PROXY)
@property
def anchor_vault_proxy(self) -> interface.InsuranceFund:
return interface.AnchorVaultProxy(ANCHOR_VAULT_PROXY)
@property
def obol_lido_split_factory(self) -> interface.ObolLidoSplitFactory:
return interface.ObolLidoSplitFactory(OBOL_LIDO_SPLIT_FACTORY)
@property
def split_main(self) -> interface.SplitMain:
return interface.SplitMain(SPLIT_MAIN)
def __getattr__(name: str) -> Any:
if name == "contracts":
return ContractsLazyLoader()
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")