example-fork-detection
TEMPLATE — replace with the description of your rule. Should activate on the specific code patterns your fork has. Activate on `<your trigger keywords or…
Detect cascading liquidations and socialized bad debt — correlated collateral (multiple LSTs/stables), bad debt socialized across unrelated markets, oracle flash-crash triggering mass liquidation, insurance-fund depletion ordering, liquidation incentives too low to clear bad
$ npx -y skills add omermaksutii/RugProof --skill liquidation-cascade --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/liquidation-cascadeContext preview
The summary Claude sees to decide when to auto-load this skill.
Detect cascading liquidations and socialized bad debt — correlated collateral (multiple LSTs/stables), bad debt socialized across unrelated markets, oracle flash-crash triggering mass liquidation, insurance-fund depletion ordering, liquidation incentives too low to clear bad
name: liquidation-cascade description: Detect cascading liquidations and socialized bad debt — correlated collateral (multiple LSTs/stables), bad debt socialized across unrelated markets, oracle flash-crash triggering mass liquidation, insurance-fund depletion ordering, liquidation incentives too low to clear bad debt, and depeg cascades. Activate whenever a lending/perp/CDP protocol liquidates positions, prices collateral, or has shared-risk pools.
Trigger on any of:
// stETH, rETH, cbETH all accepted, all priced off ETH-correlated feeds collateralFactor[stETH] = 0.9e18; collateralFactor[rETH] = 0.9e18;
**Signal:** treating correlated LSTs as independent diversification. A single LST depeg (stETH 2022, or an LRT slashing event) crashes many positions at once, overwhelming liquidation throughput. Cap aggregate exposure per risk-cluster, not per token.
A loss in one risky isolated market draining a *shared* insurance fund or pool that also backs blue-chip markets. **Signal:** one toxic listing can impair unrelated depositors (the Mango / cross-margin contagion class). Isolate bad debt to the originating market.
uint256 price = oracle.getPrice(collateral); // single-block spot, no bounds if (debt > price * collateral * cf) liquidate();
**Signal:** a momentary depeg / wick (or manipulated feed) marks thousands of healthy positions liquidatable in one block; liquidators race, price gaps, and survivors eat bad debt. Use TWAP / deviation circuit breakers before liquidating en masse.
If the liquidation bonus < gas + slippage to unwind seized collateral, liquidators don't act; positions go underwater and bad debt accrues silently. **Signal:** fixed small bonus on illiquid or volatile collateral.
Order of loss absorption matters: if the fund pays liquidator bonuses *before* covering bad debt, or if multiple markets draw from it without priority, a run drains it. Define and bound the waterfall.
Stablecoin-collateralized debt where the stable depegs: liquidations sell the depegging asset, deepening the depeg, triggering more liquidations (UST May 2022). Flag self-reinforcing sell pressure with no circuit breaker.
| Pattern | Severity | Notes | |---|---|---| | Toxic-market bad debt socialized to all depositors | **High** | Cross-market contagion | | Correlated collateral, no cluster cap | **High** | Simultaneous mass insolvency | | Spot-oracle flash-crash mass liquidation | **High** | One-block cascade | | Self-reinforcing depeg cascade | **High** | No circuit breaker | | Insurance-fund waterfall ordering flaw | **Medium** | Run-depletable | | Liquidation bonus too low → stuck bad debt | **Medium** | Slow accrual |
1. **Isolate bad debt** per market (Compound III / Morpho-style isolation, Aave isolation mode + debt ceilings); never let a risky listing impair blue-chip depositors. 2. **Risk-cluster caps** — bound aggregate exposure to correlated assets (all LSTs as one bucket), not per-token. 3. **Circuit breakers** — pause liquidations on excessive deviation; use TWAP/median so a single wick can't mass-liquidate. 4. **Right-size liquidation incentives** to gas + realistic unwind slippage on the *actual* collateral liquidity. 5. **Define the loss waterfall explicitly** (insurance fund → socialization → governance backstop) with per-market accounting.
Rugproof your code before someone else does. 🌐 Live site: omermaksutii.github.io/RugProof 📦 Latest: v1.0.0 — 45 commands · 23 agents · 45 skills · 13 MCP servers · tested, offline-first, with rule packs, a benchmark, non-EVM coverage, and post-deploy
Repo: omermaksutii/RugProof
TEMPLATE — replace with the description of your rule. Should activate on the specific code patterns your fork has. Activate on `<your trigger keywords or…
Detect unsafe assumptions about Solady's gas-optimized ERC20/ERC2612 permit and DN404 metadata. Solady's ERC20 uses custom storage slots, returns bools via…
Detect front-runnable ownership initialization in Solady Ownable / OwnableRoles. Solady's `_initializeOwner` is a guarded one-time setter (it reverts with…
Detect Solady SafeTransferLib calls that assume the token has code. SafeTransferLib.safeTransfer/safeTransferFrom/safeApprove deliberately skip the EXTCODESIZE…
Detect Uniswap V4 hooks that fail to settle currency deltas with the PoolManager. Every credit/debit a hook creates (BeforeSwapDelta, afterSwap hookDelta,…
Detect Uniswap V4 hooks whose address-encoded permission flags don't match the callbacks the hook actually implements. In V4 the hook's permissions live in the…