Architecture

The Opinion CLOB TypeScript SDK employs a hybrid architecture integrating off-chain order matching with on-chain settlement, providing access to BNB Chain prediction markets.

System Design

Core Layers

Client (client.ts)
β”œβ”€β”€ API Layer          β†’ @opinion-labs/opinion-api (auto-generated OpenAPI client)
β”œβ”€β”€ Chain Layer         β†’ viem
β”‚   β”œβ”€β”€ ContractCaller β†’ ConditionalTokens, MultiSend, ERC20, FeeManager
β”‚   └── Safe           β†’ Gnosis Safe v1.3.0 multi-sig
└── Order Utils        β†’ EIP712 signing (viem hashTypedData)
circle-info

Key dependencies: viem, @opinion-labs/opinion-api

Operational Patterns

Operation Type
Gas Required
Latency
Examples

Market Data Queries

No

50-150ms (cached: <10ms)

getMarkets, getOrderbook, getLatestPrice

Order Placement

No (gas-free CLOB)

200-500ms

placeOrder, cancelOrder

Smart Contract Ops

Yes (BNB)

~3s (block confirmation)

enableTrading, split, merge, redeem

Authentication Model

A two-key security model separates signing from funding:

1

Signing key

Private Key β€” Signs orders and transactions (can be a hot wallet).

2

Funding key

Multi-Sig Address β€” Holds USDT and outcome tokens (typically Gnosis Safe v1.3.0).

This architecture enables both individual traders and multi-signature wallet holders to participate seamlessly.

Token Specifications

  • All tokens use 18 decimal places (Wei standard)

  • 1 USDT = 1,000,000,000,000,000,000 wei (10^18)

  • Prices expressed as probability decimals: "0.5" = 50% chance

  • Valid price range: 0.01 to 0.99