checkOracleAndPause() periodically to automate oracle-driven transitions.
Contract Relationships
State Machine
Operations by Mode
| Operation | NORMAL | DEGRADED | REDUCE_ONLY | PAUSED |
|---|---|---|---|---|
| Open position | Yes | No | No | No |
| Close position | Yes | Yes | Yes | No |
| Settlement | Yes | Yes | Yes | No |
| Liquidation | Yes | Yes | Yes | No |
| Deposit | Yes | Yes | Yes | No |
| Withdraw | Yes | Yes | Yes | No |
Read Functions
currentMode
Permission Checks
| Function | Returns true when |
|---|---|
canOpenPosition() | Mode is NORMAL |
canClosePosition() | Mode is not PAUSED |
canLiquidate() | Mode is not PAUSED |
canSettle() | Mode is not PAUSED |
canDeposit() | Mode is not PAUSED |
canWithdraw() | Mode is not PAUSED |
Degraded Mode State
| Function | Returns |
|---|---|
degradedConfig() | DegradedConfig struct |
degradedEnteredAt() | Timestamp when DEGRADED mode was entered (0 if not degraded) |
oracleModule() | OracleModule contract address |
Admin Functions
enterPausedMode
PAUSER_ROLE. Can be called from any non-paused mode.
exitPausedMode
PAUSER_ROLE.
| Name | Type | Description |
|---|---|---|
targetMode | Mode | Must be NORMAL or REDUCE_ONLY |
reasonCode | bytes32 | Reason for unpausing |
setReduceOnly
DEFAULT_ADMIN_ROLE. Cannot be called from PAUSED.
setDegraded
DEFAULT_ADMIN_ROLE. Can only transition from NORMAL or REDUCE_ONLY.
exitDegradedMode
DEFAULT_ADMIN_ROLE.
checkOracleAndPause
PAUSER_ROLE. Called periodically by the keeper.
Two-stage escalation:
- If oracle is fully invalid → transition to PAUSED
- If in DEGRADED and timeout exceeded (
degradedDurationSeconds) → escalate to PAUSED - If in DEGRADED and oracle recovers → return to NORMAL
true if oracle is valid, false if degraded or paused.
setOracleModule
DEFAULT_ADMIN_ROLE.
setDegradedConfig
DEFAULT_ADMIN_ROLE.
Reason Codes
| Constant | Value | Usage |
|---|---|---|
REASON_ADMIN | keccak256("ADMIN") | Manual admin transitions |
REASON_ORACLE_INVALID | keccak256("ORACLE_INVALID") | Oracle fully invalid |
REASON_ORACLE_DEGRADED | keccak256("ORACLE_DEGRADED") | Oracle deviation detected |
REASON_ORACLE_RECOVERED | keccak256("ORACLE_RECOVERED") | Oracle recovered from DEGRADED |
REASON_DEGRADED_TIMEOUT | keccak256("DEGRADED_TIMEOUT") | DEGRADED mode exceeded duration limit |
Events
| Event | When Emitted |
|---|---|
ModeTransition | Any mode change (includes from, to, reason, actor, timestamp) |
OracleModuleSet | OracleModule address configured |
OracleInvalidated | Oracle invalid triggers auto-pause |
DegradedConfigUpdated | Degraded config parameters changed |
Related Pages
Mode Escalation
Detailed escalation paths and recovery procedures.
Emergency Procedures
Emergency shutdown and recovery playbook.
Oracle Safeguards
Oracle validation checks that trigger mode transitions.