Overview
TheUmaCtfAdapter contract is the core contract that enables resolution of Polymarket Conditional Tokens Framework (CTF) markets through UMA’s Optimistic Oracle. It manages question initialization, resolution, and administrative functions for prediction markets.
Contract Address
The contract is deployed at the address specified in your deployment configuration.Public Functions
initialize
Initializes a question and atomically adds it to the Adapter, prepares it on the Conditional Tokens Framework, and requests a price from the Optimistic Oracle.Data used to resolve a question. This should contain the question details and criteria for resolution.
ERC20 token address used for payment of rewards and fees. Must be on the collateral whitelist.
Reward offered to a successful Optimistic Oracle proposer. Must be chosen carefully to properly economically incentivize OO proposers. If non-zero, the caller must have approved the Adapter as spender.
Bond required to be posted by OO proposers/disputers. If 0, the default OO bond is used. Must be chosen carefully to properly economically incentivize OO proposers and disputers. Questions expected to secure a large amount of value should consider a larger proposal bond.
OO liveness period in seconds. If 0, the default liveness period of 2 hours is used. Must be chosen carefully depending on the value backed by the question. Questions expected to secure a large amount of value should consider a longer liveness period.
questionID(bytes32): The unique identifier for the initialized question, computed askeccak256(ancillaryData).
ready
Checks whether a questionID is ready to be resolved.The unique questionID to check.
bool: True if the question is ready to be resolved (initialized, not paused, not resolved, and has a price available), false otherwise.
resolve
Resolves a question by pulling price information from the Optimistic Oracle and resolving the underlying CTF market.The unique questionID of the question to resolve.
- Question is not initialized
- Question is paused
- Question is already resolved
- Price is not available on the Optimistic Oracle
getExpectedPayouts
Retrieves the expected payout array of the question based on the Optimistic Oracle price.The unique questionID of the question.
uint256[]: Array of payouts[YES, NO]where:- Price 0 →
[0, 1](NO wins) - Price 0.5 ether →
[1, 1](50/50 split, UNKNOWN) - Price 1 ether →
[1, 0](YES wins)
- Price 0 →
- Question is not initialized
- Question is flagged for manual resolution
- Question is paused
- Price is not available
isInitialized
Checks if a question is initialized.The unique questionID to check.
bool: True if the question is initialized, false otherwise.
isFlagged
Checks if a question has been flagged for manual resolution.The unique questionID to check.
bool: True if the question is flagged for manual resolution, false otherwise.
getQuestion
Gets the QuestionData for the given questionID.The unique questionID to retrieve.
QuestionData: The complete question data struct. See QuestionData for field details.
Admin-Only Functions
The following functions can only be called by authorized administrators.flag
Flags a market for manual resolution. Sets a safety period timestamp and pauses the question.The unique questionID of the question to flag.
- Sets
manualResolutionTimestamptoblock.timestamp + SAFETY_PERIOD(1 hour) - Pauses the question
unflag
Unflags a market for manual resolution. Can only be called before the safety period has passed.The unique questionID of the question to unflag.
- Safety period has already passed
reset
Resets a question, sending out a new price request to the Optimistic Oracle. This is a failsafe to be used if thepriceDisputed callback reverts during execution.
The unique questionID to reset.
- Refunds the reward to the question creator if necessary
- Sends a new price request to the Optimistic Oracle
- Admin pays for the new price request
resolveManually
Allows an admin to resolve a CTF market manually with specified payouts. Can only be called after the safety period has passed for a flagged question.The unique questionID of the question to resolve.
Array of position payouts for the referenced question. Must be a valid payout array.
- Payouts array is invalid
- Question is not initialized
- Question is not flagged
- Safety period has not passed
pause
Pauses market resolution for a question.The unique questionID of the question to pause.
unpause
Unpauses market resolution for a question.The unique questionID of the question to unpause.
Optimistic Oracle Callback
priceDisputed
Callback executed when a price is disputed in the Optimistic Oracle. Automatically resets the question and sends out a new price request.Ancillary data of the request, used to identify the questionID.
Constants
SAFETY_PERIOD
YES_OR_NO_IDENTIFIER
MAX_ANCILLARY_DATA
OO_ANCILLARY_DATA_LIMIT).
Immutable State Variables
ctf
NegRiskOperator contract address.
optimisticOracle
collateralWhitelist
Bulletin Board Functions
The adapter inherits from theBulletinBoard mixin, which provides functions for posting and retrieving updates about questions.
postUpdate
Post an update for a question. Anyone can post updates, but users should only consider updates posted by the question creator.The unique questionID to post an update for.
The update content to post.
AncillaryDataUpdated(bytes32 indexed questionID, address indexed owner, bytes update)
getUpdates
Gets all updates for a questionID posted by a specific owner.The unique questionID.
The address of the question initializer who posted the updates.
AncillaryDataUpdate[]: Array of all updates with timestamp and content.
getLatestUpdate
Gets the latest update for a questionID posted by a specific owner.The unique questionID.
The address of the question initializer who posted the updates.
AncillaryDataUpdate: The most recent update, or an empty update if none exist.
Events
The contract emits the following events:QuestionInitialized(bytes32 indexed questionID, uint256 indexed requestTimestamp, address indexed creator, bytes ancillaryData, address rewardToken, uint256 reward, uint256 proposalBond)QuestionPaused(bytes32 indexed questionID)QuestionUnpaused(bytes32 indexed questionID)QuestionFlagged(bytes32 indexed questionID)QuestionUnflagged(bytes32 indexed questionID)QuestionReset(bytes32 indexed questionID)QuestionResolved(bytes32 indexed questionID, int256 indexed settledPrice, uint256[] payouts)QuestionManuallyResolved(bytes32 indexed questionID, uint256[] payouts)
Errors
NotInitialized(): Question is not initializedNotFlagged(): Question is not flaggedNotReadyToResolve(): Question is not ready to be resolvedResolved(): Question is already resolvedInitialized(): Question is already initializedUnsupportedToken(): Reward token is not on the whitelistFlagged(): Question is flaggedPaused(): Question is pausedSafetyPeriodPassed(): Safety period has passedSafetyPeriodNotPassed(): Safety period has not passedPriceNotAvailable(): Price is not available from the Optimistic OracleInvalidAncillaryData(): Ancillary data is invalid (empty or too long)NotOptimisticOracle(): Caller is not the Optimistic OracleInvalidOOPrice(): Price from Optimistic Oracle is invalidInvalidPayouts(): Payout array is invalid