forked from SmoothBot/strategy-solidex-staker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.py
58 lines (45 loc) · 1.78 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
from pathlib import Path
from brownie import Strategy, accounts, config, network, project, web3
from eth_utils import is_checksum_address
import click
API_VERSION = config["dependencies"][0].split("@")[-1]
Vault = project.load(
Path.home() / ".brownie" / "packages" / config["dependencies"][0]
).Vault
def get_address(msg: str, default: str = None) -> str:
val = click.prompt(msg, default=default)
# Keep asking user for click.prompt until it passes
while True:
if is_checksum_address(val):
return val
elif addr := web3.ens.address(val):
click.echo(f"Found ENS '{val}' [{addr}]")
return addr
click.echo(
f"I'm sorry, but '{val}' is not a checksummed address or valid ENS record"
)
# NOTE: Only display default once
val = click.prompt(msg)
def main():
print(f"You are using the '{network.show_active()}' network")
dev = accounts.load(click.prompt("Account", type=click.Choice(accounts.load())))
print(f"You are using: 'dev' [{dev.address}]")
if input("Is there a Vault for this strategy already? y/[N]: ").lower() == "y":
vault = Vault.at(get_address("Deployed Vault: "))
assert vault.apiVersion() == API_VERSION
else:
print("You should deploy one vault using scripts from Vault project")
return # TODO: Deploy one using scripts from Vault project
print(
f"""
Strategy Parameters
api: {API_VERSION}
token: {vault.token()}
name: '{vault.name()}'
symbol: '{vault.symbol()}'
"""
)
publish_source = click.confirm("Verify source on etherscan?")
if input("Deploy Strategy? y/[N]: ").lower() != "y":
return
strategy = Strategy.deploy(vault, {"from": dev}, publish_source=publish_source)