Overview
A market in the UMA CTF Adapter progresses through various states from initialization to resolution. Understanding these states is crucial for proper market management and integration.State Flags
TheQuestionData struct tracks market state through several boolean flags:
Initialized
Indicator:ancillaryData.length > 0
A market is considered initialized when it has been created via the initialize() function. This:
- Creates a unique
questionIDfrom the ancillary data - Prepares the condition on the Conditional Tokens Framework
- Submits a price request to UMA’s Optimistic Oracle
- Stores all question parameters in the contract
isInitialized(questionID) to verify initialization status.
Paused
Flag:paused
A paused market cannot be resolved. Markets can be paused in two ways:
- Admin pause: Explicitly paused by an admin via
pause(questionID) - Flagged for manual resolution: Automatically paused when
flag(questionID)is called
resolve()will revert withPausederrorready()returnsfalsegetExpectedPayouts()will revert withPausederror
unpause(questionID) or unflag(questionID) (if flagged)
Flagged
Indicator:manualResolutionTimestamp > 0
A market flagged for manual resolution indicates intervention is needed. This state:
- Sets
paused = trueautomatically - Sets
manualResolutionTimestamp = block.timestamp + SAFETY_PERIOD(1 hour) - Blocks automatic resolution via UMA Oracle
- Enables manual resolution after the safety period
- Oracle malfunction or incorrect price
- Disputed outcome requiring governance decision
- Emergency intervention needed
isFlagged(questionID) to verify flagged status.
Resolved
Flag:resolved
A resolved market has finalized payouts reported to the CTF. Resolution can happen two ways:
- Automatic resolution: Via
resolve()after Oracle settles the price - Manual resolution: Via
resolveManually()by an admin after safety period
- Market is immutable - cannot be reset or re-resolved
- Payouts are fixed on the Conditional Tokens Framework
- Users can redeem positions based on the reported payouts
Reset
Flag:reset
Indicates the question has been reset after a dispute. This happens when:
- A price proposal is disputed on the Optimistic Oracle
- The
priceDisputed()callback is triggered - A new price request is submitted with updated
requestTimestamp
reset().
Refund
Flag:refund
Marks that the reward should be refunded to the question creator. Set when:
- A second dispute occurs on an already-reset question
- The reward needs to be returned on resolution or manual resolution
State Transitions
State Validation Matrix
| State | Can Resolve? | Can Reset? | Can Flag? | Can Pause? |
|---|---|---|---|---|
| Initialized | Yes (if price available) | Yes (admin) | Yes | Yes |
| Paused | No | Yes (admin) | Yes (if not flagged) | Already paused |
| Flagged | No (use manual) | Yes (admin) | Already flagged | Already paused |
| Resolved | No | No | No | No |
| Reset | Yes (new price) | Yes (admin) | Yes | Yes |
Code References
Key state check functions:- Initialization:
_isInitialized()atUmaCtfAdapter.sol:455 - Flagged:
_isFlagged()atUmaCtfAdapter.sol:451 - Ready:
_ready()atUmaCtfAdapter.sol:299- checks all conditions for resolution - Has Price:
_hasPrice()atUmaCtfAdapter.sol:441- queries Optimistic Oracle
Best Practices
- Always check initialization before performing operations on a questionID
- Monitor the
resetflag to track if a market has been disputed - Check
ready()status before attempting resolution - Track
pausedandflaggedstates separately - flagged implies paused, but paused doesn’t imply flagged - Verify
resolvedstate before attempting any state changes