Skip to main content
The CTFExchange supports three different matching scenarios that enable efficient trading and liquidity provision for binary outcome tokens. Each scenario handles different combinations of buy and sell orders.

Asset Notation

Before diving into the scenarios, let’s define the asset types used:
  • A - ERC1155 outcome token
  • A' - ERC1155 outcome token, complement of A
  • C - ERC20 collateral token (e.g., USDC)
Complements assumes 1 outcome token and 1 of its complement can always be merged into 1 unit of collateral and 1 unit of collateral can always be split into 1 outcome token and 1 of its complement (i.e., A + A' = C).Outcome tokens and collateral have the same decimals/base unit.

Matching Scenarios

Scenario 1: NORMAL Matching

The NORMAL scenario matches a buy order against a sell order for the same outcome token. This is a standard exchange where tokens are transferred directly between users.

Example: Buy vs Sell

1

Maker Order

UserA wants to BUY 100 token A @ $0.50
Order Structure
{
  "maker": "userA",
  "makerAsset": "C",
  "takerAsset": "A",
  "makerAmount": 50,
  "takerAmount": 100
}
UserA is offering 50 USDC to receive 100 token A (price: $0.50 per token)
2

Taker Order

UserB wants to SELL 50 token A @ $0.50
Order Structure
{
  "maker": "userB",
  "makerAsset": "A",
  "takerAsset": "C",
  "makerAmount": 50,
  "takerAmount": 25
}
UserB is offering 50 token A to receive 25 USDC (price: $0.50 per token)
3

Match Execution

The exchange calls matchOrders(makerOrder, [takerOrder], 50, [25])Transfer Flow:
  1. Transfer 50 token A from userB into CTFExchange
  2. Transfer 25 C from userA into CTFExchange
  3. Transfer 50 token A from CTFExchange to userA
  4. Transfer 25 C from CTFExchange to userB

Match Type Enum

The contract defines a MatchType enum to identify these scenarios:
OrderStructs.sol
enum MatchType {
    // 0: buy vs sell
    COMPLEMENTARY,
    // 1: both buys
    MINT,
    // 2: both sells
    MERGE
}

Key Takeaways

NORMAL

Direct token exchange between a buyer and seller of the same outcome token

MINT

Mints new token sets when two buyers want complementary outcomes

MERGE

Merges complementary tokens into collateral when two sellers have opposite positions

Build docs developers (and LLMs) love