From 61f497f6315c31d33d8002b5c4827f20d9188055 Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:32:40 +0100 Subject: [PATCH] add boa scripts and remove ape script --- scripts/deploy.py | 188 ---------------------------------- scripts/deploy_pool.py | 132 +++++++++++++++++++++++- scripts/deploy_proxy_admin.py | 7 +- scripts/deployment_utils.py | 60 +---------- 4 files changed, 136 insertions(+), 251 deletions(-) delete mode 100644 scripts/deploy.py diff --git a/scripts/deploy.py b/scripts/deploy.py deleted file mode 100644 index 231796c2..00000000 --- a/scripts/deploy.py +++ /dev/null @@ -1,188 +0,0 @@ -import click -from ape import Contract, accounts, project -from ape.cli import NetworkBoundCommand, account_option, network_option -from ape.logging import logger - -import scripts.deployment_utils as deploy_utils - - -@click.group(short_help="Deploy the project") -def cli(): - pass - - -@cli.command(cls=NetworkBoundCommand) -@network_option() -@account_option() -def deploy_infra(network, account): - - if account.alias == "fiddydeployer": - account.set_autosign(True) - - for _network, data in deploy_utils.curve_dao_network_settings.items(): - - if _network in network: - - owner = data.dao_ownership_contract - fee_receiver = data.fee_receiver_address - - assert owner, f"Curve's DAO contracts may not be on {network}." - assert fee_receiver, f"Curve's DAO contracts may not be on {network}." - - with accounts.use_sender(account): - - # --------------------- Deploy math, views, blueprints --------------------- - - logger.info("Deploying AMM components ...") - math_contract = account.deploy( - project.CurveStableSwapNGMath, - **deploy_utils._get_tx_params(), - ) - views_contract = account.deploy( - project.CurveStableSwapNGViews, - **deploy_utils._get_tx_params(), - ) - plain_blueprint_contract = deploy_utils.deploy_blueprint(project.CurveStableSwapNG, account) - meta_blueprint_contract = deploy_utils.deploy_blueprint(project.CurveStableSwapMetaNG, account) - gauge_blueprint_contract = deploy_utils.deploy_blueprint(project.LiquidityGauge, account) - - # --------------------- DEPLOY FACTORY --------------------------- - - logger.info("Deploying factory ...") - factory = account.deploy( - project.CurveStableSwapFactoryNG, - deploy_utils.curve_dao_network_settings[network].fee_receiver_address, # fee_receiver - account, # owner (temporary) - ) - - logger.info("Integrating AMM components into factory ...") - - factory.set_gauge_implementation(gauge_blueprint_contract, **deploy_utils._get_tx_params()) - factory.set_views_implementation(views_contract, **deploy_utils._get_tx_params()) - factory.set_math_implementation(math_contract, **deploy_utils._get_tx_params()) - - factory.set_pool_implementations(0, plain_blueprint_contract, **deploy_utils._get_tx_params()) - factory.set_metapool_implementations(0, meta_blueprint_contract, **deploy_utils._get_tx_params()) - - -@cli.command(cls=NetworkBoundCommand) -@network_option() -@account_option() -@click.option("--factory", required=True, type=str) -def set_up_base_pools(network, account, factory): - - logger.info("Setting up base pools ...") - base_pool_data = deploy_utils.base_pool_list[network] - if base_pool_data: # check if network has base pools: - for data in base_pool_data: - factory.add_base_pool( - data.pool, - data.lp_token, - data.coins, - data.asset_types, - data.n_coins, - **deploy_utils._get_tx_params(), - ) - logger.info(f"Added {data.pool} to factory") - - -@cli.command(cls=NetworkBoundCommand) -@network_option() -@account_option() -@click.option("--factory", required=True, type=str) -def set_up_registries(network, account, factory): - - if account.alias == "fiddydeployer": - account.set_autosign(True) - - for _network, data in deploy_utils.curve_dao_network_settings.items(): - - if _network in network: - - owner = data.dao_ownership_contract - fee_receiver = data.fee_receiver_address - address_provider = Contract(data.address_provider) - - assert owner, f"Curve's DAO contracts may not be on {network}." - assert fee_receiver, f"Curve's DAO contracts may not be on {network}." - - with accounts.use_sender(account): - - # -------------------------- Register into AddressProvider -------------------------- - - max_id = address_provider.max_id() - description = "Curve StableSwapNG" - boss = Contract(address_provider.admin()) - - # check if account can handle boss: - account_is_boss_handler = False - for i in range(2): - if account.address.lower() == boss.admins(i).lower(): - account_is_boss_handler = True - break - - assert account_is_boss_handler # only authorised accounts can write to address provider # noqa: E501 - - for index in range(max_id + 1): - if address_provider.get_id_info(index).description is description: - break - - if index == max_id: - - logger.info(f"Adding a new registry provider entry at id: {index + 1}") - - # we're adding a new id - with accounts.use_sender(account) as account: - boss.execute( - address_provider.address, - address_provider.add_new_id.encode_input(factory, description), - gas_limit=400000, - **deploy_utils._get_tx_params(), - ) - - else: - - assert address_provider.get_id_info(index).description == description - - logger.info(f"Updating existing registry provider entry at id: {index}") - - # we're updating an existing id with the same description: - with accounts.use_sender(account) as account: - boss.execute( - address_provider.address, - address_provider.set_address.encode_input(index, factory), - gas_limit=200000, - **deploy_utils._get_tx_params(), - ) - - assert address_provider.get_id_info(index).addr.lower() == factory.lower() - - logger.info("AddressProvider integration complete!") - - # -------------------------- Set up metaregistry -------------------------- - - metaregistry_address = deploy_utils.curve_dao_network_settings[network].metaregistry_address - base_pool_registry_address = deploy_utils.curve_dao_network_settings[network].base_pool_registry_address - - if metaregistry_address: - - metaregistry = Contract(metaregistry_address) - boss = Contract(metaregistry.owner()) - - # set up metaregistry integration: - logger.info("Integrate into Metaregistry ...") - logger.info("Deploying Factory handler to integrate it to the metaregistry:") - factory_handler = account.deploy( - project.CurveStableSwapFactoryNGHandler, - factory.address, - base_pool_registry_address, - **deploy_utils._get_tx_params(), - ) - - boss.execute( - metaregistry.address, - metaregistry.add_registry_handler.encode_input(factory_handler), - **deploy_utils._get_tx_params(), - ) - - logger.info("Metaregistry integration complete!") diff --git a/scripts/deploy_pool.py b/scripts/deploy_pool.py index 93355b6a..342e249c 100644 --- a/scripts/deploy_pool.py +++ b/scripts/deploy_pool.py @@ -1,21 +1,144 @@ import os import sys +from dataclasses import dataclass +from typing import List import boa from boa.network import NetworkEnv -from deploy_infra import deployments -from deployment_utils import pool_settings from eth_account import Account +from eth_typing import Address from rich.console import Console as RichConsole logger = RichConsole(file=sys.stdout) +ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" +deployments = { + # Ethereum + "ethereum:sepolia": { + "factory": "0xfb37b8D939FFa77114005e61CFc2e543d6F49A81", + }, + "ethereum:mainnet": { + "factory": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf", + }, + # Layer 2 + "arbitrum:mainnet": { + "factory": "0x9AF14D26075f142eb3F292D5065EB3faa646167b", + }, + "optimism:mainnet": { + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + }, + "base:mainnet": { + "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", + }, + "linea:mainnet": { + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + }, + "scroll:mainnet": { + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + }, + "zksync:mainnet": { + "factory": "", + }, + "pzkevm:mainnet": { + "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", + }, + "mantle:mainnet": {"factory": ""}, + # Layer 1 + "gnosis:mainnet": { + "factory": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + }, + "polygon:mainnet": { + "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + }, + "avax:mainnet": { + "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + }, + "ftm:mainnet": { + "factory": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b", + }, + "bsc:mainnet": { + "factory": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", + }, + "celo:mainnet": { + "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + }, + "kava:mainnet": { + "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + }, + "aurora:mainnet": { + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + }, + "tron:mainnet": { + "factory": "", + }, +} -def deploy_pool(network, url, account, fork, pool_type): + +# -------------------------- POOL SETUP -------------------------- + + +@dataclass +class PoolSettings: + name: str + symbol: str + coins: List[Address] + A: int + fee: int + offpeg_fee_multiplier: int + ma_exp_time: int + implementation_idx: int + asset_types: List[int] + method_ids: List[int] + oracles: List[Address] + + +pool_settings = { + "gnosis:mainnet": { + "plain": [ + "WXDAI/USDC/USDT", # name + "3pool-ng", # symbol + [ + "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d", # wxdai + "0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83", # usdc + "0x4ECaBa5870353805a9F068101A40E0f32ed605C6", # usdt + ], + 1000, # A + 1000000, # fee + 20000000000, # offpeg_fee_multiplier + 865, # ma_exp_time + 0, # implementation index + [0, 0, 0], # asset_types + [b"", b"", b""], # method_ids + [ZERO_ADDRESS, ZERO_ADDRESS, ZERO_ADDRESS], # oracles + ], + "meta": [ + "0x7f90122bf0700f9e7e1f688fe926940e8839f353", # base_pool + "EURE/3CRV", # name + "eure3crvng", # symbol + "0xcb444e90d8198415266c6a2724b7900fb12fc56e", # eure + 500, # A + 1000000, # fee + 20000000000, # offpeg_fee_multiplier + 865, # ma_exp_time + 0, # implementation index + 0, # asset_types + b"", # method_ids + ZERO_ADDRESS, # oracles + ], + } +} + + +def deploy_pool(network, url, account, pool_type, fork): + + logger.log(f"Deploying pool on {network} ...") if fork: boa.env.fork(url) + logger.log("Forkmode ...") + boa.env.eoa = "" # set eoa address here else: + logger.log("Prodmode ...") boa.set_env(NetworkEnv(url)) boa.env.add_account(Account.from_key(os.environ[account])) @@ -33,7 +156,8 @@ def deploy_pool(network, url, account, fork, pool_type): def main(): - deploy_pool("gnosis:mainnet", "https://gnosis.drpc.org", "FIDDYDEPLOYER", False, "meta") # forkmode + fork = True + deploy_pool("gnosis:mainnet", "https://gnosis.drpc.org", "FIDDYDEPLOYER", "meta", fork) if __name__ == "__main__": diff --git a/scripts/deploy_proxy_admin.py b/scripts/deploy_proxy_admin.py index 69263731..e65e8ae3 100644 --- a/scripts/deploy_proxy_admin.py +++ b/scripts/deploy_proxy_admin.py @@ -19,6 +19,7 @@ def deploy_proxy_admin(network, url, account, fork=False): if fork: boa.env.fork(url) logger.log("Forkmode ...") + boa.env.eoa = deploy_utils.FIDDYDEPLOYER else: logger.log("Prodmode ...") boa.set_env(NetworkEnv(url)) @@ -35,10 +36,10 @@ def deploy_proxy_admin(network, url, account, fork=False): def main(): deploy_proxy_admin( - "pzkevm:mainnet", - os.environ["RPC_PZKEVM"], + "mantle:mainnet", + os.environ["RPC_MANTLE"], "FIDDYDEPLOYER", - fork=False, + fork=True, ) diff --git a/scripts/deployment_utils.py b/scripts/deployment_utils.py index 2dd1ac0b..3570375b 100644 --- a/scripts/deployment_utils.py +++ b/scripts/deployment_utils.py @@ -1,5 +1,4 @@ from dataclasses import dataclass -from typing import List import click from ape import networks, project @@ -8,7 +7,6 @@ # from eth_utils import function_signature_to_4byte_selector DOLLAR_VALUE_OF_TOKENS_TO_DEPOSIT = 5 -ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" def _get_tx_params(): @@ -146,6 +144,10 @@ class CurveNetworkSettings: dao_ownership_contract="", fee_receiver_address="", ), + "mantle:mainnet": CurveNetworkSettings( + dao_ownership_contract="", + fee_receiver_address="", + ), } @@ -155,57 +157,3 @@ class CurveNetworkSettings: "token": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2", "quorum": 30, } - -# -------------------------- POOL SETUP -------------------------- - - -@dataclass -class PoolSettings: - name: str - symbol: str - coins: List[Address] - A: int - fee: int - offpeg_fee_multiplier: int - ma_exp_time: int - implementation_idx: int - asset_types: List[int] - method_ids: List[int] - oracles: List[Address] - - -pool_settings = { - "gnosis:mainnet": { - "plain": [ - "WXDAI/USDC/USDT", # name - "3pool-ng", # symbol - [ - "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d", # wxdai - "0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83", # usdc - "0x4ECaBa5870353805a9F068101A40E0f32ed605C6", # usdt - ], - 1000, # A - 1000000, # fee - 20000000000, # offpeg_fee_multiplier - 865, # ma_exp_time - 0, # implementation index - [0, 0, 0], # asset_types - [b"", b"", b""], # method_ids - [ZERO_ADDRESS, ZERO_ADDRESS, ZERO_ADDRESS], # oracles - ], - "meta": [ - "0x7f90122bf0700f9e7e1f688fe926940e8839f353", # base_pool - "EURE/3CRV", # name - "eure3crvng", # symbol - "0xcb444e90d8198415266c6a2724b7900fb12fc56e", # eure - 500, # A - 1000000, # fee - 20000000000, # offpeg_fee_multiplier - 865, # ma_exp_time - 0, # implementation index - 0, # asset_types - b"", # method_ids - ZERO_ADDRESS, # oracles - ], - } -}