diff --git a/contracts/interfaces/MainRegistry.json b/contracts/interfaces/MainRegistry.json index 12580ca..4c83faa 100644 --- a/contracts/interfaces/MainRegistry.json +++ b/contracts/interfaces/MainRegistry.json @@ -937,4 +937,4 @@ ], "gas": 2288 } - ] \ No newline at end of file + ] diff --git a/scripts/boa_scripts/set_up_registries.py b/scripts/boa_scripts/set_up_registries.py new file mode 100644 index 0000000..b383ff8 --- /dev/null +++ b/scripts/boa_scripts/set_up_registries.py @@ -0,0 +1,149 @@ +# flake8: noqa + +import os +import sys +from dataclasses import dataclass +from typing import List + +import boa +import deployment_utils as deploy_utils +from boa.network import NetworkEnv +from deploy_infra import deployments +from eth_account import Account +from eth_typing import Address +from eth_utils import to_checksum_address +from rich.console import Console as RichConsole + +logger = RichConsole(file=sys.stdout) + + +def deploy_factory_handler(): + + pass + + +def set_up_registries(network, url, account, fork: bool = False): + + logger.log(f"Connecting to {network} ...") + if fork: + boa.env.fork(url) + boa.env.eoa = deploy_utils.FIDDYDEPLOYER + logger.log("Forkmode") + else: + logger.log("Prodmode") + boa.set_env(NetworkEnv(url)) + boa.env.add_account(Account.from_key(os.environ[account])) + + 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}." + + # -------------------------- 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!") + + +def main(): + + fork = False + + set_up_registries( + "ethereum:mainnet", + os.environ["RPC_ETHEREUM"], + "FIDDYDEPLOYER", + fork=fork, + ) + + +if __name__ == "__main__": + main() diff --git a/scripts/set_sbtc2_gauges.py b/scripts/set_sbtc2_gauges.py deleted file mode 100644 index 6905d71..0000000 --- a/scripts/set_sbtc2_gauges.py +++ /dev/null @@ -1,71 +0,0 @@ -from brownie import ( - Contract, - ZERO_ADDRESS, - accounts, - config -) - -config['autofetch_sources'] = True - -ADDRESS_PROVIDER = "0x0000000022D53366457F9d5E68Ec105046FC4383" -babe = accounts.load('babe') -txparams = { - "from": babe, 'priority_fee': '1 gwei', 'required_confs': 5 -} - -POOL_DATA = { - "pool": "0xf253f83AcA21aAbD2A20553AE0BF7F65C755A07F", - "lp_token": "0x051d7e5609917Bd9b73f04BAc0DED8Dd46a74301", - "num_coins": 2, - "is_legacy": False, - "is_lending": False, - "is_v2": True, - "gauge": "0x6D787113F23bED1D5e1530402B3f364D0A6e5Af3" -} - - -def main(): - - # admin only: only admin of ADDRESSPROVIDER's proxy admin can do the following: - address_provider = Contract(ADDRESS_PROVIDER) - address_provider_admin = address_provider.admin() - proxy_admin = Contract(address_provider_admin) - base_pool_registry = Contract("0xDE3eAD9B2145bBA2EB74007e58ED07308716B725") - stable_registry = Contract("0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5") - metaregistry = Contract("0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC") - - assert not metaregistry.get_gauge(POOL_DATA["pool"]) == POOL_DATA["gauge"] - - # --- add base pool to base pool registry --- - call_data = base_pool_registry.add_base_pool.encode_input( - POOL_DATA["pool"], - POOL_DATA["lp_token"], - POOL_DATA["num_coins"], - POOL_DATA["is_legacy"], - POOL_DATA["is_lending"], - POOL_DATA["is_v2"], - ) - - proxy_admin.execute(base_pool_registry, call_data, txparams) - base_pool_index = base_pool_registry.base_pool_count() - 1 - assert ( - base_pool_registry.base_pool_list(base_pool_index) - == POOL_DATA["pool"] - ) - - # --- add base pool's gauge to base registry --- - gauges = stable_registry.get_gauges(POOL_DATA["pool"]) - assert gauges[0][0] == ZERO_ADDRESS - - call_data = stable_registry.set_liquidity_gauges.encode_input( - POOL_DATA["pool"], - [POOL_DATA["gauge"]] + [ZERO_ADDRESS]*9 - ) - proxy_admin.execute(stable_registry, call_data, txparams) - - gauges = stable_registry.get_gauges(POOL_DATA["pool"]) - assert gauges[0][0] == POOL_DATA["gauge"] - - # check if metaregistry has the gauge - assert metaregistry.get_gauge(POOL_DATA["pool"]) == POOL_DATA["gauge"] - print("success!")