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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.opinion.trade/developer-guide/opinion-clob-typescript-sdk/core-concepts/architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
