validateOpenPosition() during openPosition() — if any cap is exceeded, the transaction reverts.
Contract Relationships
Data Structures
RiskConfig
Read Functions
maxNetExposure
poolEquity × netExposureCapFactorBps / stressMoveBps. With defaults (100% / 2%), a pool with 1M USDC equity allows 50M net exposure.
maxPositionNotional
maxNetExposure × perPositionCapFactorBps / 10000. With defaults (5%), a 50M max exposure means 2.5M per position.
maxAccountNotional
maxNetExposure × perAccountCapFactorBps / 10000.
getConfig
Protocol Functions
validateOpenPosition
openPosition(). Reverts if any check fails. Updates rate-of-change tracking on success.
| Name | Type | Description |
|---|---|---|
account | address | Trader opening the position |
notional | uint256 | Position notional (6 decimals) |
isLong | bool | Whether the position is long |
| # | Check | Formula | Revert Error |
|---|---|---|---|
| 1 | Per-position cap | notional <= maxPositionNotional() | ExceedsPositionCap |
| 2 | Per-account cap | accountTotal + notional <= maxAccountNotional() | ExceedsAccountCap |
| 3 | Pool exposure cap | abs(proposedNetExposure) <= maxNetExposure() | ExceedsPoolExposureCap |
| 4 | Gross notional rate | windowGrossAdded + notional <= maxGrossNotionalDeltaPerWindow | RateOfChangeExceeded |
| 5 | Net exposure rate | abs(windowNetChange + delta) <= maxNetExposureDeltaPerWindow | RateOfChangeExceeded |
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
RISK_ADMIN_ROLE.
Validation:
| # | Check | Revert Error |
|---|---|---|
| 1 | netExposureCapFactorBps > 0 | InvalidParameter |
| 2 | stressMoveBps > 0 | InvalidParameter |
| 3 | perPositionCapFactorBps in (0, 10000] | InvalidParameter |
| 4 | perAccountCapFactorBps in (0, 10000] | InvalidParameter |
Events
| Event | When Emitted |
|---|---|
RiskConfigUpdated | Risk parameters changed by admin |
RiskCapBreached | A risk cap was exceeded (informational) |
Related Pages
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.