A condition that must always be true throughout a contract's execution. In Uniswap V2, the key invariant is x * y >= k after every swap. Violations of invariants indicate bugs or exploits. Invariant testing (fuzzing) is a powerful technique for finding vulnerabilities.
Security
Invariant
Related terms in Security
Reentrancy Attack
An exploit where a malicious contract calls back into the vulnerable contract before the first execution is co...
Flash Loan Attack
An exploit that uses uncollateralized flash loans to temporarily manipulate prices, governance votes, or oracl...
Front-running
Observing a pending transaction in the mempool and submitting a transaction with a higher gas price to execute...
CEI Pattern
Checks-Effects-Interactions pattern. A Solidity best practice where you first validate inputs (Checks), then u...