Skip to content

Commit

Permalink
deployed ng handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Apr 29, 2024
1 parent ff40c8d commit 5923fc5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 ---- #
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(),
]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down
47 changes: 47 additions & 0 deletions scripts/deploy_and_setup_crypto_ng_handler.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5923fc5

Please sign in to comment.