From f2d7797e8aea91b3d5f4aae4f1d38c2811fa7a36 Mon Sep 17 00:00:00 2001 From: heswithme Date: Wed, 25 Sep 2024 12:30:52 +0200 Subject: [PATCH] pre-commit runs --- .flake8 | 5 +- .pre-commit-config.yaml | 1 + pyproject.toml | 2 +- scripts/deploy_infra.py | 20 ++----- scripts/deploy_pool.py | 8 +-- scripts/set_up_base_pools.py | 19 ++----- scripts/vote_utils.py | 4 +- test_suite/generate_report.py | 11 +--- tests/conftest.py | 12 +--- tests/factory/test_factory_add_pools.py | 12 +--- tests/factory/test_factory_basic.py | 7 +-- tests/factory/test_factory_meta.py | 41 +++----------- tests/fixtures/accounts.py | 14 +---- tests/fixtures/factory.py | 13 +---- tests/fixtures/pools.py | 23 ++------ tests/fixtures/tokens.py | 13 +---- tests/pools/exchange/test_exchange.py | 12 +--- .../pools/exchange/test_exchange_received.py | 34 +++-------- .../pools/exchange/test_exchange_receiver.py | 48 +++------------- tests/pools/exchange/test_exchange_reverts.py | 11 +--- tests/pools/general/test_erc4626_swaps.py | 14 +---- tests/pools/general/test_fees.py | 23 ++------ tests/pools/general/test_ramp_A.py | 7 +-- .../test_specific_liquidity_operations.py | 10 +--- tests/pools/general/test_swap_getters.py | 6 +- tests/pools/liquidity/test_add_liquidity.py | 25 ++------- .../pools/liquidity/test_remove_liquidity.py | 24 ++------ .../test_remove_liquidity_imbalance.py | 31 ++-------- .../test_remove_liquidity_one_coin.py | 23 +------- tests/pools/meta/test_exchange_underlying.py | 12 +--- .../meta/test_exchange_underlying_reverts.py | 13 +---- .../pools/meta/test_get_dy_underlying_fix.py | 14 +---- .../pools/meta/test_get_virtual_price_meta.py | 4 +- tests/pools/meta/test_meta_new_ng_base.py | 22 ++------ tests/pools/meta/test_meta_zap.py | 36 ++---------- tests/pools/meta/test_meta_zap_ng_base.py | 56 ++++--------------- tests/pools/meta/test_receiver_meta.py | 8 +-- tests/pools/oracle/test_oracle.py | 31 ++-------- tests/pools/oracle/test_oracles.py | 10 +--- tests/token/test_token_approve.py | 4 +- tests/token/test_token_transfer_from.py | 4 +- tests/utils/tokens.py | 4 +- 42 files changed, 137 insertions(+), 554 deletions(-) diff --git a/.flake8 b/.flake8 index 76370a61..6deafc26 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,2 @@ [flake8] -max-line-length =100 -# codestyles - numpy, google, pep8 -# formatter - black -# instead of flake and black use ruff - same written in rust +max-line-length = 120 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13b11e6a..158bcdd6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,7 @@ repos: hooks: - id: black args: + - --line-length=120 - --skip-magic-trailing-comma - --target-version=py310 - repo: https://github.com/PyCQA/flake8 diff --git a/pyproject.toml b/pyproject.toml index a1241eab..1caf8ebf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ exclude = ''' )/ ) ''' -line-length = 100 +line-length = 120 target_version = ['py310'] [tool.isort] diff --git a/scripts/deploy_infra.py b/scripts/deploy_infra.py index b51d941a..eeed6273 100644 --- a/scripts/deploy_infra.py +++ b/scripts/deploy_infra.py @@ -29,14 +29,10 @@ def set_contract_pragma(contract_file, network) -> boa.contracts.vyper.vyper_con if is_shanghai_chain and "# pragma evm-version paris" in source: logger.log("Replacing EVM version to Shanghai ...") - new_source = source.replace( - "# pragma evm-version paris\n", "# pragma evm-version shanghai\n" - ) + new_source = source.replace("# pragma evm-version paris\n", "# pragma evm-version shanghai\n") elif not is_shanghai_chain and "# pragma evm-version shanghai" in source: logger.log("Replacing EVM version to Paris ...") - new_source = source.replace( - "# pragma evm-version shanghai\n", "# pragma evm-version paris\n" - ) + new_source = source.replace("# pragma evm-version shanghai\n", "# pragma evm-version paris\n") else: # all looks good ... new_source = source @@ -65,9 +61,7 @@ def check_and_deploy(contract_obj, contract_designation, network, blueprint: boo contract = contract_obj.deploy(*args) if args: constructor_args = encode(["address", "address"], args) - logger.log( - f"Constructor arguments for {contract_designation}: {constructor_args.hex()}" - ) + logger.log(f"Constructor arguments for {contract_designation}: {constructor_args.hex()}") else: if "zksync:mainnet" in network: if "CurveStableSwapNG.vy" == contract_name: @@ -114,9 +108,7 @@ def check_and_deploy(contract_obj, contract_designation, network, blueprint: boo logger.log(f"Deployed! At: {contract.address}.") else: - logger.log( - f"Deployed {contract_designation} contract exists. Using {deployed_contract} ..." - ) + logger.log(f"Deployed {contract_designation} contract exists. Using {deployed_contract} ...") contract = contract_obj.at(deployed_contract) return contract @@ -170,9 +162,7 @@ def deploy_infra(network, url, account, fork=False): meta_blueprint = check_and_deploy(meta_contract_obj, "meta_amm", network, blueprint=True) # Factory: - factory_contract_obj = set_contract_pragma( - "./contracts/main/CurveStableSwapFactoryNG.vy", network - ) + factory_contract_obj = set_contract_pragma("./contracts/main/CurveStableSwapFactoryNG.vy", network) args = [fee_receiver, deploy_utils.FIDDYDEPLOYER] factory = check_and_deploy(factory_contract_obj, "factory", network, False, args) diff --git a/scripts/deploy_pool.py b/scripts/deploy_pool.py index f58d2719..3965f70c 100644 --- a/scripts/deploy_pool.py +++ b/scripts/deploy_pool.py @@ -173,12 +173,8 @@ 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 - ) + 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) if __name__ == "__main__": diff --git a/scripts/set_up_base_pools.py b/scripts/set_up_base_pools.py index 56c45b7f..bcb57086 100644 --- a/scripts/set_up_base_pools.py +++ b/scripts/set_up_base_pools.py @@ -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, ), @@ -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, ), @@ -156,9 +147,7 @@ def set_up_base_pools(network, url, account, fork: bool = False): 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}." - ) + logger.log(f"{data.pool} is already configured as a base pool in factory {factory_address}.") assert factory.base_pool_data(data.pool)[0] == data.lp_token diff --git a/scripts/vote_utils.py b/scripts/vote_utils.py index 1180bd64..b9043e9a 100644 --- a/scripts/vote_utils.py +++ b/scripts/vote_utils.py @@ -50,9 +50,7 @@ def prepare_evm_script(target: Dict, actions: List[Tuple]) -> str: contract = ape.Contract(address) fn = getattr(contract, fn_name) calldata = fn.as_transaction(*args, sender=agent.address, gas_price=0).data - agent_calldata = agent.execute.as_transaction( - address, 0, calldata, sender=voting, gas_price=0 - ).data + agent_calldata = agent.execute.as_transaction(address, 0, calldata, sender=voting, gas_price=0).data length = hex(len(agent_calldata.hex()) // 2)[2:].zfill(8) evm_script = f"{evm_script}{agent.address[2:]}{length}{agent_calldata.hex()}" diff --git a/test_suite/generate_report.py b/test_suite/generate_report.py index 9d358ef0..75279915 100644 --- a/test_suite/generate_report.py +++ b/test_suite/generate_report.py @@ -69,16 +69,7 @@ def generate_report(): summary = extract_summary(line) if summary: - ( - failed, - passed, - skipped, - deselected, - xfailed, - warnings, - errors, - time_taken, - ) = summary + (failed, passed, skipped, deselected, xfailed, warnings, errors, time_taken) = summary total = int(sum(summary) - time_taken) # Extract folder, subfolder, filename, and timestamp relative_path = os.path.relpath(root, start=reports_base_dir) diff --git a/tests/conftest.py b/tests/conftest.py index c9ad5eff..bff1fb62 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -58,16 +58,12 @@ def pytest_generate_tests(metafunc): combined_ids.append(f"(PoolType={pool_name})") # Parametrize both pool_type and metapool_token_type together - metafunc.parametrize( - ("pool_type", "metapool_token_type"), combined_params, ids=combined_ids - ) + metafunc.parametrize(("pool_type", "metapool_token_type"), combined_params, ids=combined_ids) elif "pool_type" in metafunc.fixturenames: # or parametrize pool_type only pool_type_items = get_pool_types(metafunc) metafunc.parametrize( - "pool_type", - [v for k, v in pool_type_items], - ids=[f"(PoolType={k})" for k, v in pool_type_items], + "pool_type", [v for k, v in pool_type_items], ids=[f"(PoolType={k})" for k, v in pool_type_items] ) elif "metapool_token_type" in metafunc.fixturenames: # or parametrize metapool_token_type only @@ -89,9 +85,7 @@ def pytest_generate_tests(metafunc): # Parametrize initial_decimals if "initial_decimals" in metafunc.fixturenames: - metafunc.parametrize( - "initial_decimals", DECIMAL_PAIRS, ids=[f"(Decimals={i},{j})" for i, j in DECIMAL_PAIRS] - ) + metafunc.parametrize("initial_decimals", DECIMAL_PAIRS, ids=[f"(Decimals={i},{j})" for i, j in DECIMAL_PAIRS]) def get_pool_token_pairs(metafunc): diff --git a/tests/factory/test_factory_add_pools.py b/tests/factory/test_factory_add_pools.py index 382d62d2..f4c92d01 100644 --- a/tests/factory/test_factory_add_pools.py +++ b/tests/factory/test_factory_add_pools.py @@ -30,9 +30,7 @@ def empty_factory_with_implementations( return empty_factory -def test_add_base_pool_already_exists( - owner, factory, add_base_pool, base_pool, base_pool_lp_token, base_pool_tokens -): +def test_add_base_pool_already_exists(owner, factory, add_base_pool, base_pool, base_pool_lp_token, base_pool_tokens): with boa.reverts(): factory.add_base_pool( base_pool.address, @@ -54,9 +52,7 @@ def test_add_base_pool_only_admin(factory, bob, base_pool, base_pool_lp_token, b ) -def test_deploy_plain_pool( - empty_factory_with_implementations, amm_deployer, plain_tokens, pool_size, zero_address -): +def test_deploy_plain_pool(empty_factory_with_implementations, amm_deployer, plain_tokens, pool_size, zero_address): swap_address = empty_factory_with_implementations.deploy_plain_pool( "test", "test", @@ -81,9 +77,7 @@ def test_deploy_plain_pool( assert empty_factory_with_implementations.pool_count() == 1 assert empty_factory_with_implementations.pool_list(0) == swap.address - assert empty_factory_with_implementations.get_decimals(swap) == [ - t.decimals() for t in (plain_tokens) - ] + assert empty_factory_with_implementations.get_decimals(swap) == [t.decimals() for t in (plain_tokens)] def test_pool_count( diff --git a/tests/factory/test_factory_basic.py b/tests/factory/test_factory_basic.py index aa9a02f0..c5a24049 100644 --- a/tests/factory/test_factory_basic.py +++ b/tests/factory/test_factory_basic.py @@ -5,8 +5,7 @@ @pytest.mark.parametrize("sending,receiving", [(0, 1), (1, 0)]) def test_find_pool_for_coins(factory, basic_swap, pool_tokens, sending, receiving): assert ( - factory.find_pool_for_coins(pool_tokens[sending].address, pool_tokens[receiving].address) - == basic_swap.address + factory.find_pool_for_coins(pool_tokens[sending].address, pool_tokens[receiving].address) == basic_swap.address ) @@ -23,9 +22,7 @@ def test_get_decimals(factory, basic_swap, decimals): def test_get_balances(factory, basic_swap, pool_size): - assert factory.get_balances(basic_swap.address) == [ - basic_swap.balances(i) for i in range(pool_size) - ] + assert factory.get_balances(basic_swap.address) == [basic_swap.balances(i) for i in range(pool_size)] def test_get_underlying_balances(factory, basic_swap): diff --git a/tests/factory/test_factory_meta.py b/tests/factory/test_factory_meta.py index 21400b10..1243e964 100644 --- a/tests/factory/test_factory_meta.py +++ b/tests/factory/test_factory_meta.py @@ -9,23 +9,15 @@ @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 - ) + factory.find_pool_for_coins(underlying_tokens[sending].address, underlying_tokens[receiving].address) == meta_swap.address ) @pytest.mark.parametrize("idx", range(1, 4)) def test_find_pool_for_coins_underlying(factory, meta_swap, underlying_tokens, idx): - assert ( - factory.find_pool_for_coins(underlying_tokens[0], underlying_tokens[idx]) - == meta_swap.address - ) - assert ( - factory.find_pool_for_coins(underlying_tokens[idx], underlying_tokens[0]) - == meta_swap.address - ) + assert factory.find_pool_for_coins(underlying_tokens[0], underlying_tokens[idx]) == meta_swap.address + assert factory.find_pool_for_coins(underlying_tokens[idx], underlying_tokens[0]) == meta_swap.address def test_get_meta_n_coins(factory, meta_swap): @@ -42,34 +34,21 @@ def test_get_underlying_decimals(factory, meta_swap, base_pool_decimals): def test_get_metapool_rates(meta_setup, factory, meta_swap, base_pool, base_pool_lp_token): - 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(meta_setup, factory, meta_swap, base_pool): - 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( - factory, underlying_tokens, sending, receiving, zero_address -): - assert ( - factory.find_pool_for_coins(underlying_tokens[sending], underlying_tokens[receiving]) - == zero_address - ) +def test_find_pool_underlying_base_pool_only(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 @@ -78,9 +57,7 @@ def test_get_coin_indices_underlying(factory, meta_swap, sending, receiving, und @pytest.mark.parametrize("idx", range(1, 4)) def test_get_coin_indices_reverts(factory, meta_swap, base_pool_lp_token, underlying_tokens, idx): with boa.reverts(): - factory.get_coin_indices( - meta_swap.address, base_pool_lp_token.address, underlying_tokens[idx] - ) + factory.get_coin_indices(meta_swap.address, base_pool_lp_token.address, underlying_tokens[idx]) def test_get_implementation_address(factory, meta_swap, amm_implementation_meta): diff --git a/tests/fixtures/accounts.py b/tests/fixtures/accounts.py index 72fae5b2..2d9f89e5 100644 --- a/tests/fixtures/accounts.py +++ b/tests/fixtures/accounts.py @@ -129,9 +129,7 @@ def add_initial_liquidity_owner_meta( with boa.env.prank(owner): base_pool_lp_token.approve(meta_swap.address, 2**256 - 1) lp_token_bal = base_pool_lp_token.balanceOf(owner) - to_mint_token0 = ( - lp_token_bal * 10 ** metapool_token.decimals() // 10 ** base_pool_lp_token.decimals() - ) + to_mint_token0 = lp_token_bal * 10 ** metapool_token.decimals() // 10 ** base_pool_lp_token.decimals() mint_for_testing(owner, to_mint_token0, metapool_token, False) metapool_token.approve(meta_swap.address, 2**256 - 1) @@ -211,11 +209,7 @@ def meta_setup( alice_mp_balance_norm = metapool_token.balanceOf(alice) / 10 ** metapool_token.decimals() if alice_mp_balance_norm < alice_bp_balance_norm: - mint_for_testing( - alice, - int(math.ceil(alice_bp_balance_norm) * 10 ** metapool_token.decimals()), - metapool_token, - ) + mint_for_testing(alice, int(math.ceil(alice_bp_balance_norm) * 10 ** metapool_token.decimals()), metapool_token) with boa.env.prank(alice): metapool_token.approve(meta_swap.address, 2**256 - 1) @@ -243,8 +237,6 @@ def initial_setup(pool_type, request, metapool_token_type, pool_token_types, ini # For basic pools, we don't care about metapool_token_type metapool_token_type = None # Continue with the general logic - assert all( - fixture is not None for fixture in (initial_decimals, pool_token_types) - ), "Fixtures required downstream" + assert all(fixture is not None for fixture in (initial_decimals, pool_token_types)), "Fixtures required downstream" fixture_name = {POOL_TYPES["basic"]: "basic_setup", POOL_TYPES["meta"]: "meta_setup"}[pool_type] return request.getfixturevalue(fixture_name) diff --git a/tests/fixtures/factory.py b/tests/fixtures/factory.py index 4bda93b8..72d47672 100644 --- a/tests/fixtures/factory.py +++ b/tests/fixtures/factory.py @@ -34,13 +34,7 @@ def math_implementation(deployer, math_deployer): @pytest.fixture() def factory( - deployer, - fee_receiver, - owner, - gauge_implementation, - views_implementation, - math_implementation, - factory_deployer, + deployer, fee_receiver, owner, gauge_implementation, views_implementation, math_implementation, factory_deployer ): with boa.env.prank(deployer): factory = factory_deployer.deploy(fee_receiver, owner) @@ -70,10 +64,7 @@ def set_metapool_implementations(owner, factory, amm_implementation_meta): def add_base_pool(owner, factory, base_pool, base_pool_lp_token, base_pool_tokens): with boa.env.prank(owner): factory.add_base_pool( - base_pool.address, - base_pool_lp_token.address, - [0] * len(base_pool_tokens), - len(base_pool_tokens), + base_pool.address, base_pool_lp_token.address, [0] * len(base_pool_tokens), len(base_pool_tokens) ) diff --git a/tests/fixtures/pools.py b/tests/fixtures/pools.py index 5cdd68e9..1ed2129f 100644 --- a/tests/fixtures/pools.py +++ b/tests/fixtures/pools.py @@ -9,9 +9,7 @@ @pytest.fixture() -def basic_swap( - deployer, factory, pool_size, pool_tokens, zero_address, amm_deployer, set_pool_implementations -): +def basic_swap(deployer, factory, pool_size, pool_tokens, zero_address, amm_deployer, set_pool_implementations): A = 2000 fee = 1000000 method_ids = [b""] * pool_size @@ -55,13 +53,7 @@ def basic_swap( @pytest.fixture() def meta_swap( - factory, - set_metapool_implementations, - zero_address, - metapool_token, - base_pool, - meta_deployer, - add_base_pool, + factory, set_metapool_implementations, zero_address, metapool_token, base_pool, meta_deployer, add_base_pool ): A = 2000 fee = 1000000 @@ -115,9 +107,7 @@ def swap(request, pool_type, pool_token_types, initial_decimals, metapool_token_ metapool_token_type = None # Continue with the general logic - assert all( - fixture is not None for fixture in (initial_decimals, pool_token_types) - ), "Fixtures required downstream" + assert all(fixture is not None for fixture in (initial_decimals, pool_token_types)), "Fixtures required downstream" fixture_name = {POOL_TYPES["basic"]: "basic_swap", POOL_TYPES["meta"]: "meta_swap"}[pool_type] return request.getfixturevalue(fixture_name) @@ -128,12 +118,7 @@ def swap(request, pool_type, pool_token_types, initial_decimals, metapool_token_ def base_pool(deployer, owner, alice, base_pool_tokens, base_pool_lp_token, base_pool_deployer): with boa.env.prank(deployer): base_pool = base_pool_deployer.deploy( - owner, - [t.address for t in base_pool_tokens], - base_pool_lp_token.address, - 200, - 3000000, - 5000000000, + owner, [t.address for t in base_pool_tokens], base_pool_lp_token.address, 200, 3000000, 5000000000 ) base_pool_lp_token.set_minter(base_pool.address) return base_pool diff --git a/tests/fixtures/tokens.py b/tests/fixtures/tokens.py index ab81cc47..ba048d84 100644 --- a/tests/fixtures/tokens.py +++ b/tests/fixtures/tokens.py @@ -8,9 +8,7 @@ @pytest.fixture() def plain_tokens(erc20_deployer, deployer, decimals): with boa.env.prank(deployer): - return [ - erc20_deployer.deploy(f"TKN{i}", f"TKN{i}", decimals[i]) for i, d in enumerate(decimals) - ] + return [erc20_deployer.deploy(f"TKN{i}", f"TKN{i}", decimals[i]) for i, d in enumerate(decimals)] @pytest.fixture() @@ -48,9 +46,7 @@ def pool_tokens(pool_token_types, request, initial_decimals): # <--------------------- Metapool configuration ---------------------> @pytest.fixture() def metapool_token(metapool_token_type, request, initial_decimals, pool_token_types): - assert ( - initial_decimals and pool_token_types - ), "Fixtures required for requesting `decimals` downstream" + assert initial_decimals and pool_token_types, "Fixtures required for requesting `decimals` downstream" fixture = { TOKEN_TYPES["plain"]: "plain_tokens", TOKEN_TYPES["oracle"]: "oracle_tokens", @@ -71,10 +67,7 @@ def base_pool_decimals(): @pytest.fixture() def base_pool_tokens(erc20_deployer, deployer, base_pool_decimals): with boa.env.prank(deployer): - return [ - erc20_deployer.deploy(c, c, base_pool_decimals[i]) - for i, c in enumerate(("DAI", "USDC", "USDT")) - ] + return [erc20_deployer.deploy(c, c, base_pool_decimals[i]) for i, c in enumerate(("DAI", "USDC", "USDT"))] @pytest.fixture() diff --git a/tests/pools/exchange/test_exchange.py b/tests/pools/exchange/test_exchange.py index f67aa3e9..0d31d686 100644 --- a/tests/pools/exchange/test_exchange.py +++ b/tests/pools/exchange/test_exchange.py @@ -29,9 +29,7 @@ def test_min_dy( amount = 1_000 * 10 ** decimals[sending] initial_receiving = ( - pool_tokens[receiving].balanceOf(bob) - if pool_type == 0 - else underlying_tokens[receiving].balanceOf(bob) + pool_tokens[receiving].balanceOf(bob) if pool_type == 0 else underlying_tokens[receiving].balanceOf(bob) ) min_dy = swap.get_dy(sending, receiving, amount) @@ -55,9 +53,7 @@ def test_min_dy( # we correct for expected min_dy (inflate it) by value of pool balances after transfer_in # min_dy is thus roughly inflated by token_in (now rebased) held by pool # approximate assert because of how min_dy is approximated - min_dy += ( - pool_balance_token_in - ) // 1000000 # that works because pool has equal balances more or less + min_dy += (pool_balance_token_in) // 1000000 # that works because pool has equal balances more or less assert receiving_token_diff == pytest.approx(min_dy, rel=0.01 / 100) # 0.01% relative error elif pool_type == 0 and pool_token_types[receiving] == 2 and pool_token_types[sending] != 2: @@ -80,9 +76,7 @@ def test_min_dy( # in metapools LP tokens are always basic and always on idx 1, so idx 0 is rebasing here if sending == 0: # user sends rebasing token # if sending = 0 and receiving = 1, we have: token_in = rebasing, token_out = nonrebasing [case 1a)] - min_dy += ( - pool_balance_token_in - ) // 1000000 # that works because pool has equal balances more or less + min_dy += (pool_balance_token_in) // 1000000 # that works because pool has equal balances more or less # 1% relative error - we are in metapool, and not perfectly balanced assert receiving_token_diff == pytest.approx(min_dy, rel=0.01 / 100) else: diff --git a/tests/pools/exchange/test_exchange_received.py b/tests/pools/exchange/test_exchange_received.py index cb8b9181..384deb02 100644 --- a/tests/pools/exchange/test_exchange_received.py +++ b/tests/pools/exchange/test_exchange_received.py @@ -64,9 +64,7 @@ def _transfer_and_swap(pool, sending: int, receiving: int, underlying: bool): # swap with boa.env.prank(bob): - amount_out = callback_contract.transfer_and_swap( - sending, receiving, input_coin, amount_in, 0, underlying - ) + amount_out = callback_contract.transfer_and_swap(sending, receiving, input_coin, amount_in, 0, underlying) assert amount_out > 0 # record balances after @@ -91,14 +89,8 @@ def _transfer_and_swap(pool, sending: int, receiving: int, underlying: bool): "receiving_token": [pool_receiving_balance_before, pool_receiving_balance_after], }, "base_pool": { - "sending_token": [ - base_pool_sending_balance_before, - base_pool_sending_balance_after, - ], - "receiving_token": [ - base_pool_receiving_balance_before, - base_pool_receiving_balance_after, - ], + "sending_token": [base_pool_sending_balance_before, base_pool_sending_balance_after], + "receiving_token": [base_pool_receiving_balance_before, base_pool_receiving_balance_after], }, } @@ -120,22 +112,14 @@ def test_exchange_received_nonrebasing(swap, sending, receiving, transfer_and_sw assert swap_data is None else: swap_data = transfer_and_swap(swap, sending, receiving, False) + assert swap_data["bob"]["sending_token"][0] - swap_data["bob"]["sending_token"][1] == swap_data["amount_in"] assert ( - swap_data["bob"]["sending_token"][0] - swap_data["bob"]["sending_token"][1] - == swap_data["amount_in"] - ) - assert ( - swap_data["bob"]["receiving_token"][1] - swap_data["bob"]["receiving_token"][0] - == swap_data["amount_out"] + swap_data["bob"]["receiving_token"][1] - swap_data["bob"]["receiving_token"][0] == swap_data["amount_out"] ) + assert swap_data["swap"]["sending_token"][1] - swap_data["swap"]["sending_token"][0] == swap_data["amount_in"] assert ( - swap_data["swap"]["sending_token"][1] - swap_data["swap"]["sending_token"][0] - == swap_data["amount_in"] - ) - assert ( - swap_data["swap"]["receiving_token"][0] - swap_data["swap"]["receiving_token"][1] - == swap_data["amount_out"] + swap_data["swap"]["receiving_token"][0] - swap_data["swap"]["receiving_token"][1] == swap_data["amount_out"] ) @@ -147,9 +131,7 @@ def test_exchange_not_received(bob, swap, pool_tokens, sending, receiving): @pytest.mark.parametrize("sending,receiving", [(0, 1), (1, 0)]) -def test_exchange_received_no_dos( - bob, charlie, swap, pool_tokens, sending, receiving, transfer_and_swap -): +def test_exchange_received_no_dos(bob, charlie, swap, pool_tokens, sending, receiving, transfer_and_swap): if not swap._immutables.pool_contains_rebasing_tokens: mint_for_testing(bob, 1, pool_tokens[sending], False) pool_tokens[sending].transfer(swap, 1, sender=bob) diff --git a/tests/pools/exchange/test_exchange_receiver.py b/tests/pools/exchange/test_exchange_receiver.py index fd82168b..ef03709b 100644 --- a/tests/pools/exchange/test_exchange_receiver.py +++ b/tests/pools/exchange/test_exchange_receiver.py @@ -11,19 +11,9 @@ def test_add_liquidity(bob, charlie, swap, deposit_amounts): def test_exchange( - bob, - charlie, - swap, - pool_type, - pool_tokens, - underlying_tokens, - decimals, - pool_token_types, - metapool_token_type, + bob, charlie, swap, pool_type, pool_tokens, underlying_tokens, decimals, pool_token_types, metapool_token_type ): - balance = ( - pool_tokens[0].balanceOf(bob) if pool_type == 0 else underlying_tokens[0].balanceOf(bob) - ) + balance = pool_tokens[0].balanceOf(bob) if pool_type == 0 else underlying_tokens[0].balanceOf(bob) swap.exchange(1, 0, 1000 * 10**18, 0, charlie, sender=bob) if pool_type == 0: @@ -41,15 +31,7 @@ def test_exchange( def test_remove_liquidity( - bob, - swap, - charlie, - pool_type, - pool_tokens, - underlying_tokens, - initial_amounts, - pool_size, - deposit_amounts, + bob, swap, charlie, pool_type, pool_tokens, underlying_tokens, initial_amounts, pool_size, deposit_amounts ): swap.add_liquidity(deposit_amounts, 0, sender=bob) initial_amount = swap.balanceOf(bob) @@ -59,23 +41,15 @@ def test_remove_liquidity( i = 0 if pool_type == 0: for coin, amount in zip(pool_tokens, deposit_amounts): - assert coin.balanceOf(swap) + coin.balanceOf(charlie) == pytest.approx( - deposit_amounts[0] * 2, rel=1.5e-2 - ) + assert coin.balanceOf(swap) + coin.balanceOf(charlie) == pytest.approx(deposit_amounts[0] * 2, rel=1.5e-2) i += 1 else: for coin, amount in zip(underlying_tokens[:2], deposit_amounts): - assert coin.balanceOf(swap) + coin.balanceOf(charlie) == pytest.approx( - deposit_amounts[0] * 2, rel=1.5e-2 - ) + assert coin.balanceOf(swap) + coin.balanceOf(charlie) == pytest.approx(deposit_amounts[0] * 2, rel=1.5e-2) i += 1 - assert swap.balanceOf(bob) == pytest.approx( - deposit_amounts[0] * pool_size - withdraw_amount, rel=1.5e-2 - ) - assert swap.totalSupply() == pytest.approx( - deposit_amounts[0] * 2 * pool_size - withdraw_amount, rel=1.5e-2 - ) + assert swap.balanceOf(bob) == pytest.approx(deposit_amounts[0] * pool_size - withdraw_amount, rel=1.5e-2) + assert swap.totalSupply() == pytest.approx(deposit_amounts[0] * 2 * pool_size - withdraw_amount, rel=1.5e-2) def test_remove_imbalanced( @@ -89,15 +63,11 @@ def test_remove_imbalanced( if pool_type == 0: for i, coin in enumerate(pool_tokens): assert coin.balanceOf(charlie) == pytest.approx(amounts[i], rel=1.5e-2) - assert coin.balanceOf(swap) == pytest.approx( - initial_amounts[i] - amounts[i], rel=1.5e-2 - ) + assert coin.balanceOf(swap) == pytest.approx(initial_amounts[i] - amounts[i], rel=1.5e-2) else: for i, coin in enumerate(underlying_tokens[:2]): assert coin.balanceOf(charlie) == pytest.approx(amounts[i], rel=1.5e-2) - assert coin.balanceOf(swap) == pytest.approx( - initial_amounts[i] - amounts[i], rel=1.5e-2 - ) + assert coin.balanceOf(swap) == pytest.approx(initial_amounts[i] - amounts[i], rel=1.5e-2) assert swap.balanceOf(bob) / balance == pytest.approx(0.5, rel=1.5e-2) diff --git a/tests/pools/exchange/test_exchange_reverts.py b/tests/pools/exchange/test_exchange_reverts.py index 9fff4ad8..b9df774d 100644 --- a/tests/pools/exchange/test_exchange_reverts.py +++ b/tests/pools/exchange/test_exchange_reverts.py @@ -1,5 +1,3 @@ -import time - import boa import pytest @@ -55,14 +53,7 @@ def test_insufficient_balance( @pytest.mark.parametrize("sending,receiving", [(0, 1), (1, 0)]) def test_zero_amount_swap( - charlie, - pool_tokens, - underlying_tokens, - swap, - sending, - receiving, - decimals, - contains_rebasing_tokens, + charlie, pool_tokens, underlying_tokens, swap, sending, receiving, decimals, contains_rebasing_tokens ): with boa.reverts(): swap.exchange(sending, receiving, 0, 0, sender=charlie) diff --git a/tests/pools/general/test_erc4626_swaps.py b/tests/pools/general/test_erc4626_swaps.py index 6abeba77..d3e962e3 100644 --- a/tests/pools/general/test_erc4626_swaps.py +++ b/tests/pools/general/test_erc4626_swaps.py @@ -30,9 +30,7 @@ def mint_tokens(charlie, pool_erc20_tokens, pool_tokens, swap, i): mint_for_testing(charlie, amount_erc20_in, pool_erc20_tokens[i], False) amount_in = pool_erc20_tokens[i].balanceOf(charlie) - bal_before else: - amount_in = mint_vault_tokens( - amount_erc20_in, pool_erc20_tokens[0], pool_tokens[0], charlie - ) + amount_in = mint_vault_tokens(amount_erc20_in, pool_erc20_tokens[0], pool_tokens[0], charlie) pool_tokens[i].approve(swap, 2**256 - 1, sender=charlie) @@ -89,15 +87,7 @@ def asset_types(pool_tokens): @pytest.fixture() -def empty_swap( - deployer, - factory, - pool_tokens, - zero_address, - amm_deployer, - asset_types, - set_pool_implementations, -): +def empty_swap(deployer, factory, pool_tokens, zero_address, amm_deployer, asset_types, set_pool_implementations): pool_size = len(pool_tokens) oracle_method_id = function_signature_to_4byte_selector("exchangeRate()") offpeg_fee_multiplier = 20000000000 diff --git a/tests/pools/general/test_fees.py b/tests/pools/general/test_fees.py index 30f896de..f1f62511 100644 --- a/tests/pools/general/test_fees.py +++ b/tests/pools/general/test_fees.py @@ -4,9 +4,7 @@ @pytest.mark.parametrize("sending,receiving", [(0, 1), (1, 0)]) -def test_admin_balances( - bob, swap, pool_type, pool_tokens, underlying_tokens, initial_amounts, sending, receiving -): +def test_admin_balances(bob, swap, pool_type, pool_tokens, underlying_tokens, initial_amounts, sending, receiving): for send, recv in [(sending, receiving), (receiving, sending)]: swap.exchange(send, recv, initial_amounts[send], 0, sender=bob) @@ -21,16 +19,7 @@ def test_admin_balances( @pytest.mark.parametrize("sending,receiving", [(0, 1), (1, 0)]) def test_withdraw_one_coin( - alice, - bob, - fee_receiver, - swap, - pool_type, - pool_tokens, - underlying_tokens, - sending, - receiving, - initial_amounts, + alice, bob, fee_receiver, swap, pool_type, pool_tokens, underlying_tokens, sending, receiving, initial_amounts ): swap.exchange(sending, receiving, initial_amounts[sending], 0, sender=bob) @@ -41,9 +30,7 @@ def test_withdraw_one_coin( swap.withdraw_admin_fees(sender=alice) swap_balance = ( - pool_tokens[receiving].balanceOf(swap) - if pool_type == 0 - else underlying_tokens[receiving].balanceOf(swap) + pool_tokens[receiving].balanceOf(swap) if pool_type == 0 else underlying_tokens[receiving].balanceOf(swap) ) assert swap.balances(receiving) == swap_balance expected_balance = ( @@ -66,9 +53,7 @@ def test_no_fees(bob, fee_receiver, swap, pool_type, pool_tokens, underlying_tok assert coin.balanceOf(fee_receiver) == 0 -def test_withdraw_admin_fees( - bob, swap, pool_type, pool_tokens, underlying_tokens, fee_receiver, decimals -): +def test_withdraw_admin_fees(bob, swap, pool_type, pool_tokens, underlying_tokens, fee_receiver, decimals): swap.exchange(1, 0, 10_000 * 10 ** decimals[1], 0, sender=bob) fees = [] diff --git a/tests/pools/general/test_ramp_A.py b/tests/pools/general/test_ramp_A.py index 6d3b041d..b7de264a 100644 --- a/tests/pools/general/test_ramp_A.py +++ b/tests/pools/general/test_ramp_A.py @@ -35,9 +35,7 @@ def test_ramp_A_value_up(owner, swap): while boa.env.evm.patch.timestamp < future_time: boa.env.time_travel(100000) - expected = int( - initial_A + ((boa.env.evm.patch.timestamp - initial_timestamp) / duration) * initial_A - ) + expected = int(initial_A + ((boa.env.evm.patch.timestamp - initial_timestamp) / duration) * initial_A) assert 0.999 < expected / swap.A() <= 1 @@ -52,8 +50,7 @@ def test_ramp_A_value_down(owner, swap): while boa.env.evm.patch.timestamp < future_time: boa.env.time_travel(100000) expected = int( - initial_A - - ((boa.env.evm.patch.timestamp - initial_timestamp) / duration) * (initial_A // 10 * 9) + initial_A - ((boa.env.evm.patch.timestamp - initial_timestamp) / duration) * (initial_A // 10 * 9) ) if expected == 0: assert swap.A() == initial_A // 10 diff --git a/tests/pools/general/test_specific_liquidity_operations.py b/tests/pools/general/test_specific_liquidity_operations.py index 4d1a857d..15285ff0 100644 --- a/tests/pools/general/test_specific_liquidity_operations.py +++ b/tests/pools/general/test_specific_liquidity_operations.py @@ -42,15 +42,7 @@ def asset_types(pool_tokens): @pytest.fixture() -def empty_swap( - deployer, - factory, - pool_tokens, - zero_address, - amm_deployer, - asset_types, - set_pool_implementations, -): +def empty_swap(deployer, factory, pool_tokens, zero_address, amm_deployer, asset_types, set_pool_implementations): pool_size = len(pool_tokens) oracle_method_id = function_signature_to_4byte_selector("exchangeRate()") offpeg_fee_multiplier = 20000000000 diff --git a/tests/pools/general/test_swap_getters.py b/tests/pools/general/test_swap_getters.py index db853f04..e4f33ac0 100644 --- a/tests/pools/general/test_swap_getters.py +++ b/tests/pools/general/test_swap_getters.py @@ -2,11 +2,7 @@ from boa.test import strategy from hypothesis import HealthCheck, given, settings -SETTINGS = { - "max_examples": 100, - "deadline": None, - "suppress_health_check": [HealthCheck.function_scoped_fixture], -} +SETTINGS = {"max_examples": 100, "deadline": None, "suppress_health_check": [HealthCheck.function_scoped_fixture]} @given( diff --git a/tests/pools/liquidity/test_add_liquidity.py b/tests/pools/liquidity/test_add_liquidity.py index 7737ebe3..1c8b2cbc 100644 --- a/tests/pools/liquidity/test_add_liquidity.py +++ b/tests/pools/liquidity/test_add_liquidity.py @@ -89,9 +89,7 @@ def test_add_one_coin( if metapool_token_type == 2: is_ideal = False assert underlying_tokens[0].balanceOf(bob) >= initial_amounts[0] - amounts[0] - 1 - assert ( - underlying_tokens[0].balanceOf(swap.address) >= deposit_amounts[0] + amounts[0] - 1 - ) + assert underlying_tokens[0].balanceOf(swap.address) >= deposit_amounts[0] + amounts[0] - 1 else: assert underlying_tokens[0].balanceOf(bob) == initial_amounts[0] - amounts[0] assert underlying_tokens[0].balanceOf(swap) == deposit_amounts[0] + amounts[0] @@ -107,9 +105,7 @@ def test_add_one_coin( @pytest.mark.extensive_token_pairs -def test_insufficient_balance( - charlie, swap, pool_type, decimals, meta_decimals, pool_token_types, pool_tokens -): +def test_insufficient_balance(charlie, swap, pool_type, decimals, meta_decimals, pool_token_types, pool_tokens): if pool_type == 0: amounts = [(10**i) for i in decimals] else: @@ -128,14 +124,10 @@ def test_min_amount_too_high(bob, swap, pool_type, deposit_amounts, pool_tokens) size = len(pool_tokens) with boa.reverts(): - swap.add_liquidity( - deposit_amounts, size * INITIAL_AMOUNT // 2 * 10**18 * 101 // 100, sender=bob - ) + swap.add_liquidity(deposit_amounts, size * INITIAL_AMOUNT // 2 * 10**18 * 101 // 100, sender=bob) -def test_event( - bob, swap, pool_type, deposit_amounts, pool_tokens, pool_token_types, metapool_token_type -): +def test_event(bob, swap, pool_type, deposit_amounts, pool_tokens, pool_token_types, metapool_token_type): # if pool_type == 1 and metapool_token_type == 0: # pytest.xfail("pool_type = meta, meta token type = plain - should be fixed") size = 2 @@ -151,9 +143,7 @@ def test_event( if metapool_token_type != 0: check_invariant = False - _, events = call_returning_result_and_logs( - swap, "add_liquidity", deposit_amounts, 0, sender=bob - ) + _, events = call_returning_result_and_logs(swap, "add_liquidity", deposit_amounts, 0, sender=bob) assert len(events) == 4 # Transfer token1, Transfer token2, Transfer LP, Add liquidity @@ -164,10 +154,7 @@ def test_event( event_string = repr(events[3]) # Extract values using regex provider = re.search(r"provider=([0-9a-fA-Fx]+)", event_string).group(1) - token_amounts = [ - int(x) - for x in re.search(r"token_amounts=\[([0-9, ]+)\]", event_string).group(1).split(", ") - ] + # token_amounts = [int(x) for x in re.search(r"token_amounts=\[([0-9, ]+)\]", event_string).group(1).split(", ")] fees = [int(x) for x in re.search(r"fees=\[([0-9, ]+)\]", event_string).group(1).split(", ")] invariant = int(re.search(r"invariant=([0-9]+)", event_string).group(1)) token_supply = int(re.search(r"token_supply=([0-9]+)", event_string).group(1)) diff --git a/tests/pools/liquidity/test_remove_liquidity.py b/tests/pools/liquidity/test_remove_liquidity.py index e10fa7de..0d524d8f 100644 --- a/tests/pools/liquidity/test_remove_liquidity.py +++ b/tests/pools/liquidity/test_remove_liquidity.py @@ -27,29 +27,21 @@ def test_remove_liquidity( or (pool_type == 1 and metapool_token_type == 2) # and we have rebasing tokens ): swap.remove_liquidity( - swap.balanceOf(alice), - [int(0.99 * i * min_amount) for i in deposit_amounts], - sender=alice, + swap.balanceOf(alice), [int(0.99 * i * min_amount) for i in deposit_amounts], sender=alice ) else: - swap.remove_liquidity( - swap.balanceOf(alice), [i * min_amount for i in deposit_amounts], sender=alice - ) + swap.remove_liquidity(swap.balanceOf(alice), [i * min_amount for i in deposit_amounts], sender=alice) amounts_after = [coin.balanceOf(alice) for coin in coins] - for coin, coin_type, amount_before, amount_after in zip( - coins, pool_token_types, amounts_before, amounts_after - ): + for coin, coin_type, amount_before, amount_after in zip(coins, pool_token_types, amounts_before, amounts_after): assert amount_after == pytest.approx( amount_before * 2, rel=1.5e-2 ) # we deposit half of all balance value (approx for orcales, rebasing etc) if (pool_type == 0 and coin_type == 2) or (pool_type == 1 and metapool_token_type == 2): assert coin.balanceOf(swap) == pytest.approx( - 0, - abs=(amount_after - amount_before) - * (1 - 1000000 / 1000001), # approx for rebasing tokens + 0, abs=(amount_after - amount_before) * (1 - 1000000 / 1000001) # approx for rebasing tokens ) else: assert coin.balanceOf(swap) == 0 @@ -65,9 +57,7 @@ def test_remove_partial(alice, swap, pool_type, pool_tokens, underlying_tokens, swap.remove_liquidity(withdraw_amount, [0] * pool_size, sender=alice) for coin in coins: - assert coin.balanceOf(swap) + coin.balanceOf(alice) == pytest.approx( - initial_amount, rel=1.5e-2 - ) + assert coin.balanceOf(swap) + coin.balanceOf(alice) == pytest.approx(initial_amount, rel=1.5e-2) assert swap.balanceOf(alice) == initial_amount - withdraw_amount assert swap.totalSupply() == initial_amount - withdraw_amount @@ -89,8 +79,6 @@ def test_amount_exceeds_balance(alice, swap, pool_size): def test_event(alice, bob, swap, pool_size): swap.transfer(bob, 10**18, sender=alice) - _, events = call_returning_result_and_logs( - swap, "remove_liquidity", 10**18, [0] * pool_size, sender=alice - ) + _, events = call_returning_result_and_logs(swap, "remove_liquidity", 10**18, [0] * pool_size, sender=alice) assert f"RemoveLiquidity(provider={alice}" in repr(events[3]) diff --git a/tests/pools/liquidity/test_remove_liquidity_imbalance.py b/tests/pools/liquidity/test_remove_liquidity_imbalance.py index 80fd3eef..2cb5fad6 100644 --- a/tests/pools/liquidity/test_remove_liquidity_imbalance.py +++ b/tests/pools/liquidity/test_remove_liquidity_imbalance.py @@ -8,14 +8,7 @@ @pytest.mark.parametrize("divisor", [2, 5, 10]) def test_remove_balanced( - alice, - swap, - pool_type, - pool_tokens, - underlying_tokens, - divisor, - deposit_amounts, - initial_amounts, + alice, swap, pool_type, pool_tokens, underlying_tokens, divisor, deposit_amounts, initial_amounts ): initial_balance = swap.balanceOf(alice) amounts = [i // divisor for i in deposit_amounts] @@ -24,9 +17,7 @@ def test_remove_balanced( coins = pool_tokens if pool_type == 0 else underlying_tokens[:2] for i, coin in enumerate(coins): - assert coin.balanceOf(alice) == pytest.approx( - amounts[i] + initial_amounts[i] - deposit_amounts[i], rel=1.5e-2 - ) + assert coin.balanceOf(alice) == pytest.approx(amounts[i] + initial_amounts[i] - deposit_amounts[i], rel=1.5e-2) assert coin.balanceOf(swap) == pytest.approx(deposit_amounts[i] - amounts[i], rel=1.5e-2) assert swap.balanceOf(alice) / initial_balance == pytest.approx(1 - 1 / divisor, rel=1.5e-2) @@ -34,15 +25,7 @@ def test_remove_balanced( @pytest.mark.parametrize("idx", range(2)) def test_remove_one( - alice, - swap, - pool_type, - pool_tokens, - underlying_tokens, - pool_size, - idx, - deposit_amounts, - initial_amounts, + alice, swap, pool_type, pool_tokens, underlying_tokens, pool_size, idx, deposit_amounts, initial_amounts ): amounts = [0] * pool_size amounts[idx] = deposit_amounts[idx] // 2 @@ -53,9 +36,7 @@ def test_remove_one( coins = pool_tokens if pool_type == 0 else underlying_tokens[:2] for i, coin in enumerate(coins): - assert coin.balanceOf(alice) == pytest.approx( - amounts[i] + initial_amounts[i] - deposit_amounts[i], rel=1.5e-2 - ) + assert coin.balanceOf(alice) == pytest.approx(amounts[i] + initial_amounts[i] - deposit_amounts[i], rel=1.5e-2) assert coin.balanceOf(swap) == pytest.approx(deposit_amounts[i] - amounts[i], rel=1.5e-2) actual_balance = swap.balanceOf(alice) @@ -92,8 +73,6 @@ def test_event(alice, bob, swap, pool_size, deposit_amounts): amounts = [i // 5 for i in deposit_amounts] max_burn = pool_size * 1_000_000 * 10**18 - _, events = call_returning_result_and_logs( - swap, "remove_liquidity_imbalance", amounts, max_burn, sender=bob - ) + _, events = call_returning_result_and_logs(swap, "remove_liquidity_imbalance", amounts, max_burn, sender=bob) assert f"RemoveLiquidityImbalance(provider={bob}" in repr(events[3]) diff --git a/tests/pools/liquidity/test_remove_liquidity_one_coin.py b/tests/pools/liquidity/test_remove_liquidity_one_coin.py index 0632d6cf..26e89f77 100644 --- a/tests/pools/liquidity/test_remove_liquidity_one_coin.py +++ b/tests/pools/liquidity/test_remove_liquidity_one_coin.py @@ -8,15 +8,7 @@ @pytest.mark.parametrize("idx", range(2)) def test_amount_received( - alice, - swap, - pool_type, - pool_tokens, - pool_token_types, - metapool_token_type, - underlying_tokens, - decimals, - idx, + alice, swap, pool_type, pool_tokens, pool_token_types, metapool_token_type, underlying_tokens, decimals, idx ): coins = pool_tokens if pool_type == 0 else underlying_tokens[:2] initial_amount = coins[idx].balanceOf(alice) @@ -49,14 +41,7 @@ def test_lp_token_balance(alice, swap, idx, divisor): @pytest.mark.parametrize("idx", range(2)) def test_expected_vs_actual( - alice, - swap, - pool_type, - pool_tokens, - pool_token_types, - metapool_token_type, - underlying_tokens, - idx, + alice, swap, pool_type, pool_tokens, pool_token_types, metapool_token_type, underlying_tokens, idx ): coins = pool_tokens if pool_type == 0 else underlying_tokens[:2] initial_amount = coins[idx].balanceOf(alice) @@ -102,7 +87,5 @@ def test_above_n_coins(alice, swap, pool_size): @pytest.mark.parametrize("idx", range(2)) def test_event(alice, bob, swap, idx): swap.transfer(bob, 10**18, sender=alice) - _, events = call_returning_result_and_logs( - swap, "remove_liquidity_one_coin", 10**18, idx, 0, sender=bob - ) + _, events = call_returning_result_and_logs(swap, "remove_liquidity_one_coin", 10**18, idx, 0, sender=bob) assert f"RemoveLiquidityOne(provider={bob}" in repr(events[2]) diff --git a/tests/pools/meta/test_exchange_underlying.py b/tests/pools/meta/test_exchange_underlying.py index a99dca33..7b7ec435 100644 --- a/tests/pools/meta/test_exchange_underlying.py +++ b/tests/pools/meta/test_exchange_underlying.py @@ -11,9 +11,7 @@ @pytest.mark.only_plain_tokens @pytest.mark.parametrize("sending,receiving", [p for p in permutations if 0 in p]) -def test_amounts( - bob, meta_swap, underlying_tokens, sending, receiving, meta_decimals, base_pool_decimals -): +def test_amounts(bob, meta_swap, underlying_tokens, sending, receiving, meta_decimals, base_pool_decimals): underlying_decimals = [meta_decimals] + base_pool_decimals underlying_tokens = [underlying_tokens[0], *underlying_tokens[2:]] amount_sent = 10 ** underlying_decimals[sending] @@ -22,17 +20,13 @@ def test_amounts( underlying_tokens[sending]._mint_for_testing(bob, amount_sent) expected_received = meta_swap.get_dy_underlying(sending, receiving, amount_sent) - received_true = meta_swap.exchange_underlying( - sending, receiving, amount_sent, 0, sender=bob - ) # noqa: F841 + received_true = meta_swap.exchange_underlying(sending, receiving, amount_sent, 0, sender=bob) # noqa: F841 assert approx(received_true, expected_received, 1e-3) @pytest.mark.only_plain_tokens @pytest.mark.parametrize("sending,receiving", permutations) -def test_min_dy_underlying( - bob, meta_swap, underlying_tokens, sending, receiving, meta_decimals, base_pool_decimals -): +def test_min_dy_underlying(bob, meta_swap, underlying_tokens, sending, receiving, meta_decimals, base_pool_decimals): underlying_decimals = [meta_decimals] + base_pool_decimals underlying_tokens = [underlying_tokens[0], *underlying_tokens[2:]] amount = 10 ** underlying_decimals[sending] diff --git a/tests/pools/meta/test_exchange_underlying_reverts.py b/tests/pools/meta/test_exchange_underlying_reverts.py index 11061188..5309e201 100644 --- a/tests/pools/meta/test_exchange_underlying_reverts.py +++ b/tests/pools/meta/test_exchange_underlying_reverts.py @@ -10,14 +10,7 @@ @pytest.mark.parametrize("sending,receiving", permutations) def test_min_dy_too_high( - bob, - meta_swap, - underlying_tokens, - meta_decimals, - base_pool_decimals, - sending, - receiving, - metapool_token_type, + bob, meta_swap, underlying_tokens, meta_decimals, base_pool_decimals, sending, receiving, metapool_token_type ): if sending == 0 and metapool_token_type == 2: pytest.skip("This test does not revert sending rebasing tokens") @@ -54,9 +47,7 @@ def test_insufficient_balance( underlying_tokens = [underlying_tokens[0], *underlying_tokens[2:]] amount = 10 ** underlying_decimals[sending] underlying_tokens[sending]._mint_for_testing(bob, amount, sender=bob) - underlying_tokens[sending].transfer( - zero_address, underlying_tokens[sending].balanceOf(bob), sender=bob - ) + underlying_tokens[sending].transfer(zero_address, underlying_tokens[sending].balanceOf(bob), sender=bob) underlying_tokens[sending]._mint_for_testing(bob, amount, sender=bob) with boa.reverts(): diff --git a/tests/pools/meta/test_get_dy_underlying_fix.py b/tests/pools/meta/test_get_dy_underlying_fix.py index bd954347..46245135 100644 --- a/tests/pools/meta/test_get_dy_underlying_fix.py +++ b/tests/pools/meta/test_get_dy_underlying_fix.py @@ -17,10 +17,7 @@ def ng_base_pool_decimals(base_n_coins): @pytest.fixture() def ng_base_pool_tokens(ng_base_pool_decimals, erc20_deployer, base_n_coins): - return [ - erc20_deployer.deploy(f"tkn{i}", f"tkn{i}", ng_base_pool_decimals[i]) - for i in range(base_n_coins) - ] + return [erc20_deployer.deploy(f"tkn{i}", f"tkn{i}", ng_base_pool_decimals[i]) for i in range(base_n_coins)] @pytest.fixture() @@ -29,9 +26,7 @@ def meta_token(erc20_deployer): @pytest.fixture() -def ng_base_pool( - deployer, factory, ng_base_pool_tokens, zero_address, amm_deployer, set_pool_implementations -): +def ng_base_pool(deployer, factory, ng_base_pool_tokens, zero_address, amm_deployer, set_pool_implementations): pool_size = len(ng_base_pool_tokens) offpeg_fee_multiplier = 20000000000 method_ids = [bytes(b"")] * pool_size @@ -66,10 +61,7 @@ def ng_metapool_tokens(meta_token, ng_base_pool): def add_ng_base_pool(owner, factory, ng_base_pool, ng_base_pool_tokens): with boa.env.prank(owner): factory.add_base_pool( - ng_base_pool.address, - ng_base_pool.address, - [0] * len(ng_base_pool_tokens), - len(ng_base_pool_tokens), + ng_base_pool.address, ng_base_pool.address, [0] * len(ng_base_pool_tokens), len(ng_base_pool_tokens) ) diff --git a/tests/pools/meta/test_get_virtual_price_meta.py b/tests/pools/meta/test_get_virtual_price_meta.py index 9778394c..7360cc17 100644 --- a/tests/pools/meta/test_get_virtual_price_meta.py +++ b/tests/pools/meta/test_get_virtual_price_meta.py @@ -6,9 +6,7 @@ @pytest.mark.parametrize("sending,receiving", itertools.permutations(range(4), 2)) -def test_exchange_underlying( - bob, meta_swap, sending, receiving, meta_decimals, base_pool_decimals, underlying_tokens -): +def test_exchange_underlying(bob, meta_swap, sending, receiving, meta_decimals, base_pool_decimals, underlying_tokens): underlying_decimals = [meta_decimals] + base_pool_decimals virtual_price = meta_swap.get_virtual_price() diff --git a/tests/pools/meta/test_meta_new_ng_base.py b/tests/pools/meta/test_meta_new_ng_base.py index ec5a9aa0..f1b24980 100644 --- a/tests/pools/meta/test_meta_new_ng_base.py +++ b/tests/pools/meta/test_meta_new_ng_base.py @@ -15,10 +15,7 @@ def ng_base_pool_decimals(): @pytest.fixture() def ng_base_pool_tokens(ng_base_pool_decimals, erc20_deployer): - return [ - erc20_deployer.deploy(f"tkn{i}", f"tkn{i}", ng_base_pool_decimals[i]) - for i in range(BASE_N_COINS) - ] + return [erc20_deployer.deploy(f"tkn{i}", f"tkn{i}", ng_base_pool_decimals[i]) for i in range(BASE_N_COINS)] @pytest.fixture() @@ -27,9 +24,7 @@ def meta_token(erc20_deployer): @pytest.fixture() -def ng_base_pool( - deployer, factory, ng_base_pool_tokens, zero_address, amm_deployer, set_pool_implementations -): +def ng_base_pool(deployer, factory, ng_base_pool_tokens, zero_address, amm_deployer, set_pool_implementations): pool_size = len(ng_base_pool_tokens) offpeg_fee_multiplier = 20000000000 method_ids = [bytes(b"")] * pool_size @@ -64,10 +59,7 @@ def ng_metapool_tokens(meta_token, ng_base_pool): def add_ng_base_pool(owner, factory, ng_base_pool, ng_base_pool_tokens): with boa.env.prank(owner): factory.add_base_pool( - ng_base_pool.address, - ng_base_pool.address, - [0] * len(ng_base_pool_tokens), - len(ng_base_pool_tokens), + ng_base_pool.address, ng_base_pool.address, [0] * len(ng_base_pool_tokens), len(ng_base_pool_tokens) ) @@ -117,13 +109,7 @@ def mint_and_approve_for_bob(meta_token, ng_base_pool_tokens, bob, empty_swap, n @pytest.fixture() def deposit_amounts( - meta_token, - ng_base_pool, - ng_base_pool_tokens, - ng_base_pool_decimals, - empty_swap, - bob, - mint_and_approve_for_bob, + meta_token, ng_base_pool, ng_base_pool_tokens, ng_base_pool_decimals, empty_swap, bob, mint_and_approve_for_bob ): _deposit_amounts = [] INITIAL_AMOUNT = 1_000_000 * BASE_N_COINS diff --git a/tests/pools/meta/test_meta_zap.py b/tests/pools/meta/test_meta_zap.py index 57489664..b713fdf9 100644 --- a/tests/pools/meta/test_meta_zap.py +++ b/tests/pools/meta/test_meta_zap.py @@ -28,23 +28,13 @@ def tokens_all(meta_token, base_pool_tokens): def add_base_pool(owner, factory, base_pool, base_pool_lp_token, base_pool_tokens): with boa.env.prank(owner): factory.add_base_pool( - base_pool.address, - base_pool_lp_token.address, - [0] * len(base_pool_tokens), - len(base_pool_tokens), + base_pool.address, base_pool_lp_token.address, [0] * len(base_pool_tokens), len(base_pool_tokens) ) @pytest.fixture() def empty_swap( - deployer, - factory, - zero_address, - meta_token, - base_pool, - meta_deployer, - add_base_pool, - set_metapool_implementations, + deployer, factory, zero_address, meta_token, base_pool, meta_deployer, add_base_pool, set_metapool_implementations ): method_id = bytes(b"") oracle = zero_address @@ -74,9 +64,7 @@ def empty_swap( @pytest.fixture() def zap(base_pool, base_pool_tokens, base_pool_lp_token, zap_deployer): - return zap_deployer.deploy( - base_pool.address, base_pool_lp_token.address, [a.address for a in base_pool_tokens] - ) + return zap_deployer.deploy(base_pool.address, base_pool_lp_token.address, [a.address for a in base_pool_tokens]) @pytest.fixture() @@ -117,15 +105,7 @@ def test_calc_amts_add(zap, swap, charlie, tokens_all): def test_calc_amts_remove_imbalance( - zap, - swap, - meta_token, - base_pool_tokens, - base_pool_lp_token, - base_pool, - charlie, - tokens_all, - initial_amts, + zap, swap, meta_token, base_pool_tokens, base_pool_lp_token, base_pool, charlie, tokens_all, initial_amts ): amounts = [i // 4 for i in initial_amts] initial_balance = swap.balanceOf(charlie) @@ -157,14 +137,10 @@ def test_calc_amts_remove(zap, swap, charlie, tokens_all, meta_token, base_pool, base_amts_received = base_pool.remove_liquidity(amts_received[1], [0, 0, 0], sender=charlie) total_expected_received = [amts_received[0]] + base_amts_received - total_token_balances = [meta_token.balanceOf(swap)] + [ - _t.balanceOf(base_pool) for _t in base_pool_tokens - ] + total_token_balances = [meta_token.balanceOf(swap)] + [_t.balanceOf(base_pool) for _t in base_pool_tokens] swap.approve(zap, 2**256 - 1, sender=charlie) - total_received_amount = zap.remove_liquidity( - swap.address, charlie_lp_bal_before, [0] * 4, sender=charlie - ) + total_received_amount = zap.remove_liquidity(swap.address, charlie_lp_bal_before, [0] * 4, sender=charlie) # tokens owned by zap: zap_balances = [] diff --git a/tests/pools/meta/test_meta_zap_ng_base.py b/tests/pools/meta/test_meta_zap_ng_base.py index 56c7b67e..0fe120c7 100644 --- a/tests/pools/meta/test_meta_zap_ng_base.py +++ b/tests/pools/meta/test_meta_zap_ng_base.py @@ -18,10 +18,7 @@ def ng_base_pool_decimals(): @pytest.fixture() def ng_base_pool_tokens(ng_base_pool_decimals, erc20_deployer): - return [ - erc20_deployer.deploy(f"tkn{i}", f"tkn{i}", ng_base_pool_decimals[i]) - for i in range(BASE_N_COINS) - ] + return [erc20_deployer.deploy(f"tkn{i}", f"tkn{i}", ng_base_pool_decimals[i]) for i in range(BASE_N_COINS)] @pytest.fixture() @@ -35,15 +32,7 @@ def tokens_all(meta_token, ng_base_pool_tokens): @pytest.fixture() -def ng_base_pool( - deployer, - factory, - ng_base_pool_tokens, - zero_address, - amm_deployer, - set_pool_implementations, - alice, -): +def ng_base_pool(deployer, factory, ng_base_pool_tokens, zero_address, amm_deployer, set_pool_implementations, alice): pool_size = len(ng_base_pool_tokens) offpeg_fee_multiplier = 20000000000 method_ids = [bytes(b"")] * pool_size @@ -74,9 +63,7 @@ def ng_base_pool( mint_for_testing(alice, amt_to_deposit, token, False) token.approve(base_pool.address, 2**256 - 1, sender=alice) - out_amount = base_pool.add_liquidity( - [amt_to_deposit] * len(ng_base_pool_tokens), 0, sender=alice - ) + out_amount = base_pool.add_liquidity([amt_to_deposit] * len(ng_base_pool_tokens), 0, sender=alice) assert base_pool.totalSupply() == out_amount return base_pool @@ -90,10 +77,7 @@ def ng_metapool_tokens(meta_token, ng_base_pool): def add_ng_base_pool(owner, factory, ng_base_pool, ng_base_pool_tokens): with boa.env.prank(owner): factory.add_base_pool( - ng_base_pool.address, - ng_base_pool.address, - [0] * len(ng_base_pool_tokens), - len(ng_base_pool_tokens), + ng_base_pool.address, ng_base_pool.address, [0] * len(ng_base_pool_tokens), len(ng_base_pool_tokens) ) @@ -147,9 +131,7 @@ def swap(zap, empty_swap, charlie, tokens_all): mint_for_testing(charlie, to_deposit, token, False) token.approve(zap.address, 2**256 - 1, sender=charlie) - out_amount = zap.add_liquidity( - empty_swap.address, [to_deposit] * len(tokens_all), 0, sender=charlie - ) + out_amount = zap.add_liquidity(empty_swap.address, [to_deposit] * len(tokens_all), 0, sender=charlie) assert out_amount > 0 assert 0 not in empty_swap.get_balances() assert empty_swap.totalSupply() > 0 @@ -171,9 +153,7 @@ def test_calc_amts_add(zap, swap, charlie, tokens_all, ng_base_pool): assert calc_amt_zap == out_amount -def test_calc_amts_remove_imbalance( - zap, swap, meta_token, ng_base_pool_tokens, ng_base_pool, charlie, tokens_all -): +def test_calc_amts_remove_imbalance(zap, swap, meta_token, ng_base_pool_tokens, ng_base_pool, charlie, tokens_all): initial_balance = swap.balanceOf(charlie) amounts_to_remove = [initial_balance // len(tokens_all)] * len(tokens_all) @@ -193,9 +173,7 @@ def test_calc_amts_remove_imbalance( assert swap.balanceOf(charlie) == swap.totalSupply() -def test_calc_amts_remove( - zap, swap, charlie, tokens_all, meta_token, ng_base_pool, ng_base_pool_tokens -): +def test_calc_amts_remove(zap, swap, charlie, tokens_all, meta_token, ng_base_pool, ng_base_pool_tokens): charlie_bal_before = [] for _t in tokens_all: charlie_bal_before.append(_t.balanceOf(charlie)) @@ -227,9 +205,7 @@ def test_calc_amts_remove( assert total_received_amount[i] == total_expected_received[i] -def test_calc_amts_remove_one_meta_coin( - zap, swap, charlie, tokens_all, meta_token, ng_base_pool, ng_base_pool_tokens -): +def test_calc_amts_remove_one_meta_coin(zap, swap, charlie, tokens_all, meta_token, ng_base_pool, ng_base_pool_tokens): charlie_bal_before = [] for _t in tokens_all: charlie_bal_before.append(_t.balanceOf(charlie)) @@ -242,16 +218,12 @@ def test_calc_amts_remove_one_meta_coin( amts_received_swap = swap.remove_liquidity_one_coin(lp_to_remove, 0, 0, sender=charlie) assert calc_amt_removed == amts_received_swap - amts_received_zap = zap.remove_liquidity_one_coin( - swap.address, lp_to_remove, 0, 0, sender=charlie - ) + amts_received_zap = zap.remove_liquidity_one_coin(swap.address, lp_to_remove, 0, 0, sender=charlie) assert amts_received_zap == amts_received_swap -def test_calc_amts_remove_one_base_coin( - zap, swap, charlie, tokens_all, meta_token, ng_base_pool, ng_base_pool_tokens -): +def test_calc_amts_remove_one_base_coin(zap, swap, charlie, tokens_all, meta_token, ng_base_pool, ng_base_pool_tokens): charlie_bal_before = [] for _t in tokens_all: charlie_bal_before.append(_t.balanceOf(charlie)) @@ -262,12 +234,8 @@ def test_calc_amts_remove_one_base_coin( with boa.env.anchor(): amts_received_swap = swap.remove_liquidity_one_coin(lp_to_remove, 1, 0, sender=charlie) - amts_received_base = ng_base_pool.remove_liquidity_one_coin( - amts_received_swap, 0, 0, sender=charlie - ) + amts_received_base = ng_base_pool.remove_liquidity_one_coin(amts_received_swap, 0, 0, sender=charlie) assert calc_amt_removed == amts_received_base - amts_received_zap = zap.remove_liquidity_one_coin( - swap.address, lp_to_remove, 1, 0, sender=charlie - ) + amts_received_zap = zap.remove_liquidity_one_coin(swap.address, lp_to_remove, 1, 0, sender=charlie) assert amts_received_zap == amts_received_base diff --git a/tests/pools/meta/test_receiver_meta.py b/tests/pools/meta/test_receiver_meta.py index 833bfc7d..93c6d6ab 100644 --- a/tests/pools/meta/test_receiver_meta.py +++ b/tests/pools/meta/test_receiver_meta.py @@ -4,13 +4,7 @@ def test_exchange_underlying( - bob, - charlie, - meta_swap, - underlying_tokens, - meta_decimals, - base_pool_decimals, - metapool_token_type, + bob, charlie, meta_swap, underlying_tokens, meta_decimals, base_pool_decimals, metapool_token_type ): initial_amount = underlying_tokens[0].balanceOf(bob) diff --git a/tests/pools/oracle/test_oracle.py b/tests/pools/oracle/test_oracle.py index 5e0853db..defc869e 100644 --- a/tests/pools/oracle/test_oracle.py +++ b/tests/pools/oracle/test_oracle.py @@ -41,13 +41,7 @@ def basic_setup_alice( @pytest.fixture() def meta_setup_alice( - alice, - base_pool_tokens, - base_pool, - base_pool_decimals, - meta_initial_amounts, - meta_swap, - underlying_tokens, + alice, base_pool_tokens, base_pool, base_pool_decimals, meta_initial_amounts, meta_swap, underlying_tokens ): mint_for_testing(alice, amount=1 * 10**18, token_contract=None, mint_eth=True) add_base_pool_liquidity(alice, base_pool, base_pool_tokens, base_pool_decimals) @@ -103,14 +97,7 @@ def test_oracles(alice, swap, pool_size, pool_type): def test_get_dy_basic( - alice, - basic_setup_alice, - basic_swap, - pool_token_types, - decimals, - meta_decimals, - oracle_tokens, - metapool_token, + alice, basic_setup_alice, basic_swap, pool_token_types, decimals, meta_decimals, oracle_tokens, metapool_token ): amounts = [ ( @@ -130,20 +117,10 @@ def test_get_dy_basic( def test_get_dy_meta( - alice, - meta_setup_alice, - meta_swap, - metapool_token_type, - decimals, - meta_decimals, - oracle_tokens, - metapool_token, + alice, meta_setup_alice, meta_swap, metapool_token_type, decimals, meta_decimals, oracle_tokens, metapool_token ): amounts = ( - [ - DEPOSIT_AMOUNT * 10**meta_decimals * 10**18 // metapool_token.exchangeRate(), - DEPOSIT_AMOUNT * 10**18, - ] + [DEPOSIT_AMOUNT * 10**meta_decimals * 10**18 // metapool_token.exchangeRate(), DEPOSIT_AMOUNT * 10**18] if metapool_token_type == 1 else [DEPOSIT_AMOUNT * 10**meta_decimals, DEPOSIT_AMOUNT * 10**18] ) diff --git a/tests/pools/oracle/test_oracles.py b/tests/pools/oracle/test_oracles.py index 2afd5519..afc85148 100644 --- a/tests/pools/oracle/test_oracles.py +++ b/tests/pools/oracle/test_oracles.py @@ -9,11 +9,7 @@ from tests.utils import approx from tests.utils.tokens import mint_for_testing -SETTINGS = { - "max_examples": 10, - "deadline": None, - "suppress_health_check": [HealthCheck.function_scoped_fixture], -} +SETTINGS = {"max_examples": 10, "deadline": None, "suppress_health_check": [HealthCheck.function_scoped_fixture]} pytestmark = pytest.mark.usefixtures("initial_setup") @@ -189,9 +185,7 @@ def test_manipulate_ema(basic_swap, bob, pool_tokens, underlying_tokens, decimal dt=strategy("uint256", min_value=0, max_value=10**6), ) @settings(**SETTINGS) -def test_D_ema( - swap, bob, pool_tokens, underlying_tokens, decimals, amount, dt0, dt, math_implementation -): +def test_D_ema(swap, bob, pool_tokens, underlying_tokens, decimals, amount, dt0, dt, math_implementation): i, j = random.sample(range(swap.N_COINS()), 2) # calc amount in: diff --git a/tests/token/test_token_approve.py b/tests/token/test_token_approve.py index 2196432c..6d64fab0 100644 --- a/tests/token/test_token_approve.py +++ b/tests/token/test_token_approve.py @@ -136,9 +136,7 @@ def _recover_signer(_hash: bytes32, _signature: Bytes[65]) -> address: with boa.env.prank(eth_acc.address): mock_contract = boa.loads(src) - permit = permit_class(swap)( - owner=mock_contract.address, spender=bob, value=2**256 - 1, nonce=0 - ) + permit = permit_class(swap)(owner=mock_contract.address, spender=bob, value=2**256 - 1, nonce=0) sig = eth_acc.sign_message(permit.signable_message) res, events = call_returning_result_and_logs( diff --git a/tests/token/test_token_transfer_from.py b/tests/token/test_token_transfer_from.py index b6b224b6..89d2cd9c 100644 --- a/tests/token/test_token_transfer_from.py +++ b/tests/token/test_token_transfer_from.py @@ -166,9 +166,7 @@ def test_transfer_event_fires(alice, bob, charlie, swap): swap.approve(bob, amount, sender=alice) - _, events = call_returning_result_and_logs( - swap, "transferFrom", alice, charlie, amount, sender=bob - ) + _, events = call_returning_result_and_logs(swap, "transferFrom", alice, charlie, amount, sender=bob) assert len(events) == 2 # assert repr(events[0]) == f"Transfer(sender={alice}, receiver={charlie}, value={amount})" diff --git a/tests/utils/tokens.py b/tests/utils/tokens.py index f74394e8..187b2b05 100644 --- a/tests/utils/tokens.py +++ b/tests/utils/tokens.py @@ -5,9 +5,7 @@ from eth_utils import to_checksum_address -def mint_for_testing( - user: str, amount: int, token_contract: VyperContract | None, mint_eth: bool = False -) -> None: +def mint_for_testing(user: str, amount: int, token_contract: VyperContract | None, mint_eth: bool = False) -> None: assert token_contract is not None or mint_eth user = to_checksum_address(user)