Skip to main content
RiskManager enforces four layers of risk validation on every new position. PositionManager calls validateOpenPosition() during openPosition() — if any cap is exceeded, the transaction reverts.

Contract Relationships

Data Structures

RiskConfig

struct RiskConfig {
    uint16 netExposureCapFactorBps;        // Pool exposure cap factor (default: 10000 = 100%)
    uint16 stressMoveBps;                  // Stress scenario move (default: 200 = 2%)
    uint16 perPositionCapFactorBps;        // Per-position cap factor (default: 500 = 5%)
    uint16 perAccountCapFactorBps;         // Per-account cap factor (default: 500 = 5%)
    uint256 maxGrossNotionalDeltaPerWindow; // Max gross notional change per window (0 = disabled)
    uint256 maxNetExposureDeltaPerWindow;   // Max net exposure change per window (0 = disabled)
    uint32 rateWindowSeconds;              // Rate-of-change window (default: 3600 = 1h)
}

Read Functions

maxNetExposure

function maxNetExposure() public view returns (uint256)
Returns the maximum allowed net pool exposure: poolEquity × netExposureCapFactorBps / stressMoveBps. With defaults (100% / 2%), a pool with 1M USDC equity allows 50M net exposure.

maxPositionNotional

function maxPositionNotional() public view returns (uint256)
Returns per-position notional cap: maxNetExposure × perPositionCapFactorBps / 10000. With defaults (5%), a 50M max exposure means 2.5M per position.

maxAccountNotional

function maxAccountNotional() public view returns (uint256)
Returns per-account total notional cap: maxNetExposure × perAccountCapFactorBps / 10000.

getConfig

function getConfig() external view returns (RiskConfig memory)
Returns the current risk configuration struct.

Protocol Functions

validateOpenPosition

function validateOpenPosition(address account, uint256 notional, bool isLong) external
Validates a proposed position against all four risk layers. Called by PositionManager during openPosition(). Reverts if any check fails. Updates rate-of-change tracking on success.
NameTypeDescription
accountaddressTrader opening the position
notionaluint256Position notional (6 decimals)
isLongboolWhether the position is long
Validation checks (in order):
#CheckFormulaRevert Error
1Per-position capnotional <= maxPositionNotional()ExceedsPositionCap
2Per-account capaccountTotal + notional <= maxAccountNotional()ExceedsAccountCap
3Pool exposure capabs(proposedNetExposure) <= maxNetExposure()ExceedsPoolExposureCap
4Gross notional ratewindowGrossAdded + notional <= maxGrossNotionalDeltaPerWindowRateOfChangeExceeded
5Net exposure rateabs(windowNetChange + delta) <= maxNetExposureDeltaPerWindowRateOfChangeExceeded
Rate-of-change checks (4 and 5) are disabled by default (maxGrossNotionalDeltaPerWindow = 0). The window resets automatically after rateWindowSeconds (default: 1 hour).

Admin Functions

setConfig

function setConfig(RiskConfig calldata newConfig) external
Updates the risk configuration. Restricted to RISK_ADMIN_ROLE. Validation:
#CheckRevert Error
1netExposureCapFactorBps > 0InvalidParameter
2stressMoveBps > 0InvalidParameter
3perPositionCapFactorBps in (0, 10000]InvalidParameter
4perAccountCapFactorBps in (0, 10000]InvalidParameter

Events

EventWhen Emitted
RiskConfigUpdatedRisk parameters changed by admin
RiskCapBreachedA risk cap was exceeded (informational)

Pool Exposure Caps

Exposure cap formulas and examples.

Position & Account Limits

Per-position and per-account cap mechanics.

Pool Vault

Pool equity and exposure tracking.