Models

Data Models

Reference for all data models and enums used in the Opinion CLOB SDK.

Enums

TopicType

Defines the type of prediction market. Topic is conceptional equivalent to Market.

Module: opinion_clob_sdk.model

from opinion_clob_sdk.model import TopicType

class TopicType(Enum):
    BINARY = 0        # Two-outcome markets (YES/NO)
    CATEGORICAL = 1   # Multi-outcome markets (Option A/B/C/...)

Usage:

# Filter for binary markets only
markets = client.get_markets(topic_type=TopicType.BINARY)

# Filter for categorical markets
markets = client.get_markets(topic_type=TopicType.CATEGORICAL)

TopicStatus

Market lifecycle status codes.

Module: opinion_clob_sdk.model

Usage:


TopicStatusFilter

Filter values for querying markets by status.

Module: opinion_clob_sdk.model

Usage:


OrderSide

Trade direction for orders.

Module: opinion_clob_sdk.chain.py_order_utils.model.sides

Usage:


Order Types

Constants for order type selection.

Module: opinion_clob_sdk.chain.py_order_utils.model.order_type

Usage:


Data Classes

PlaceOrderDataInput

Input data for placing an order.

Module: opinion_clob_sdk.chain.py_order_utils.model.order

Fields:

Field
Type
Required
Description

marketId

int

Yes

Market ID to trade on

tokenId

str

Yes

Token ID (e.g., "token_yes")

side

int

Yes

OrderSide.BUY (0) or OrderSide.SELL (1)

orderType

int

Yes

MARKET_ORDER (1) or LIMIT_ORDER (2)

price

str

Yes

Price as string (e.g., "0.55"), "0" for market orders

makerAmountInQuoteToken

str

No*

Amount in quote token (e.g., "100" for 100 USDT)

makerAmountInBaseToken

str

No*

Amount in base token (e.g., "50" for 50 YES tokens)

* Must provide exactly ONE of makerAmountInQuoteToken or makerAmountInBaseToken

Amount Selection Rules:

For BUY orders:

  • makerAmountInQuoteToken - Common (specify how much USDT to spend)

  • makerAmountInBaseToken - Specify how many tokens to buy

  • ❌ Both - Invalid

For SELL orders:

  • makerAmountInBaseToken - Common (specify how many tokens to sell)

  • makerAmountInQuoteToken - Specify how much USDT to receive

  • ❌ Both - Invalid

Examples:

Buy 100 USDT worth at $0.55:

Sell 50 YES tokens at market price:


OrderData

Internal order data structure (used by OrderBuilder).

Module: opinion_clob_sdk.chain.py_order_utils.model.order

Note: This is an internal structure. Users should use PlaceOrderDataInput instead.


OrderDataInput

Simplified order input (internal use).

Module: opinion_clob_sdk.chain.py_order_utils.model.order

Note: This is used internally by _place_order(). Users should use PlaceOrderDataInput.


Response Models

API Response Structure

All API methods return responses with this standard structure:

Result Types

For single objects:

For lists/arrays:

Example Usage:


Market Data Models

Market Object

Returned by get_market() and get_markets().

Key Fields:

Field
Type
Description

marketId

int

Market ID

marketTitle

str

Market question/title

status

int

Market status (see TopicStatus)

marketType

int

Market type (0=binary, 1=categorical)

conditionId

str

Blockchain condition ID (hex string)

quoteToken

str

Quote token address (e.g., USDT)

chainId

str

Blockchain chain ID

volume

str

Trading volume

yesTokenId

str

Token ID of Yes side

noTokenId

str

Token ID of No side

resultTokenId

str

Token ID of Winning side

yesLabel

str

Token Label of Yes side

noLabel

str

Token Label of No side

rules

str

Market Resolution Criteria

cutoffAt

int

The latest date to resolve the market

resolvedAt

int

The date that market resolved

Example:


Quote Token Object

Returned by get_quote_tokens().

Key Fields:

Field
Type
Description

quoteTokenAddress

str

Token contract address

decimal

int

Token decimals (e.g., 18 for USDT)

ctfExchangeAddress

str

CTF exchange contract address

chainId

int

Blockchain chain ID

quoteTokenName

str

Token name (e.g., "USDT")

symbol

str

Token symbol

Example:


Orderbook Object

Returned by get_orderbook().

Structure:

Example:


Constants

Signature Types

Module: opinion_clob_sdk.chain.py_order_utils.model.signatures

Usage: Orders are signed with POLY_GNOSIS_SAFE signature type by default.


Address Constants

Module: opinion_clob_sdk.chain.py_order_utils.constants

Usage:

  • ZERO_ADDRESS is used for taker field in public orders (anyone can fill)


Chain IDs

Module: opinion_clob_sdk.sdk

Usage:


Decimals

Module: opinion_clob_sdk.sdk

Common Decimals:

  • USDT: 18 decimals

  • BNB: 18 decimals

  • Outcome tokens: Usually match quote token decimals


Helper Functions

safe_amount_to_wei()

Convert human-readable amount to wei units.

Module: opinion_clob_sdk.sdk

Signature:

Parameters:

  • amount - Human-readable amount (e.g., 1.5)

  • decimals - Token decimals (e.g., 18 for USDT)

Returns: Integer amount in wei units

Example:


calculate_order_amounts()

Calculate maker and taker amounts for limit orders.

Module: opinion_clob_sdk.chain.py_order_utils.utils

Signature:

Parameters:

  • price - Order price (e.g., 0.55)

  • maker_amount - Maker amount in wei

  • side - OrderSide.BUY or OrderSide.SELL

  • decimals - Token decimals

Returns: Tuple of (recalculated_maker_amount, taker_amount)

Example:


Next Steps

Last updated