Skip to content
Business logic Audit finding Intermediate

Liquidity providers unable to remove liquidity when the pool is in deficit state

Liquidity provider shares are calculated from the total reserve, which can exceed the pool's actual available balance when the pool is in deficit. In that state, a provider trying to redeem shares hits an underflow and a failed transfer, so they cannot withdraw their funds.

kyliek Follow

Originally disclosed on Code4rena

Submitted by kyliek

LiquidityProviders.sol#L388 LiquidityProviders.sol#L392

LP token holders can not redeem their tokens when the pool is in the deficit state, i.e. currentLiquidity << providedLiquidity. This is due to that LP shares are computed based on providedLiquidity and the actual available pool balance is based on currentLiquidity.

Proof of Concept

When a high valued withdrawal happens in the liquidity pool of the destination chain, the current liquidity will be reduced when the executor calls sendFundsToUser LiquidityPool.sol#L285

and the pool contract balance will also be reduced by the same amount. The pool reached a deficit state with provided liquidity much bigger than current liquidity.

The LP shares are computed based on the value of totalReserve that is roughly equivalent to totalLiquidity + LpFees. In a deficit state, totalReserve could be much bigger than the available pool balance (up to 90% since max fee is 10%). If the LP token holder wants to redeem his shares,

        _decreaseCurrentLiquidity(_tokenAddress, _amount);

will underflow and revert and

        _transferFromLiquidityPool(_tokenAddress, _msgSender(), amountToWithdraw);

will revert because there is not enough balance.

Recommended Mitigation Steps

This is a tricky problem. On one hand, separating currentLiquidity from providedLiquidity made sure that by bridging tokens over, it will not inflate or deflate the pool. On the other hand, decoupling the two made it hard to compute the actual available liquidity to redeem LP shares. One may need to think through this a bit more.

ankurdubey521 (Biconomy) disagreed with High severity and commented:

Liquidity Providers will be able to withdraw their funds as long as they’re sufficient currentLiquidity in the pool, as you mentioned. This will be the case when all pools are balanced, ie the current liquidity is very close to the supplied liquidity.

By design, hyphen liquidity pools incentivize people to rebalance the pools by providing rewards from the incentive pool, so we believe this should not be that big of an issue in practice.

pauliax (judge) decreased severity to Medium and commented:

A valid concern, and even though per the sponsor’s comment it should not be a problem in practice, a hypothetical path of risk still exists so I would like to leave this as of Medium severity issue.


The original report as published on Code4rena, by kyliek. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 share value is derived from a reserve figure that includes fees and can exceed the pool's real balance, so redemption arithmetic underflows and the transfer lacks funds.

Impact

Liquidity providers could be unable to withdraw their funds while the pool is in deficit, though the sponsor argues rebalancing incentives make this unlikely in practice.

What the attacker needed

Pool in deficit state; user holds LP share tokens

The fix

The report offers no concrete fix, saying the decoupling of current and provided liquidity needs more thought so redemption can reflect actual available liquidity.

How it was found

  1. A large withdrawal on the destination chain reduces the pool's current liquidity and balance.
  2. The pool enters a deficit state where provided liquidity greatly exceeds current liquidity.
  3. A share holder tries to redeem, and the liquidity decrease underflows and reverts.
  4. The transfer from the pool also reverts for lack of balance.

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.

A liquidity pool holds money that people put in and can later take out. Each person gets a share token showing how much of the pool is theirs. This report says that when the pool has paid out more than it holds, the maths used to cash out a share breaks, so the withdrawal fails and the person's money is stuck until the pool is refilled.

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.

More by kyliek

View all

3 more disclosed reports, best first.

More from Biconomy - Smart Contract Wallet contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.