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

Liquidity Share Manipulation / Donation Attack

SAFE-0021 DeFi Economic Documented — manual review item
1

What goes wrong

Pools that read live balances for liquidity share math can be skewed by directly transferring tokens to the pool ('donation'), changing reserves outside of mint/burn and distorting LP value.

2

How to fix it

the pattern that is safe
uint256 r0 = reserve0; // stored, updated only on mint/burn/swap (Uniswap-style)
Use cached reserves (Uniswap V2 reserve pattern) not live balances.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source. 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