Skip to content

Commit

Permalink
Merge branch 'main' into xlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy authored Apr 25, 2024
2 parents 54bc614 + 5ff951c commit b280aaa
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 37 deletions.
52 changes: 45 additions & 7 deletions .github/workflows/push_pr.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on:
release:
types: [created]
types: [ created ]

name: on-creating-new-tag
name: push-changes-on-release

jobs:
send-pull-requests:
Expand All @@ -20,8 +20,8 @@ jobs:

- name: Create release file
run: |
TITLE='${{ github.event.release.name }}'
NOTES='${{ github.event.release.body }}'
TITLE="${{ github.event.release.name }}"
NOTES="${{ github.event.release.body }}"
DATE=$(date '+%d-%m-%Y')
mkdir -p deployments
echo $NOTES >> "deployments/release-$TITLE-$DATE.txt"
Expand All @@ -35,7 +35,7 @@ jobs:
git commit -m "chore: add release file - $TITLE"
git push
- name: Checkout to other repo
- name: Checkout to curve-js
uses: actions/checkout@v3
with:
repository: curvefi/curve-js
Expand All @@ -45,7 +45,7 @@ jobs:
run: |
TAG=${{ env.RELEASE_VERSION }}
ORG="curvefi"
CURRENT_REPOSITORY="$ORG/stableswap-ng"
CURRENT_REPOSITORY="${{ github.repository }}"
REPOSITORY="$ORG/curve-js"
FOLDER="bin/$REPOSITORY"
BRANCH_NAME="deployment-$CURRENT_REPOSITORY-$TAG"
Expand All @@ -68,7 +68,45 @@ jobs:
# create a pull-requests containing the updates.
gh auth login --with-token < token.txt
gh pr create \
--body "Link to release: https://github.com/$CURRENT_REPOSITORY/releases/tag/$TAG" \
--body "${{ github.event.release.body }}" \
--title "Deployment from $CURRENT_REPOSITORY - $TAG" \
--head "$BRANCH_NAME" \
--base "master"
- name: Checkout to curve-api
uses: actions/checkout@v3
with:
repository: curvefi/curve-api
token: ${{ secrets.ACCESS_TOKEN }}

- name: Send pull-request to curve-api
run: |
TAG=${{ env.RELEASE_VERSION }}
ORG="curvefi"
CURRENT_REPOSITORY="${{ github.repository }}"
REPOSITORY="$ORG/curve-api"
FOLDER="bin/$REPOSITORY"
BRANCH_NAME="deployment-$CURRENT_REPOSITORY-$TAG"
# Setup the committers identity.
git config user.email "[email protected]"
git config user.name "Curvefi"
# Create a new feature branch for the changes.
git checkout -b $BRANCH_NAME
# Store the PAT in a file that can be accessed by the GitHub CLI.
echo "${{ secrets.ACCESS_TOKEN }}" > token.txt
# Create an empty commit for PR
git commit --allow-empty -m "deployment from $CURRENT_REPOSITORY - $TAG"
git push -u origin $BRANCH_NAME
# Authorize GitHub CLI for the current repository and
# create a pull-requests containing the updates.
gh auth login --with-token < token.txt
gh pr create \
--body "${{ github.event.release.body }}" \
--title "Deployment from $CURRENT_REPOSITORY - $TAG" \
--head "$BRANCH_NAME" \
--base "main"
11 changes: 6 additions & 5 deletions contracts/main/CurveStableSwapNGViews.vy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pragma version 0.3.10
# pragma evm-version shanghai
# pragma evm-version paris
"""
@title CurveStableSwapNGViews
@author Curve.Fi
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions contracts/main/MetaZapNG.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# pragma version 0.3.10
# pragma evm-version paris
"""
@title MetaZapNG
@author Curve.Fi
Expand Down
72 changes: 48 additions & 24 deletions scripts/deploy_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# Ethereum
"ethereum:mainnet": {
"math": "0xc9CBC565A9F4120a2740ec6f64CC24AeB2bB3E5E",
"views": "0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA",
# "views_old": "0xe0B15824862f3222fdFeD99FeBD0f7e0EC26E1FA",
"views": "0x13526206545e2DC7CcfBaF28dC88F440ce7AD3e0",
"plain_amm": "0xDCc91f930b42619377C200BA05b7513f2958b202",
"meta_amm": "0xede71F77d7c900dCA5892720E76316C6E575F0F7",
"factory": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf",
Expand All @@ -23,7 +24,8 @@
},
"ethereum:sepolia": {
"math": "0x2cad7b3e78e10bcbf2cc443ddd69ca8bcc09a758",
"views": "0x9d3975070768580f755D405527862ee126d0eA08",
# "views": "0x9d3975070768580f755D405527862ee126d0eA08",
"views": "",
"plain_amm": "0xE12374F193f91f71CE40D53E0db102eBaA9098D5",
"meta_amm": "0xB00E89EaBD59cD3254c88E390103Cf17E914f678",
"factory": "0xfb37b8D939FFa77114005e61CFc2e543d6F49A81",
Expand All @@ -32,39 +34,44 @@
# Layer 2
"arbitrum:mainnet": {
"math": "0xD4a8bd4d59d65869E99f20b642023a5015619B34",
"views": "0x9293f068912bae932843a1bA01806c54f416019D",
# "views_old": "0x9293f068912bae932843a1bA01806c54f416019D",
"views": "0xDD7EBB1C49780519dD9755B8B1A23a6f42CE099E",
"plain_amm": "0xf6841C27fe35ED7069189aFD5b81513578AFD7FF",
"meta_amm": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61",
"factory": "0x9AF14D26075f142eb3F292D5065EB3faa646167b",
"zap": "",
},
"optimism:mainnet": {
"math": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
"views": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a",
# "views_old": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a",
"views": "0xf6841C27fe35ED7069189aFD5b81513578AFD7FF",
"plain_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd",
"meta_amm": "0x5702BDB1Ec244704E3cBBaAE11a0275aE5b07499",
"factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E",
"zap": "",
},
"base:mainnet": {
"math": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
"views": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
# "views_old": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
"views": "0xC1b393EfEF38140662b91441C6710Aa704973228",
"plain_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a",
"meta_amm": "0x635742dCC8313DCf8c904206037d962c042EAfBd",
"factory": "0xd2002373543Ce3527023C75e7518C274A51ce712",
"zap": "",
},
"linea:mainnet": {
"math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
"views": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
# "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
"views": "0x3E3B5F27bbf5CC967E074b70E9f4046e31663181",
"plain_amm": "0xa7b9d886a9a374a1c86dc52d2ba585c5cdfdac26",
"meta_amm": "0xf3a6aa40cf048a3960e9664847e9a7be025a390a",
"factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E",
"zap": "",
},
"scroll:mainnet": {
"math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
"views": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
# "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
"views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A",
"plain_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
"meta_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a",
"factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E",
Expand All @@ -81,79 +88,89 @@
# Layer 1
"gnosis:mainnet": {
"math": "0xFAbC421e3368D158d802684A217a83c083c94CeB",
"views": "0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf",
# "views_old": "0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf",
"views": "0x33e72383472f77B0C6d8F791D1613C75aE2C5915",
"plain_amm": "0x3d6cb2f6dcf47cdd9c13e4e3beae9af041d8796a",
"meta_amm": "0xC1b393EfEF38140662b91441C6710Aa704973228",
"factory": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
"zap": "",
},
"polygon:mainnet": {
"math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B",
"views": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
# "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
"views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A",
"plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
"meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
"factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
"zap": "",
},
"avax:mainnet": {
"math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B",
"views": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
# "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
"views": "0x8F7632122125699da7E22d465fa16EdE4f687Fa4",
"plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
"meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
"factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
"zap": "",
},
"ftm:mainnet": {
"math": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a",
"views": "0x635742dCC8313DCf8c904206037d962c042EAfBd",
# "views_old": "0x635742dCC8313DCf8c904206037d962c042EAfBd",
"views": "0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf",
"plain_amm": "0x5702BDB1Ec244704E3cBBaAE11a0275aE5b07499",
"meta_amm": "0x046207cB759F527b6c10C2D61DBaca45513685CC",
"factory": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b",
"zap": "",
},
"bsc:mainnet": {
"math": "0x166c4084Ad2434E8F2425C64dabFE6875A0D45c5",
"views": "0x5Ea9DD3b6f042A34Df818C6c1324BC5A7c61427a",
# "views_old": "0x5Ea9DD3b6f042A34Df818C6c1324BC5A7c61427a",
"views": "0xFf02cBD91F57A778Bab7218DA562594a680B8B61",
"plain_amm": "0x505d666E4DD174DcDD7FA090ed95554486d2Be44",
"meta_amm": "0x5a8C93EE12a8Df4455BA111647AdA41f29D5CfcC",
"factory": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B",
"zap": "",
},
"celo:mainnet": {
"math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B",
"views": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
# "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
"views": "0x8F7632122125699da7E22d465fa16EdE4f687Fa4",
"plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
"meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
"factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
"zap": "",
},
"kava:mainnet": {
"math": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B",
"views": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
# "views_old": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
"views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A",
"plain_amm": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
"meta_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
"factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
"zap": "",
},
"aurora:mainnet": {
"math": "0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8",
"views": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
# "views_old": "0xe265FC390E9129b7E337Da23cD42E00C34Da2CE3",
"views": "0x20D1c021525C85D9617Ccc64D8f547d5f730118A",
"plain_amm": "0xa7b9d886A9a374A1C86DC52d2BA585c5CDFdac26",
"meta_amm": "0xf3A6aa40cf048a3960E9664847E9a7be025a390a",
"factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E",
"zap": "",
},
"fraxtal:mainnet": {
"math": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f",
"views": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617",
# "views_old": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617",
"views": "0xFAbC421e3368D158d802684A217a83c083c94CeB",
"plain_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
"meta_amm": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E",
"factory": "0xd2002373543Ce3527023C75e7518C274A51ce712",
"zap": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b",
},
"mantle:mainnet": {
"math": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6",
"views": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f",
# "views_old": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f",
"views": "0x166c4084Ad2434E8F2425C64dabFE6875A0D45c5",
"plain_amm": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617",
"meta_amm": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
"factory": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E",
Expand Down Expand Up @@ -236,7 +253,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)
Expand All @@ -255,20 +271,28 @@ def deploy_infra(network, url, account, fork=False):
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}")

Expand Down
20 changes: 19 additions & 1 deletion tests/pools/liquidity/test_add_liquidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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:
Expand Down
Loading

0 comments on commit b280aaa

Please sign in to comment.