Skip to content

Commit

Permalink
Merge pull request #15 from curvefi/update_twocryptong_implementation
Browse files Browse the repository at this point in the history
Update twocryptong implementation
  • Loading branch information
bout3fiddy authored Jun 6, 2024
2 parents 3b0226a + 422b9dd commit 96c2d02
Show file tree
Hide file tree
Showing 8 changed files with 10,186 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,4 @@ node_modules
# temp
docs/
scripts/experiments/get_p.py
*.csv
2 changes: 1 addition & 1 deletion contracts/main/CurveCryptoMathOptimized2.vy
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MAX_GAMMA: constant(uint256) = 199 * 10**15 # 1.99 * 10**17
MIN_A: constant(uint256) = N_COINS**N_COINS * A_MULTIPLIER / 10
MAX_A: constant(uint256) = N_COINS**N_COINS * A_MULTIPLIER * 1000

version: public(constant(String[8])) = "v2.0.0"
version: public(constant(String[8])) = "v2.1.0"


# ------------------------ AMM math functions --------------------------------
Expand Down
2 changes: 1 addition & 1 deletion contracts/main/CurveTwocryptoOptimized.vy
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ MAX_GAMMA: constant(uint256) = 199 * 10**15 # 1.99 * 10**17
name: public(immutable(String[64]))
symbol: public(immutable(String[32]))
decimals: public(constant(uint8)) = 18
version: public(constant(String[8])) = "v2.0.0"
version: public(constant(String[8])) = "v2.1.0"

balanceOf: public(HashMap[address, uint256])
allowance: public(HashMap[address, HashMap[address, uint256]])
Expand Down
112 changes: 74 additions & 38 deletions deployments.yaml
Original file line number Diff line number Diff line change
@@ -1,96 +1,132 @@
arbitrum:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: 0x2005995a71243be9FB995DaB4742327dc76564Df.
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
aurora:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
avax:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
base:mainnet:
amm: '0x1A83348F9cCFD3Fe1A8C0adBa580Ac4e267Fe495'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x1A83348F9cCFD3Fe1A8C0adBa580Ac4e267Fe495'
factory: '0xc9Fe0C63Af9A39402e8a5514f9c43Af0322b665F'
math: '0x64379C265Fc6595065D7d835AAaa731c0584dB80'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x64379C265Fc6595065D7d835AAaa731c0584dB80'
views: '0xd3B17f862956464ae4403cCF829CE69199856e1e'
bsc:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
celo:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
ethereum:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
gauge: '0x38D9BdA812da2C68dFC6aDE85A7F7a54E77F8325'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
ethereum:sepolia:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
fraxtal:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
ftm:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
gnosis:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
kava:mainnet:
amm: '0x64379C265Fc6595065D7d835AAaa731c0584dB80'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x64379C265Fc6595065D7d835AAaa731c0584dB80'
factory: '0xd3B17f862956464ae4403cCF829CE69199856e1e'
math: '0x7Ca46A636b02D4aBC66883D7FF164bDE506DC66a'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x7Ca46A636b02D4aBC66883D7FF164bDE506DC66a'
views: '0x0C9D8c7e486e822C29488Ff51BFf0167B4650953'
linea:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
mantle:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
optimism:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
polygon:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
pzkevm:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
scroll:mainnet:
amm: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0x04Fd6beC7D45EFA99a27D29FB94b55c56dD07223'
factory: '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F'
math: '0x2005995a71243be9FB995DaB4742327dc76564Df'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x2005995a71243be9FB995DaB4742327dc76564Df'
views: '0x07CdEBF81977E111B08C126DEFA07818d0045b80'
xlayer:mainnet:
amm: '0xFAbC421e3368D158d802684A217a83c083c94CeB'
amm: '0x934791f7F391727db92BFF94cd789c4623d14c52'
amm_v2_0_0: '0xFAbC421e3368D158d802684A217a83c083c94CeB'
factory: '0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf'
math: '0x505d666E4DD174DcDD7FA090ed95554486d2Be44'
math: '0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1'
math_v2_0_0: '0x505d666E4DD174DcDD7FA090ed95554486d2Be44'
views: '0x5a8C93EE12a8Df4455BA111647AdA41f29D5CfcC'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ matplotlib
cytoolz

# vyper and dev framework (boa interpreter):
git+https://github.com/vyperlang/titanoboa@1bf16f916b91aab299e293b4148be455c1674706
git+https://github.com/vyperlang/titanoboa@40e85c602aa2c15baaf5060547c1224178d9efae
vyper>=0.3.10
106 changes: 106 additions & 0 deletions scripts/deploy_implementation_and_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# flake8: noqa E501

import os
import sys

import boa
import deployment_utils as deploy_utils
import yaml
from boa.network import NetworkEnv
from eth_account import Account
from rich.console import Console as RichConsole

sys.path.append("./")
from scripts.deploy_infra import check_and_deploy

logger = RichConsole(file=sys.stdout)


def fetch_url(network):
return os.getenv("DRPC_URL") % (network, os.getenv("DRPC_KEY"))


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

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

if not url:
url = fetch_url(network.split(":")[0])

if fork:
boa.env.fork(url)
logger.log("Forkmode ...")
boa.env.eoa = deploy_utils.FIDDYDEPLOYER # set eoa address here
else:
logger.log("Prodmode ...")
boa.set_env(NetworkEnv(url))
boa.env.add_account(Account.from_key(os.environ[account]))

CREATE2DEPLOYER = boa.load_abi("abi/create2deployer.json").at(
"0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2"
)

with open("./deployments.yaml", "r") as file:
deployments = yaml.safe_load(file)

factory = boa.load_partial("./contracts/main/CurveTwocryptoFactory.vy").at(
deployments[network]["factory"]
)

math_contract_obj = boa.load_partial(
"./contracts/main/CurveCryptoMathOptimized2.vy"
)
amm_contract_obj = boa.load_partial(
"./contracts/main/CurveTwocryptoOptimized.vy"
)

math_contract = check_and_deploy(
contract_obj=math_contract_obj,
contract_designation="math",
network=network,
create2deployer=CREATE2DEPLOYER,
calculated_address="0x1Fd8Af16DC4BEBd950521308D55d0543b6cDF4A1",
upkeep_deploy_log=not fork,
)

amm_blueprint = check_and_deploy(
contract_obj=amm_contract_obj,
contract_designation="amm",
network=network,
create2deployer=CREATE2DEPLOYER,
calculated_address="0x934791f7F391727db92BFF94cd789c4623d14c52",
blueprint=True,
upkeep_deploy_log=not fork,
)

if boa.env.eoa == factory.admin():

# update implementation here
if not factory.pool_implementations(0) == amm_blueprint.address:
logger.log("Setting AMM implementation ...")
factory.set_pool_implementation(amm_blueprint, 0)

if not factory.math_implementation() == math_contract.address:
logger.log("Setting Math implementation ...")
factory.set_math_implementation(math_contract)

logger.log("Done!")

else:

logger.log(f"Could not update implementation for factory on {network}")


def main():

forkmode = False
deploy(
network="",
url="",
account="",
fork=forkmode,
)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion scripts/deploy_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def check_and_deploy(
blueprint=blueprint,
blueprint_preamble=b"\xFE\x71\x00",
)
assert precomputed_address == calculated_address
# assert precomputed_address == calculated_address

deploy_utils.deploy_via_create2_factory(
deployment_bytecode,
Expand Down
Loading

0 comments on commit 96c2d02

Please sign in to comment.