Account for locked liquidity in a Uniswap v2 pair’s first mint

The first liquidity provider in a reference v2 pair receives fewer LP units than the initial geometric mean. A separate minimum amount is permanently minted to the zero address.

Identify the initial liquidity event

Check that the pair’s pre-mint LP supply was zero. Compute the integer square root of the product of the deposited raw amounts and subtract MINIMUM_LIQUIDITY for the provider’s share.

first deposits = 10000 and 40000 raw units
sqrt(product) = 20000
provider LP = 20000 - 1000 = 19000

In this fixture the provider receives 19,000 and the zero address receives 1,000 LP base units. The total newly issued amount is 20,000. Preserve both transfers when reconciling supply against LP balances.

Use the correct rule for later deposits

Subsequent mints use the smaller proportional contribution relative to existing reserves and supply. Applying the first-mint formula repeatedly understates later provider balances. The example uses the reference constant and raw units, independent of token display decimals. github.com UniswapV2Pair.sol