Skip to content

Commit

Permalink
fix: metapool impl should use static arrays for zap compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Nov 16, 2023
1 parent 06c712e commit 0d14719
Show file tree
Hide file tree
Showing 5 changed files with 523 additions and 14 deletions.
36 changes: 26 additions & 10 deletions contracts/main/CurveStableSwapMetaNG.vy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pragma version 0.3.10
# pragma optimize codesize
# pragma evm-version paris
# pragma evm-version shanghai
"""
@title CurveStableSwapMetaNG
@author Curve.Fi
Expand Down Expand Up @@ -741,7 +741,7 @@ def exchange_underlying(
@external
@nonreentrant('lock')
def add_liquidity(
_amounts: DynArray[uint256, MAX_COINS],
_amounts: uint256[N_COINS],
_min_mint_amount: uint256,
_receiver: address = msg.sender
) -> uint256:
Expand Down Expand Up @@ -857,7 +857,13 @@ def add_liquidity(
self.total_supply = total_supply
log Transfer(empty(address), _receiver, mint_amount)

log AddLiquidity(msg.sender, _amounts, fees, D1, total_supply)
log AddLiquidity(
msg.sender,
[_amounts[0], _amounts[1]],
fees,
D1,
total_supply
)

return mint_amount

Expand Down Expand Up @@ -907,7 +913,7 @@ def remove_liquidity_one_coin(
@external
@nonreentrant('lock')
def remove_liquidity_imbalance(
_amounts: DynArray[uint256, MAX_COINS],
_amounts: uint256[N_COINS],
_max_burn_amount: uint256,
_receiver: address = msg.sender
) -> uint256:
Expand Down Expand Up @@ -976,7 +982,13 @@ def remove_liquidity_imbalance(

self._burnFrom(msg.sender, burn_amount)

log RemoveLiquidityImbalance(msg.sender, _amounts, fees, D1, total_supply)
log RemoveLiquidityImbalance(
msg.sender,
[_amounts[0], _amounts[1]],
fees,
D1,
total_supply
)

return burn_amount

Expand All @@ -985,10 +997,10 @@ def remove_liquidity_imbalance(
@nonreentrant('lock')
def remove_liquidity(
_burn_amount: uint256,
_min_amounts: DynArray[uint256, MAX_COINS],
_min_amounts: uint256[N_COINS],
_receiver: address = msg.sender,
_claim_admin_fees: bool = True,
) -> DynArray[uint256, MAX_COINS]:
) -> uint256[N_COINS]:
"""
@notice Withdraw coins from the pool
@dev Withdrawal amounts are based on current deposit ratios
Expand Down Expand Up @@ -1047,7 +1059,7 @@ def remove_liquidity(
if _claim_admin_fees:
self._withdraw_admin_fees()

return amounts
return [amounts[0], amounts[1]]


@external
Expand Down Expand Up @@ -1729,7 +1741,7 @@ def get_virtual_price() -> uint256:
@view
@external
def calc_token_amount(
_amounts: DynArray[uint256, MAX_COINS],
_amounts: uint256[N_COINS],
_is_deposit: bool
) -> uint256:
"""
Expand All @@ -1738,7 +1750,11 @@ def calc_token_amount(
@param _is_deposit set True for deposits, False for withdrawals
@return Expected amount of LP tokens received
"""
return StableSwapViews(factory.views_implementation()).calc_token_amount(_amounts, _is_deposit, self)
return StableSwapViews(factory.views_implementation()).calc_token_amount(
[_amounts[0], _amounts[1]],
_is_deposit,
self
)


@view
Expand Down
Loading

0 comments on commit 0d14719

Please sign in to comment.