# liquidation-risk-simulation

> Monte Carlo and historical-replay stress tests to size leverage, margin and insurance funds.

liquidation-risk-simulation is a paid AI agent skill on Agensi by BanditXBT. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $3.15 (one-time purchase)
- Creator: [BanditXBT](https://www.agensi.io/creators/banditxbt)
- Version: 1.0
- Last updated: 2026-11-21
- Security: scan passed (2026-11-21); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/liquidation-risk-simulation
- Tags: trading-investing, research-analysis, web3-crypto

## About this skill

Goal: choose parameters (max leverage, maintenance margin, liquidation penalty, OI caps, insurance size) that keep **bad debt probability and magnitude** within a stated tolerance under realistic stress, including keeper failure.

1. **Positions:** distribution of size, leverage, side, collateral type. Calibrate to real data (on-chain events, subgraph exports) or conservative worst-case concentrations (top-N accounts = x% of OI).
2. **Price paths:** simulate at the oracle/block resolution, not daily.
   - Baseline: GBM with volatility from realized vol (EWMA or GARCH for clustering).
   - Tails: add jump process (Merton/Kou) and fat tails (Student-t); calibrate jump frequency/size to historical crashes.
   - **Historical replay:** feed actual minute/second data from past cascades (e.g., Mar 2020, May 2021, Nov 2022, Oct 2025) and gap events; replay is more honest than any parametric fit. Oct 10, 2025 liquidated roughly $19B in about a day and triggered auto-deleveraging that closed profitable opposite-side positions on some venues: replay it including ADL and cross-margin effects, and expect venue-level data (liquidation feeds are incomplete; some venues report only samples).
   - **Correlation:** collateral and positions correlate to 1 in crashes; do not diversify with calm-period correlations.
3. **Liquidation engine:** replicate the contract rules exactly (maintenance margin, close factor, penalty split, min size, oracle mark/TWAP lag).
4. **Keeper/market frictions (the part that causes real bad debt):**
   - Liquidator latency distribution and capacity per block; failure probability when gas spikes or the chain is congested.
   - Oracle lag (heartbeat/deviation) and update delay → liquidations trigger late.
   - Slippage/price impact when closing large positions on the hedge venue or AMM (square-root impact: `impact ≈ k·σ·√(Q/ADV)`).
   - Sequencer outage window (no liquidations, then price gap on restart).
5. **Loss waterfall:** position equity → liquidation penalty → insurance fund → LP/vault/ADL/socialization. Record which layers are hit.

- Bad debt: P(any), expected, 95th/99th/99.9th percentile (CVaR/expected shortfall of bad debt).
- Insurance fund drawdown and time to depletion; ADL trigger probability.
- Liquidation shortfall: % notional liquidated late (equity < 0 at execution).
- Liquidator profitability vs. gas: minimum position size where liquidation is net-positive per chain.
- LP/vault PnL tail (for pool-counterparty designs); skew/OI-imbalance exposure.

Sweep leverage × maintenance margin × penalty × cap. Plot the frontier: capital efficiency (OI / collateral) vs. 99.9% bad debt. Rule of thumb check: maintenance margin must exceed the **expected adverse move during the liquidation delay**: `MM ≳ z · σ_per_√time · √(delay)` + slippage buffer, with `z` set from the tail (≥ 3-4 plus jump allowance). Re-run when volatility regime or asset liquidity changes; per-asset parameters, not one-size.

## Requires

- Python 3
- numpy
- pandas

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the liquidation-risk-simulation skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What does liquidation-risk-simulation do?

Monte Carlo and historical-replay stress tests to size leverage, margin and insurance funds.

### Which AI agents support liquidation-risk-simulation?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use liquidation-risk-simulation?

Connect your AI agent to Agensi through MCP, then ask it to use liquidation-risk-simulation on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
