# Fix the invariant, not the instance

> Canonical: https://blazephoenix.xyz/learn/fix-the-invariant-not-the-instance/
> License: CC BY-NC-ND 4.0 (attribution + link) · © 2026 BlazePhoenix
> Updated: 2026-11-16

The instance is not the finding: the finding is the invariant that failed to hold, and the instance is one place it failed. A fix that states the invariant, puts the guard where every instance of the class passes, and arrives with a test over the class and its own mutant resolves many instances with one fix and refuses the next one by construction.

## The short answer

Because the instance is not the finding. The finding is the invariant that failed to hold, and the instance is one place it failed. A patch to the instance restores that place and leaves every other place the same class can occur. A fix that states the invariant, puts the guard where every instance of the class passes through it, and arrives with a test over the class resolves N instances with one fix, one test and one watcher, and refuses the next instance by construction.

## The shape of a class-level fix



## One invariant, many routes

Take a property every route must keep: the Router holds nothing when a swap ends. A fix written per route would need a separate check for each shape. The repository states it once as an invariant and exercises it over every shape of route.

## What this method does not do

It does not turn an invariant into a proof of the whole contract; an invariant covers the class it states, and its register of mutants says which changes it notices. The method is a way of making each correction cover more than the place it was found, and of making that coverage checkable.

## Check it yourself



**Verify it yourself:** In a clean checkout of Blaze-Phoenix-Dex at 969bcc6: git grep -n -i "holdsnothing" -- test (the files and lines in the table, among them test/BlazePhoenixRouter.invariant.t.sol line 402); forge test --match-test invariant_ --fuzz-seed 0xb1a2ef00 (the stateful campaigns, Appendix C). Whitepaper 2.4: section 2.8.

Related: https://blazephoenix.xyz/learn/invariant-driven-design/ · https://blazephoenix.xyz/learn/how-we-audit-ourselves/ · https://blazephoenix.xyz/learn/a-guard-that-cannot-fire/
