def main(): accounts.from_mnemonic(SEED) admin = accounts[0] token = ERC20CRV.deploy("Curve DAO Token", "CRV", 18, {'from': admin, 'required_confs': confs}) voting_escrow = VotingEscrow.deploy( token, "Vote-escrowed CRV", "veCRV", "veCRV_1.0.0", {'from': admin, 'required_confs': confs} ) coin_a = ERC20.deploy("Coin A", "USDA", 18, {'from': admin, 'required_confs': confs}) coin_b = ERC20.deploy("Coin B", "USDB", 18, {'from': admin, 'required_confs': confs}) coin_a._mint_for_testing(10 ** 9 * 10 ** 18, {'from': admin, 'required_confs': confs}) coin_b._mint_for_testing(10 ** 9 * 10 ** 18, {'from': admin, 'required_confs': confs}) lp_token = ERC20LP.deploy("Some pool", "cPool", 18, 0, {'from': admin, 'required_confs': confs}) pool = CurvePool.deploy([coin_a, coin_b], lp_token, 100, 4 * 10 ** 6, {'from': admin, 'required_confs': confs}) lp_token.set_minter(pool, {'from': admin, 'required_confs': confs}) coin_a.approve(pool, "1000000000000000000000", {'from': admin}) coin_b.approve(pool, "1000000000000000000000", {'from': admin}) pool.add_liquidity(["100000000000000", "200000000000000"], 0, {'from': admin}) contract = CurveRewards.deploy(lp_token, coin_a, {'from': accounts[0], 'required_confs': confs}) contract.setRewardDistribution(accounts[0], {'from': accounts[0], 'required_confs': confs}) registry = Registry.deploy([ZERO_ADDRESS] * 4, {'from': admin, 'required_confs': confs}) coin_a.transfer(contract, 100e18, {'from': accounts[0], 'required_confs': confs}) liquidity_gauge_rewards = LiquidityGaugeReward.deploy(lp_token, '0xbE45e0E4a72aEbF9D08F93E64701964d2CC4cF96', contract, coin_a, {'from': admin, 'required_confs': confs}) for account in DISTRIBUTION_ADDRESSES: coin_a.transfer(account, DISTRIBUTION_AMOUNT, {'from': admin, 'required_confs': confs}) coin_b.transfer(account, DISTRIBUTION_AMOUNT, {'from': admin, 'required_confs': confs}) pool.commit_transfer_ownership(ARAGON_AGENT, {'from': admin, 'required_confs': confs}) pool.apply_transfer_ownership({'from': admin, 'required_confs': confs}) registry.commit_transfer_ownership(ARAGON_AGENT, {'from': admin, 'required_confs': confs}) registry.apply_transfer_ownership({'from': admin, 'required_confs': confs}) gauge_controller = GaugeController.deploy(token, voting_escrow, {'from': admin, 'required_confs': confs}) minter = Minter.deploy(token, gauge_controller, {'from': admin, 'required_confs': confs}) liquidity_gauge = LiquidityGauge.deploy(lp_token, minter, {'from': admin, 'required_confs': confs}) token.set_minter(minter, {'from': admin, 'required_confs': confs}) gauge_controller.add_type(b'Liquidity', {'from': admin, 'required_confs': confs}) gauge_controller.change_type_weight(0, 10 ** 18, {'from': admin, 'required_confs': confs}) gauge_controller.add_gauge(liquidity_gauge, 0, 10 ** 18, {'from': admin, 'required_confs': confs}) gauge_controller.commit_transfer_ownership(ARAGON_AGENT, {'from': admin, 'required_confs': confs}) gauge_controller.apply_transfer_ownership({'from': admin, 'required_confs': confs}) voting_escrow.commit_transfer_ownership(ARAGON_AGENT, {'from': admin, 'required_confs': confs}) voting_escrow.apply_transfer_ownership({'from': admin, 'required_confs': confs}) PoolProxy.deploy({'from': admin, 'required_confs': confs})
def deploy_registry(): """ Deploy `Registry`, add all current pools, and set the address in `AddressProvider`. """ balance = deployer.balance() provider = AddressProvider.at(ADDRESS_PROVIDER) registry = Registry.deploy( ADDRESS_PROVIDER, GAUGE_CONTROLLER, {"from": deployer, "gas_price": gas_strategy} ) add_pools(registry, deployer) provider.set_address(0, registry, {"from": deployer, "gas_price": gas_strategy}) print(f"Registry deployed to: {registry.address}") print(f"Total gas used: {(balance - deployer.balance()) / 1e18:.4f} eth")
def main(registry=REGISTRY, deployer=DEPLOYER): """ * Fetch pool data from Github * Add new pools to the existing registry deployment * Add / update pool gauges within the registry """ balance = deployer.balance() registry = Registry.at(registry) pool_data = get_pool_data() print("Adding pools to registry...") for name, data in pool_data.items(): pool = data['swap_address'] if registry.get_n_coins(pool)[0] == 0: print(f"\nAdding {name}...") add_pool(data, registry, deployer) else: print(f"\n{name} has already been added to registry") gauges = data['gauge_addresses'] gauges = gauges + ["0x0000000000000000000000000000000000000000" ] * (10 - len(gauges)) if registry.get_gauges(pool)[0] == gauges: print(f"{name} gauges are up-to-date") continue print(f"Updating gauges for {name}...") for gauge in data['gauge_addresses']: try: Contract(GAUGE_CONTROLLER).gauge_types(gauge) except (ValueError, VirtualMachineError): print( f"Gauge {gauge} is not known to GaugeController, cannot add to registry" ) gauges = False break if gauges: registry.set_liquidity_gauges(pool, gauges, { 'from': deployer, 'gas_price': gas_strategy }) print(f"Total gas used: {(balance - deployer.balance()) / 1e18:.4f} eth")
def main(registry=REGISTRY, deployer=DEPLOYER): """ * Fetch pool data from Github * Add new pools to the existing registry deployment * Add / update pool gauges within the registry """ deployer = accounts.at(deployer, force=True) balance = deployer.balance() registry = Registry.at(registry) # sort keys leaving metapools last pool_data = sorted(get_pool_data().items(), key=lambda item: item[1].get("base_pool", "")) print("Adding pools to registry...") for name, data in pool_data: pool = data["swap_address"] if registry.get_n_coins(pool)[0] == 0: print(f"\nAdding {name}...") add_pool(data, registry, deployer, name) else: print(f"\n{name} has already been added to registry") gauges = data["gauge_addresses"] gauges = gauges + ["0x0000000000000000000000000000000000000000"] * (10 - len(gauges)) if registry.get_gauges(pool)[0] == gauges: print(f"{name} gauges are up-to-date") continue print(f"Updating gauges for {name}...") for gauge in data["gauge_addresses"]: try: Contract(GAUGE_CONTROLLER).gauge_types(gauge) except (ValueError, VirtualMachineError): print(f"Gauge {gauge} is not known to GaugeController, cannot add to registry") gauges = False break if gauges: registry.set_liquidity_gauges( pool, gauges, {"from": deployer, "gas_price": gas_strategy} ) print(f"Total gas used: {(balance - deployer.balance()) / 1e18:.4f} eth")
def main(): click.echo(f"You are using the '{network.show_active()}' network") dev = accounts.load(click.prompt("Account", type=click.Choice(accounts.load()))) click.echo(f"You are using: 'dev' [{dev.address}]") registry = Registry.at( get_address("Vault Registry", default="v2.registry.ychad.eth") ) latest_release = Version(registry.latestRelease()) num_releases = registry.numReleases() - 1 target_release_index = num_releases release_delta = 0 click.echo( f""" Release Information latest release version: {latest_release} latest release index: {num_releases} local package version: {PACKAGE_VERSION} """ ) use_proxy = False # NOTE: Use a proxy to save on gas for experimental Vaults if Version(PACKAGE_VERSION) <= latest_release: click.echo( f""" Recommended Releases DO NOT USE => 0-2 0.3.2 => 3 0.3.3 => 4 0.3.4 => 5 (DO NOT USE) 0.3.5 => 6 0.4.0 => 7 (DO NOT USE) 0.4.1 => 8 """ ) target_release_index = click.prompt( "Please select a target release index from options or press enter for latest release:", type=click.Choice([str(i) for i in range(num_releases + 1)]), default=num_releases, ) if click.confirm("Deploy a Proxy Vault", default="Y"): use_proxy = True elif Version(PACKAGE_VERSION) > latest_release: target_release_index = num_releases + 1 if not click.confirm(f"Deploy {PACKAGE_VERSION} as new release"): return token = Token.at(get_address("ERC20 Token")) if use_proxy: gov_default = ( "0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7" # strategist msig, no ENS ) else: gov_default = "ychad.eth" gov = get_address("Yearn Governance", default=dev.address) rewards = get_address("Rewards contract", default="treasury.ychad.eth") guardian = get_address("Vault Guardian", default="dev.ychad.eth") management = get_address("Vault Management", default="brain.ychad.eth") name = click.prompt(f"Set description", default=DEFAULT_VAULT_NAME(token)) symbol = click.prompt(f"Set symbol", default=DEFAULT_VAULT_SYMBOL(token)) release_delta = num_releases - target_release_index target_release = ( Vault.at(registry.releases(target_release_index)).apiVersion() if release_delta >= 0 else PACKAGE_VERSION ) click.echo( f""" Vault Deployment Parameters use proxy: {use_proxy} target release: {target_release} release delta: {release_delta} token address: {token.address} token symbol: {DEFAULT_VAULT_SYMBOL(token)} governance: {gov} management: {management} rewards: {rewards} guardian: {guardian} name: '{name}' symbol: '{symbol}' """ ) if click.confirm("Deploy New Vault"): args = [ token, gov, rewards, # NOTE: Empty string `""` means no override (don't use click default tho) name if name != DEFAULT_VAULT_NAME(token) else "", symbol if symbol != DEFAULT_VAULT_SYMBOL(token) else "", ] if use_proxy: # NOTE: Must always include guardian, even if default args.insert(2, guardian) args.append(release_delta) txn_receipt = registry.newExperimentalVault(*args, {"from": dev, "gas_price": Wei('9 gwei'), "required_confs": 0}) vault = Vault.at(txn_receipt.events["NewExperimentalVault"]["vault"]) click.echo(f"Experimental Vault deployed [{vault.address}]") click.echo(" NOTE: Vault is not registered in Registry!") else: args.append(guardian) args.append(management) vault = Vault.deploy({"from": dev, "gas_price": Wei('9 gwei'), "required_confs": 0}) vault.initialize(*args) click.echo(f"New Vault Release deployed [{vault.address}]") click.echo( " NOTE: Vault is not registered in Registry, please register!" )
def main(): click.echo(f"You are using the '{network.show_active()}' network") dev = accounts.load( click.prompt("Account", type=click.Choice(accounts.load()))) click.echo(f"You are using: 'dev' [{dev.address}]") registry = Registry.at( get_address("Vault Registry", default="v2.registry.ychad.eth")) latest_release = Version(registry.latestRelease()) use_proxy = False # NOTE: Use a proxy to save on gas for experimental Vaults if Version(PACKAGE_VERSION) < latest_release: click.echo("Cannot deploy Vault for old API version") return elif Version(PACKAGE_VERSION) > latest_release: if not click.confirm(f"Deploy {PACKAGE_VERSION} as new release"): return else: if not click.confirm("Deploy Experimental Vault"): return use_proxy = True token = Token.at(get_address("ERC20 Token")) gov = get_address("Yearn Governance", default="ychad.eth") rewards = get_address("Rewards contract", default="0x93A62dA5a14C80f265DAbC077fCEE437B1a0Efde") guardian = get_address("Vault Guardian", default=dev.address) name = click.prompt(f"Set description", default=DEFAULT_VAULT_NAME(token)) symbol = click.prompt(f"Set symbol", default=DEFAULT_VAULT_SYMBOL(token)) click.echo(f""" Vault Parameters version: {PACKAGE_VERSION} token: {token.address} governer: {gov} rewards: {rewards} guardian: {guardian} name: '{name}' symbol: '{symbol}' """) if click.confirm("Deploy New Vault"): args = [ token, gov, rewards, # NOTE: Empty string `""` means no override (don't use click default tho) name if name != DEFAULT_VAULT_NAME(token) else "", symbol if symbol != DEFAULT_VAULT_SYMBOL(token) else "", ] if use_proxy: # NOTE: Must always include guardian, even if default args.insert(3, guardian) txn_receipt = registry.newExperimentalVault(*args, {"from": dev}) vault = Vault.at( txn_receipt.events["NewExperimentalVault"]["vault"]) click.echo(f"Experimental Vault deployed [{vault.address}]") click.echo(" NOTE: Vault is not registered in Registry!") else: if guardian != dev.address: # NOTE: Only need to include if guardian is not self args.push(guardian) vault = dev.deploy(Vault) vault.initialize(*args) click.echo(f"New Vault Release deployed [{vault.address}]") click.echo( " NOTE: Vault is not registered in Registry, please register!" )
def main(deployment_address=DEPLOYER): deployer = accounts.at(deployment_address) if deployment_address else accounts[1] print("Deploying from:", deployer) if CONFS: deployer_kwargs = {'from': deployer, 'required_confs': CONFS} else: deployer_kwargs = {'from': deployer} if USE_MIDDLEWARE: web3.eth.setGasPriceStrategy(gas_strategy) web3.middleware_onion.add(middleware.time_based_cache_middleware) web3.middleware_onion.add(middleware.latest_block_based_cache_middleware) web3.middleware_onion.add(middleware.simple_cache_middleware) if POA: web3.middleware_onion.inject(middleware.geth_poa_middleware, layer=0) try: registry = Contract(CONTRACT) print("Using saved registry") except Exception: print("Deploying...") sleep(5) while True: try: registry = Registry.deploy(TETHERS, deployer_kwargs) except KeyError: continue break with open('registry.abi', 'w') as f: json.dump(registry.abi, f, indent=True) while True: try: calculator = CurveCalc.deploy(deployer_kwargs) except KeyError: continue break with open('calculator.abi', 'w') as f: json.dump(calculator.abi, f, indent=True) pools = POOLS pools = [insert_calculator(p, calculator) for p in pools] pools_no_underlying = POOLS_NO_UNDERLYING pools_no_underlying = [insert_calculator(p, calculator) for p in pools_no_underlying] length = len(pools) + len(pools_no_underlying) for i, pool in enumerate(pools + pools_no_underlying, start=1): print(f"Adding pool {i} out of {length}...") args = list(pool) + [deployer_kwargs] while True: try: if pool in pools: registry.add_pool(*args) elif pool in pools_no_underlying: registry.add_pool_without_underlying(*args) else: raise RuntimeError("Something weird happened.") except (KeyError, ValueError): continue break gas_prices_coins = list(GAS_PRICES_COINS.items()) gas_prices_pools = list(GAS_PRICES_POOLS.items()) for i in range(0, len(gas_prices_coins), 10): chunk = gas_prices_coins[i:(i + 10)] chunk += [(ZERO_ADDRESS, 0)] * (10 - len(chunk)) addrs, gas = list(zip(*chunk)) registry.set_coin_gas_estimates(addrs, gas, deployer_kwargs) for i in range(0, len(gas_prices_pools), 5): chunk = gas_prices_pools[i:(i + 5)] chunk += [(ZERO_ADDRESS, (0, 0))] * (5 - len(chunk)) addrs, gas = list(zip(*chunk)) registry.set_pool_gas_estimates(addrs, gas, deployer_kwargs) registry.commit_transfer_ownership(DEPLOYER_DEST, deployer_kwargs)