Skip to content

ConditionalTokens (CTF)

The ConditionalTokens contract is the core engine for the prediction market. It implements the Gnosis Conditional Tokens Framework for creating conditions, splitting collateral into conditional positions, merging positions, and redeeming payouts.

Key Concepts

Conditions

A condition represents a question with a set of possible outcomes. For binary markets (Yes/No), the outcome slot count is 2.

solidity
function prepareCondition(
    address oracle,
    bytes32 questionId,
    uint outcomeSlotCount
) external

The conditionId is derived from:

conditionId = keccak256(abi.encodePacked(oracle, questionId, outcomeSlotCount))

Positions

Positions are ERC-1155 tokens representing stakes in specific outcomes. Each position has a unique positionId (used as the ERC-1155 token ID).

For a binary market, there are two positions:

  • YES token — pays out if the condition resolves to outcome 0
  • NO token — pays out if the condition resolves to outcome 1

Split / Merge / Redeem

OperationDescription
splitPositionLock collateral → receive YES + NO tokens
mergePositionsBurn YES + NO tokens → receive collateral back
redeemPositionsAfter resolution, burn winning tokens → receive collateral

Oracle Adapter

The MockUmaAdapter serves as the oracle for this platform. It is owner-controlled and provides:

solidity
function createMarket(bytes32 questionId) external onlyOwner
function resolveMarket(bytes32 questionId, uint256[] calldata payouts) external onlyOwner

For a binary market resolution:

  • [1, 0] = YES wins
  • [0, 1] = NO wins

INFO

In production, you would replace MockUmaAdapter with a real oracle integration (e.g., UMA Optimistic Oracle, Chainlink, or a custom resolution mechanism).