> For the complete documentation index, see [llms.txt](https://docs.opinion.trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opinion.trade/developer-guide/opinion-clob-typescript-sdk/core-concepts/architecture.md).

# 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)
```

{% hint style="info" %}
Key dependencies: `viem`, `@opinion-labs/opinion-api`
{% endhint %}

### 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:

{% stepper %}
{% step %}

### Signing key

Private Key — Signs orders and transactions (can be a hot wallet).
{% endstep %}

{% step %}

### Funding key

Multi-Sig Address — Holds USDT and outcome tokens (typically Gnosis Safe v1.3.0).
{% endstep %}
{% endstepper %}

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`
