Skip to main content
A swap should not reduce the reserve product of a constant-product pool. This template compares the recorded reserve product before and after a transaction.

Behavior

ConstantProductAssertion reads separate reserve slots 0 and 1 at transaction boundaries. It requires postReserve0 × postReserve1 >= preReserve0 × preReserve1.

Configuration

Replace the slots and decode packed reserves if necessary. Real Uniswap V2 reserves do not occupy these two independent slots. The template runs at transaction end, so a deployment that permits liquidity removal needs operation-specific coverage or an explicit policy for those removals.

Scenarios

Coverage limits

Stored reserves are not proof of token custody or a fair market price. A manipulated swap can preserve the product. Bound reserve values to avoid multiplication overflow, and test fee-on-transfer behavior.

Source

The reviewed source is a teaching template. The example setup guide provides the pinned checkout and test procedure.