Skip to content
Business logic Audit finding Beginner

MINIMUM_LIQUIDITY checks missing - Bringing Liquidity below required min

The contract lacks a check to ensure that after a liquidity provider withdraws, the remaining liquidity stays above the MINIMUM_LIQUIDITY threshold. A large liquidity provider could remove all their funds, leaving the pool below the required minimum, which the report says is incorrect.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain

Whale who provided most liquidity to the contract can simply use removeLiquidity function and can remove all of his liquidity. This can leave the residual liquidity to be less than MINIMUM_LIQUIDITY which is incorrect.

Proof of Concept

  1. Whale A provided initial liquidity plus more liquidity using enableLiquidityReserve and addLiquidity function
  2. There are other small liquidity providers as well
  3. Now Whale A decides to remove all the liquidity provided
  4. This means after liquidity removal the balance liquidity will even drop below MINIMUM_LIQUIDITY which is incorrect

Recommended Mitigation Steps

Add below check

require(
            IERC20Upgradeable(stakingToken).balanceOf(address(this)) - MINIMUM_LIQUIDITY >=
                amountToWithdraw,
            "Not enough funds"
        );

toshiSat (Yieldy) confirmed and resolved


The original report as published on Code4rena, by csanuragjain. 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

What the attacker needed

Attacker holds most of the pool's liquidity

The fix

A check should be added to ensure that the contract balance minus MINIMUM_LIQUIDITY is at least the amount being withdrawn.

How it was found

  1. A large liquidity provider adds initial and additional liquidity using the enableLiquidityReserve and addLiquidity functions.
  2. Other smaller liquidity providers also add liquidity.
  3. The large provider then removes all of their liquidity.
  4. The remaining liquidity drops below MINIMUM_LIQUIDITY because no check prevents it.

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 is a shared pot of money that users add to and take from. The contract is supposed to keep a minimum amount in the pot at all times, but it does not check this when someone takes money out. So a big user could empty almost everything, leaving the pot below the required minimum.

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 Anurag Jain

View all

63 more disclosed reports, best first.

More from Yieldy 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.