Skip to main content

Risk Engine Overview

The Risk Engine is the central risk assessment and solvency calculator for the Panoptic Protocol. It serves as the mathematical framework that governs position safety, collateral requirements, and liquidation parameters across the entire protocol.

Purpose
​

The Risk Engine does not hold funds or manage user balances directly. Instead, it provides the computational logic for:

  • Collateral Requirement Calculations: Determining how much collateral is needed for various option strategies including spreads, strangles, synthetic positions, and more
  • Account Solvency Verification: Checking whether accounts maintain sufficient collateral to support their open positions
  • Oracle Price Management: Utilizing volatility safeguards, exponential moving averages (EMAs), and median filters to provide manipulation-resistant pricing
  • Liquidation Parameters: Computing bonuses and costs associated with liquidations and force exercises
  • Interest Rate Computation: Calculating adaptive borrow rates based on pool utilization using a PID controller

Core Components
​

The Risk Engine comprises several interconnected systems:

​

The protocol's internal price oracle uses a sophisticated combination of EMAs and median filters to provide stable, manipulation-resistant price feeds for all risk calculations.

​

An automatic protection mechanism that activates during periods of extreme volatility, applying more conservative risk parameters to protect the protocol and its users.

​

An emergency oversight role that can manually intervene in extreme circumstances to lock or unlock pools, providing an additional layer of protocol security.

​

The comprehensive system for tracking user balances, computing maintenance requirements, and determining account solvency.

​

How pool utilization affects collateral ratios for both buyers and sellers, including the cross-buffer mechanism for cross-asset margin benefits.

​

Detailed requirements for different position types including loans, credits, sold options, and purchased options.

​

Special collateral treatment for defined-risk strategies like spreads, strangles, and synthetic positions that benefit from capital efficiency.

​

The fee structure for force-exercising out-of-range positions, designed to compensate position holders for involuntary closure.

​

A PID controller-based system that dynamically adjusts borrow rates based on pool utilization to maintain equilibrium between buyers and sellers.

​

The protocol's commission system, including notional and premium fees, and the builder wallet revenue sharing mechanism.

​

How compound interest is tracked and settled for borrowers using the global borrow index system.

​

The utilization metric that drives interest rates and collateral requirements, including flash deposit protection via transient storage.

​

The settleMint and settleBurn processes that handle all balance updates during position creation and closure.

​

The primary user interface for minting, burning, and settling positions through the PanopticPool.

​

Third-party operations including liquidations, force exercises, and premium settlements.

​

Low-level position mechanics including zero-width legs (loans/credits) and finalTick slippage protection.

Key Constants
​

ParameterValueDescription
DECIMALS10,000,000Precision for ratio calculations (1 millitick = 0.00001%)
MAX_SPREAD90,000Maximum allowed ratio of removed to net liquidity
MAX_TWAP_DELTA_LIQUIDATION513 ticksMaximum price deviation (~5%) allowed during liquidation
MAX_TICKS_DELTA953 ticksMaximum cumulative oracle deviation (~10%) before safe mode
BP_DECREASE_BUFFER13,333,333Buying power decrease buffer (133.33%)

Architecture
​

The Risk Engine is designed as a stateless calculation engine. All state regarding user positions and balances is maintained in the PanopticPool and CollateralTracker contracts. The Risk Engine receives this data as function parameters and returns computed values without storing any persistent state (with the exception of guardian-controlled safe mode locks).

This architecture provides several benefits:

  • Upgradeability: Risk calculations can be updated without migrating user state
  • Composability: External contracts can query risk parameters directly
  • Gas Efficiency: No storage reads for most calculations
  • Auditability: Pure functions are easier to formally verify