From 902abc2bf72bbeb2ca4b7a3c497c853454a222df Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:54:06 +0200 Subject: [PATCH 1/3] add script to deploy all registries at once --- deployments.yaml | 10 +- scripts/add_new_id_addressprovider.py | 5 +- scripts/address_provider_constants.py | 6 +- ...deploy_addressprovider_and_setup_zksync.py | 2 +- scripts/deploy_metaregistryl2.py | 8 +- scripts/deploy_rate_provider.py | 2 +- scripts/deploy_registries_zksync.py | 375 ++++++++++++++++++ scripts/update_address_provider.py | 144 +++++++ 8 files changed, 539 insertions(+), 13 deletions(-) create mode 100644 scripts/deploy_registries_zksync.py create mode 100644 scripts/update_address_provider.py diff --git a/deployments.yaml b/deployments.yaml index d78fe13..4c8ab8c 100644 --- a/deployments.yaml +++ b/deployments.yaml @@ -72,7 +72,9 @@ polygon: TricryptoFactoryNGHandler: '0xf46D25696677898454dfDd644830C821243A1188' TwocryptoFactoryNGHandler: '0xb00e89eabd59cd3254c88e390103cf17e914f678' zksync: - Metaregistry: '0x48e4b27553e7643E10229ea3cba91c188dc524B1' - StableswapFactoryNGHandler: '0x4Cabf81fbf1F42531d55507F38Be77367481a8dF' - TricryptoFactoryNGHandler: '0xf3f38b1677553789A048FFf4A2CeedCDf063309e' - TwocryptoFactoryNGHandler: '0x0F3d82D719582BcaB662F434D77B089C86D05FAb' + AddressProvider: '0xBF664Ac8e934230FC6A381702678cc29661d38D5' + Metaregistry: '' + RateProvider: '0x9eB20D123F877f06c93CE82De4507B0911dFA783' + StableswapFactoryNGHandler: '' + TricryptoFactoryNGHandler: '' + TwocryptoFactoryNGHandler: '' diff --git a/scripts/add_new_id_addressprovider.py b/scripts/add_new_id_addressprovider.py index db716ab..cdfcfd4 100644 --- a/scripts/add_new_id_addressprovider.py +++ b/scripts/add_new_id_addressprovider.py @@ -11,6 +11,9 @@ from eth_account import Account from rich.console import Console as RichConsole +import sys +sys.path.append("./") + from scripts.address_provider_constants import ( ADDRESS_PROVIDER_MAPPING, addresses, @@ -100,7 +103,7 @@ def main(network, fork, url): import boa_zksync url = "https://mainnet.era.zksync.io" - ADDRESS_PROVIDER = "0x54A5a69e17Aa6eB89d77aa3828E38C9Eb4fF263D" + ADDRESS_PROVIDER = "0x3934a3bB913E4a44316a89f5a83876B9C63e4F31" elif network == "fraxtal": network_url = "https://rpc.frax.com" elif network == "kava": diff --git a/scripts/address_provider_constants.py b/scripts/address_provider_constants.py index f7c25ea..f5ddd97 100644 --- a/scripts/address_provider_constants.py +++ b/scripts/address_provider_constants.py @@ -309,9 +309,9 @@ "zksync": { 2: "0x7C915390e109CA66934f1eB285854375D1B127FA", # 2: "Exchange Router", 4: "0xCb8799BFF48bb549F7B69Bb9BE60DbA7cd4F1BB7", # 4: "Fee Distributor", - 11: "0x5044112fDf6c8DCc788a669c17345cfDB06549fa", # 11: "TricryptoNG Factory", - 12: "0x375444aeDEb6C3db897f293E1DBa85D7422A6859", # 12: "StableswapNG Factory", - 13: "0x24992A09E2257AF325102Cefa1F09E80E9062d49", # 13: "TwocryptoNG Factory", + 11: "0x5d4174C40f1246dABe49693845442927d5929f0D", # 11: "TricryptoNG Factory", + 12: "0xFcAb5d04e8e031334D5e8D2C166B08daB0BE6CaE", # 12: "StableswapNG Factory", + 13: "0xf3a546AF64aFd6BB8292746BA66DB33aFAE72114", # 13: "TwocryptoNG Factory", 19: "0x5945932099f124194452a4c62d34bB37f16183B2", # 19: "CRV Token", 20: "", # 20: "Gauge Factory", 21: "", # 21: "Ownership Admin", diff --git a/scripts/deploy_addressprovider_and_setup_zksync.py b/scripts/deploy_addressprovider_and_setup_zksync.py index b3841d0..b13a51e 100644 --- a/scripts/deploy_addressprovider_and_setup_zksync.py +++ b/scripts/deploy_addressprovider_and_setup_zksync.py @@ -1,4 +1,4 @@ -# AddressProvider deployed on zksync at: 0x54A5a69e17Aa6eB89d77aa3828E38C9Eb4fF263D +# AddressProvider deployed on zksync at: 0x3934a3bB913E4a44316a89f5a83876B9C63e4F31 import os diff --git a/scripts/deploy_metaregistryl2.py b/scripts/deploy_metaregistryl2.py index 0c87d8b..4493b5d 100644 --- a/scripts/deploy_metaregistryl2.py +++ b/scripts/deploy_metaregistryl2.py @@ -262,8 +262,11 @@ def main(network, fork, url): console.log("Deploying Metaregistry ...") gauge_factory = address_provider.get_address(20) # 20 is for Gauge Factory gauge_type = GAUGE_TYPE[network] + + deploy_mregistry = metaregistry_address == ZERO_ADDRESS + deploy_mregistry = False - if metaregistry_address == ZERO_ADDRESS: + if deploy_mregistry: metaregistry = deploy_and_cache_contracts( network, "Metaregistry", @@ -303,9 +306,8 @@ def main(network, fork, url): if network == "zksync": import boa_zksync - url = "https://mainnet.era.zksync.io" - ADDRESS_PROVIDER = "0x54A5a69e17Aa6eB89d77aa3828E38C9Eb4fF263D" + ADDRESS_PROVIDER = "0x3934a3bB913E4a44316a89f5a83876B9C63e4F31" elif network == "fraxtal": network_url = "https://rpc.frax.com" elif network == "kava": diff --git a/scripts/deploy_rate_provider.py b/scripts/deploy_rate_provider.py index 4758560..e79c053 100644 --- a/scripts/deploy_rate_provider.py +++ b/scripts/deploy_rate_provider.py @@ -69,7 +69,7 @@ def main(network, fork, url): import boa_zksync network_url = "https://mainnet.era.zksync.io" - ADDRESS_PROVIDER = "0x54A5a69e17Aa6eB89d77aa3828E38C9Eb4fF263D" + ADDRESS_PROVIDER = "0x3934a3bB913E4a44316a89f5a83876B9C63e4F31" elif network == "fraxtal": network_url = "https://rpc.frax.com" elif network == "kava": diff --git a/scripts/deploy_registries_zksync.py b/scripts/deploy_registries_zksync.py new file mode 100644 index 0000000..106cc01 --- /dev/null +++ b/scripts/deploy_registries_zksync.py @@ -0,0 +1,375 @@ +# flake8: noqa + +import os +import sys + +import boa +import yaml +from boa.network import NetworkEnv +from eth.constants import ZERO_ADDRESS +from eth_account import Account +from rich import console as rich_console + +sys.path.append("./") +from scripts.deploy_addressprovider_and_setup import fetch_url +from scripts.address_provider_constants import ( + ADDRESS_PROVIDER_MAPPING, + addresses, +) +from scripts.legacy_base_pools import base_pools as BASE_POOLS +from scripts.utils.constants import FIDDY_DEPLOYER + +console = rich_console.Console() + +ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" + +# if -1: no gauge type known just yet +GAUGE_TYPE = { + "arbitrum": 7, + "optimism": 11, + "polygon": 2, + "base": 0, + "fraxtal": 11, + "bsc": 12, + "gnosis": 4, + "fantom": 1, + "avalanche": 8, + "aurora": -1, + "celo": -1, + "kava": 9, + "mantle": -1, + "linea": -1, + "scroll": -1, + "polygon-zkevm": -1, + "xlayer": -1, + "zksync": -1, +} + + +def check_contract_deployed(network, designation): + with open("./deployments.yaml", "r") as file: + deployments = yaml.safe_load(file) + + if deployments is None: + deployments = {} + + if ( + network in deployments.keys() + and designation in deployments[network].keys() + ): + contract_address = deployments[network][designation] + console.log( + f"{designation} deployed already at {network}: {contract_address}" + ) + return contract_address + + return ZERO_ADDRESS + + +def store_deployed_contract(network, designation, deployment_address): + with open("./deployments.yaml", "r") as file: + deployments = yaml.safe_load(file) + + if deployments is None: + deployments = {} + + if not network in deployments.keys(): + deployments[network] = {} + + deployments[network][designation] = str(deployment_address) + with open("./deployments.yaml", "w") as file: + yaml.dump(deployments, file) + + +def deploy_and_cache_contracts( + network, designation, contract_file, args, fork=False +): + contract_address = check_contract_deployed(network, designation) + if contract_address != ZERO_ADDRESS: + return boa.load_partial(contract_file).at(contract_address) + + deployed_contract = boa.load(contract_file, *args) + if not fork: + store_deployed_contract( + network, designation, deployed_contract.address + ) + + return deployed_contract + + +def deploy_base_pool_registry(network, fork): + # deploy base pool registry (even if there are no legacy base pools): + console.log("Deploying base pool registry ...") + base_pools = [] + if network in BASE_POOLS.keys(): + base_pools = BASE_POOLS[network] + + base_pools_registry = deploy_and_cache_contracts( + network, + "BasePoolRegistry", + "contracts/registries/BasePoolRegistry.vy", + [], + fork, + ) + + # will add new base pools if registry does not have it: + if not len(base_pools) == base_pools_registry.base_pool_count(): + console.log("Adding base pools to the base pool registry ...") + added_base_pools = [ + base_pools_registry.base_pool_list(i) + for i in range(len(base_pools)) + ] + for base_pool in base_pools: + if not base_pool[0] in added_base_pools: + base_pools_registry.add_base_pool(*base_pool) + + return base_pools_registry + + +def legacy_deployment(address_provider, metaregistry, registry_list): + # deploy stableswap registry and factory handlers + stableswap_custom_pool_registry = address_provider.get_address(0) + if stableswap_custom_pool_registry != ZERO_ADDRESS: + console.log( + "Adding stableswap custom pool registry to the Metaregistry ..." + ) + registry_handler = deploy_and_cache_contracts( + network, + "StableRegistryHandler", + "contracts/registry_handlers/StableRegistryHandler.vy", + [stableswap_custom_pool_registry], + fork, + ) + if registry_handler.address not in registry_list: + metaregistry.add_registry_handler(registry_handler.address) + + stableswap_factory = address_provider.get_address(3) + if stableswap_factory != ZERO_ADDRESS: + # we need the base pools registry for legacy deployments + base_pools_registry = deploy_base_pool_registry(network, fork) + + console.log("Adding stableswap factory to the Metaregistry ...") + registry_handler = deploy_and_cache_contracts( + network, + "StableFactoryHandler", + "contracts/registry_handlers/StableFactoryHandler.vy", + [stableswap_factory, base_pools_registry.address], + fork, + ) + if registry_handler.address not in registry_list: + metaregistry.add_registry_handler(registry_handler.address) + + # deploy cryptoswap registry and factory handlers + cryptoswap_custom_pool_registry = address_provider.get_address(5) + if cryptoswap_custom_pool_registry != ZERO_ADDRESS: + console.log( + "Adding cryptoswap custom pool registry to the Metaregistry ..." + ) + registry_handler = deploy_and_cache_contracts( + network, + "CryptoRegistryHandler", + "contracts/registry_handlers/CryptoRegistryHandler.vy", + [cryptoswap_custom_pool_registry], + fork, + ) + if registry_handler.address not in registry_list: + metaregistry.add_registry_handler(registry_handler.address) + + cryptoswap_factory = address_provider.get_address(6) + if cryptoswap_factory != ZERO_ADDRESS: + console.log("Adding cryptoswap factory to the Metaregistry ...") + registry_handler = deploy_and_cache_contracts( + network, + "CryptoFactoryHandler", + "contracts/registry_handlers/CryptoFactoryHandler.vy", + [cryptoswap_factory, base_pools_registry.address], + fork, + ) + if registry_handler.address not in registry_list: + metaregistry.add_registry_handler(registry_handler.address) + + +def ng_deployment(address_provider, metaregistry, registry_list): + # set up tricrypto ng factory handler + tricrypto_ng_factory = address_provider.get_address(11) + if tricrypto_ng_factory != ZERO_ADDRESS: + console.log("Adding Tricrypto Factory NG Handler ...") + registry_handler = deploy_and_cache_contracts( + network, + "TricryptoFactoryNGHandler", + "contracts/registry_handlers/ng/CurveTricryptoFactoryHandler.vy", + [tricrypto_ng_factory], + fork, + ) + if registry_handler.address not in registry_list: + metaregistry.add_registry_handler(registry_handler.address) + + # set up stableswap ng factory handler + stableswap_ng_factory = address_provider.get_address(12) + if stableswap_ng_factory != ZERO_ADDRESS: + console.log("Adding Stableswap Factory NG Handler ...") + registry_handler = deploy_and_cache_contracts( + network, + "StableswapFactoryNGHandler", + "contracts/registry_handlers/ng/CurveStableSwapFactoryNGHandler.vy", + [stableswap_ng_factory], + fork, + ) + if registry_handler.address not in registry_list: + metaregistry.add_registry_handler(registry_handler.address) + + # set up twocrypto ng factory handler + twocrypto_ng_factory = address_provider.get_address(13) + if twocrypto_ng_factory != ZERO_ADDRESS: + console.log("Adding Twocrypto Factory NG Handler ...") + registry_handler = deploy_and_cache_contracts( + network, + "TwocryptoFactoryNGHandler", + "contracts/registry_handlers/ng/CurveTwocryptoFactoryHandler.vy", + [twocrypto_ng_factory], + fork, + ) + if registry_handler.address not in registry_list: + metaregistry.add_registry_handler(registry_handler.address) + + +def main(network, fork, url): + if network == "zksync": + if not fork: + boa_zksync.set_zksync_env(url) + console.log("Prodmode on zksync Era ...") + else: + boa_zksync.set_zksync_fork(url) + console.log("Forkmode on zksync Era ...") + + boa.env.set_eoa(Account.from_key(os.environ["FIDDYDEPLOYER"])) + + else: + if fork: + boa.env.fork(url) + console.log("Forkmode ...") + boa.env.eoa = FIDDY_DEPLOYER # set eoa address here + else: + console.log("Prodmode ...") + boa.set_env(NetworkEnv(url)) + boa.env.add_account(Account.from_key(os.environ["FIDDYDEPLOYER"])) + + # deploy address provider: + address_provider = deploy_and_cache_contracts( + network, + "AddressProvider", + "contracts/AddressProviderNG.vy", + [], + fork, + ) + + # deploy rate provider: + rate_provider = deploy_and_cache_contracts( + network, + "RateProvider", + "contracts/RateProvider.vy", + [address_provider.address], + fork, + ) + + console.log("Adding rate provider to address provider") + if address_provider.get_address(18) == ZERO_ADDRESS: + address_provider.add_new_id( + 18, rate_provider.address, "Spot Rate Provider" + ) + elif address_provider.get_address(18) != rate_provider.address: + address_provider.update_address(18, rate_provider.address) + + # set up address provider: + ids = [] + addresses_for_id = [] + descriptions = [] + for id in addresses[network].keys(): + address = addresses[network][id] + description = ADDRESS_PROVIDER_MAPPING[id] + existing_id = address_provider.get_id_info(id) + + if not address: + continue + + if ( + existing_id[0].lower() + == "0x0000000000000000000000000000000000000000" + ): + console.log(f"New id {id} at {address} for {description}.") + ids.append(id) + addresses_for_id.append(address) + descriptions.append(description) + + elif existing_id[0].lower() != address.lower(): + console.log(f"Updating id {id} for {description} with {address}.") + address_provider.update_id(id, address, description) + + if len(ids) > 20: + raise + + if len(ids) > 0: + console.log("Adding new IDs to the Address Provider.") + address_provider.add_new_ids(ids, addresses_for_id, descriptions) + + # metaregistry deployment: + metaregistry_address = address_provider.get_address(7) + + # deploy metaregistry or fetch if it doesnt exist: + console.log("Deploying Metaregistry ...") + gauge_factory = address_provider.get_address(20) # 20 is for Gauge Factory + gauge_type = GAUGE_TYPE[network] + + deploy_mregistry = metaregistry_address == ZERO_ADDRESS + deploy_mregistry = False + + if deploy_mregistry: + metaregistry = deploy_and_cache_contracts( + network, + "Metaregistry", + "contracts/MetaregistryL2.vy", + [gauge_factory, gauge_type], + fork, + ) + + # Add Metaregistry to AddressProvider + console.log("Add Metaregistry to AddressProvider ...") + address_provider.add_new_id(7, metaregistry.address, "Metaregistry") + else: + metaregistry = boa.load_partial("contracts/MetaRegistryL2.vy").at( + metaregistry_address + ) + + registry_list = [ + metaregistry.get_registry(i) + for i in range(metaregistry.registry_length()) + ] + + # legacy registry handlers deployment: + legacy_deployment(address_provider, metaregistry, registry_list) + + # ng registry handlers deployment: + ng_deployment(address_provider, metaregistry, registry_list) + + console.log( + f"Deployment and integration of the Metaregistry on {network} completed." + ) + + +if __name__ == "__main__": + network = "zksync" + url = "" + fork = False + + if network == "zksync": + import boa_zksync + url = "https://mainnet.era.zksync.io" + ADDRESS_PROVIDER = "0x3934a3bB913E4a44316a89f5a83876B9C63e4F31" + elif network == "fraxtal": + network_url = "https://rpc.frax.com" + elif network == "kava": + network_url = "https://rpc.ankr.com/kava_evm" + else: + network_url = fetch_url(network) + + main(network, fork, url) diff --git a/scripts/update_address_provider.py b/scripts/update_address_provider.py new file mode 100644 index 0000000..797d3af --- /dev/null +++ b/scripts/update_address_provider.py @@ -0,0 +1,144 @@ +# flake8 no-qa E402 +# Contract deployed at: 0x5ffe7FB82894076ECB99A30D6A32e969e6e35E98 +# Deployed at: Ethereum, Arbitrum, Optimism, Base, Bsc, Polygon, +# Fantom, Gnosis, Aurora, Celo, Mantle, +# Linea, Polygon zkEVM, Scroll, Fraxtal, Avalanche, Kava + +import os + +import boa +from boa.network import NetworkEnv +from eth_account import Account +from rich.console import Console as RichConsole + + +FIDDY_DEPLOYER = "0x2d12D0907A388811e3AA855A550F959501d303EE" +ADDRESS_PROVIDER = ( + "0x5ffe7FB82894076ECB99A30D6A32e969e6e35E98" # gets replaced for zksync +) +to_update = { + "ethereum": { + 2: '0x16C6521Dff6baB339122a0FE25a9116693265353', + 4: '0xD16d5eC345Dd86Fb63C6a9C43c517210F1027914', + }, + "optimism": { + 2: '0x0DCDED3545D565bA3B19E683431381007245d983', + }, + "gnosis": { + 2: '0x0DCDED3545D565bA3B19E683431381007245d983', + }, + "polygon": { + 2: '0x0DCDED3545D565bA3B19E683431381007245d983', + }, + "fantom": { + 2: '0x0DCDED3545D565bA3B19E683431381007245d983', + }, + "kava": { + 2: '0x0DCDED3545D565bA3B19E683431381007245d983', + }, + "arbitrum": { + 2: '0x2191718CD32d02B8E60BAdFFeA33E4B5DD9A0A0D', + }, + "avalanche": { + 2: '0x0DCDED3545D565bA3B19E683431381007245d983', + }, + "base": { + 2: '0x4f37A9d177470499A2dD084621020b023fcffc1F', + }, + "bsc": { + 2: '0xA72C85C258A81761433B4e8da60505Fe3Dd551CC', + }, + "fraxtal": { + 2: '0x9f2Fa7709B30c75047980a0d70A106728f0Ef2db', + }, + "xlayer": { + 2: '0xBFab8ebc836E1c4D81837798FC076D219C9a1855', + }, + "mantle": { + 2: '0x4f37A9d177470499A2dD084621020b023fcffc1F', + }, + "zksync": { + 2: '0x7C915390e109CA66934f1eB285854375D1B127FA', + }, +} + + +def fetch_url(network): + return os.getenv("DRPC_URL") % (network, os.getenv("DRPC_KEY")) + + +def main(network, fork, url): + """ + Deploy the AddressProvider to the network. + """ + + console = RichConsole() + + if network == "zksync": + if not fork: + boa_zksync.set_zksync_env(url) + console.log("Prodmode on zksync Era ...") + else: + boa_zksync.set_zksync_fork(url) + console.log("Forkmode on zksync Era ...") + + boa.env.set_eoa(Account.from_key(os.environ["FIDDYDEPLOYER"])) + + else: + if fork: + boa.env.fork(url) + console.log("Forkmode ...") + boa.env.eoa = FIDDY_DEPLOYER # set eoa address here + else: + console.log("Prodmode ...") + boa.set_env(NetworkEnv(url)) + boa.env.add_account(Account.from_key(os.environ["FIDDYDEPLOYER"])) + + address_provider_obj = boa.load_partial("contracts/AddressProviderNG.vy") + address_provider = address_provider_obj.at(ADDRESS_PROVIDER) + + console.log(f"For network: {network}") + + # set up address provider + network_update = to_update[network] + if not network_update: + return + + updating = False + for key, value in network_update.items(): + current_value = address_provider.get_address(key) + if not current_value == value: + updating = True + console.log(f"Updating id {key} from {current_value} to {value}.") + address_provider.update_address(key, value) + + if updating: + console.log("Done!") + else: + console.log("Already updated!") + + +if __name__ == "__main__": + + fork = False + + for network in to_update.keys(): + + url = "" + + if network == "zksync": + import boa_zksync + network_url = "https://mainnet.era.zksync.io" + ADDRESS_PROVIDER = "0x3934a3bB913E4a44316a89f5a83876B9C63e4F31" + elif network == "fraxtal": + network_url = "https://rpc.frax.com" + elif network == "kava": + network_url = "https://rpc.ankr.com/kava_evm" + elif network == "xlayer": + network_url = "https://xlayerrpc.okx.com" + elif network == "mantle": + network_url = "https://rpc.mantle.xyz" + else: + network_url = fetch_url(network) + + main(network, fork, network_url) From aaa66170e938506aa1a73533b4450372bb8b3d7d Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Tue, 20 Aug 2024 11:49:45 +0200 Subject: [PATCH 2/3] Update dependencies, small fixes --- deployments.yaml | 4 +- requirements.in | 4 +- requirements.txt | 149 ++++++++++++++++------------ scripts/deploy_registries_zksync.py | 40 +++----- 4 files changed, 105 insertions(+), 92 deletions(-) diff --git a/deployments.yaml b/deployments.yaml index 4c8ab8c..600b145 100644 --- a/deployments.yaml +++ b/deployments.yaml @@ -72,9 +72,9 @@ polygon: TricryptoFactoryNGHandler: '0xf46D25696677898454dfDd644830C821243A1188' TwocryptoFactoryNGHandler: '0xb00e89eabd59cd3254c88e390103cf17e914f678' zksync: - AddressProvider: '0xBF664Ac8e934230FC6A381702678cc29661d38D5' + AddressProvider: '' Metaregistry: '' - RateProvider: '0x9eB20D123F877f06c93CE82De4507B0911dFA783' + RateProvider: '' StableswapFactoryNGHandler: '' TricryptoFactoryNGHandler: '' TwocryptoFactoryNGHandler: '' diff --git a/requirements.in b/requirements.in index 0522e83..4e2c886 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ -titanoboa[forking-recommended] @ git+https://github.com/vyperlang/titanoboa@05ec84ad1decfe23cd4a3ffc588d567fd322a509 -git+https://github.com/DanielSchiavini/titanoboa-zksync.git@0121e1f9a59b47f015cef55574b6084599144f20 +titanoboa[forking-recommended]==0.1.10 +titanoboa-zksync==0.1.1 black flake8 isort diff --git a/requirements.txt b/requirements.txt index 9e3c05c..29e8e02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,61 +4,69 @@ # # pip-compile # +annotated-types==0.7.0 + # via pydantic asttokens==2.4.1 # via vyper -attrs==23.1.0 +attrs==24.2.0 # via hypothesis -bitarray==2.8.3 +bitarray==2.9.2 # via eth-account -black==23.11.0 +black==24.8.0 # via -r requirements.in -build==1.0.3 +build==1.2.1 # via pip-tools cached-property==1.5.2 # via # py-ecc # py-evm -cbor2==5.5.1 +cbor2==5.6.4 # via vyper -certifi==2023.11.17 +certifi==2024.7.4 # via requests cfgv==3.4.0 # via pre-commit charset-normalizer==3.3.2 # via requests +ckzg==1.0.2 + # via + # eth-account + # py-evm click==8.1.7 # via # black # pip-tools -cytoolz==0.12.2 +coverage[toml]==7.6.1 + # via pytest-cov +cytoolz==0.12.3 # via eth-utils -distlib==0.3.7 +distlib==0.3.8 # via virtualenv -eth-abi==4.2.1 +eth-abi==5.1.0 # via # eth-account # titanoboa -eth-account==0.10.0 +eth-account==0.13.1 # via titanoboa -eth-bloom==3.0.0 +eth-bloom==3.0.1 # via py-evm -eth-hash[pycryptodome]==0.5.2 +eth-hash[pycryptodome]==0.7.0 # via # eth-bloom # eth-utils # trie -eth-keyfile==0.6.1 +eth-keyfile==0.8.1 # via eth-account -eth-keys==0.4.0 +eth-keys==0.5.1 # via # eth-account # eth-keyfile # py-evm -eth-rlp==0.3.0 +eth-rlp==2.1.0 # via eth-account eth-stdlib==0.2.7 # via titanoboa -eth-typing==3.5.2 +eth-typing==5.0.0 # via # eth-abi # eth-keys @@ -66,7 +74,7 @@ eth-typing==3.5.2 # py-ecc # py-evm # titanoboa -eth-utils==2.3.1 +eth-utils==5.0.0 # via # eth-abi # eth-account @@ -77,32 +85,33 @@ eth-utils==2.3.1 # py-evm # rlp # trie -exceptiongroup==1.2.0 +exceptiongroup==1.2.2 # via # hypothesis # pytest -execnet==2.0.2 +execnet==2.1.1 # via pytest-xdist -filelock==3.13.1 +filelock==3.15.4 # via virtualenv -flake8==6.1.0 +flake8==7.1.1 # via -r requirements.in -hexbytes==0.3.1 +hexbytes==1.2.1 # via # eth-account # eth-rlp + # eth-utils # trie -hypothesis==6.90.0 +hypothesis==6.111.1 # via titanoboa -identify==2.5.32 +identify==2.6.0 # via pre-commit -idna==3.4 +idna==3.7 # via requests -importlib-metadata==6.8.0 +importlib-metadata==8.3.0 # via vyper iniconfig==2.0.0 # via pytest -isort==5.12.0 +isort==5.13.2 # via -r requirements.in lru-dict==1.3.0 # via py-evm @@ -113,11 +122,8 @@ mccabe==0.7.0 mdurl==0.1.2 # via markdown-it-py mypy-extensions==1.0.0 - # via - # black - # py-ecc - # py-evm -nodeenv==1.8.0 + # via black +nodeenv==1.9.1 # via pre-commit packaging==23.2 # via @@ -125,56 +131,65 @@ packaging==23.2 # build # pytest # vyper -parsimonious==0.9.0 +parsimonious==0.10.0 # via eth-abi -pathspec==0.11.2 +pathspec==0.12.1 # via black -pip-tools==7.3.0 +pip-tools==7.4.1 # via -r requirements.in -platformdirs==4.0.0 +platformdirs==4.2.2 # via # black # virtualenv -pluggy==1.3.0 +pluggy==1.5.0 # via pytest -pre-commit==3.5.0 +pre-commit==3.8.0 # via -r requirements.in -py-ecc==6.0.0 +py-ecc==7.0.1 # via py-evm -py-evm==0.8.0b1 +py-evm==0.10.1b1 # via titanoboa -pycodestyle==2.11.1 +pycodestyle==2.12.1 # via flake8 -pycryptodome==3.19.0 +pycryptodome==3.20.0 # via # eth-hash # eth-keyfile # eth-stdlib # vyper -pyflakes==3.1.0 +pydantic==2.8.2 + # via eth-account +pydantic-core==2.20.1 + # via pydantic +pyflakes==3.2.0 # via flake8 -pygments==2.17.2 +pygments==2.18.0 # via rich -pyproject-hooks==1.0.0 - # via build -pytest==7.4.3 +pyproject-hooks==1.1.0 + # via + # build + # pip-tools +pytest==8.3.2 # via # -r requirements.in + # pytest-cov # pytest-xdist # titanoboa -pytest-xdist==3.5.0 +pytest-cov==5.0.0 + # via titanoboa +pytest-xdist==3.6.1 # via -r requirements.in -pyyaml==6.0.1 +pyyaml==6.0.2 # via pre-commit -regex==2023.10.3 +regex==2024.7.24 # via parsimonious -requests==2.31.0 +requests==2.32.3 # via titanoboa -rich==13.7.0 +rich==13.7.1 # via # -r requirements.in # titanoboa -rlp==3.0.0 +rlp==4.0.1 # via # eth-account # eth-rlp @@ -188,36 +203,44 @@ sortedcontainers==2.4.0 # trie tabulate==0.9.0 # via -r requirements.in -titanoboa[forking-recommended] @ git+https://github.com/vyperlang/titanoboa@e85ab24 +titanoboa[forking-recommended]==0.1.10 + # via + # -r requirements.in + # titanoboa-zksync +titanoboa-zksync==0.1.1 # via -r requirements.in tomli==2.0.1 # via # black # build + # coverage # pip-tools - # pyproject-hooks # pytest -toolz==0.12.0 +toolz==0.12.1 # via cytoolz -trie==2.2.0 +trie==3.0.1 # via py-evm -typing-extensions==4.8.0 +typing-extensions==4.12.2 # via # black + # eth-rlp # eth-typing -ujson==5.8.0 + # pydantic + # pydantic-core + # titanoboa +ujson==5.10.0 # via titanoboa -urllib3==2.1.0 +urllib3==2.2.2 # via requests -virtualenv==20.24.7 +virtualenv==20.26.3 # via pre-commit vyper==0.3.10 # via titanoboa -wheel==0.41.3 +wheel==0.44.0 # via # pip-tools # vyper -zipp==3.17.0 +zipp==3.20.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: diff --git a/scripts/deploy_registries_zksync.py b/scripts/deploy_registries_zksync.py index 106cc01..5126156 100644 --- a/scripts/deploy_registries_zksync.py +++ b/scripts/deploy_registries_zksync.py @@ -11,11 +11,11 @@ from rich import console as rich_console sys.path.append("./") -from scripts.deploy_addressprovider_and_setup import fetch_url from scripts.address_provider_constants import ( ADDRESS_PROVIDER_MAPPING, addresses, ) +from scripts.deploy_addressprovider_and_setup import fetch_url from scripts.legacy_base_pools import base_pools as BASE_POOLS from scripts.utils.constants import FIDDY_DEPLOYER @@ -53,10 +53,7 @@ def check_contract_deployed(network, designation): if deployments is None: deployments = {} - if ( - network in deployments.keys() - and designation in deployments[network].keys() - ): + if network in deployments and deployments[network].get(designation): contract_address = deployments[network][designation] console.log( f"{designation} deployed already at {network}: {contract_address}" @@ -85,7 +82,7 @@ def deploy_and_cache_contracts( network, designation, contract_file, args, fork=False ): contract_address = check_contract_deployed(network, designation) - if contract_address != ZERO_ADDRESS: + if contract_address and contract_address != ZERO_ADDRESS: return boa.load_partial(contract_file).at(contract_address) deployed_contract = boa.load(contract_file, *args) @@ -235,6 +232,8 @@ def ng_deployment(address_provider, metaregistry, registry_list): def main(network, fork, url): if network == "zksync": + import boa_zksync + if not fork: boa_zksync.set_zksync_env(url) console.log("Prodmode on zksync Era ...") @@ -262,7 +261,7 @@ def main(network, fork, url): [], fork, ) - + # deploy rate provider: rate_provider = deploy_and_cache_contracts( network, @@ -279,7 +278,7 @@ def main(network, fork, url): ) elif address_provider.get_address(18) != rate_provider.address: address_provider.update_address(18, rate_provider.address) - + # set up address provider: ids = [] addresses_for_id = [] @@ -311,7 +310,7 @@ def main(network, fork, url): if len(ids) > 0: console.log("Adding new IDs to the Address Provider.") address_provider.add_new_ids(ids, addresses_for_id, descriptions) - + # metaregistry deployment: metaregistry_address = address_provider.get_address(7) @@ -319,15 +318,14 @@ def main(network, fork, url): console.log("Deploying Metaregistry ...") gauge_factory = address_provider.get_address(20) # 20 is for Gauge Factory gauge_type = GAUGE_TYPE[network] - + deploy_mregistry = metaregistry_address == ZERO_ADDRESS - deploy_mregistry = False if deploy_mregistry: metaregistry = deploy_and_cache_contracts( network, "Metaregistry", - "contracts/MetaregistryL2.vy", + "contracts/MetaRegistryL2.vy", [gauge_factory, gauge_type], fork, ) @@ -358,18 +356,10 @@ def main(network, fork, url): if __name__ == "__main__": network = "zksync" - url = "" + url = { + "zksync": "https://mainnet.era.zksync.io", + "fraxtal": "https://rpc.frax.com", + "kava": "https://rpc.ankr.com/kava_evm", + }.get(network) or fetch_url(network) fork = False - - if network == "zksync": - import boa_zksync - url = "https://mainnet.era.zksync.io" - ADDRESS_PROVIDER = "0x3934a3bB913E4a44316a89f5a83876B9C63e4F31" - elif network == "fraxtal": - network_url = "https://rpc.frax.com" - elif network == "kava": - network_url = "https://rpc.ankr.com/kava_evm" - else: - network_url = fetch_url(network) - main(network, fork, url) From 6b5410b2e7a3bd1cbb8e00fd17f344d52651e52b Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Tue, 20 Aug 2024 09:08:19 -0400 Subject: [PATCH 3/3] zksync registries deployed --- deployments.yaml | 136 +++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/deployments.yaml b/deployments.yaml index 600b145..9e596c3 100644 --- a/deployments.yaml +++ b/deployments.yaml @@ -1,80 +1,80 @@ arbitrum: - BasePoolRegistry: '0x1b0882f15efD4FF36C3E23C887518080ECe28B2B' - CryptoRegistryHandler: '0x4bf079cAC8AA62253978f6382aeBB73feDDAeD35' - Metaregistry: '0x13526206545e2DC7CcfBaF28dC88F440ce7AD3e0' - StableFactoryHandler: '0x39FFd8A06E80c12AC9151c57b72E709b0d735B9f' - StableRegistryHandler: '0x04A59aaD6b7EE48e6A4F7978cABB52CaedCCE4b2' - StableswapFactoryNGHandler: '0xdfdD8365e8D5823836427cFd8d54Dd390181477C' - TricryptoFactoryNGHandler: '0xb29841F457B102ce42b40eB8E602AEbc2fE6C2a2' - TwocryptoFactoryNGHandler: '0xBC397375a6Ae7A397010860f5a4b9fE65A3d6843' + BasePoolRegistry: "0x1b0882f15efD4FF36C3E23C887518080ECe28B2B" + CryptoRegistryHandler: "0x4bf079cAC8AA62253978f6382aeBB73feDDAeD35" + Metaregistry: "0x13526206545e2DC7CcfBaF28dC88F440ce7AD3e0" + StableFactoryHandler: "0x39FFd8A06E80c12AC9151c57b72E709b0d735B9f" + StableRegistryHandler: "0x04A59aaD6b7EE48e6A4F7978cABB52CaedCCE4b2" + StableswapFactoryNGHandler: "0xdfdD8365e8D5823836427cFd8d54Dd390181477C" + TricryptoFactoryNGHandler: "0xb29841F457B102ce42b40eB8E602AEbc2fE6C2a2" + TwocryptoFactoryNGHandler: "0xBC397375a6Ae7A397010860f5a4b9fE65A3d6843" aurora: - BasePoolRegistry: '0xe548590f9fAe7a23EA6501b144B0D58b74Fc4B53' - Metaregistry: '0xFf02cBD91F57A778Bab7218DA562594a680B8B61' - StableRegistryHandler: '0xA54f3c1DFa5f7DbF2564829d14b3B74a65d26Ae2' - StableswapFactoryNGHandler: '0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da' - TricryptoFactoryNGHandler: '0xb47988aD49DCE8D909c6f9Cf7B26caF04e1445c8' - TwocryptoFactoryNGHandler: '0x64AFA95e0C3D8410240a4262df9Fd82B12b64eDd' + BasePoolRegistry: "0xe548590f9fAe7a23EA6501b144B0D58b74Fc4B53" + Metaregistry: "0xFf02cBD91F57A778Bab7218DA562594a680B8B61" + StableRegistryHandler: "0xA54f3c1DFa5f7DbF2564829d14b3B74a65d26Ae2" + StableswapFactoryNGHandler: "0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da" + TricryptoFactoryNGHandler: "0xb47988aD49DCE8D909c6f9Cf7B26caF04e1445c8" + TwocryptoFactoryNGHandler: "0x64AFA95e0C3D8410240a4262df9Fd82B12b64eDd" avalanche: - BasePoolRegistry: '0xb47988aD49DCE8D909c6f9Cf7B26caF04e1445c8' - Metaregistry: '0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb' - StableFactoryHandler: '0x33e72383472f77B0C6d8F791D1613C75aE2C5915' - StableRegistryHandler: '0x64AFA95e0C3D8410240a4262df9Fd82B12b64eDd' + BasePoolRegistry: "0xb47988aD49DCE8D909c6f9Cf7B26caF04e1445c8" + Metaregistry: "0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb" + StableFactoryHandler: "0x33e72383472f77B0C6d8F791D1613C75aE2C5915" + StableRegistryHandler: "0x64AFA95e0C3D8410240a4262df9Fd82B12b64eDd" base: - BasePoolRegistry: '0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb' - CryptoFactoryHandler: '0x64AFA95e0C3D8410240a4262df9Fd82B12b64eDd' - StableFactoryHandler: '0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da' + BasePoolRegistry: "0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb" + CryptoFactoryHandler: "0x64AFA95e0C3D8410240a4262df9Fd82B12b64eDd" + StableFactoryHandler: "0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da" bsc: - BasePoolRegistry: '0x64891ab20392A029c0f231656ff13C5ee64b730C' - CryptoFactoryHandler: '0xA04511C09E493eD36895b665d43d452aBB042579' - StableFactoryHandler: '0x8A00365Ae28D75B92ec695D5a041b744f140438D' + BasePoolRegistry: "0x64891ab20392A029c0f231656ff13C5ee64b730C" + CryptoFactoryHandler: "0xA04511C09E493eD36895b665d43d452aBB042579" + StableFactoryHandler: "0x8A00365Ae28D75B92ec695D5a041b744f140438D" celo: - BasePoolRegistry: '0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb' - StableFactoryHandler: '0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da' + BasePoolRegistry: "0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb" + StableFactoryHandler: "0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da" fantom: - BasePoolRegistry: '0xA04511C09E493eD36895b665d43d452aBB042579' - CryptoRegistryHandler: '0xc65CB3156225380BEda366610BaB18D5835A1647' - Metaregistry: '0x803de445F0C272Bb6a036495F531a828D538Ab9A' - StableFactoryHandler: '0x452b9481fe83deadAf9f35226Cf79a53B26032da' - StableRegistryHandler: '0xfb37b8D939FFa77114005e61CFc2e543d6F49A81' - StableswapFactoryNGHandler: '0xf46D25696677898454dfDd644830C821243A1188' - TricryptoFactoryNGHandler: '0x08390C76DFDaB74249754C8e71cC2747351bd388' - TwocryptoFactoryNGHandler: '0x9d3975070768580f755D405527862ee126d0eA08' + BasePoolRegistry: "0xA04511C09E493eD36895b665d43d452aBB042579" + CryptoRegistryHandler: "0xc65CB3156225380BEda366610BaB18D5835A1647" + Metaregistry: "0x803de445F0C272Bb6a036495F531a828D538Ab9A" + StableFactoryHandler: "0x452b9481fe83deadAf9f35226Cf79a53B26032da" + StableRegistryHandler: "0xfb37b8D939FFa77114005e61CFc2e543d6F49A81" + StableswapFactoryNGHandler: "0xf46D25696677898454dfDd644830C821243A1188" + TricryptoFactoryNGHandler: "0x08390C76DFDaB74249754C8e71cC2747351bd388" + TwocryptoFactoryNGHandler: "0x9d3975070768580f755D405527862ee126d0eA08" gnosis: - BasePoolRegistry: '0x3f4a2bffa78d50cd61401a440526378e2155a8ae' - CryptoRegistryHandler: '0x550574e33b81c45d3d69250b46ae30c7bc40d330' - Metaregistry: '0xb6265659d7e9FEccB59e076e949Da556FC5E1429' - StableFactoryHandler: '0xF493Cd722951346E646eE666f0525e7cDcde9c03' - StableRegistryHandler: '0x6DCD097C0639ebF7dD932808C6965E43638AE6D2' - StableswapFactoryNGHandler: '0x4b00E8c997AeBACeEf6B8c6F89eE2bf99b2CA846' - TricryptoFactoryNGHandler: '0xc9621394A73A071d8084CB9a15b04F182a7C9634' - TwocryptoFactoryNGHandler: '0xD8D569f74D3Ea07708d92802dD3f60353Ef1d8a8' + BasePoolRegistry: "0x3f4a2bffa78d50cd61401a440526378e2155a8ae" + CryptoRegistryHandler: "0x550574e33b81c45d3d69250b46ae30c7bc40d330" + Metaregistry: "0xb6265659d7e9FEccB59e076e949Da556FC5E1429" + StableFactoryHandler: "0xF493Cd722951346E646eE666f0525e7cDcde9c03" + StableRegistryHandler: "0x6DCD097C0639ebF7dD932808C6965E43638AE6D2" + StableswapFactoryNGHandler: "0x4b00E8c997AeBACeEf6B8c6F89eE2bf99b2CA846" + TricryptoFactoryNGHandler: "0xc9621394A73A071d8084CB9a15b04F182a7C9634" + TwocryptoFactoryNGHandler: "0xD8D569f74D3Ea07708d92802dD3f60353Ef1d8a8" kava: - BasePoolRegistry: '0x64AFA95e0C3D8410240a4262df9Fd82B12b64eDd' - StableFactoryHandler: '0x21688e843a99B0a47E750e7dDD2b5dAFd9269d30' - StableRegistryHandler: '0x72DbDFA64965C9ADbcdD7343bEe4AEC1370d35bd' + BasePoolRegistry: "0x64AFA95e0C3D8410240a4262df9Fd82B12b64eDd" + StableFactoryHandler: "0x21688e843a99B0a47E750e7dDD2b5dAFd9269d30" + StableRegistryHandler: "0x72DbDFA64965C9ADbcdD7343bEe4AEC1370d35bd" optimism: - BasePoolRegistry: '0xa0EC67a3C483674f77915893346A8CA3AbE2b785' - CryptoRegistryHandler: '0xB00E89EaBD59cD3254c88E390103Cf17E914f678' - Metaregistry: '0xc65CB3156225380BEda366610BaB18D5835A1647' - StableFactoryHandler: '0x9d3975070768580f755D405527862ee126d0eA08' - StableRegistryHandler: '0xf46D25696677898454dfDd644830C821243A1188' - StableswapFactoryNGHandler: '0xDCc91f930b42619377C200BA05b7513f2958b202' - TricryptoFactoryNGHandler: '0xc9CBC565A9F4120a2740ec6f64CC24AeB2bB3E5E' - TwocryptoFactoryNGHandler: '0x442B22fd19A25c1582Dc1Bc3949fb364ad7f34F4' + BasePoolRegistry: "0xa0EC67a3C483674f77915893346A8CA3AbE2b785" + CryptoRegistryHandler: "0xB00E89EaBD59cD3254c88E390103Cf17E914f678" + Metaregistry: "0xc65CB3156225380BEda366610BaB18D5835A1647" + StableFactoryHandler: "0x9d3975070768580f755D405527862ee126d0eA08" + StableRegistryHandler: "0xf46D25696677898454dfDd644830C821243A1188" + StableswapFactoryNGHandler: "0xDCc91f930b42619377C200BA05b7513f2958b202" + TricryptoFactoryNGHandler: "0xc9CBC565A9F4120a2740ec6f64CC24AeB2bB3E5E" + TwocryptoFactoryNGHandler: "0x442B22fd19A25c1582Dc1Bc3949fb364ad7f34F4" polygon: - BasePoolRegistry: '0xDD7EBB1C49780519dD9755B8B1A23a6f42CE099E' - CryptoFactoryHandler: '0x08390c76dfdab74249754c8e71cc2747351bd388' - CryptoRegistryHandler: '0xc65cb3156225380beda366610bab18d5835a1647' - Metaregistry: '0x296d2B5C23833A70D07c8fCBB97d846c1ff90DDD' - StableFactoryHandler: '0x452b9481fe83deadAf9f35226Cf79a53B26032da' - StableRegistryHandler: '0xfb37b8D939FFa77114005e61CFc2e543d6F49A81' - StableswapFactoryNGHandler: '0x9d3975070768580f755D405527862ee126d0eA08' - TricryptoFactoryNGHandler: '0xf46D25696677898454dfDd644830C821243A1188' - TwocryptoFactoryNGHandler: '0xb00e89eabd59cd3254c88e390103cf17e914f678' + BasePoolRegistry: "0xDD7EBB1C49780519dD9755B8B1A23a6f42CE099E" + CryptoFactoryHandler: "0x08390c76dfdab74249754c8e71cc2747351bd388" + CryptoRegistryHandler: "0xc65cb3156225380beda366610bab18d5835a1647" + Metaregistry: "0x296d2B5C23833A70D07c8fCBB97d846c1ff90DDD" + StableFactoryHandler: "0x452b9481fe83deadAf9f35226Cf79a53B26032da" + StableRegistryHandler: "0xfb37b8D939FFa77114005e61CFc2e543d6F49A81" + StableswapFactoryNGHandler: "0x9d3975070768580f755D405527862ee126d0eA08" + TricryptoFactoryNGHandler: "0xf46D25696677898454dfDd644830C821243A1188" + TwocryptoFactoryNGHandler: "0xb00e89eabd59cd3254c88e390103cf17e914f678" zksync: - AddressProvider: '' - Metaregistry: '' - RateProvider: '' - StableswapFactoryNGHandler: '' - TricryptoFactoryNGHandler: '' - TwocryptoFactoryNGHandler: '' + AddressProvider: "0x960C90aE833af0fd699dBc2503468A07cC28FA4F" + Metaregistry: "0x88ea923A0AD0D43B7879837C3172a0F2de7Bc099" + RateProvider: "0x0437633Db8341C2527f83785a27d15319d9a3396" + StableswapFactoryNGHandler: "0x56CEfe069f0Ed1F1098c8d2B335DB96E998070dD" + TricryptoFactoryNGHandler: "0x40E0671268af080396c73DA4b50827B1FC69D35a" + TwocryptoFactoryNGHandler: "0x3D50cFd815eDFda6f41c998F7D58722d5F1770ED"