From 7c9479ef7fd1bbb1033e4952b2ef6489dd7a47af Mon Sep 17 00:00:00 2001 From: macket Date: Mon, 5 Feb 2024 17:46:01 +0400 Subject: [PATCH] test: stable-ng pools --- .gitignore | 1 + contracts/pools/usdv/pooldata.json | 27 ++++++++++++++ contracts/pools/veth/pooldata.json | 25 +++++++++++++ tests/conftest.py | 4 +-- tests/fixtures/coins.py | 8 ++--- tests/fixtures/pooldata.py | 12 +++++-- tests/test_underlying.py | 42 ++++++++++++++++------ tests/test_wrapped.py | 58 ++++++++++++++++++------------ 8 files changed, 135 insertions(+), 42 deletions(-) create mode 100644 contracts/pools/usdv/pooldata.json create mode 100644 contracts/pools/veth/pooldata.json diff --git a/.gitignore b/.gitignore index 21450c4..9427152 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ __pycache__ build/ reports/ .idea +node_modules diff --git a/contracts/pools/usdv/pooldata.json b/contracts/pools/usdv/pooldata.json new file mode 100644 index 0000000..009131c --- /dev/null +++ b/contracts/pools/usdv/pooldata.json @@ -0,0 +1,27 @@ +{ + "base_pool": "3pool", + "pool_types": ["meta", "factory"], + "lp_contract": "CurveTokenV3", + "swap_address": "0x00e6fd108c4640d21b40d02f18dd6fe7c7f725ca", + "lp_token_address": "0x00e6fd108c4640d21b40d02f18dd6fe7c7f725ca", + "zap_address": "0xA79828DF1850E8a3A3064576f380D90aECDD3359", + "gauge_addresses": ["0x2d5727a90edd42b4d666ff773c7809215284c326"], + "lp_constructor": { + "symbol": "USDV3crv", + "name": "USDV/3Crv" + }, + "coins": [ + { + "name": "USDV", + "decimals": 6, + "tethered": false, + "underlying_address": "0x0e573ce2736dd9637a0b21058352e1667925c7a8" + }, + { + "name": "3CRV", + "decimals": 18, + "base_pool_token": true, + "underlying_address": "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490" + } + ] +} diff --git a/contracts/pools/veth/pooldata.json b/contracts/pools/veth/pooldata.json new file mode 100644 index 0000000..6622e1d --- /dev/null +++ b/contracts/pools/veth/pooldata.json @@ -0,0 +1,25 @@ +{ + "lp_contract": "CurveTokenV3", + "swap_address": "0x6685fcfce05e7502bf9f0aa03b36025b09374726", + "lp_token_address": "0x6685fcfce05e7502bf9f0aa03b36025b09374726", + "gauge_addresses": ["0x8dff75976f22db58d7c3fd7b68d782238b0dbe30"], + "lp_constructor": { + "name": "vETH/ETH", + "symbol": "vETHETH" + }, + "coins": [ + { + "name": "vETH", + "decimals": 18, + "tethered": false, + "underlying_address": "0x38d64ce1bdf1a9f24e0ec469c9cade61236fb4a0" + }, + { + "name": "WETH", + "decimals": 18, + "tethered": false, + "underlying_address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" + + } + ] +} diff --git a/tests/conftest.py b/tests/conftest.py index 3ae0926..62bb220 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,10 +6,10 @@ POOLS = ['3pool', 'aave', 'aeth', 'bbtc', 'busd', 'compound', 'dusd', 'gusd', 'hbtc', 'husd', 'ib', 'link', 'musd', 'obtc', 'pax', 'pbtc', 'ren', 'reth', 'rsv', 'saave', 'sbtc', 'seth', 'steth', 'susd', 'tbtc', 'usdk', 'usdn', 'usdp', 'usdt', - 'ust', 'y', 'tricrypto2', 'eurt', 'eurtusd', 'crveth', 'cvxeth', 'tusd'] # 'eurs' + 'ust', 'y', 'tricrypto2', 'eurt', 'eurtusd', 'crveth', 'cvxeth', 'tusd', 'veth', 'usdv'] # 'eurs' LENDING_POOLS = ['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib'] -META_POOLS = ['gusd', 'husd', 'usdk', 'usdn', 'musd', 'rsv', 'tbtc', 'dusd', 'pbtc', 'bbtc', 'obtc', 'ust', 'usdp', 'eurtusd'] +META_POOLS = ['gusd', 'husd', 'usdk', 'usdn', 'musd', 'rsv', 'tbtc', 'dusd', 'pbtc', 'bbtc', 'obtc', 'ust', 'usdp', 'eurtusd', 'usdv'] FACTORY_POOOLS = ['tusd'] # 'frax', 'lusd', 'busdv2', 'alusd', 'mim' WETH_POOLS = ['tricrypto2', 'crveth', 'cvxeth'] diff --git a/tests/fixtures/coins.py b/tests/fixtures/coins.py index 31131fa..c8230f2 100644 --- a/tests/fixtures/coins.py +++ b/tests/fixtures/coins.py @@ -39,27 +39,27 @@ def wrong_coins(wrong_coin_addresses, pool_data): @pytest.fixture(scope="module") def wrapped_coin_addresses(wrapped_coins): addresses = list(map(lambda x: x if type(x) is str else x.address, wrapped_coins)) - return addresses + [ZERO_ADDRESS] * (5 - len(addresses)) + return addresses @pytest.fixture(scope="module") def wrapped_coin_addresses_wrong_order(wrapped_coins): addresses = list(map(lambda x: x if type(x) is str else x.address, wrapped_coins)) addresses.reverse() - return addresses + [ZERO_ADDRESS] * (5 - len(addresses)) + return addresses @pytest.fixture(scope="module") def underlying_coin_addresses(underlying_coins): addresses = list(map(lambda x: x if type(x) is str else x.address, underlying_coins)) - return addresses + [ZERO_ADDRESS] * (5 - len(addresses)) + return addresses @pytest.fixture(scope="module") def underlying_coin_addresses_wrong_order(underlying_coins): addresses = list(map(lambda x: x if type(x) is str else x.address, underlying_coins)) addresses.reverse() - return addresses + [ZERO_ADDRESS] * (5 - len(addresses)) + return addresses @pytest.fixture(scope="module") diff --git a/tests/fixtures/pooldata.py b/tests/fixtures/pooldata.py index f70be10..70c4b33 100644 --- a/tests/fixtures/pooldata.py +++ b/tests/fixtures/pooldata.py @@ -81,13 +81,13 @@ def wrong_amounts_to_mint(): # Different amounts are needed to always pass test_wrong_order_of_coins @pytest.fixture(scope="module") def wrapped_amounts(wrapped_decimals, n_coins_wrapped): - return [(10 + i) * 10 ** wrapped_decimals[i] for i in range(n_coins_wrapped)] + [0] * (5 - n_coins_wrapped) + return [(10 + i) * 10 ** wrapped_decimals[i] for i in range(n_coins_wrapped)] # Different amounts are needed to always pass test_wrong_order_of_coins @pytest.fixture(scope="module") def underlying_amounts(underlying_decimals, n_coins_underlying): - return [(10 + i) * 10 ** underlying_decimals[i] for i in range(n_coins_underlying)] + [0] * (5 - n_coins_underlying) + return [(10 + i) * 10 ** underlying_decimals[i] for i in range(n_coins_underlying)] @pytest.fixture(scope="module") @@ -132,3 +132,11 @@ def is_meta(pool_data): @pytest.fixture(scope="module") def factory_pool_address(pool_data): return pool_data["swap_address"] if "factory" in pool_data.get("pool_types", []) else ZERO_ADDRESS + + +@pytest.fixture(scope="module") +def is_plain_stable_ng(pool_data): + if pool_data['swap_address'] == "0x6685fcfce05e7502bf9f0aa03b36025b09374726": # vETH/ETH + return True + + return False diff --git a/tests/test_underlying.py b/tests/test_underlying.py index 4d46784..9b16dd0 100644 --- a/tests/test_underlying.py +++ b/tests/test_underlying.py @@ -6,7 +6,8 @@ def test_balance( zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, - underlying_coin_addresses, underlying_amounts, value_underlying, gauge, use_underlying, factory_pool_address + underlying_coin_addresses, underlying_amounts, value_underlying, gauge, use_underlying, + is_plain_stable_ng, factory_pool_address ): assert gauge.balanceOf(margo.address) == 0 @@ -19,6 +20,7 @@ def test_balance( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) @@ -29,7 +31,8 @@ def test_balance( def test_approve( zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, underlying_coin_addresses, - underlying_amounts, value_underlying, underlying_coins, lp_token, use_underlying, factory_pool_address + underlying_amounts, value_underlying, underlying_coins, lp_token, use_underlying, is_plain_stable_ng, + factory_pool_address ): for coin in underlying_coins: if coin == '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE': @@ -47,6 +50,7 @@ def test_approve( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) @@ -61,9 +65,10 @@ def test_approve( def test_token_mismatch( zap, margo, deposit_address, other_token_address, gauge_address, n_coins_underlying, - underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address + underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, + is_plain_stable_ng, factory_pool_address ): - with brownie.reverts("dev: swap-token mismatch"): + with brownie.reverts(): zap.deposit_and_stake( deposit_address, other_token_address, @@ -73,6 +78,7 @@ def test_token_mismatch( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) @@ -80,7 +86,8 @@ def test_token_mismatch( def test_gauge_mismatch( zap, margo, deposit_address, token_address, other_gauge_address, n_coins_underlying, - underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address + underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, + is_plain_stable_ng, factory_pool_address ): with brownie.reverts(): zap.deposit_and_stake( @@ -92,6 +99,7 @@ def test_gauge_mismatch( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) @@ -99,7 +107,8 @@ def test_gauge_mismatch( def test_n_coins_too_high( zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, - underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address + underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, + is_plain_stable_ng, factory_pool_address ): with brownie.reverts(): zap.deposit_and_stake( @@ -111,6 +120,7 @@ def test_n_coins_too_high( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) @@ -118,7 +128,8 @@ def test_n_coins_too_high( def test_n_coins_too_low( zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, - underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address + underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, + is_plain_stable_ng, factory_pool_address ): with brownie.reverts(): zap.deposit_and_stake( @@ -130,6 +141,7 @@ def test_n_coins_too_low( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) @@ -137,7 +149,8 @@ def test_n_coins_too_low( def test_wrong_coins( zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, - wrong_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address + wrong_coin_addresses, underlying_amounts, value_underlying, use_underlying, + is_plain_stable_ng, factory_pool_address ): with brownie.reverts(): zap.deposit_and_stake( @@ -149,6 +162,7 @@ def test_wrong_coins( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) @@ -156,7 +170,8 @@ def test_wrong_coins( def test_wrong_order_of_coins( zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, - underlying_coin_addresses_wrong_order, underlying_amounts, value_underlying, use_underlying, factory_pool_address + underlying_coin_addresses_wrong_order, underlying_amounts, value_underlying, + use_underlying, is_plain_stable_ng, factory_pool_address ): with brownie.reverts(): zap.deposit_and_stake( @@ -168,6 +183,7 @@ def test_wrong_order_of_coins( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) @@ -175,7 +191,8 @@ def test_wrong_order_of_coins( def test_wrong_value( zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, - underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address + underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, + is_plain_stable_ng, factory_pool_address ): with brownie.reverts(): zap.deposit_and_stake( @@ -187,6 +204,7 @@ def test_wrong_value( underlying_amounts, 0, use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': 0 if value_underlying > 0 else 10**18} ) @@ -194,7 +212,8 @@ def test_wrong_value( def test_wrong_use_underlying( zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, - underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address + underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, + is_plain_stable_ng, factory_pool_address ): if factory_pool_address == brownie.ZERO_ADDRESS: with brownie.reverts(): @@ -207,6 +226,7 @@ def test_wrong_use_underlying( underlying_amounts, 0, not use_underlying, + is_plain_stable_ng, factory_pool_address, {'from': margo, 'value': value_underlying} ) diff --git a/tests/test_wrapped.py b/tests/test_wrapped.py index 6822244..83b81a6 100644 --- a/tests/test_wrapped.py +++ b/tests/test_wrapped.py @@ -6,7 +6,7 @@ def test_balance( zap, margo, swap_address, token_address, gauge_address, n_coins_wrapped, - wrapped_coin_addresses, wrapped_amounts, value_wrapped, gauge + wrapped_coin_addresses, wrapped_amounts, value_wrapped, gauge, is_plain_stable_ng ): assert gauge.balanceOf(margo.address) == 0 @@ -19,6 +19,7 @@ def test_balance( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': value_wrapped} ) @@ -28,7 +29,8 @@ def test_balance( def test_approve( zap, margo, swap_address, token_address, gauge_address, n_coins_wrapped, - wrapped_coin_addresses, wrapped_amounts, value_wrapped, wrapped_coins, lp_token + wrapped_coin_addresses, wrapped_amounts, value_wrapped, wrapped_coins, + lp_token, is_plain_stable_ng ): for coin in wrapped_coins: if coin == '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE': @@ -46,6 +48,7 @@ def test_approve( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': value_wrapped} ) @@ -59,9 +62,9 @@ def test_approve( def test_token_mismatch( zap, margo, swap_address, other_token_address, gauge_address, n_coins_wrapped, - wrapped_coin_addresses, wrapped_amounts, value_wrapped + wrapped_coin_addresses, wrapped_amounts, value_wrapped, is_plain_stable_ng ): - with brownie.reverts("dev: swap-token mismatch"): + with brownie.reverts(): zap.deposit_and_stake( swap_address, other_token_address, @@ -71,13 +74,14 @@ def test_token_mismatch( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': value_wrapped} ) def test_gauge_mismatch( zap, margo, swap_address, token_address, other_gauge_address, n_coins_wrapped, - wrapped_coin_addresses, wrapped_amounts, value_wrapped + wrapped_coin_addresses, wrapped_amounts, value_wrapped, is_plain_stable_ng ): with brownie.reverts(): zap.deposit_and_stake( @@ -89,13 +93,14 @@ def test_gauge_mismatch( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': value_wrapped} ) def test_n_coins_too_high( zap, margo, swap_address, token_address, gauge_address, n_coins_wrapped, - wrapped_coin_addresses, wrapped_amounts, value_wrapped + wrapped_coin_addresses, wrapped_amounts, value_wrapped, is_plain_stable_ng ): with brownie.reverts(): zap.deposit_and_stake( @@ -107,13 +112,14 @@ def test_n_coins_too_high( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': value_wrapped} ) def test_n_coins_too_low( zap, margo, swap_address, token_address, gauge_address, n_coins_wrapped, - wrapped_coin_addresses, wrapped_amounts, value_wrapped + wrapped_coin_addresses, wrapped_amounts, value_wrapped, is_plain_stable_ng ): with brownie.reverts(): zap.deposit_and_stake( @@ -125,13 +131,14 @@ def test_n_coins_too_low( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': value_wrapped} ) def test_wrong_coins( zap, margo, deposit_address, token_address, gauge_address, n_coins_wrapped, - wrong_coin_addresses, wrapped_amounts, value_wrapped + wrong_coin_addresses, wrapped_amounts, value_wrapped, is_plain_stable_ng ): with brownie.reverts(): zap.deposit_and_stake( @@ -143,13 +150,14 @@ def test_wrong_coins( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': value_wrapped} ) def test_wrong_order_of_coins( zap, margo, deposit_address, token_address, gauge_address, n_coins_wrapped, - wrapped_coin_addresses_wrong_order, wrapped_amounts, value_wrapped + wrapped_coin_addresses_wrong_order, wrapped_amounts, value_wrapped, is_plain_stable_ng ): with brownie.reverts(): zap.deposit_and_stake( @@ -161,13 +169,14 @@ def test_wrong_order_of_coins( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': value_wrapped} ) def test_wrong_value( zap, margo, deposit_address, token_address, gauge_address, n_coins_wrapped, - wrapped_coin_addresses, wrapped_amounts, value_wrapped + wrapped_coin_addresses, wrapped_amounts, value_wrapped, is_plain_stable_ng ): with brownie.reverts(): zap.deposit_and_stake( @@ -179,23 +188,26 @@ def test_wrong_value( wrapped_amounts, 0, False, + is_plain_stable_ng, {'from': margo, 'value': 0 if value_wrapped > 0 else 10**18} ) def test_wrong_use_underlying( zap, margo, deposit_address, token_address, gauge_address, n_coins_wrapped, - wrapped_coin_addresses, wrapped_amounts, value_wrapped + wrapped_coin_addresses, wrapped_amounts, value_wrapped, is_plain_stable_ng ): - with brownie.reverts(): - zap.deposit_and_stake( - deposit_address, - token_address, - gauge_address, - n_coins_wrapped, - wrapped_coin_addresses, - wrapped_amounts, - 0, - True, - {'from': margo, 'value': value_wrapped} - ) + if not is_plain_stable_ng: + with brownie.reverts(): + zap.deposit_and_stake( + deposit_address, + token_address, + gauge_address, + n_coins_wrapped, + wrapped_coin_addresses, + wrapped_amounts, + 0, + True, + is_plain_stable_ng, + {'from': margo, 'value': value_wrapped} + )