How coriom/deopt-v2-sol works
DeOpt v2 is a derivatives protocol for on-chain options and perpetual markets, with unified collateral, risk controls, liquidation, and governance. The main user flow is collateral deposited into the vault, then options or perp trading through matching and engine execution, with oracle-backed risk checks and liquidation safeguards. The repository also contains substantial Base Sepolia cutover tooling for snapshot verification, migration replay and resealing, and maintenance-lock operations. Solidity relationships below rely on README documentation; tool relationships use the shown excerpts and SOURCE INDEX references, so unsampled links are omitted.
Main entry points: MarginEngine.sol Options Engine · PerpEngine.sol Perp Engine · migration_reseal_preflight.py Reseal Preflight · matching Matching Engines
Components 23
Trading
- Option Registry
src/OptionProductRegistry.sol - Options Engine
src/margin/MarginEngine.sol - Perp Registry
src/perp/PerpMarketRegistry.sol - Perp Engine
src/perp/PerpEngine.sol - Matching Engines
src/matching
Collateral and Risk
- Collateral Vault
src/collateral/CollateralVault.sol - Risk Modules
src/risk - Perp Risk
src/perp/PerpRiskModule.sol - Collateral Seizer
src/liquidation/CollateralSeizer.sol
Protocol Services
- Oracle Router
src/oracle/OracleRouter.sol - Insurance Fund
src/core/InsuranceFund.sol - Fee Routing
src/fees/FeesManager.sol - Governance Controls
src/gouvernance
Cutover Operations
- Snapshot Hashing
tools/perps_v2_cutover/snapshot_hash.py - Migration Replay
tools/perps_v2_cutover/migration_replay.py - Replay Preflight
tools/perps_v2_cutover/migration_replay_preflight.py - Replay Executor
tools/perps_v2_cutover/migration_replay_execute.py - Reseal Preflight
tools/perps_v2_cutover/migration_reseal_preflight.py - Reseal Executor
tools/perps_v2_cutover/migration_reseal_execute.py - Maintenance Preflight
tools/perps_v2_cutover/maintenance_lock_preflight.py - Maintenance Executor
tools/perps_v2_cutover/maintenance_lock_execute.py - Fee Guard
tools/perps_v2_cutover/maintenance_fee_guard.py
Other components
- Trader
Connections 28
- Trader → Collateral Vault: deposits collateral
README.md - Trader → Matching Engines: submits trades
README.md - Matching Engines → Options Engine: executes options
README.md - Matching Engines → Perp Engine: executes perps
README.md - Option Registry → Options Engine: manages series
README.md - Perp Registry → Perp Engine: manages markets
README.md - Options Engine → Collateral Vault: accounts collateral
README.md - Perp Engine → Collateral Vault: accounts collateral
README.md - Options Engine → Risk Modules: checks risk
README.md - Perp Engine → Perp Risk: checks risk
README.md - Risk Modules → Oracle Router: values collateral
README.md - Perp Risk → Oracle Router: values collateral
README.md - Options Engine → Collateral Seizer: resolves unsafe accounts
README.md - Perp Engine → Collateral Seizer: resolves unsafe accounts
README.md - Collateral Seizer → Insurance Fund: requests backstop
README.md - Options Engine → Fee Routing: routes fees
README.md - Perp Engine → Fee Routing: routes fees
README.md - Governance Controls → Risk Modules: controls parameters
README.md - Migration Replay → Snapshot Hashing: imports hashing
tools/perps_v2_cutover/migration_replay.py - Replay Preflight → Migration Replay: imports replay checks
tools/perps_v2_cutover/migration_replay_preflight.py - Replay Preflight → Snapshot Hashing: imports hashing
tools/perps_v2_cutover/migration_replay_preflight.py - Replay Executor → Replay Preflight: reuses checks
- Reseal Preflight → Snapshot Hashing: imports hashing
- Reseal Executor → Reseal Preflight: uses preview
tools/perps_v2_cutover/migration_reseal_execute.py - Maintenance Preflight → Reseal Preflight: imports preflight
tools/perps_v2_cutover/maintenance_lock_preflight.py - Maintenance Executor → Maintenance Preflight: checks preflight
tools/perps_v2_cutover/maintenance_lock_execute.py - Maintenance Executor → Reseal Preflight: imports preflight
tools/perps_v2_cutover/maintenance_lock_execute.py - Fee Guard → Maintenance Executor: guards fees