Build parametric insurance contracts that automatically trigger payouts based on verifiable on-chain conditions without claims assessment.
ROLE: You are a smart contract developer who builds parametric insurance products for DeFi. You understand how to create contracts that automatically detect trigger events and distribute payouts without human intervention, using on-chain data and oracles as the source of truth. CONTEXT: Parametric insurance is the most blockchain-native form of insurance — payouts are triggered automatically when predefined conditions are met, eliminating the need for claims assessment and reducing disputes. I want to build parametric insurance contracts for DeFi-specific risks like stablecoin depegs, protocol TVL crashes, and oracle failures. TASK: 1. Parametric Insurance Design Principles — Explain how parametric insurance differs from traditional indemnity insurance. Cover the trigger-based payout model (if X happens, pay Y — no loss assessment needed), the advantages for DeFi (instant payouts, no subjective claims process, fully automated), the basis risk challenge (the trigger may not perfectly correlate with actual losses), designing triggers that minimize basis risk, the role of oracles in verifying trigger conditions, and comparing parametric to indemnity models for different DeFi risk types. 2. Stablecoin Depeg Insurance Contract — Detail the implementation of a stablecoin depeg protection contract. Cover defining the trigger condition (stablecoin price falls below threshold for a sustained period — e.g., below 0.95 for 4 hours using Chainlink TWAP), the policy parameters (coverage amount, premium, duration, trigger price, observation window), the payout calculation (fixed payout or proportional to depeg severity), the oracle integration for reliable price monitoring, preventing manipulation of the trigger (using TWAP instead of spot price, multiple oracle sources), and the full smart contract architecture (policy purchase, trigger monitoring, automatic payout execution). 3. Protocol TVL Crash Insurance — Walk through building insurance for sudden protocol TVL drops. Cover defining the TVL drop trigger (e.g., TVL decreases by more than 40% within 24 hours), on-chain TVL measurement methodology (reading pool balances from protocol contracts), distinguishing between organic TVL changes and exploit-driven crashes, the insurance contract structure (users purchase protection for specific protocols), payout timing and amount calculation, and the challenge of defining what constitutes an insurable event vs normal market movement. 4. Oracle Failure Protection — Explain how to insure against oracle-related losses. Cover defining oracle failure events (stale prices beyond heartbeat, extreme deviation from true market price, oracle downtime), monitoring oracle health from the insurance contract, payout triggers based on measurable oracle failure metrics, covering the secondary losses caused by oracle failures (liquidations triggered by bad prices), coordinating with the covered protocol for loss verification, and the technical implementation of cross-protocol oracle monitoring. 5. Policy Lifecycle Smart Contract — Describe the complete smart contract system for a parametric insurance policy. Cover policy creation and premium payment (user selects coverage parameters and pays premium), premium pool management (collecting premiums, investing in yield strategies while maintaining liquidity for claims), trigger monitoring (continuously checking conditions or using keeper networks), payout execution (automatic distribution upon trigger activation), policy expiration handling (return unused capital, settle unclaimed payouts), and the governance mechanisms for updating parameters or adding new coverage types. 6. Testing & Deployment for Insurance Contracts — Guide through the thorough testing required for insurance smart contracts. Cover unit testing every trigger condition and edge case, simulation testing against historical data (would the triggers have activated during past events correctly?), fuzzing for unexpected input handling, formal verification of payout logic (ensuring payouts never exceed the pool and always pay legitimate claims), the staged deployment approach (small coverage limits initially, expand after validation), and ongoing monitoring and parameter adjustment post-deployment.
Or press ⌘C to copy