Skip to content

Commit

Permalink
Updated linting
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Jan 15, 2024
1 parent f2cbfc2 commit 33e4ba9
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 281 deletions.
13 changes: 1 addition & 12 deletions scripts/deploy_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@


def set_evm_version(contract_file, network) -> boa.vyper.contract.VyperDeployer:

with open(contract_file, "r") as f:
source = f.read()

Expand All @@ -159,7 +158,6 @@ def set_evm_version(contract_file, network) -> boa.vyper.contract.VyperDeployer:


def check_and_deploy(contract_obj, contract_designation, network, blueprint: bool = False, args=[]):

deployed_contract = deployments[network][contract_designation]

if not deployed_contract:
Expand All @@ -180,7 +178,6 @@ def check_and_deploy(contract_obj, contract_designation, network, blueprint: boo


def deploy_infra(network, url, account, fork=False):

logger.log(f"Deploying on {network} ...")

if fork:
Expand All @@ -192,9 +189,7 @@ def deploy_infra(network, url, account, fork=False):
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

Expand Down Expand Up @@ -252,13 +247,7 @@ def deploy_infra(network, url, account, fork=False):


def main():

deploy_infra(
"ethereum:mainnet",
os.environ["RPC_ETHEREUM"],
"FIDDYDEPLOYER",
fork=False,
)
deploy_infra("ethereum:mainnet", os.environ["RPC_ETHEREUM"], "FIDDYDEPLOYER", fork=False)


if __name__ == "__main__":
Expand Down
76 changes: 18 additions & 58 deletions scripts/deploy_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,27 @@

deployments = {
# Ethereum
"ethereum:sepolia": {
"factory": "0xfb37b8D939FFa77114005e61CFc2e543d6F49A81",
},
"ethereum:mainnet": {
"factory": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf",
},
"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",
},
"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": "",
},
"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": ""},
}


Expand Down Expand Up @@ -130,7 +94,6 @@ class PoolSettings:


def deploy_pool(network, url, account, pool_type, fork):

logger.log(f"Deploying pool on {network} ...")

if fork:
Expand Down Expand Up @@ -158,7 +121,6 @@ def deploy_pool(network, url, account, pool_type, fork):


def deploy_gauge(network, url, account, pool_addr, fork):

logger.log(f"Deploying gauge for pool {pool_addr} on {network} ...")

if fork:
Expand All @@ -181,7 +143,6 @@ def deploy_gauge(network, url, account, pool_addr, fork):


def deploy_pool_and_gauge(network, url, account, pool_type, fork):

logger.log(f"Deploying pool on {network} ...")

if fork:
Expand Down Expand Up @@ -211,7 +172,6 @@ def deploy_pool_and_gauge(network, url, account, pool_type, fork):


def main():

fork = False
deploy_pool_and_gauge("ethereum:mainnet", os.environ["RPC_ETHEREUM"], "FIDDYDEPLOYER", "plain", fork)
deploy_pool_and_gauge("ethereum:mainnet", "http://localhost:9090/", "FIDDYDEPLOYER", "meta", fork)
Expand Down
8 changes: 1 addition & 7 deletions scripts/deploy_proxy_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


def deploy_proxy_admin(network, url, account, fork=False):

logger.log(f"Deploying ProxyAdmin for {network} ...")

if fork:
Expand All @@ -35,12 +34,7 @@ def deploy_proxy_admin(network, url, account, fork=False):


def main():
deploy_proxy_admin(
":mainnet",
os.environ["RPC_"],
"",
fork=False,
)
deploy_proxy_admin(":mainnet", os.environ["RPC_"], "", fork=False)


if __name__ == "__main__":
Expand Down
8 changes: 2 additions & 6 deletions scripts/deployment_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class CurveNetworkSettings:
fee_receiver_address="0xf3A431008396df8A8b2DF492C913706BDB0874ef",
),
"zksync:mainnet": CurveNetworkSettings(
dao_ownership_contract="",
fee_receiver_address="0x4920088D9a5e5De9c098FCA4960d0DA5f4caa4c1",
dao_ownership_contract="", fee_receiver_address="0x4920088D9a5e5De9c098FCA4960d0DA5f4caa4c1"
),
"pzkevm:mainnet": CurveNetworkSettings(
dao_ownership_contract="0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6",
Expand Down Expand Up @@ -98,10 +97,7 @@ class CurveNetworkSettings:
dao_ownership_contract="0x98B4029CaBEf7Fd525A36B0BF8555EC1d42ec0B6",
fee_receiver_address="0x98B4029CaBEf7Fd525A36B0BF8555EC1d42ec0B6",
),
"tron:mainnet": CurveNetworkSettings(
dao_ownership_contract="",
fee_receiver_address="",
),
"tron:mainnet": CurveNetworkSettings(dao_ownership_contract="", fee_receiver_address=""),
"mantle:mainnet": CurveNetworkSettings(
dao_ownership_contract="0xf3A431008396df8A8b2DF492C913706BDB0874ef",
fee_receiver_address="0xf3A431008396df8A8b2DF492C913706BDB0874ef",
Expand Down
54 changes: 9 additions & 45 deletions scripts/set_up_base_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,14 @@ class BasePoolSettings:
BasePoolSettings( # 2pool
pool="0x7f90122BF0700F9E7e1F688fe926940E8839F353",
lp_token="0x7f90122BF0700F9E7e1F688fe926940E8839F353",
coins=[
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
],
coins=["0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],
asset_types=[0, 0],
n_coins=2,
),
BasePoolSettings( # fraxbp
pool="0xC9B8a3FDECB9D5b218d02555a8Baf332E5B740d5",
lp_token="0xC9B8a3FDECB9D5b218d02555a8Baf332E5B740d5",
coins=[
"0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F",
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
],
coins=["0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F", "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"],
asset_types=[0, 0],
n_coins=2,
),
Expand All @@ -108,10 +102,7 @@ class BasePoolSettings:
BasePoolSettings( # fraxbp
pool="0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7",
lp_token="0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7",
coins=[
"0x2E3D870790dC77A83DD1d18184Acc7439A53f475",
"0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
],
coins=["0x2E3D870790dC77A83DD1d18184Acc7439A53f475", "0x7F5c764cBc14f9669B88837ca1490cCa17c31607"],
asset_types=[0, 0],
n_coins=2,
),
Expand All @@ -127,13 +118,12 @@ class BasePoolSettings:
],
asset_types=[0, 0, 0],
n_coins=3,
),
)
],
}


def set_up_base_pools(network, url, account, fork: bool = False):

logger.log(f"Connecting to {network} ...")
if fork:
boa.env.fork(url)
Expand All @@ -154,12 +144,7 @@ def set_up_base_pools(network, url, account, fork: bool = False):
if base_pool_data: # check if network has base pools:
for data in base_pool_data:
if to_checksum_address(data.pool) not in onboarded_base_pools:
factory.add_base_pool(
data.pool,
data.lp_token,
data.asset_types,
data.n_coins,
)
factory.add_base_pool(data.pool, data.lp_token, data.asset_types, data.n_coins)
logger.log(f"Added {data.pool} to factory {factory_address} on {network}.")
else:
logger.log(f"{data.pool} is already configured as a base pool in factory {factory_address}.")
Expand All @@ -170,33 +155,12 @@ def set_up_base_pools(network, url, account, fork: bool = False):


def main():

fork = False

set_up_base_pools(
"ethereum:mainnet",
os.environ["RPC_ETHEREUM"],
"FIDDYDEPLOYER",
fork=fork,
)
set_up_base_pools(
"arbitrum:mainnet",
os.environ["RPC_ARBITRUM"],
"FIDDYDEPLOYER",
fork=fork,
)
set_up_base_pools(
"optimism:mainnet",
os.environ["RPC_OPTIMISM"],
"FIDDYDEPLOYER",
fork=fork,
)
set_up_base_pools(
"gnosis:mainnet",
os.environ["RPC_GNOSIS"],
"FIDDYDEPLOYER",
fork=fork,
)
set_up_base_pools("ethereum:mainnet", os.environ["RPC_ETHEREUM"], "FIDDYDEPLOYER", fork=fork)
set_up_base_pools("arbitrum:mainnet", os.environ["RPC_ARBITRUM"], "FIDDYDEPLOYER", fork=fork)
set_up_base_pools("optimism:mainnet", os.environ["RPC_OPTIMISM"], "FIDDYDEPLOYER", fork=fork)
set_up_base_pools("gnosis:mainnet", os.environ["RPC_GNOSIS"], "FIDDYDEPLOYER", fork=fork)


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion scripts/vote_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def prepare_evm_script(target: Dict, actions: List[Tuple]) -> str:
evm_script = "0x00000001"

for address, fn_name, *args in actions:

contract = ape.Contract(address)
fn = getattr(contract, fn_name)
calldata = fn.as_transaction(*args, sender=agent.address, gas_price=0).data
Expand Down
6 changes: 1 addition & 5 deletions tests/factory/test_factory_forked.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
@pytest.fixture
def empty_factory(deployer, fee_receiver, owner):
with boa.env.prank(deployer):
return boa.load(
"contracts/main/CurveStableSwapFactoryNG.vy",
fee_receiver,
owner,
)
return boa.load("contracts/main/CurveStableSwapFactoryNG.vy", fee_receiver, owner)


def test_add_base_pool(empty_factory, owner, forked_chain):
Expand Down
16 changes: 6 additions & 10 deletions tests/factory/test_factory_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
@pytest.mark.parametrize("sending,receiving", [(0, 1), (1, 0)])
def test_find_pool_for_coins(factory, meta_swap, underlying_tokens, sending, receiving):
assert (
factory.find_pool_for_coins(underlying_tokens[sending].address, underlying_tokens[receiving].address)
== meta_swap.address
factory.find_pool_for_coins(underlying_tokens[sending].address, underlying_tokens[receiving].address)
== meta_swap.address
)


Expand All @@ -34,25 +34,21 @@ def test_get_underlying_decimals(factory, meta_swap, base_pool_decimals, pool_ty


def test_get_metapool_rates(factory, meta_swap, base_pool, initial_setup):
assert factory.get_metapool_rates(meta_swap.address) == [10 ** 18, base_pool.get_virtual_price()]
assert factory.get_metapool_rates(meta_swap.address) == [10**18, base_pool.get_virtual_price()]


def test_get_underlying_balances(factory, meta_swap, base_pool, initial_setup):
assert factory.get_metapool_rates(meta_swap.address) == [10 ** 18, base_pool.get_virtual_price()]
assert factory.get_metapool_rates(meta_swap.address) == [10**18, base_pool.get_virtual_price()]


@pytest.mark.parametrize("sending,receiving", itertools.permutations(range(1, 4), 2))
def test_find_pool_underlying_base_pool_only(
self, factory, underlying_tokens, sending, receiving, zero_address
):
def test_find_pool_underlying_base_pool_only(self, factory, underlying_tokens, sending, receiving, zero_address):
assert factory.find_pool_for_coins(underlying_tokens[sending], underlying_tokens[receiving]) == zero_address


@pytest.mark.parametrize("sending,receiving", itertools.permutations(range(2, 5), 2))
def test_get_coin_indices_underlying(factory, meta_swap, sending, receiving, underlying_tokens):
i, j, is_underlying = factory.get_coin_indices(
meta_swap, underlying_tokens[sending], underlying_tokens[receiving]
)
i, j, is_underlying = factory.get_coin_indices(meta_swap, underlying_tokens[sending], underlying_tokens[receiving])
assert i == sending - 1
assert j == receiving - 1
assert is_underlying is True
Expand Down
4 changes: 2 additions & 2 deletions tests/factory/test_factory_plain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
@pytest.mark.parametrize("sending,receiving", [(0, 1), (1, 0)])
def test_find_pool_for_coins(factory, basic_swap, plain_tokens, sending, receiving):
assert (
factory.find_pool_for_coins(plain_tokens[sending].address, plain_tokens[receiving].address)
== basic_swap.address
factory.find_pool_for_coins(plain_tokens[sending].address, plain_tokens[receiving].address)
== basic_swap.address
)


Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

@pytest.fixture(scope="module")
def callback_contract(bob, swap, pool_tokens, underlying_tokens):

with boa.env.prank(bob):
_callback = boa.load("contracts/mocks/CallbackSwap.vy", swap.address, bob)
for token in pool_tokens + underlying_tokens:
Expand Down
Loading

0 comments on commit 33e4ba9

Please sign in to comment.