Contract Architecture
The Protocol Registry is the root — all contracts discover each other through it rather than storing direct addresses. Solid arrows show ownership, dotted arrows show runtime reads.Contract Summary
| Contract | Purpose | Key Functions |
|---|---|---|
| PositionManager | Position lifecycle: open, increase, reduce, margin adjust | openPosition, increasePosition, addPositionMargin, removePositionMargin |
| SettlementEngine | Settlement at maturity, liquidation, early termination | settlePosition, liquidatePosition, closePosition, reducePosition |
| PoolVault | ERC-4626 LP vault, counterparty to all trader positions | deposit, withdraw, mint, redeem, applyPnl |
| MarginAccounts | Trader collateral custody and per-position margin locking | deposit, withdraw, lockMargin, settlePosition |
| OracleModule | Pyth spot prices, publisher forward prices, fixing prices | publishForwardRound, recordFixingPriceFromPyth, getForwardPrice |
| Config | Protocol parameters: margin, fees, tenors, pricing | setMarginConfig, setPricingConfig, setTimeConfig |
| ModeController | Operating mode state machine (NORMAL → DEGRADED → REDUCE_ONLY → PAUSED) | enterPausedMode, exitPausedMode, setReduceOnly, checkOracleAndPause |
| RiskManager | Per-position, per-account, pool exposure caps, rate-of-change throttling | validateOpenPosition, maxNetExposure, maxPositionNotional |
Access Control
| Role | Capabilities |
|---|---|
DEFAULT_ADMIN_ROLE | Full admin — set config, manage roles, mode transitions |
PAUSER_ROLE | Emergency pause/unpause only |
PUBLISHER_ROLE | Submit forward prices via OracleModule |
ORACLE_ADMIN_ROLE | Configure oracle safeguard parameters |
RISK_ADMIN_ROLE | Configure risk caps and rate-of-change limits |
Related Pages
Architecture
Full system architecture including off-chain services.
Types Reference
Shared enums, structs, and constants used across all contracts.
Errors Reference
Complete reference of custom errors by contract.