Wrong inequality when adding/removing liquidity in current price range
The mint and burn functions in a concentrated liquidity pool use a strict inequality to check if the current price is within the liquidity range, so when the current price equals the lower bound, liquidity is not added or removed correctly. This can lead to incorrect swap amounts and users losing funds when adding liquidity in that specific range.
Submitted by cmichel
The ConcentratedLiquidityPool.mint/burn functions add/remove liquidity when (priceLower < currentPrice && currentPrice < priceUpper). Shouldn’t it also be changed if priceLower == currentPrice?
Impact
Pools that mint/burn liquidity at a time where the currentPrice is right at the lower price range do not work correctly and will lead to wrong swap amounts.
Recommended Mitigation Steps
Change the inequalities to if (priceLower <= currentPrice && currentPrice < priceUpper).
sarangparikh22 (Sushi) disputed:
You shouldn’t be able to reach this, can you produce a POC?
@sarangparikh22 (Sushi), could you please elaborate on why this is not reachable?
sarangparikh22 (Sushi) confirmed:
I confused this with another similar issue, my apologies, took a look at this, and this a valid issue, we should probably even bump the severity to Sev 3, not sure if I am allowed to do so haha, I created a PoC in which users can actually loose funds, when they add liquidity in that specific range. @alcueca (judge)
Sponsors are allowed to bump up severity, and I’ve done it myself in my past as a sponsor as well.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the inequality check for the lower price bound uses a strict less-than instead of less-than-or-equal, so the condition fails when currentPrice equals priceLower.
Impact
Users could lose funds when adding liquidity at the exact lower price bound, and swaps may return wrong amounts.
What the attacker needed
Current price equals lower bound; user adds or removes liquidity
The fix
The inequalities should be changed to include equality on the lower bound, i.e., use less-than-or-equal for priceLower.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a liquidity pool, people add or remove their funds (liquidity) to earn fees. The code checks if the current price is between two bounds, but it uses a strict 'less than' instead of 'less than or equal to' for the lower bound. So when the price exactly hits the lower bound, the code doesn't update the liquidity properly, which can cause users to lose money when they add funds at that price.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.