diff --git a/contracts/main/CurveStableSwapNGViews.vy b/contracts/main/CurveStableSwapNGViews.vy index 6bab1b8a..cde392bc 100644 --- a/contracts/main/CurveStableSwapNGViews.vy +++ b/contracts/main/CurveStableSwapNGViews.vy @@ -8,6 +8,8 @@ integrators """ +from vyper.interfaces import ERC20Detailed + interface StableSwapNG: def N_COINS() -> uint256: view def BASE_POOL() -> address: view @@ -20,15 +22,8 @@ interface StableSwapNG: def A() -> uint256: view def calc_withdraw_one_coin(_token_amount: uint256, i: int128) -> uint256: view def totalSupply() -> uint256: view - def calc_token_amount(amounts: DynArray[uint256, MAX_COINS], deposit: bool) -> uint256: view def offpeg_fee_multiplier() -> uint256: view - -interface StableSwap2: - def calc_token_amount(amounts: uint256[2], deposit: bool) -> uint256: view - -interface StableSwap3: - def calc_token_amount(amounts: uint256[3], deposit: bool) -> uint256: view - + def coins(i: uint256) -> address: view A_PRECISION: constant(uint256) = 100 MAX_COINS: constant(uint256) = 8 @@ -36,6 +31,11 @@ PRECISION: constant(uint256) = 10 ** 18 FEE_DENOMINATOR: constant(uint256) = 10 ** 10 +VERSION: public(constant(String[8])) = "1.2.0" +# first version was: 0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA (ethereum mainnet) +# second version was: 0x13526206545e2DC7CcfBaF28dC88F440ce7AD3e0 (ethereum mainnet) + + # ------------------------------ Public Getters ------------------------------ @@ -99,6 +99,7 @@ def get_dx_underlying( BASE_N_COINS: uint256 = StableSwapNG(pool).BASE_N_COINS() N_COINS: uint256 = StableSwapNG(pool).N_COINS() base_pool_has_static_fee: bool = self._has_static_fee(BASE_POOL) + base_pool_lp_token: address = StableSwapNG(pool).coins(1) # 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. @@ -114,7 +115,7 @@ def get_dx_underlying( if i == 0: # Calculate LP tokens that are burnt to receive dy amount of base_j tokens. lp_amount_burnt: uint256 = self._base_calc_token_amount( - dy, j - 1, BASE_N_COINS, BASE_POOL, False + dy, j - 1, BASE_N_COINS, BASE_POOL, base_pool_lp_token, False, ) return self._get_dx(0, 1, lp_amount_burnt, pool, False, N_COINS) @@ -152,6 +153,7 @@ def get_dy_underlying( N_COINS: uint256 = StableSwapNG(pool).N_COINS() MAX_COIN: int128 = convert(N_COINS, int128) - 1 BASE_POOL: address = StableSwapNG(pool).BASE_POOL() + base_lp_token: address = StableSwapNG(pool).coins(1) rates: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) balances: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) @@ -182,7 +184,12 @@ def get_dy_underlying( # i is from BasePool base_n_coins: uint256 = StableSwapNG(pool).BASE_N_COINS() x = self._base_calc_token_amount( - dx, base_i, base_n_coins, BASE_POOL, True + dx, + base_i, + base_n_coins, + BASE_POOL, + base_lp_token, + True, ) * rates[1] / PRECISION # Adding number of pool tokens @@ -225,83 +232,19 @@ def calc_token_amount( ) -> uint256: """ @notice Calculate addition or reduction in token supply from a deposit or withdrawal + @dev Only works for StableswapNG pools and not legacy versions @param _amounts Amount of each coin being deposited @param _is_deposit set True for deposits, False for withdrawals @return Expected amount of LP tokens received """ - amp: uint256 = StableSwapNG(pool).A() * A_PRECISION - N_COINS: uint256 = StableSwapNG(pool).N_COINS() - - rates: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) - old_balances: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) - xp: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) - rates, old_balances, xp = self._get_rates_balances_xp(pool, N_COINS) - - # Initial invariant - D0: uint256 = self.get_D(xp, amp, N_COINS) - - total_supply: uint256 = StableSwapNG(pool).totalSupply() - new_balances: DynArray[uint256, MAX_COINS] = old_balances - for i in range(MAX_COINS): - if i == N_COINS: - break - - amount: uint256 = _amounts[i] - if _is_deposit: - new_balances[i] += amount - else: - new_balances[i] -= amount - - # Invariant after change - for idx in range(MAX_COINS): - if idx == N_COINS: - break - xp[idx] = rates[idx] * new_balances[idx] / PRECISION - D1: uint256 = self.get_D(xp, amp, N_COINS) - - # We need to recalculate the invariant accounting for fees - # to calculate fair user's share - D2: uint256 = D1 - if total_supply > 0: - - # Only account for fees if we are not the first to deposit - base_fee: uint256 = StableSwapNG(pool).fee() * N_COINS / (4 * (N_COINS - 1)) - fee_multiplier: uint256 = StableSwapNG(pool).offpeg_fee_multiplier() - _dynamic_fee_i: uint256 = 0 - xs: uint256 = 0 - ys: uint256 = (D0 + D1) / N_COINS - - for i in range(MAX_COINS): - if i == N_COINS: - break - - ideal_balance: uint256 = D1 * old_balances[i] / D0 - difference: uint256 = 0 - new_balance: uint256 = new_balances[i] - if ideal_balance > new_balance: - difference = ideal_balance - new_balance - else: - difference = new_balance - ideal_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 - for idx in range(MAX_COINS): - if idx == N_COINS: - break - xp[idx] = rates[idx] * new_balances[idx] / PRECISION - - D2 = self.get_D(xp, amp, N_COINS) - else: - return D1 # Take the dust if there was any - - diff: uint256 = 0 - if _is_deposit: - diff = D2 - D0 - else: - diff = D0 - D2 - return diff * total_supply / D0 + return self._calc_token_amount( + _amounts, + _is_deposit, + pool, + pool, + StableSwapNG(pool).N_COINS() + ) @view @@ -449,36 +392,125 @@ def _dynamic_fee(xpi: uint256, xpj: uint256, _fee: uint256, _fee_multiplier: uin @internal @view -def _base_calc_token_amount( - dx: uint256, - base_i: int128, - base_n_coins: uint256, - base_pool: address, - is_deposit: bool +def _calc_token_amount( + _amounts: DynArray[uint256, MAX_COINS], + _is_deposit: bool, + pool: address, + pool_lp_token: address, + n_coins: uint256, ) -> 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 and not base_pool_is_ng: + amp: uint256 = StableSwapNG(pool).A() * A_PRECISION - base_inputs: uint256[2] = empty(uint256[2]) - base_inputs[base_i] = dx - return StableSwap2(base_pool).calc_token_amount(base_inputs, is_deposit) + rates: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) + old_balances: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) + xp: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) - elif base_n_coins == 3 and not base_pool_is_ng: + pool_is_ng: bool = raw_call( + pool, + method_id("D_ma_time()"), + revert_on_failure=False, + is_static_call=True + ) + use_dynamic_fees: bool = True + if pool_is_ng: + rates, old_balances, xp = self._get_rates_balances_xp(pool, n_coins) + else: + use_dynamic_fees = False + for i in range(n_coins, bound=MAX_COINS): + rates.append( + 10 ** (36 - convert(ERC20Detailed(StableSwapNG(pool).coins(i)).decimals(), uint256)) + ) + old_balances.append(StableSwapNG(pool).balances(i)) + xp.append(rates[i] * old_balances[i] / PRECISION) - base_inputs: uint256[3] = empty(uint256[3]) - base_inputs[base_i] = dx - return StableSwap3(base_pool).calc_token_amount(base_inputs, is_deposit) + # Initial invariant + D0: uint256 = self.get_D(xp, amp, n_coins) - else: + total_supply: uint256 = StableSwapNG(pool_lp_token).totalSupply() + new_balances: DynArray[uint256, MAX_COINS] = old_balances + for i in range(n_coins, bound=MAX_COINS): + amount: uint256 = _amounts[i] + if _is_deposit: + new_balances[i] += amount + else: + new_balances[i] -= amount + + # Invariant after change + for idx in range(n_coins, bound=MAX_COINS): + xp[idx] = rates[idx] * new_balances[idx] / PRECISION + D1: uint256 = self.get_D(xp, amp, n_coins) + + # We need to recalculate the invariant accounting for fees + # to calculate fair user's share + D2: uint256 = D1 + fee_multiplier: uint256 = 0 + _dynamic_fee_i: uint256 = 0 + if total_supply > 0: + + # Only account for fees if we are not the first to deposit + base_fee: uint256 = StableSwapNG(pool).fee() * n_coins / (4 * (n_coins - 1)) + if use_dynamic_fees: + fee_multiplier = StableSwapNG(pool).offpeg_fee_multiplier() + + xs: uint256 = 0 + ys: uint256 = (D0 + D1) / n_coins + + for i in range(n_coins, bound=MAX_COINS): - base_inputs: DynArray[uint256, MAX_COINS] = empty(DynArray[uint256, MAX_COINS]) - for i in range(base_n_coins, bound=MAX_COINS): - if i == convert(base_i, uint256): - base_inputs.append(dx) + ideal_balance: uint256 = D1 * old_balances[i] / D0 + difference: uint256 = 0 + new_balance: uint256 = new_balances[i] + if ideal_balance > new_balance: + difference = ideal_balance - new_balance + else: + difference = new_balance - ideal_balance + + xs = rates[i] * (old_balances[i] + new_balance) / PRECISION + + # use dynamic fees only if pool is NG + if use_dynamic_fees: + _dynamic_fee_i = self._dynamic_fee(xs, ys, base_fee, fee_multiplier) + new_balances[i] -= _dynamic_fee_i * difference / FEE_DENOMINATOR else: - base_inputs.append(0) - return StableSwapNG(base_pool).calc_token_amount(base_inputs, is_deposit) + new_balances[i] -= base_fee * difference / FEE_DENOMINATOR + + for idx in range(n_coins, bound=MAX_COINS): + xp[idx] = rates[idx] * new_balances[idx] / PRECISION + + D2 = self.get_D(xp, amp, n_coins) + else: + return D1 # Take the dust if there was any + + diff: uint256 = 0 + if _is_deposit: + diff = D2 - D0 + else: + diff = D0 - D2 + return diff * total_supply / D0 + + +@internal +@view +def _base_calc_token_amount( + dx: uint256, + base_i: int128, + base_n_coins: uint256, + base_pool: address, + base_pool_lp_token: address, + is_deposit: bool, +) -> uint256: + + base_inputs: DynArray[uint256, MAX_COINS] = [0, 0, 0, 0, 0, 0, 0, 0] + base_inputs[base_i] = dx + + return self._calc_token_amount( + base_inputs, + is_deposit, + base_pool, + base_pool_lp_token, + base_n_coins + ) @internal diff --git a/poetry.lock b/poetry.lock index 69fcafa9..5db33363 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3135,13 +3135,14 @@ typing-extensions = "*" vyper = ">=0.3.10" [package.extras] +colab = ["ipykernel (>=6.29.4)"] forking-recommended = ["ujson"] [package.source] type = "git" -url = "https://github.com/DanielSchiavini/titanoboa" -reference = "zksync" -resolved_reference = "f96fff3450c060b6849a632608377b4477667884" +url = "https://github.com/vyperlang/titanoboa" +reference = "master" +resolved_reference = "ea18746a7405b237cea934b678c3ecffc83f951b" [[package]] name = "titanoboa-zksync" @@ -3153,7 +3154,7 @@ files = [] develop = false [package.dependencies] -titanoboa = {git = "https://github.com/DanielSchiavini/titanoboa", rev = "zksync"} +titanoboa = {git = "https://github.com/vyperlang/titanoboa", rev = "master"} [package.extras] forking-recommended = ["ujson"] @@ -3161,8 +3162,8 @@ forking-recommended = ["ujson"] [package.source] type = "git" url = "https://github.com/DanielSchiavini/titanoboa-zksync.git" -reference = "5f13b427df4b8832fcc16ec1f6d44460f1d04b49" -resolved_reference = "5f13b427df4b8832fcc16ec1f6d44460f1d04b49" +reference = "HEAD" +resolved_reference = "126b53f6b7872d6949e4d44d8e95514aa0fb44a2" [[package]] name = "tomli" @@ -3473,4 +3474,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "251db9973fb842214b8fa1401ec565f64f6e82e3aac76755a4a26fab226fca05" +content-hash = "f8037e6bb9ee4524d8e1ca00d043746a682d20fac5743eaaf3b0f0d1d608d0ad" diff --git a/pyproject.toml b/pyproject.toml index 0d8ca2c8..a5df2948 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ poetry = "1.5.1" vyper = "0.3.10" pycryptodome = "^3.18.0" pre-commit = "^3.3.3" -titanoboa-zksync = {git = "https://github.com/DanielSchiavini/titanoboa-zksync.git", rev = "5f13b427df4b8832fcc16ec1f6d44460f1d04b49"} +titanoboa-zksync = {git = "https://github.com/DanielSchiavini/titanoboa-zksync.git"} [tool.poetry.group.dev.dependencies] black = "22.3.0" diff --git a/scripts/deploy_infra.py b/scripts/deploy_infra.py index 9087bd04..eeed6273 100644 --- a/scripts/deploy_infra.py +++ b/scripts/deploy_infra.py @@ -9,194 +9,16 @@ from eth_account import Account from rich.console import Console as RichConsole +# sys.path.append(".") +from scripts import deployments + ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" logger = RichConsole(file=sys.stdout) -deployments = { - # Ethereum - "ethereum:mainnet": { - "math": "0xc9CBC565A9F4120a2740ec6f64CC24AeB2bB3E5E", - # "views_old": "0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA", - "views": "0x13526206545e2DC7CcfBaF28dC88F440ce7AD3e0", - "plain_amm": "0xDCc91f930b42619377C200BA05b7513f2958b202", - "meta_amm": "0xede71F77d7c900dCA5892720E76316C6E575F0F7", - "factory": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf", - "gauge": "0x38D9BdA812da2C68dFC6aDE85A7F7a54E77F8325", - "zap": "", - }, - "ethereum:sepolia": { - "math": "0x2cad7b3e78e10bcbf2cc443ddd69ca8bcc09a758", - # "views": "0x9d3975070768580f755D405527862ee126d0eA08", - "views": "", - "plain_amm": "0xE12374F193f91f71CE40D53E0db102eBaA9098D5", - "meta_amm": "0xB00E89EaBD59cD3254c88E390103Cf17E914f678", - "factory": "0xfb37b8D939FFa77114005e61CFc2e543d6F49A81", - "zap": "", - }, - # Layer 2 - "arbitrum:mainnet": { - "math": "0xD4a8bd4d59d65869E99f20b642023a5015619B34", - # "views_old": "0x9293f068912bae932843a1bA01806c54f416019D", - "views": "0xDD7EBB1C49780519dD9755B8B1A23a6f42CE099E", - "plain_amm": "0xf6841C27fe35ED7069189aFD5b81513578AFD7FF", - "meta_amm": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61", - "factory": "0x9AF14D26075f142eb3F292D5065EB3faa646167b", - "zap": "", - }, - "optimism:mainnet": { - "math": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - # "views_old": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", - "views": "0xf6841C27fe35ED7069189aFD5b81513578AFD7FF", - "plain_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", - "meta_amm": "0x5702BDB1Ec244704E3cBBaAE11a0275aE5b07499", - "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", - "zap": "", - }, - "base:mainnet": { - "math": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - # "views_old": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - "views": "0xC1b393EfEF38140662b91441C6710Aa704973228", - "plain_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", - "meta_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", - "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", - "zap": "", - }, - "linea:mainnet": { - "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - # "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "views": "0x3E3B5F27bbf5CC967E074b70E9f4046e31663181", - "plain_amm": "0xa7b9d886a9a374a1c86dc52d2ba585c5cdfdac26", - "meta_amm": "0xf3a6aa40cf048a3960e9664847e9a7be025a390a", - "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", - "zap": "", - }, - "scroll:mainnet": { - "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - # "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", - "plain_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - "meta_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", - "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", - "zap": "", - }, - "pzkevm:mainnet": { - "math": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "views": "0x87DD13Dd25a1DBde0E1EdcF5B8Fa6cfff7eABCaD", - "plain_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", - "meta_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", - "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", - "zap": "", - }, - # Layer 1 - "gnosis:mainnet": { - "math": "0xFAbC421e3368D158d802684A217a83c083c94CeB", - # "views_old": "0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf", - "views": "0x33e72383472f77B0C6d8F791D1613C75aE2C5915", - "plain_amm": "0x3d6cb2f6dcf47cdd9c13e4e3beae9af041d8796a", - "meta_amm": "0xC1b393EfEF38140662b91441C6710Aa704973228", - "factory": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - "zap": "", - }, - "polygon:mainnet": { - "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - # "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - "views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", - "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", - "zap": "", - }, - "avax:mainnet": { - "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - # "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - "views": "0x8F7632122125699da7E22d465fa16EdE4f687Fa4", - "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", - "zap": "", - }, - "ftm:mainnet": { - "math": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", - # "views_old": "0x635742dCC8313DCf8c904206037d962c042EAfBd", - "views": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf", - "plain_amm": "0x5702BDB1Ec244704E3cBBaAE11a0275aE5b07499", - "meta_amm": "0x046207cB759F527b6c10C2D61DBaca45513685CC", - "factory": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b", - "zap": "", - }, - "bsc:mainnet": { - "math": "0x166c4084Ad2434E8F2425C64dabFE6875A0D45c5", - # "views_old": "0x5Ea9DD3b6f042A34Df818C6c1324BC5A7c61427a", - "views": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61", - "plain_amm": "0x505d666E4DD174DcDD7FA090ed95554486d2Be44", - "meta_amm": "0x5a8C93EE12a8Df4455BA111647AdA41f29D5CfcC", - "factory": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - "zap": "", - }, - "celo:mainnet": { - "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - # "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - "views": "0x8F7632122125699da7E22d465fa16EdE4f687Fa4", - "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", - "zap": "", - }, - "kava:mainnet": { - "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - # "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - "views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", - "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", - "zap": "", - }, - "aurora:mainnet": { - "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", - # "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", - "views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", - "plain_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", - "meta_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", - "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", - "zap": "", - }, - "fraxtal:mainnet": { - "math": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f", - # "views_old": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", - "views": "0xFAbC421e3368D158d802684A217a83c083c94CeB", - "plain_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585", - "meta_amm": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", - "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", - "zap": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b", - }, - "mantle:mainnet": { - "math": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6", - # "views_old": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f", - "views": "0x166c4084Ad2434E8F2425C64dabFE6875A0D45c5", - "plain_amm": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", - "meta_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585", - "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", - "zap": "", - "factory_ctor": "000000000000000000000000f3a431008396df8a8b2df492c913706bdb0874ef0000000000000000000000002d12d0907a388811e3aa855a550f959501d303ee", # noqa:E501 - }, - "xlayer:mainnet": { - "math": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6", - "views": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", - "plain_amm": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", - "meta_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585", - "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", - "zap": "0x604388Bb1159AFd21eB5191cE22b4DeCdEE2Ae22", - }, - "zksync:mainnet": { - "math": "0xcf19236e85000901dE2Fad3199aA4A1F74a78B6C", - "views": "0xDD82bEe76CB4b161B44533e4B6Dfc2eee7e066D4", - "plain_amm": "0x3ce3009F8ad07161BA9d02d7A0173180d0281cA4", - "meta_amm": "0x1E9A82C2a3DF2E0793a2B828aA652Db192f3C8F3", - "factory": "0x375444aeDEb6C3db897f293E1DBa85D7422A6859", - "zap": "0x4232Dcc6D31543A2431079BdE2082C69eA3A771E", - }, -} + +def fetch_url(network): + return os.getenv("DRPC_URL") % (network, os.getenv("DRPC_KEY")) def set_contract_pragma(contract_file, network) -> boa.contracts.vyper.vyper_contract.VyperDeployer: @@ -227,7 +49,7 @@ def set_contract_pragma(contract_file, network) -> boa.contracts.vyper.vyper_con def check_and_deploy(contract_obj, contract_designation, network, blueprint: bool = False, args=[]): - deployed_contract = deployments[network][contract_designation] + deployed_contract = deployments.deployments[network][contract_designation] try: contract_name = os.path.basename(contract_obj.filename) except AttributeError: @@ -389,7 +211,16 @@ def main(): deployer = "FIDDYDEPLOYER" fork = False network = "zksync" - rpc = "https://mainnet.era.zksync.io" + + if network == "zksync": + rpc = "https://mainnet.era.zksync.io" + elif network == "fraxtal": + rpc = "https://rpc.frax.com" + elif network == "xlayer": + rpc = "https://rpc.xlayer.tech" + else: + rpc = fetch_url(network) + deploy_infra(f"{network}:mainnet", rpc, deployer, fork=fork) diff --git a/scripts/deployment_utils.py b/scripts/deployment_utils.py index e3463339..434e86be 100644 --- a/scripts/deployment_utils.py +++ b/scripts/deployment_utils.py @@ -61,7 +61,7 @@ class CurveNetworkSettings: dao_ownership_contract="0xCb8799BFF48bb549F7B69Bb9BE60DbA7cd4F1BB7", fee_receiver_address="0xCb8799BFF48bb549F7B69Bb9BE60DbA7cd4F1BB7", ), - "pzkevm:mainnet": CurveNetworkSettings( + "polygon-zkevm:mainnet": CurveNetworkSettings( dao_ownership_contract="0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6", fee_receiver_address="0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6", ), @@ -74,11 +74,11 @@ class CurveNetworkSettings: dao_ownership_contract="0xB055EbbAcc8Eefc166c169e9Ce2886D0406aB49b", # proxy fee_receiver_address="0xB055EbbAcc8Eefc166c169e9Ce2886D0406aB49b", # proxy ), - "avax:mainnet": CurveNetworkSettings( + "avalanche:mainnet": CurveNetworkSettings( dao_ownership_contract="0xB055EbbAcc8Eefc166c169e9Ce2886D0406aB49b", # proxy fee_receiver_address="0x06534b0BF7Ff378F162d4F348390BDA53b15fA35", ), - "ftm:mainnet": CurveNetworkSettings( + "fantom:mainnet": CurveNetworkSettings( dao_ownership_contract="0xB055EbbAcc8Eefc166c169e9Ce2886D0406aB49b", # proxy fee_receiver_address="0x2B039565B2b7a1A9192D4847fbd33B25b836B950", ), diff --git a/scripts/deployments.py b/scripts/deployments.py new file mode 100644 index 00000000..1aa99e01 --- /dev/null +++ b/scripts/deployments.py @@ -0,0 +1,203 @@ +deployments = { + # Ethereum + "ethereum:mainnet": { + "math": "0xc9CBC565A9F4120a2740ec6f64CC24AeB2bB3E5E", + # "views_old_0": "0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA", + # "views_old_1": "0x13526206545e2DC7CcfBaF28dC88F440ce7AD3e0", + "views": "0xFF53042865dF617de4bB871bD0988E7B93439cCF", + "plain_amm": "0xDCc91f930b42619377C200BA05b7513f2958b202", + "meta_amm": "0xede71F77d7c900dCA5892720E76316C6E575F0F7", + "factory": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf", + "gauge": "0x38D9BdA812da2C68dFC6aDE85A7F7a54E77F8325", + "zap": "0xDfeF1725Ab767f165171709C6d1E1A6247425fE0", + }, + "ethereum:sepolia": { + "math": "0x2cad7b3e78e10bcbf2cc443ddd69ca8bcc09a758", + # "views": "0x9d3975070768580f755D405527862ee126d0eA08", + "views": "", + "plain_amm": "0xE12374F193f91f71CE40D53E0db102eBaA9098D5", + "meta_amm": "0xB00E89EaBD59cD3254c88E390103Cf17E914f678", + "factory": "0xfb37b8D939FFa77114005e61CFc2e543d6F49A81", + "zap": "", + }, + # Layer 2 + "arbitrum:mainnet": { + "math": "0xD4a8bd4d59d65869E99f20b642023a5015619B34", + # "views_old_0": "0x9293f068912bae932843a1bA01806c54f416019D", + # "views_old_1": "0xDD7EBB1C49780519dD9755B8B1A23a6f42CE099E", + "views": "", + "plain_amm": "0xf6841C27fe35ED7069189aFD5b81513578AFD7FF", + "meta_amm": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61", + "factory": "0x9AF14D26075f142eb3F292D5065EB3faa646167b", + "zap": "0x59AfCD3e931018dc493AA1d833B11bb5A0744906", + }, + "optimism:mainnet": { + "math": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + # "views_old_0": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", + # "views_old_1": "0xf6841C27fe35ED7069189aFD5b81513578AFD7FF", + "views": "0xbC7654d2DD901AaAa3BE4Cb5Bc0f10dEA9f96443", + "plain_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", + "meta_amm": "0x5702BDB1Ec244704E3cBBaAE11a0275aE5b07499", + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + "zap": "0x07920E98a66e462C2Aa4c8fa6200bc68CA161ea0", + }, + "base:mainnet": { + "math": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + # "views_old_0": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + # "views_old_1": "0xC1b393EfEF38140662b91441C6710Aa704973228", + "views": "0xA54f3c1DFa5f7DbF2564829d14b3B74a65d26Ae2", + "plain_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", + "meta_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", + "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", + "zap": "0x3f445D38E820c010a7A6E33c5F80cBEBE6930f61", + }, + "linea:mainnet": { + "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old_0": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + # "views_old_1": "0x3E3B5F27bbf5CC967E074b70E9f4046e31663181", + "views": "0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb", + "plain_amm": "0xa7b9d886a9a374a1c86dc52d2ba585c5cdfdac26", + "meta_amm": "0xf3a6aa40cf048a3960e9664847e9a7be025a390a", + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + "zap": "0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da", + }, + "scroll:mainnet": { + "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old_0": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + # "views_old_1": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", + "views": "0x3f445D38E820c010a7A6E33c5F80cBEBE6930f61", + "plain_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + "meta_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + "zap": "0xb47988aD49DCE8D909c6f9Cf7B26caF04e1445c8", + }, + "polygon-zkevm:mainnet": { + "math": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + # "views_old_1": "0x87DD13Dd25a1DBde0E1EdcF5B8Fa6cfff7eABCaD", + "views": "0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb", + "plain_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", + "meta_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd", + "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", + "zap": "0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da", + }, + # Layer 1 + "gnosis:mainnet": { + "math": "0xFAbC421e3368D158d802684A217a83c083c94CeB", + # "views_old_0": "0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf", + # "views_old_1": "0x33e72383472f77B0C6d8F791D1613C75aE2C5915", + "views": "0xa0EC67a3C483674f77915893346A8CA3AbE2b785", + "plain_amm": "0x3d6cb2f6dcf47cdd9c13e4e3beae9af041d8796a", + "meta_amm": "0xC1b393EfEF38140662b91441C6710Aa704973228", + "factory": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + "zap": "0x08390C76DFDaB74249754C8e71cC2747351bd388", + }, + "polygon:mainnet": { + "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", + # "views_old_0": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old_1": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", + "views": "0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da", + "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + "zap": "0x4c7a5a5d57f98d362f1c00d7135f0da5b6f82227", + }, + "avalanche:mainnet": { + "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", + # "views_old_0": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old_1": "0x8F7632122125699da7E22d465fa16EdE4f687Fa4", + "views": "0xe548590f9fAe7a23EA6501b144B0D58b74Fc4B53", + "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + "zap": "0xA54f3c1DFa5f7DbF2564829d14b3B74a65d26Ae2", + }, + "fantom:mainnet": { + "math": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", + # "views_old_0": "0x635742dCC8313DCf8c904206037d962c042EAfBd", + # "views_old_1": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf", + "views": "0x33e72383472f77B0C6d8F791D1613C75aE2C5915", + "plain_amm": "0x5702BDB1Ec244704E3cBBaAE11a0275aE5b07499", + "meta_amm": "0x046207cB759F527b6c10C2D61DBaca45513685CC", + "factory": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b", + "zap": "0x21688e843a99B0a47E750e7dDD2b5dAFd9269d30", + }, + "bsc:mainnet": { + "math": "0x166c4084Ad2434E8F2425C64dabFE6875A0D45c5", + # "views_old_0": "0x5Ea9DD3b6f042A34Df818C6c1324BC5A7c61427a", + # "views_old_1": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61", + "views": "0xbC7654d2DD901AaAa3BE4Cb5Bc0f10dEA9f96443", + "plain_amm": "0x505d666E4DD174DcDD7FA090ed95554486d2Be44", + "meta_amm": "0x5a8C93EE12a8Df4455BA111647AdA41f29D5CfcC", + "factory": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", + "zap": "0x07920e98a66e462c2aa4c8fa6200bc68ca161ea0", + }, + "celo:mainnet": { + "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", + # "views_old_0": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old_1": "0x8F7632122125699da7E22d465fa16EdE4f687Fa4", + "views": "0xA54f3c1DFa5f7DbF2564829d14b3B74a65d26Ae2", + "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + "zap": "0x3f445D38E820c010a7A6E33c5F80cBEBE6930f61", + }, + "kava:mainnet": { + "math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", + # "views_old_0": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old_1": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", + "views": "0xB6845b562F01eB02ef20CBB63553d2a768e5a1Cb", + "plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + "meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + "factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + "zap": "0xf2eff2Cd0d9C82b7b2f17FbBed703fA7931dB1da", + }, + "aurora:mainnet": { + "math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8", + # "views_old_0": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3", + # "views_old_1": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A", + "views": "0xD4a8bd4d59d65869E99f20b642023a5015619B34", + "plain_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26", + "meta_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a", + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + "zap": "0x9293f068912bae932843a1bA01806c54f416019D", + }, + "fraxtal:mainnet": { + "math": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f", + # "views_old_0": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", + # "views_old_1": "0xFAbC421e3368D158d802684A217a83c083c94CeB", + "views": "0xeEcCd039d7228530D5F0c3ce7291Dd9677CCFFb1", + "plain_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + "meta_amm": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + "factory": "0xd2002373543Ce3527023C75e7518C274A51ce712", + "zap": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b", + }, + "mantle:mainnet": { + "math": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6", + # "views_old_0": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f", + # "views_old_1": "0x166c4084Ad2434E8F2425C64dabFE6875A0D45c5", + "views": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61", + "plain_amm": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", + "meta_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + "zap": "0xe548590f9fAe7a23EA6501b144B0D58b74Fc4B53", + "factory_ctor": "000000000000000000000000f3a431008396df8a8b2df492c913706bdb0874ef0000000000000000000000002d12d0907a388811e3aa855a550f959501d303ee", # noqa:E501 + }, + "xlayer:mainnet": { + "math": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6", + # "views_old_1": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B", + "views": "0xb47988aD49DCE8D909c6f9Cf7B26caF04e1445c8", + "plain_amm": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617", + "meta_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585", + "factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E", + "zap": "0x604388Bb1159AFd21eB5191cE22b4DeCdEE2Ae22", + }, + "zksync:mainnet": { + "math": "0xcf19236e85000901dE2Fad3199aA4A1F74a78B6C", + # "views_old_1": "0xDD82bEe76CB4b161B44533e4B6Dfc2eee7e066D4", + "views": "0xeF62cD5CBa8B040827B648dBc6a755ddeeb84E65", + "plain_amm": "0x3ce3009F8ad07161BA9d02d7A0173180d0281cA4", + "meta_amm": "0x1E9A82C2a3DF2E0793a2B828aA652Db192f3C8F3", + "factory": "0x375444aeDEb6C3db897f293E1DBa85D7422A6859", + "zap": "0x4232Dcc6D31543A2431079BdE2082C69eA3A771E", + }, +}