state-invariant-detection

Detect broken state-variable invariants in smart contracts and identify violating functions.

1|Updated Feb 17, 2026
One-click install
npx skills add https://github.com/Ramprasad4121/srp --skill state-invariant-detection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: state-invariant-detection
Source: https://github.com/Ramprasad4121/srp/tree/main/skills-repos/quillai/plugins/state-invariant-detection/skills/state-invariant-detection
Command: npx skills add https://github.com/Ramprasad4121/srp --skill state-invariant-detection

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill automatically identifies and flags critical vulnerabilities in smart contracts arising from broken mathematical relationships between state variables, preventing financial losses due to accounting errors, tokenomics flaws, or state desynchronization.

Core Features & Use Cases

  • Invariant Inference: Automatically discovers and classifies mathematical relationships (e.g., totalSupply = Σ balances, k = reserveA × reserveB).
  • Violation Detection: Pinpoints specific functions that violate these inferred invariants.
  • Use Case: Auditing a DeFi token contract to ensure that totalSupply always accurately reflects the sum of all user balances, preventing unauthorized minting or supply discrepancies.

Quick Start

Analyze the provided smart contract code for state-invariant violations.

Frequently Asked Questions about state-invariant-detection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect broken invariants in DeFi smart contracts?

You can detect broken invariants in DeFi smart contracts by inferring mathematical relationships between state variables and pinpointing functions that violate them. This process identifies vulnerabilities like unauthorized minting and accounting desynchronization.

What is state variable co-modification analysis in smart contract auditing?

State variable co-modification analysis tracks how variables change together to infer mathematical relationships. It ensures invariant integrity by detecting delta patterns and expression mining anomalies that indicate broken tokenomics or state desynchronization.

How do I audit a token contract for unauthorized minting vulnerabilities?

You audit a token contract for unauthorized minting by verifying that totalSupply always equals the sum of all user balances. Invariant detection automatically flags functions violating this relationship to prevent supply discrepancies.

Can I find accounting desynchronization bugs in DeFi protocols automatically?

You can find accounting desynchronization bugs automatically by analyzing state variable co-modification and delta patterns. This discovers broken mathematical relationships that cause financial losses due to flawed accounting or state desynchronization.

What types of mathematical relationships can be inferred during smart contract security auditing?

Mathematical relationships like totalSupply equaling the sum of balances or constant product formulas like k equals reserveA times reserveB can be inferred. Violation detection then pinpoints specific functions breaking these invariants.

When do I need invariant detection for smart contract vulnerability assessments?

You need invariant detection when auditing DeFi protocols to prevent financial losses from accounting errors, tokenomics flaws, or state desynchronization. It identifies critical vulnerabilities arising from broken mathematical relationships between state variables.