<!-- canonical: https://0xsimao.com/findings/singularity-curve-legacy-0b10-eth -->

# CurveAddLiquidityAssetManager::curveAddLiquidity() does not deal correctly with isLegacy = 0b10 and ETH

Medium · Three Sigma · Private DeFi access · 26th February, 2024

Finding 3S-SG-M02 of the Singularity security review.

- Protocol: https://www.thesingularity.network/
- Report: /reports/singularity
- Source: https://cdn.sanity.io/files/qoqld077/production/45b8aac56a2b8e3b557df4329ac9bf8220b64012.pdf

---

### Description

If isETH, but args.isLegacy is 1, it wraps to weth and allows pool, see [here](https://github.com/portalgateme/darkpool-v1-zk-contracts-fork/blob/master/contracts/defi/curve/CurveAddLiquidityAssetManager.sol#L229).
if args.islegacy is 0b10 and the asset is ETH, it does not send ETH to the pool, [here](https://github.com/portalgateme/darkpool-v1-zk-contracts-fork/blob/master/contracts/defi/curve/CurveAddLiquidityAssetManager.sol#L262-L279).
Additionally, it seems that it expects the ether balance to [increase](https://github.com/portalgateme/darkpool-v1-zk-contracts-fork/blob/master/contracts/defi/uniswap/UniswapLiquidityAssetManager.sol#L696-L699), which is unexpected,
[mintAmount](https://github.com/portalgateme/darkpool-v1-zk-contracts-fork/blob/master/contracts/defi/uniswap/UniswapLiquidityAssetManager.sol#L748-L750) = address(this).balance - initAmount;, as can be seen [here](https://github.com/portalgateme/darkpool-v1-zk-contracts-fork/blob/master/contracts/defi/curve/CurveAddLiquidityAssetManager.sol#L276).

### Recommendation

It seems that the mintAmount would always be
IERC20(_args.lpToken).balanceOf(address(this)) - initAmount, where initAmount
= IERC20(_args.lpToken).balanceOf(address(this));, but a pool example should be
given to confirm.

### Status

Addressed in [#8b300f0](https://github.com/portalgateme/darkpool-v1-zk-contracts-fork/commit/8b300f07a28f2c073154c8de3e9e90ba64ef1934).

---

Related findings:

- [BasicVault::_redeem() does not correctly deal with a disabled redeem queue after it was enabled](https://0xsimao.com/findings/mitosis-redeem-correctly-queue-enabled): Mitosis
- [Add a 0 address check on the pool when adding liquidity for greater verbosity](https://0xsimao.com/findings/nftperp-ii-add-adding-greater-verbosity): Nftperp Matching Engine
- [ShadowStrategyGauge::addVestingPosition() may revert if there is 0 liquidity to add](https://0xsimao.com/findings/yieldoor-i-shadow-gauge-vesting-revert): Yieldoor Gauges
- [`SyrupBitcoinRouter::requestRedeem()` could also check if the asset picked to redeem has liquidity](https://0xsimao.com/findings/maple-finance-iii-syrup-bitcoin-redeem-picked): Maple Withdrawal Queue
