Skip to content
high DeFi Economic No SWC entry CWE-682

First Liquidity Not Locked (MINIMUM_LIQUIDITY)

SAFE-0218 DeFi Economic Checked automatically by the scanner
1

What goes wrong

An AMM/pool mints LP shares to the first provider without burning a MINIMUM_LIQUIDITY amount to address(0). The first LP can then manipulate the share price via a tiny supply, enabling an inflation attack on later providers.

2

The vulnerable pattern

proof of concept — how it is exploited
// first mint gives attacker 1 wei of LP; attacker donates tokens to the
// pair to inflate reserves-per-share; next LP's mint rounds to 0 shares.
3

How to fix it

the pattern that is safe
if (totalSupply == 0) {
  liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY;
  _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock
}
Uniswap V2 MINIMUM_LIQUIDITY lock.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0218 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs