# In the case of Single Asset Entry, new liquidity providers will suffer fund loss due to wrong formula of ΔRo

ElasticSwap's single-asset addLiquidity used a wrong Gamma formula for ΔRo, so new LPs after a rebase received far fewer shares than their deposit value.

- Payout: Audit contest
- Severity: high
- Program: ElasticSwap
- Found by: WatchPug
- Disclosed: 2022-03-02
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2022-01-elasticswap-findings/issues/144
- Library page: https://bugbountylibrary.com/r/c4%3A2022-01-elasticswap%3AH-01
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** AMM addLiquidity math (MathLib.sol) for rebasing baseToken
**Root cause:** Gamma (share ratio) computed as ΔY/Y'/2 * ΔX/α^ (and symmetric rebase-down variant) does not match the intended ΔRo = Ro*Gamma/(1-Gamma) relationship, so minted shares understate deposit value after rebase.
**Steps:**
1. Set state X=Alpha=1, Y=Beta=1, Omega=1; rebase baseToken up so Alpha=10.
2. Call addLiquidity() with 4 quoteToken; Gamma = 4/((1+4)*2) * (4*1)/(10-1) = 16/90.
3. New LP receives 10*16/90 baseToken and 5*16/90 quoteToken = 240/90 quoteToken value vs 4 deposited.
4. Loss of 4 - 240/90 = 1.333 quoteToken; reproduce by editing numbers in exchangeTest.js line 1804.
5. Rebase-down case: X=10,Alpha=1,Y=Beta=10,Omega=1; add 4 baseToken gives Gamma=8/90, LP value 120/90 vs 4 deposited (loss 2.666).
**How found:** Compared documented Gamma/ΔRo relationship (ΔRo = Ro*Gamma/(1-Gamma)) against the implemented formula in MathLib.sol, then constructed numeric rebase-up and rebase-down examples showing value shortfall.
**Exploitation:** Not an attack; any new single-sided liquidity provider calling addLiquidity() after a rebase receives fewer shares than fair value, losing funds to the pool.
**Insight:** When auditing AMM share-minting math, derive the intended Gamma from the ΔRo = Ro*Gamma/(1-Gamma) identity and check the code's formula against it under extreme rebase states (Alpha far from X), not just at equilibrium.
