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

# Stuck ETH in Curve exchanges due to sending msg.value to the exchange instead of amountIn

Crit/High · Three Sigma · Private DeFi access · 26th February, 2024

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

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

---

### Description

The curve exchanges allow users who deposited to use their note commitments to swap for
other assets. Thus, they have already deposited the ETH, but the exchanges still [require](https://github.com/portalgateme/darkpool-v1-zk-contracts-fork/blob/master/contracts/defi/curve/CurveSingleExchangeAssetManager.sol#L146) the
amountIn to be msg.value, leading to stuck ETH.
POC [here](https://github.com/portalgateme/darkpool-v1-zk-contracts-fork/blob/fuzzing/test/foundry/CurveSingleExchangeAssetManager.t.sol#L68).

### Recommendation

Replace IExchange(exchangeContract).exchange{value: msg.value} by
IExchange(exchangeContract).exchange{value: amountIn}.

### Status

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

---

Related findings:

- [User to sell the last supply will make the exchange contribution forever stuck](https://0xsimao.com/findings/mento-sell-supply-contribution-stuck): Mento
- [Depositing to another receiver othan than `msg.sender` will lead to stuck funds by increasing `avgStart` without claiming](https://0xsimao.com/findings/exactly-protocol-update-staking-contract-ii-othan-stuck-increasing-avg): Exactly Protocol Update - Staking Contract
- [Incorrect redeemAmount Is Accounted Due To Not Accounting For The  Exchange Rate](https://0xsimao.com/findings/cork-protocol-redeem-accounted-accounting-exchange): Cork Protocol
- [Midnight constructor can use `msg.sender` instead of reading `roleSetter` from storage](https://0xsimao.com/findings/morpho-midnight-midnight-reading-setter-storage): Morpho Midnight
