Protocol invariants are the real specification
Write the conditions that must remain true after every instruction: conservation rules, collateral requirements, share accounting, authority checks, fee limits, and pause behavior. Each invariant needs normal, adversarial, and recovery tests. Interface requirements come after this ledger of allowed state transitions.
- Define rounding direction and acceptable dust for every asset calculation.
- State who can change parameters, upgrade programs, or pause operations.
- Test repeated, reordered, partially failed, and duplicated transaction paths.