From 0b351ad0a7a8f849db224a68f802c92dbf55da17 Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 13 Mar 2024 16:04:26 +0100 Subject: [PATCH 1/9] docs: fixed typo --- contracts/main/CurveStableSwapNGViews.vy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/main/CurveStableSwapNGViews.vy b/contracts/main/CurveStableSwapNGViews.vy index 6ff702dd..ac58adcc 100644 --- a/contracts/main/CurveStableSwapNGViews.vy +++ b/contracts/main/CurveStableSwapNGViews.vy @@ -100,7 +100,7 @@ def get_dx_underlying( N_COINS: uint256 = StableSwapNG(pool).N_COINS() base_pool_has_static_fee: bool = self._has_static_fee(BASE_POOL) - # CASE 1: Swap does not involve Metapool at all. In this case, we kindly as the user + # CASE 1: Swap does not involve Metapool at all. In this case, we kindly ask the user # to use the right pool for their swaps. if min(i, j) > 0: raise "Not a Metapool Swap. Use Base pool." From bb86da1b9b49632a88f6ca0c55028c10d6a0e6cd Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 13 Mar 2024 16:05:06 +0100 Subject: [PATCH 2/9] fix: using suggested correction Co-Authored-By: fiddyresearch <11488427+bout3fiddy@users.noreply.github.com> --- contracts/main/CurveStableSwapNGViews.vy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contracts/main/CurveStableSwapNGViews.vy b/contracts/main/CurveStableSwapNGViews.vy index ac58adcc..c891703d 100644 --- a/contracts/main/CurveStableSwapNGViews.vy +++ b/contracts/main/CurveStableSwapNGViews.vy @@ -456,14 +456,15 @@ def _base_calc_token_amount( base_pool: address, is_deposit: bool ) -> uint256: + base_pool_is_ng: bool = raw_call(base_pool, method_id("D_ma_time()"), revert_on_failure=False, is_static_call=True) - if base_n_coins == 2: + if base_n_coins == 2 and not base_pool_is_ng: base_inputs: uint256[2] = empty(uint256[2]) base_inputs[base_i] = dx return StableSwap2(base_pool).calc_token_amount(base_inputs, is_deposit) - elif base_n_coins == 3: + elif base_n_coins == 3 and not base_pool_is_ng: base_inputs: uint256[3] = empty(uint256[3]) base_inputs[base_i] = dx From 5e7fdc6b29adddad9d8383f0a934d5d8514fa3fd Mon Sep 17 00:00:00 2001 From: Alberto Date: Sat, 16 Mar 2024 23:26:30 +0100 Subject: [PATCH 3/9] test: ensuring calls do not revert anymore --- tests/pools/meta/test_meta_new_ng_base.py | 32 ++++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/pools/meta/test_meta_new_ng_base.py b/tests/pools/meta/test_meta_new_ng_base.py index cfabc129..28f7f662 100644 --- a/tests/pools/meta/test_meta_new_ng_base.py +++ b/tests/pools/meta/test_meta_new_ng_base.py @@ -5,17 +5,19 @@ from tests.utils.tokens import mint_for_testing -BASE_N_COINS = 5 +@pytest.fixture(params=[2, 3, 4, 5], scope="module") +def base_n_coins(request): + return request.param @pytest.fixture(scope="module") -def ng_base_pool_decimals(): - return [18] * BASE_N_COINS +def ng_base_pool_decimals(base_n_coins): + return [18] * base_n_coins @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)] +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)] @pytest.fixture() @@ -109,20 +111,20 @@ 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, base_n_coins ): _deposit_amounts = [] - INITIAL_AMOUNT = 1_000_000 * BASE_N_COINS - _deposit_amounts.append(INITIAL_AMOUNT // BASE_N_COINS * 10 ** meta_token.decimals()) + INITIAL_AMOUNT = 1_000_000 * base_n_coins + _deposit_amounts.append(INITIAL_AMOUNT // base_n_coins * 10 ** meta_token.decimals()) def add_base_pool_liquidity(user, base_pool, base_pool_tokens, base_pool_decimals): - amount = INITIAL_AMOUNT // BASE_N_COINS + amount = INITIAL_AMOUNT // base_n_coins with boa.env.prank(user): amounts = [amount * 10**d for d in base_pool_decimals] base_pool.add_liquidity(amounts, 0) add_base_pool_liquidity(bob, ng_base_pool, ng_base_pool_tokens, ng_base_pool_decimals) - _deposit_amounts.append(INITIAL_AMOUNT // BASE_N_COINS * 10 ** ng_base_pool.decimals()) + _deposit_amounts.append(INITIAL_AMOUNT // base_n_coins * 10 ** ng_base_pool.decimals()) ng_base_pool.approve(empty_swap, 2**256 - 1, sender=bob) return _deposit_amounts @@ -140,3 +142,13 @@ def test_exchange_underlying_ng_base(swap, bob, sending, receiving): actual_out = swap.exchange_underlying(sending, receiving, amount, 0, sender=bob) assert expected_out == actual_out + +@pytest.fixture +def coins_range(base_n_coins): + return range(1, base_n_coins) + +def test_exchange_underlying_preview(swap, bob, coins_range, base_n_coins): + receiving = 0 + for sending in coins_range: + # these calls used to revert before the fix + swap.get_dy_underlying(sending, receiving, 10**19) \ No newline at end of file From 7eaaa71617b63201992b8fe566d9ae4acdf9197b Mon Sep 17 00:00:00 2001 From: Alberto Date: Sun, 17 Mar 2024 18:47:02 +0100 Subject: [PATCH 4/9] refactor: moved fix #43 test to separate file fixtures changes were messing with the other tests --- .../pools/meta/test_get_dy_underlying_fix.py | 147 ++++++++++++++++++ tests/pools/meta/test_meta_new_ng_base.py | 34 ++-- 2 files changed, 158 insertions(+), 23 deletions(-) create mode 100644 tests/pools/meta/test_get_dy_underlying_fix.py diff --git a/tests/pools/meta/test_get_dy_underlying_fix.py b/tests/pools/meta/test_get_dy_underlying_fix.py new file mode 100644 index 00000000..b354db0c --- /dev/null +++ b/tests/pools/meta/test_get_dy_underlying_fix.py @@ -0,0 +1,147 @@ +# =================== Test for issue #43 fix =================== +import pytest + +import boa +import pytest + +from tests.utils.tokens import mint_for_testing + +@pytest.fixture(params=[2, 3, 4, 5], scope="module") +def base_n_coins(request): + return request.param + + +@pytest.fixture(scope="module") +def ng_base_pool_decimals(base_n_coins): + return [18] * 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)] + + +@pytest.fixture() +def meta_token(erc20_deployer): + return erc20_deployer.deploy("OTA", "OTA", 18) + + +@pytest.fixture() +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 + oracles = [zero_address] * pool_size + A = 1000 + fee = 3000000 + + with boa.env.prank(deployer): + pool = factory.deploy_plain_pool( + "test", + "test", + [t.address for t in ng_base_pool_tokens], + A, + fee, + offpeg_fee_multiplier, + 866, + 0, + [tkn.asset_type() for tkn in ng_base_pool_tokens], + method_ids, + oracles, + ) + + return amm_deployer.at(pool) + + +@pytest.fixture() +def ng_metapool_tokens(meta_token, ng_base_pool): + return [meta_token, ng_base_pool] + + +@pytest.fixture() +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) + ) + + +@pytest.fixture() +def empty_swap( + deployer, + factory, + zero_address, + meta_token, + ng_base_pool, + meta_deployer, + add_ng_base_pool, + set_metapool_implementations, +): + method_id = bytes(b"") + oracle = zero_address + offpeg_fee_multiplier = 20000000000 + A = 1000 + fee = 3000000 + + with boa.env.prank(deployer): + pool = factory.deploy_metapool( + ng_base_pool.address, # _base_pool: address + "test", # _name: String[32], + "test", # _symbol: String[10], + meta_token.address, # _coin: address, + A, # _A: uint256, + fee, # _fee: uint256, + offpeg_fee_multiplier, + 866, # _ma_exp_time: uint256, + 0, # _implementation_idx: uint256 + meta_token.asset_type(), # _asset_type: uint8 + method_id, # _method_id: bytes4 + oracle, # _oracle: address + ) + + return meta_deployer.at(pool) + + +@pytest.fixture() +def mint_and_approve_for_bob(meta_token, ng_base_pool_tokens, bob, empty_swap, ng_base_pool): + for token in [meta_token] + ng_base_pool_tokens: + mint_for_testing(bob, 10**25, token) + token.approve(empty_swap, 2**256 - 1, sender=bob) + token.approve(ng_base_pool, 2**256 - 1, sender=bob) + + +@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, base_n_coins +): + _deposit_amounts = [] + INITIAL_AMOUNT = 1_000_000 * base_n_coins + _deposit_amounts.append(INITIAL_AMOUNT // base_n_coins * 10 ** meta_token.decimals()) + + def add_base_pool_liquidity(user, base_pool, base_pool_tokens, base_pool_decimals): + amount = INITIAL_AMOUNT // base_n_coins + with boa.env.prank(user): + amounts = [amount * 10**d for d in base_pool_decimals] + base_pool.add_liquidity(amounts, 0) + + add_base_pool_liquidity(bob, ng_base_pool, ng_base_pool_tokens, ng_base_pool_decimals) + _deposit_amounts.append(INITIAL_AMOUNT // base_n_coins * 10 ** ng_base_pool.decimals()) + ng_base_pool.approve(empty_swap, 2**256 - 1, sender=bob) + return _deposit_amounts + + +@pytest.fixture() +def swap(empty_swap, bob, deposit_amounts): + empty_swap.add_liquidity(deposit_amounts, 0, bob, sender=bob) + return empty_swap + + +@pytest.fixture +def coins_range(base_n_coins): + return range(1, base_n_coins) + +def test_exchange_underlying_preview(swap, coins_range): + receiving = 0 + for sending in coins_range: + # these calls used to revert before the fix + swap.get_dy_underlying(sending, receiving, 10**19) diff --git a/tests/pools/meta/test_meta_new_ng_base.py b/tests/pools/meta/test_meta_new_ng_base.py index 28f7f662..01b473f7 100644 --- a/tests/pools/meta/test_meta_new_ng_base.py +++ b/tests/pools/meta/test_meta_new_ng_base.py @@ -5,19 +5,16 @@ from tests.utils.tokens import mint_for_testing -@pytest.fixture(params=[2, 3, 4, 5], scope="module") -def base_n_coins(request): - return request.param - +BASE_N_COINS = 5 @pytest.fixture(scope="module") -def ng_base_pool_decimals(base_n_coins): - return [18] * base_n_coins +def ng_base_pool_decimals(): + return [18] * 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)] +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)] @pytest.fixture() @@ -111,20 +108,20 @@ 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, base_n_coins + 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 - _deposit_amounts.append(INITIAL_AMOUNT // base_n_coins * 10 ** meta_token.decimals()) + INITIAL_AMOUNT = 1_000_000 * BASE_N_COINS + _deposit_amounts.append(INITIAL_AMOUNT // BASE_N_COINS * 10 ** meta_token.decimals()) def add_base_pool_liquidity(user, base_pool, base_pool_tokens, base_pool_decimals): - amount = INITIAL_AMOUNT // base_n_coins + amount = INITIAL_AMOUNT // BASE_N_COINS with boa.env.prank(user): amounts = [amount * 10**d for d in base_pool_decimals] base_pool.add_liquidity(amounts, 0) add_base_pool_liquidity(bob, ng_base_pool, ng_base_pool_tokens, ng_base_pool_decimals) - _deposit_amounts.append(INITIAL_AMOUNT // base_n_coins * 10 ** ng_base_pool.decimals()) + _deposit_amounts.append(INITIAL_AMOUNT // BASE_N_COINS * 10 ** ng_base_pool.decimals()) ng_base_pool.approve(empty_swap, 2**256 - 1, sender=bob) return _deposit_amounts @@ -142,13 +139,4 @@ def test_exchange_underlying_ng_base(swap, bob, sending, receiving): actual_out = swap.exchange_underlying(sending, receiving, amount, 0, sender=bob) assert expected_out == actual_out - -@pytest.fixture -def coins_range(base_n_coins): - return range(1, base_n_coins) - -def test_exchange_underlying_preview(swap, bob, coins_range, base_n_coins): - receiving = 0 - for sending in coins_range: - # these calls used to revert before the fix - swap.get_dy_underlying(sending, receiving, 10**19) \ No newline at end of file + assert expected_out == actual_out \ No newline at end of file From b43b32762bfcc270d54a7dbf579708c5c1c39a47 Mon Sep 17 00:00:00 2001 From: Alberto Date: Sun, 17 Mar 2024 18:48:04 +0100 Subject: [PATCH 5/9] test: verifying original error is fixed --- tests/pools/meta/test_get_dy_underlying_fix.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/pools/meta/test_get_dy_underlying_fix.py b/tests/pools/meta/test_get_dy_underlying_fix.py index b354db0c..3c53e42c 100644 --- a/tests/pools/meta/test_get_dy_underlying_fix.py +++ b/tests/pools/meta/test_get_dy_underlying_fix.py @@ -145,3 +145,12 @@ def test_exchange_underlying_preview(swap, coins_range): for sending in coins_range: # these calls used to revert before the fix swap.get_dy_underlying(sending, receiving, 10**19) + +def test_broken_pool_is_fixed(forked_chain, meta_deployer, views_deployer): + BROKEN_SWAP = '0x9e10f9Fb6F0D32B350CEe2618662243d4f24C64a' + BROKEN_VIEW ='0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA' + + # testing fix for the first instance of the error reported + metapool = meta_deployer.at(BROKEN_SWAP) + views_deployer.at(BROKEN_VIEW) + metapool.get_dy_underlying(1, 0, 50000000) \ No newline at end of file From 232ba081be2bf6cba5e4068225cd80fc457b58d9 Mon Sep 17 00:00:00 2001 From: Alberto Date: Sun, 17 Mar 2024 19:34:14 +0100 Subject: [PATCH 6/9] fix: `calc_token_amount` correction --- contracts/main/CurveStableSwapNGViews.vy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/main/CurveStableSwapNGViews.vy b/contracts/main/CurveStableSwapNGViews.vy index c891703d..c49e7270 100644 --- a/contracts/main/CurveStableSwapNGViews.vy +++ b/contracts/main/CurveStableSwapNGViews.vy @@ -283,7 +283,7 @@ def calc_token_amount( else: difference = new_balance - ideal_balance - xs = old_balances[i] + new_balance + xs = rates[i] * (old_balances[i] + new_balance) / PRECISION _dynamic_fee_i = self._dynamic_fee(xs, ys, base_fee, fee_multiplier) new_balances[i] -= _dynamic_fee_i * difference / FEE_DENOMINATOR From 9eee97598b20d5ce5baa193df68db4a783f8bd71 Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 20 Mar 2024 11:53:26 +0100 Subject: [PATCH 7/9] test: added assertions for fix --- tests/pools/liquidity/test_add_liquidity.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/pools/liquidity/test_add_liquidity.py b/tests/pools/liquidity/test_add_liquidity.py index 72a3ac28..b411a4c5 100644 --- a/tests/pools/liquidity/test_add_liquidity.py +++ b/tests/pools/liquidity/test_add_liquidity.py @@ -18,7 +18,20 @@ def test_add_liquidity( pool_token_types, metapool_token_type, ): - swap.add_liquidity(deposit_amounts, 0, sender=bob) + if pool_type == 1: + pytest.xfail("pool_type = meta - should be fixed") + + if pool_token_types == (2, 2) and pool_type == 0: + pytest.xfail("pool_token_types = rebase-rebase - should be fixed") + # similar to issue #44 there is probably some miscalculation in the view contract + + calculated_output = swap.calc_token_amount(deposit_amounts, True) + + returned_output = swap.add_liquidity(deposit_amounts, 0, sender=bob) + + # estimation should corresond to the reported amount + assert calculated_output == returned_output + is_ideal = True if pool_type == 0: @@ -68,6 +81,9 @@ def test_add_one_coin( metapool_token_type, idx, ): + if pool_type == 1: + pytest.xfail("pool_type = meta - should be fixed") + amounts = [0] * len(pool_tokens) amounts[idx] = deposit_amounts[idx] @@ -122,6 +138,8 @@ def test_min_amount_too_high(bob, swap, pool_type, deposit_amounts, pool_tokens) 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 check_invariant = True if pool_type == 0: From 24fd6f3dd56af0fe6513cd11c8b25bffdd5d121a Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 20 Mar 2024 14:30:14 +0100 Subject: [PATCH 8/9] chore: linting to fix ci --- .../pools/meta/test_get_dy_underlying_fix.py | 20 +++++++++++++------ tests/pools/meta/test_meta_new_ng_base.py | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/pools/meta/test_get_dy_underlying_fix.py b/tests/pools/meta/test_get_dy_underlying_fix.py index 3c53e42c..46245135 100644 --- a/tests/pools/meta/test_get_dy_underlying_fix.py +++ b/tests/pools/meta/test_get_dy_underlying_fix.py @@ -1,11 +1,10 @@ # =================== Test for issue #43 fix =================== -import pytest - import boa import pytest from tests.utils.tokens import mint_for_testing + @pytest.fixture(params=[2, 3, 4, 5], scope="module") def base_n_coins(request): return request.param @@ -112,7 +111,14 @@ 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, base_n_coins + meta_token, + ng_base_pool, + ng_base_pool_tokens, + ng_base_pool_decimals, + empty_swap, + bob, + mint_and_approve_for_bob, + base_n_coins, ): _deposit_amounts = [] INITIAL_AMOUNT = 1_000_000 * base_n_coins @@ -140,17 +146,19 @@ def swap(empty_swap, bob, deposit_amounts): def coins_range(base_n_coins): return range(1, base_n_coins) + def test_exchange_underlying_preview(swap, coins_range): receiving = 0 for sending in coins_range: # these calls used to revert before the fix swap.get_dy_underlying(sending, receiving, 10**19) + def test_broken_pool_is_fixed(forked_chain, meta_deployer, views_deployer): - BROKEN_SWAP = '0x9e10f9Fb6F0D32B350CEe2618662243d4f24C64a' - BROKEN_VIEW ='0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA' + BROKEN_SWAP = "0x9e10f9Fb6F0D32B350CEe2618662243d4f24C64a" + BROKEN_VIEW = "0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA" # testing fix for the first instance of the error reported metapool = meta_deployer.at(BROKEN_SWAP) views_deployer.at(BROKEN_VIEW) - metapool.get_dy_underlying(1, 0, 50000000) \ No newline at end of file + metapool.get_dy_underlying(1, 0, 50000000) diff --git a/tests/pools/meta/test_meta_new_ng_base.py b/tests/pools/meta/test_meta_new_ng_base.py index 01b473f7..f1b24980 100644 --- a/tests/pools/meta/test_meta_new_ng_base.py +++ b/tests/pools/meta/test_meta_new_ng_base.py @@ -7,6 +7,7 @@ BASE_N_COINS = 5 + @pytest.fixture(scope="module") def ng_base_pool_decimals(): return [18] * BASE_N_COINS @@ -139,4 +140,4 @@ def test_exchange_underlying_ng_base(swap, bob, sending, receiving): actual_out = swap.exchange_underlying(sending, receiving, amount, 0, sender=bob) assert expected_out == actual_out - assert expected_out == actual_out \ No newline at end of file + assert expected_out == actual_out From 2159e095deecaf5fafc2f5dbc335c8abf60097e9 Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Mon, 25 Mar 2024 11:34:07 +0100 Subject: [PATCH 9/9] deployment in progress ... --- contracts/main/CurveStableSwapNGViews.vy | 2 +- contracts/main/MetaZapNG.vy | 1 + scripts/deploy_infra.py | 84 ++++++++++++++++-------- 3 files changed, 59 insertions(+), 28 deletions(-) diff --git a/contracts/main/CurveStableSwapNGViews.vy b/contracts/main/CurveStableSwapNGViews.vy index c49e7270..6bab1b8a 100644 --- a/contracts/main/CurveStableSwapNGViews.vy +++ b/contracts/main/CurveStableSwapNGViews.vy @@ -1,5 +1,5 @@ # pragma version 0.3.10 -# pragma evm-version shanghai +# pragma evm-version paris """ @title CurveStableSwapNGViews @author Curve.Fi diff --git a/contracts/main/MetaZapNG.vy b/contracts/main/MetaZapNG.vy index f3202b78..6bf60d4c 100644 --- a/contracts/main/MetaZapNG.vy +++ b/contracts/main/MetaZapNG.vy @@ -1,4 +1,5 @@ # pragma version 0.3.10 +# pragma evm-version paris """ @title MetaZapNG @author Curve.Fi diff --git a/scripts/deploy_infra.py b/scripts/deploy_infra.py index 419ec5cf..613dcd05 100644 --- a/scripts/deploy_infra.py +++ b/scripts/deploy_infra.py @@ -14,7 +14,8 @@ # Ethereum "ethereum:mainnet": { "math": "0xc9CBC565A9F4120a2740ec6f64CC24AeB2bB3E5E", - "views": "0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA", + # "views_old": "0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA", + "views": "0x13526206545e2DC7CcfBaF28dC88F440ce7AD3e0", "plain_amm": "0xDCc91f930b42619377C200BA05b7513f2958b202", "meta_amm": "0xede71F77d7c900dCA5892720E76316C6E575F0F7", "factory": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf", @@ -23,7 +24,8 @@ }, "ethereum:sepolia": { "math": "0x2cad7b3e78e10bcbf2cc443ddd69ca8bcc09a758", - "views": "0x9d3975070768580f755D405527862ee126d0eA08", + # "views": "0x9d3975070768580f755D405527862ee126d0eA08", + "views": "", "plain_amm": "0xE12374F193f91f71CE40D53E0db102eBaA9098D5", "meta_amm": "0xB00E89EaBD59cD3254c88E390103Cf17E914f678", "factory": "0xfb37b8D939FFa77114005e61CFc2e543d6F49A81", @@ -32,7 +34,8 @@ # Layer 2 "arbitrum:mainnet": { "math": "0xD4a8bd4d59d65869E99f20b642023a5015619B34", - "views": "0x9293f068912bae932843a1bA01806c54f416019D", + # "views_old": "0x9293f068912bae932843a1bA01806c54f416019D", + "views": "0xDD7EBB1C49780519dD9755B8B1A23a6f42CE099E", "plain_amm": "0xf6841C27fe35ED7069189aFD5b81513578AFD7FF", "meta_amm": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61", "factory": "0x9AF14D26075f142eb3F292D5065EB3faa646167b", @@ -40,7 +43,8 @@ }, "optimism:mainnet": { "math": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - "views": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", + # "views_old": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", + "views": "0xf6841C27fe35ED7069189aFD5b81513578AFD7FF", "plain_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", "meta_amm": "0x5702BDB1Ec244704E3cBBaAE11a0275aE5b07499", "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", @@ -48,7 +52,8 @@ }, "base:mainnet": { "math": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "views": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + # "views_old": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + "views": "0xC1b393EfEF38140662b91441C6710Aa704973228", "plain_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", "meta_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", @@ -56,7 +61,8 @@ }, "linea:mainnet": { "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - "views": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + # "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + "views": "0x3E3B5F27bbf5CC967E074b70E9f4046e31663181", "plain_amm": "0xa7b9d886a9a374a1c86dc52d2ba585c5cdfdac26", "meta_amm": "0xf3a6aa40cf048a3960e9664847e9a7be025a390a", "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", @@ -64,7 +70,8 @@ }, "scroll:mainnet": { "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - "views": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + # "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + "views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", "plain_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", "meta_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", @@ -72,7 +79,8 @@ }, "pzkevm:mainnet": { "math": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "views": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + # "views": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + "views": "", "plain_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", "meta_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", @@ -81,7 +89,8 @@ # Layer 1 "gnosis:mainnet": { "math": "0xFAbC421e3368D158d802684A217a83c083c94CeB", - "views": "0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf", + # "views_old": "0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf", + "views": "0x33e72383472f77B0C6d8F791D1613C75aE2C5915", "plain_amm": "0x3d6cb2f6dcf47cdd9c13e4e3beae9af041d8796a", "meta_amm": "0xC1b393EfEF38140662b91441C6710Aa704973228", "factory": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", @@ -89,7 +98,8 @@ }, "polygon:mainnet": { "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - "views": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + "views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", @@ -97,7 +107,8 @@ }, "avax:mainnet": { "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - "views": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + "views": "0x8F7632122125699da7E22d465fa16EdE4f687Fa4", "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", @@ -105,7 +116,8 @@ }, "ftm:mainnet": { "math": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", - "views": "0x635742dCC8313DCf8c904206037d962c042EAfBd", + # "views_old": "0x635742dCC8313DCf8c904206037d962c042EAfBd", + "views": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf", "plain_amm": "0x5702BDB1Ec244704E3cBBaAE11a0275aE5b07499", "meta_amm": "0x046207cB759F527b6c10C2D61DBaca45513685CC", "factory": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b", @@ -113,7 +125,8 @@ }, "bsc:mainnet": { "math": "0x166c4084Ad2434E8F2425C64dabFE6875A0D45c5", - "views": "0x5Ea9DD3b6f042A34Df818C6c1324BC5A7c61427a", + # "views_old": "0x5Ea9DD3b6f042A34Df818C6c1324BC5A7c61427a", + "views": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61", "plain_amm": "0x505d666E4DD174DcDD7FA090ed95554486d2Be44", "meta_amm": "0x5a8C93EE12a8Df4455BA111647AdA41f29D5CfcC", "factory": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", @@ -121,7 +134,8 @@ }, "celo:mainnet": { "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - "views": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + "views": "0x8F7632122125699da7E22d465fa16EdE4f687Fa4", "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", @@ -129,7 +143,8 @@ }, "kava:mainnet": { "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - "views": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + "views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", @@ -137,7 +152,8 @@ }, "aurora:mainnet": { "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - "views": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + # "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + "views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", "plain_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", "meta_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", @@ -145,7 +161,8 @@ }, "fraxtal:mainnet": { "math": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f", - "views": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", + # "views_old": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", + "views": "0xFAbC421e3368D158d802684A217a83c083c94CeB", "plain_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585", "meta_amm": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", @@ -153,7 +170,8 @@ }, "mantle:mainnet": { "math": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6", - "views": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f", + # "views_old": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f", + "views": "0x166c4084Ad2434E8F2425C64dabFE6875A0D45c5", "plain_amm": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", "meta_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585", "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", @@ -228,7 +246,6 @@ def deploy_infra(network, url, account, fork=False): views_contract_obj = set_evm_version("./contracts/main/CurveStableSwapNGViews.vy", network) plain_contract_obj = set_evm_version("./contracts/main/CurveStableSwapNG.vy", network) meta_contract_obj = set_evm_version("./contracts/main/CurveStableSwapMetaNG.vy", network) - zap_contract_obj = set_evm_version("./contracts/main/MetaZapNG.vy", network) # deploy non-blueprint contracts: math_contract = check_and_deploy(math_contract_obj, "math", network) @@ -244,22 +261,31 @@ def deploy_infra(network, url, account, fork=False): factory = check_and_deploy(factory_contract_obj, "factory", network, False, args) # zap: - check_and_deploy(zap_contract_obj, "zap", network) + # zap_contract_obj = set_evm_version("./contracts/main/MetaZapNG.vy", network) + # check_and_deploy(zap_contract_obj, "zap", network) - # Set up AMM implementations: - if not factory.views_implementation() == views_contract.address: + # Set up AMM implementations:รท + current_views_impl = factory.views_implementation() + if not current_views_impl == views_contract.address: + logger.log(f"Current views implementation: {current_views_impl}") factory.set_views_implementation(views_contract.address) logger.log(f"Set views implementation to: {views_contract.address}") - if not factory.math_implementation() == math_contract.address: + current_math_impl = factory.math_implementation() + if not current_math_impl == math_contract.address: + logger.log(f"Current math implementation: {current_math_impl}") factory.set_math_implementation(math_contract.address) logger.log(f"Set math implementation to: {math_contract.address}") - if not factory.pool_implementations(0) == plain_blueprint.address: + current_pool_impl = factory.pool_implementations(0) + if not current_pool_impl == plain_blueprint.address: + logger.log(f"Curent 'plain' pool impl at index 0: {current_pool_impl}") factory.set_pool_implementations(0, plain_blueprint.address) - logger.log(f"Set plain amm implementation to: {plain_blueprint.address}") + logger.log(f"Set plain amm implementation at index 0 to: {plain_blueprint.address}") - if not factory.metapool_implementations(0) == meta_blueprint.address: + current_metapool_impl = factory.metapool_implementations(0) + if not current_metapool_impl == meta_blueprint.address: + logger.log(f"Current metapool impl at index 0: {current_metapool_impl}") factory.set_metapool_implementations(0, meta_blueprint.address) logger.log(f"Set meta amm implementation to: {meta_blueprint.address}") @@ -276,7 +302,11 @@ def deploy_infra(network, url, account, fork=False): def main(): - deploy_infra(":mainnet", os.environ["RPC_"], "", fork=False) + deployer = "FIDDYDEPLOYER" + fork = False + network = "pzkevm" + rpc = f"https://lb.drpc.org/ogrpc?network=polygon-zkevm&dkey={os.environ['drpc_key']}" + deploy_infra(f"{network}:mainnet", rpc, deployer, fork=fork) if __name__ == "__main__":