DeFi Risk Modeling and Simulation

The use of computational simulations, like Agent-Based Modeling, to stress-test decentralized finance protocols against extreme market volatility and exploit vectors.

Risk modeling cannot predict smart contract hacks (logic bugs), but rather focuses on economic exploits and systemic insolvency. Parameters derived from these models are highly dynamic and must be re-simulated continuously as on-chain liquidity depth changes.

        graph LR
  Center["DeFi Risk Modeling and Simulation"]:::main
  Rel_decentralized_perpetual_futures_risk["decentralized-perpetual-futures-risk"]:::related -.-> Center
  click Rel_decentralized_perpetual_futures_risk "/terms/decentralized-perpetual-futures-risk"
  Rel_risk_assessment["risk-assessment"]:::related -.-> Center
  click Rel_risk_assessment "/terms/risk-assessment"
  Rel_decentralized_derivatives_pricing_models["decentralized-derivatives-pricing-models"]:::related -.-> Center
  click Rel_decentralized_derivatives_pricing_models "/terms/decentralized-derivatives-pricing-models"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Knowledge Check

1 / 5

🧒 Explain Like I'm 5

Imagine designing a new roller coaster. Before letting real people ride it, engineers run computer simulations dropping virtual dummy passengers through extreme loops and winds to see if anyone falls out. In [DeFi](/en/terms/defi), protocols hold billions of dollars. Risk modeling is how they run virtual 'dummy' traders through extreme market crashes to make sure the protocol's math doesn't break and lose everyone's money.

🤓 Expert Deep Dive

Agent-Based Modeling (ABM)
Traditional Value at Risk (VaR) models fail in DeFi because they assume continuous liquidity and normal distributions. DeFi firms (like Gauntlet and Chaos Labs) use ABM. They build a 'digital twin' of the EVM and deploy the protocol's actual smart contracts. They then program agents to execute specific strategies (e.g., 'liquidate when profit > gas fee', 'sell collateral if asset drops 10%').

Chaos Engineering and Stress Testing
The simulation introduces macroeconomic shocks (e.g., ETH drops 50% in one hour) alongside micro-shocks (e.g., network congestion pushing gas fees to 1000 gwei). The goal is to observe emergent behavior: will liquidators stop liquidating because gas is too expensive? If so, the protocol accrues bad debt. Based on these simulations, risk managers propose parameter optimizations to the DAO, such as lowering the Collateral Factor of an illiquid asset to prevent a cascading liquidation failure.

❓ Frequently Asked Questions

Why can't DeFi just use Wall Street risk models?

Traditional models assume that markets have designated market makers and circuit breakers. DeFi markets operate 24/7, are highly volatile, and rely on anonymous automated bots to maintain solvency, requiring distinct simulation methods.

What is Agent-Based Modeling (ABM)?

A computer simulation where thousands of virtual 'agents' (representing different types of crypto users and bots) are programmed with specific goals and let loose on a simulated version of the protocol to see what happens during a crash.

What is the end goal of DeFi risk simulation?

To determine the safest settings for a protocol, such as how much users can borrow against an asset (LTV) and the maximum amount of an asset the protocol should accept (Borrow Caps).

📚 Sources