How It Works
Hybrid exchange architecture combining offchain order matching with onchain settlement and resolution.
Architecture
Scalar operates as a hybrid peer-to-peer exchange. Orders are matched offchain for performance while all trades settle and resolve onchain for full transparency and self-custody.
| Layer | Where | Purpose |
|---|---|---|
| Order matching | Offchain | Pairs counterparties with minimal latency |
| Trade settlement | Onchain | Records trades, balances, and positions |
| Market resolution | Onchain | Determines the final market outcome |
Offchain Matching
Scalar uses a CLOB (Central Limit Order Book) model. The matching engine is written in Rust, optimized for speed and fairness.
- Strict price-time priority. Orders are matched by best price first, then by submission time.
- Immediate trade confirmation. Matched trades confirm instantly without waiting for block finality.
- Guaranteed settlement. Every matched order is committed to onchain settlement. No trade is dropped.
Onchain Settlement
All trades, balances, and positions are recorded in a smart contract. Scalar never takes custody of user funds.
Non-custodial. Funds are held by the contract. Scalar cannot access, freeze, or move user assets.
- Verifiable. Every position and trade history is auditable onchain.
- No counterparty risk. The contract programmatically enforces all payouts at resolution.
Market Resolution
For price-derived markets, resolution is permissionless and trustless.
Price data comes from Pyth Network oracles. Resolution logic lives in onchain settler contracts. Anyone can trigger resolution by submitting valid oracle data. No human intervention required.
For markets where outcomes cannot be determined by an oracle (e.g. sports, politics), resolution is submitted by a designated operator.