Submitted by neocrao, also found by jasonxiale, J4X, 0x11singh99, okolicodes, HALITUS, memforvik, Kalyan-Singh, The-Seraphs, wangxx2026, zhaojohnson, 00xSEV, juancito, cu5t0mpeo, parrotAudits0, AgileJune, agadzhalov, aman, Drynooo, ewah, RootKit0xCE, MSaptarshi, Imp, 0xRobocop, 0xAlix2, erosjohn, jesjupyter, 0x3b, rudolph, 0xanmol, ayden, KHOROAMU, 0xSmartContractSamurai, t0x1c, and klau5
The function Pools::removeLiquidity() checks that the reserve0 and reserve1 amounts for a pool are always above or at DUST amount. If after the liquidity is removed, and the reserve0 or reserve1 goes below DUST level, then the transaction should revert.
But, this check is implemented incorrectly. The code that performs this check is as below in the code:
If you notice, the reserve0 is checked twice, instead of the checks being for each reserve0 and reserve1.
The documentation states the following reason for the DUST check:
So, if the reserve1 goes below the DUST amount, then it can imbalance the ratios. Also, once a pool has been established with the reserves, functions like and related to swap() rely on the amounts to be above the DUST amounts. If either of the reserves go below the DUST levels, then these functions will start to revert.
Use the below test in the file: src/pools/tests/Pools.t.sol
This is Medium severity, based on the Code4rena Severity Categorization: https://docs.code4rena.com/awarding/judging-criteria/severity-categorization
2  Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.
The check should be updated to check for reserve1 as well.
Picodes (Judge) commented:
othernet-global (Salty.IO) confirmed and commented:
Status: Mitigation confirmed. Full details in reports from t0x1c, 0xpiken, and zzebra83.
