# Architecture at a glance

MoveX is a **hybrid protocol**: the matching engine runs off-chain for speed, but every position-changing event settles on-chain for verifiability.

```
                       ┌─────────────────────────────┐
                       │   Your wallet (signs only)  │
                       └──────────────┬──────────────┘
                                      │ EIP-712 intents
                                      ▼
                       ┌─────────────────────────────┐
                       │   MoveX frontend (the App)  │
                       └──────────────┬──────────────┘
                                      │ HTTP / WebSocket
                                      ▼
                       ┌─────────────────────────────┐
                       │       Off-chain Sequencer   │
                       │   • orderbook              │
                       │   • intent validation       │
                       │   • risk + accounting       │
                       │   • match engine           │
                       └──────────────┬──────────────┘
                                      │ submits batches
                                      ▼
                       ┌─────────────────────────────┐
                       │     BatchSettler.sol        │
                       │   (atomic settlement)       │
                       └──────────────┬──────────────┘
                                      ▼
              ┌───────────────────────┴───────────────────────┐
              ▼                       ▼                       ▼
       ┌────────────┐         ┌────────────┐          ┌────────────┐
       │   Hub.sol  │         │ Market.sol │          │ Market.sol │
       │ (treasury) │         │ (BTC-WEEK) │          │ (HYPE-DAY) │
       └────────────┘         └────────────┘          └────────────┘
                                      ▲
                                      │ price feeds
                       ┌──────────────┴──────────────┐
                       │  HyperCore precompiles      │  primary
                       │  Pyth Network               │  safety layer
                       └─────────────────────────────┘
```

The components, top to bottom:

#### Your wallet

You hold your own keys. MoveX never gets them. Every action that moves your funds requires a signature from you, either an on-chain transaction (deposit, withdraw, claim) or an EIP-712 signed message (order intent).

#### The frontend (the App)

A web app built with Next.js, RainbowKit, and wagmi. It's what you interact with: the dashboard, the trading terminal, the chart, the order book. It talks to the sequencer over HTTPS for trading and to the blockchain via RPC for on-chain reads and transactions.

The frontend never holds custody and is replaceable, anyone could build an alternative frontend against the same sequencer + smart contracts.

#### The off-chain sequencer

Written in Rust for speed. Single-threaded matching engine on a dedicated CPU core, with separate threads for chain monitoring, settlement publishing, persistence, and WebSocket broadcasting.

The sequencer:

* Validates your signed intents (signature, nonce, deadline, margin).
* Maintains the live order book.
* Matches orders by **price-time priority**.
* Tracks balance buckets (available / locked / reserved / in-positions).
* Submits matched fills to the on-chain `BatchSettler` for settlement.
* Listens to on-chain events to keep its internal state synced.

What the sequencer **cannot** do:

* It cannot move your funds, every settlement requires your signed intent.
* It cannot fake fills, as fills are verified on-chain against your signed intent's parameters.
* It cannot censor your collateral, you can always withdraw via direct on-chain calls if the sequencer is down.

#### The smart contracts

Three main contracts, all deployed on HyperEVM:

* **`Hub.sol`** - the treasury. Holds your USDC collateral. Tracks `available` and `locked` balances per user. Handles deposits, withdrawals (via signed permits), and inter-market collateral movement during settlement.
* **`Market.sol`** - one per market (e.g., `BTC-MOVE-WEEKLY`, `HYPE-MOVE-DAILY`). Holds open positions, computes PnL using the absolute-move formula, manages the epoch lifecycle (active → settling → expired → next epoch), and exposes `settleTrade`, `claim`, `liquidateAndSettle`, `settleEpoch`.
* **`BatchSettler.sol`** - the atomic settlement gateway. The sequencer calls `batchSettle(intents[])` and the contract executes every `settleTrade` in the batch atomically. If any one settles fails, the entire batch reverts. No half-filled batches, ever.

Supporting contracts include `IntentVerifier` (EIP-712 verification), `PairStorage` and `Oracle` (oracle wiring), and an `InsuranceFund` per market for bad-debt absorption during liquidations.

#### Oracles

Mark prices, reference prices, and settlement prices come from on-chain price sources. The protocol's primary feed is **HyperCore**, read directly via HyperEVM precompiles; this is the core reason MoveX is built on HyperEVM in the first place.

By reading Hyperliquid's matching engine state synchronously from the EVM, we avoid relaying prices through any external oracle for the assets HyperCore covers. **Pyth Network** is layered on top as a safety mechanism, cross-checking HyperCore prices and triggering circuit breakers if the two ever diverge meaningfully. There is no MoveX-controlled price feed.

***


---

# Agent Instructions: 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.movex.market/architecture/architecture-at-a-glance.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.
