defi-invariant-check

defi-invariant-check is a skill for Claude Code, Codex from mtarcure/claude-vibe-squad. It costs 72 tokens per session (2,276 once invoked), scanned A, original, MIT.

A security-testing method for DeFi protocols, such as exchanges, lending markets, yield vaults, stablecoins, and perpetual-trading systems. It defines financial rules that should always remain true and tests whether the code can break them.

In plain words
What is it for?
It helps test token conservation, exchange reserves, deposits and loans, vault shares, access controls, and oracle settings in smart contracts.
Why use it?
Generic tests may miss accounting errors that create tokens, over-lend funds, misprice assets, or give users incorrect shares.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

Good fit It helps test token conservation, exchange reserves, deposits and loans, vault shares, access controls, and oracle settings in smart contracts.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mtarcure/claude-vibe-squad/defi-invariant-check
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mtarcure/claude-vibe-squad --skill defi-invariant-check
Clone the repo
git clone --depth 1 https://github.com/mtarcure/claude-vibe-squad

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for defi-invariant-check

README.md
[![agentmods](https://agentmods.dev/badge/skills/mtarcure/claude-vibe-squad/defi-invariant-check/github.svg)](https://agentmods.dev/skills/mtarcure/claude-vibe-squad/defi-invariant-check)
Your own site
<a href="https://agentmods.dev/skills/mtarcure/claude-vibe-squad/defi-invariant-check"><img src="https://agentmods.dev/badge/skills/mtarcure/claude-vibe-squad/defi-invariant-check/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for defi-invariant-check

Your own site · 80×15
<a href="https://agentmods.dev/skills/mtarcure/claude-vibe-squad/defi-invariant-check"><img src="https://agentmods.dev/badge/skills/mtarcure/claude-vibe-squad/defi-invariant-check.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 72 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,276 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00072 $0.02276
Opus 5.5 $0.00029 $0.00910
Sonnet 5.5 $0.00014 $0.00455
Haiku 4.5 $0.00007 $0.00228

Measured 27d ago against content hash e9bf84a2a33c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

defi-invariant-check scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 27d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/defi-invariant-check/SKILL.md · 158 lines

How it starts

The opening of the file, as written. The whole thing — 158 lines — stays where its author put it; the contents beside it link to each section on GitHub.

defi-invariant-check

DeFi-specific invariant authoring and testing discipline. Use this as a sub-skill during evm-audit-flow when the target is a DeFi protocol (AMM, lending, yield, bridge, stablecoin, perps). Generic Echidna/Medusa campaigns miss DeFi-specific invariants — this skill provides the property checklist. All tools are the native host CLIs (echidna, medusa, forge, halmos) run in the target project directory; there is no wrapper layer.

Invariant categories

Token accounting invariants (always required):

  • totalSupply == sum(balanceOf(all_holders)) — no spurious minting or burning.
  • reserve0 * reserve1 >= k (for constant-product AMMs) — k-invariant never decreases except via fee accrual.
  • totalBorrow <= totalDeposit for all lending pools — protocol cannot lend out more than deposited.
  • sum(userShares) == totalShares for yield vaults — share accounting is consistent.

Access-control invariants:

  • Only authorized roles can set oracle addresses, fee parameters, or pause state.
  • onlyOwner/onlyGovernance functions cannot be called by arbitrary external accounts.
  • Upgradeable proxy implementation slots cannot be modified except through the upgrade pathway.

Economic/oracle invariants:

  • Flash loan callbacks cannot leave the protocol in a net-loss state after the loan repayment.
  • Liquidation proceeds must cover the borrowed amount plus protocol fee — no bad-debt accrual from liquidations.

2026 incident-derived oracle-input robustness invariants (highest-priority economic class):

  • Spot versus TWAP: a price used for collateral, borrowing, liquidation, minting, or redemption must reject or clamp a same-block spot price when abs(spot - TWAP) / TWAP > maxDeviation; no value-affecting path may silently fall back to the divergent spot. This targets the oracle/valuation-manipulation class represented by Moonwell (2026-08-27), Lazy Summer (2026-07-06), Makina (2026-01-20), and Edel (2026-07-01) in V114-51.
  • Low-liquidity collateral: within the protocol's configured manipulation budget, an atomic trade against a thin market cannot increase an account's borrowable value or liquidation proceeds by more than the attacker's net cost plus the configured safety margin. Reject collateral whose observable depth cannot support the valuation notional. This is the Moonwell low-liquidity-collateral oracle shape from V114-51.
  • NAV manipulation bound: absent external profit or loss, a deposit/reprice/redeem round trip across any supported asset must not return more value than entered after fees and rounding tolerance, and one manipulable component price must not move total NAV beyond its configured exposure and deviation caps. This targets the Lazy Summer, Makina, and Edel valuation/NAV incident class from V114-51.

Read the full file on GitHub · 158 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 27d ago First seen · 158 lines · 72 tokens per session scan A e9bf84a2a33c

Subscribe to this mod's changes

defi-invariant-check is a skill published in the GitHub repository mtarcure/claude-vibe-squad (165 stars, last pushed 25d ago), licensed MIT. It adds 72 tokens to every session and 2,276 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-19.