From 5923fc5cacd791516e0cef36fa1f813ce0412a0f Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:37:53 +0200 Subject: [PATCH] deployed ng handlers --- .../ng/CurveTricryptoFactoryHandler.vy | 6 +-- .../ng/CurveTwocryptoFactoryHandler.vy | 29 ++++-------- scripts/deploy_and_setup_crypto_ng_handler.py | 47 +++++++++++++++++++ 3 files changed, 58 insertions(+), 24 deletions(-) create mode 100644 scripts/deploy_and_setup_crypto_ng_handler.py diff --git a/contracts/mainnet/registry_handlers/ng/CurveTricryptoFactoryHandler.vy b/contracts/mainnet/registry_handlers/ng/CurveTricryptoFactoryHandler.vy index e2655d6..86b923e 100644 --- a/contracts/mainnet/registry_handlers/ng/CurveTricryptoFactoryHandler.vy +++ b/contracts/mainnet/registry_handlers/ng/CurveTricryptoFactoryHandler.vy @@ -21,7 +21,7 @@ interface BaseRegistry: interface TricryptoNG: def adjustment_step() -> uint256: view - def admin_fee() -> uint256: view + def ADMIN_FEE() -> uint256: view def allowed_extra_profit() -> uint256: view def A() -> uint256: view def balances(i: uint256) -> uint256: view @@ -177,7 +177,7 @@ def get_admin_balances(_pool: address) -> uint256[MAX_METAREGISTRY_COINS]: xcp_profit: uint256 = TricryptoNG(_pool).xcp_profit() xcp_profit_a: uint256 = TricryptoNG(_pool).xcp_profit_a() - admin_fee: uint256 = TricryptoNG(_pool).admin_fee() + admin_fee: uint256 = TricryptoNG(_pool).ADMIN_FEE() admin_balances: uint256[MAX_METAREGISTRY_COINS] = empty(uint256[MAX_METAREGISTRY_COINS]) # admin balances are non zero if pool has made more than allowed profits: @@ -282,7 +282,7 @@ def get_fees(_pool: address) -> uint256[10]: fees: uint256[10] = empty(uint256[10]) pool_fees: uint256[4] = [ TricryptoNG(_pool).fee(), - TricryptoNG(_pool).admin_fee(), + TricryptoNG(_pool).ADMIN_FEE(), TricryptoNG(_pool).mid_fee(), TricryptoNG(_pool).out_fee(), ] diff --git a/contracts/mainnet/registry_handlers/ng/CurveTwocryptoFactoryHandler.vy b/contracts/mainnet/registry_handlers/ng/CurveTwocryptoFactoryHandler.vy index 88b4c0d..3878c60 100644 --- a/contracts/mainnet/registry_handlers/ng/CurveTwocryptoFactoryHandler.vy +++ b/contracts/mainnet/registry_handlers/ng/CurveTwocryptoFactoryHandler.vy @@ -21,7 +21,7 @@ interface BaseRegistry: interface TricryptoNG: def adjustment_step() -> uint256: view - def admin_fee() -> uint256: view + def ADMIN_FEE() -> uint256: view def allowed_extra_profit() -> uint256: view def A() -> uint256: view def balances(i: uint256) -> uint256: view @@ -101,15 +101,6 @@ def _get_decimals(_pool: address) -> uint256[MAX_METAREGISTRY_COINS]: return self._pad_uint_array(self.base_registry.get_decimals(_pool)) -@internal -@view -def _get_n_coins(_pool: address) -> uint256: - - if (self.base_registry.get_coins(_pool)[0] != empty(address)): - return N_COINS - return 0 - - @internal @view def _get_gauge_type(_gauge: address) -> int128: @@ -140,7 +131,7 @@ def _get_gauge_type(_gauge: address) -> int128: @internal @view def _is_registered(_pool: address) -> bool: - return self._get_n_coins(_pool) > 0 + return self._get_coins(_pool)[0] != empty(address) # ---- view methods (API) of the contract ---- # @@ -177,7 +168,7 @@ def get_admin_balances(_pool: address) -> uint256[MAX_METAREGISTRY_COINS]: xcp_profit: uint256 = TricryptoNG(_pool).xcp_profit() xcp_profit_a: uint256 = TricryptoNG(_pool).xcp_profit_a() - admin_fee: uint256 = TricryptoNG(_pool).admin_fee() + admin_fee: uint256 = TricryptoNG(_pool).ADMIN_FEE() admin_balances: uint256[MAX_METAREGISTRY_COINS] = empty(uint256[MAX_METAREGISTRY_COINS]) # admin balances are non zero if pool has made more than allowed profits: @@ -282,7 +273,7 @@ def get_fees(_pool: address) -> uint256[10]: fees: uint256[10] = empty(uint256[10]) pool_fees: uint256[4] = [ TricryptoNG(_pool).fee(), - TricryptoNG(_pool).admin_fee(), + TricryptoNG(_pool).ADMIN_FEE(), TricryptoNG(_pool).mid_fee(), TricryptoNG(_pool).out_fee(), ] @@ -327,7 +318,7 @@ def get_n_coins(_pool: address) -> uint256: @param _pool Address of the pool @return uint256 Number of coins """ - return self._get_n_coins(_pool) + return 2 @external @@ -338,12 +329,8 @@ def get_n_underlying_coins(_pool: address) -> uint256: @param _pool Address of the pool @return uint256 Number of underlying coins """ - _coins: address[MAX_METAREGISTRY_COINS] = self._get_coins(_pool) + return 2 - for i in range(MAX_METAREGISTRY_COINS): - if _coins[i] == empty(address): - return i - raise @external @view @@ -365,7 +352,7 @@ def get_pool_from_lp_token(_lp_token: address) -> address: @param _lp_token Address of the Liquidity Provider token @return Address of the pool """ - if self._get_n_coins(_lp_token) > 0: + if self._is_registered(_lp_token): return _lp_token return empty(address) @@ -463,7 +450,7 @@ def is_registered(_pool: address) -> bool: @param _pool The address of the pool @return A bool corresponding to whether the pool belongs or not """ - return self._get_n_coins(_pool) > 0 + return self._is_registered(_pool) @external diff --git a/scripts/deploy_and_setup_crypto_ng_handler.py b/scripts/deploy_and_setup_crypto_ng_handler.py new file mode 100644 index 0000000..80b50ca --- /dev/null +++ b/scripts/deploy_and_setup_crypto_ng_handler.py @@ -0,0 +1,47 @@ +# flake8: noqa + +import os +import sys + +import boa +from boa.network import NetworkEnv +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.utils.constants import FIDDY_DEPLOYER + + +def main(network: str = "ethereum", fork: bool = True): + console = rich_console.Console() + + if not fork: + # Prodmode + console.log("Running script in prod mode...") + boa.set_env(NetworkEnv(fetch_url(network))) + boa.env.add_account(Account.from_key(os.environ["FIDDYDEPLOYER"])) + + else: + # Forkmode + console.log("Simulation Mode. Writing to mainnet-fork.") + boa.env.fork(url=fetch_url(network)) + boa.env.eoa = FIDDY_DEPLOYER + + # deploy handlers: + registry = boa.load( + "contracts/mainnet/registry_handlers/ng/CurveTwocryptoFactoryHandler.vy", + "0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F", + ) + registry = boa.load( + "contracts/mainnet/registry_handlers/ng/CurveTricryptoFactoryHandler.vy", + "0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963", + ) + console.log(f"Deployed Factory Handlers.") + + +if __name__ == "__main__": + network = "ethereum" + fork = False + + main(network, fork)