Trion Documentation V2 · Live on Robinhood Chain
Browse documentation

System architecture

In one paragraph. Trion V2 is a hybrid exchange: an off-chain, single-writer matching engine decides order (who traded with whom, in what sequence), and a set of non-upgradeable contracts decide money (custody, margin, funding, liquidation). Nothing the matcher says becomes true until a signed batch is accepted by the PerpetualV2 contract on chain. Prices come from a separate oracle path that the matcher cannot override.

System map

The six moving parts

PartWhat it doesWhere it lives
Wallet / browserSigns EIP-712 orders and strategy policies; sends deposits, withdrawals and hard revocations directly to the contracts.overdrive/exchange/web/src/wallet.ts
Matcher (EngineV2)One writer per market. Verifies signatures in a worker pool, reserves margin, matches against an in-memory FIFO book, and proposes fill batches.overdrive/exchange/matcher/src/v2-engine/engine.ts
Binary WALEvery command and external fact (order, cancel, price, receipt, reorg…) is appended and fsynced before it is acknowledged, so a restart replays to the same state.overdrive/exchange/matcher/src/v2-engine/wal.ts, replay.ts
Settlement relayTakes durable batches, checks the matcher signature, simulates settleBatch with eth_call, enforces a gas budget, sends the transaction and reconciles the receipt.overdrive/exchange/matcher/src/v2-relay/relay.ts, reconciliation.ts
ContractsRegistry, price verifier, funding, risk, orders, perpetual, closeout/backstop/ADL/slow-mode, strategy policy. Custody never leaves them.overdrive/perps/src/v2/*.sol, overdrive/shared/v2/IV2.sol
Oracle / price feedCollects source prices and hashes evidence; in V2, a keyless publisher coordinates three independent one-key signer services to deliver threshold-signed PricePayloads, FundingPayloads and FixingPayloads to TrionPriceVerifierV2 and FundingEpochsV2.overdrive/exchange/oracle/src/publisher.ts, signer.ts, publication-evidence.ts; overdrive/exchange/matcher/src/index-feed.ts

Life of an order

Trade lifecycle

  1. Sign. The browser builds a 14-field Order, signs it under the TrionOrders v2 EIP-712 domain bound to the market's OrdersV2 address, and POSTs {order, signature} to the matcher. See Signed orders.
  2. Admit. EngineV2.submitOrder recovers the signer off the hot thread, refreshes the trader's on-chain AccountView/RiskView, and checks collateral reservations. A failure returns a structured Fault (BAD_SIGNATURE, MARGIN, …), never a silently reordered acceptance.
  3. Persist, then match. The order is written to the WAL (SUBMIT frame) and only then matched. GTC remainders rest; IOC remainders are dropped; FOK is all-or-nothing.
  4. Propose. Fills accumulate into a packed batch (target 50, cap 100, 100 ms flush timer) that the matcher key signs under the TrionPerpetual domain. The batch is itself a WAL frame (BATCH_PROPOSED).
  5. Settle. The relay simulates, submits PerpetualV2.settleBatch(packed, matcherSig) and waits for the receipt. The contract re-validates every signature, epoch, tick, price band, fee cap and margin rule; it also pins the batch to the latest accepted oracle priceSequence.
  6. Confirm. Only receipt-confirmed fills become the tape (L) and are pushed to WebSocket subscribers. Until then the API reports the order as matched, never confirmed.

Deposits, withdrawals, hard revocation (OrdersV2.advanceAccountEpoch) and direct OrdersV2.cancel go straight from the wallet to the chain; the matcher learns about them by polling PerpetualV2 events (ChainIngester, 500 ms) and re-checking account state on every submission.

Price path

Price pipeline

The design separates four prices: I (independent index), M (bounded mark, ±0.5 % of I), E (actual fill) and L (last confirmed fill). Risk uses M; funding notional uses I; the tape uses L. The matcher samples its own book into an EMA mark (mark-sampler.ts) and serves an authenticated snapshot of its depth to the oracle (/v2/mark-evidence), but it cannot push a price on chain: only a payload two of the three committee signers independently reproduced and signed is accepted. Details and current limits are in Data & methodology.

What is implemented versus what is designed

The normative design is docs/spec/V2_ARCHITECTURE.md. The code above implements its main shapes (single-writer engine, binary WAL, packed settleBatch, threshold verifier, epoch revocation, independent signer services). It is deployed and verified on Robinhood Chain (4663) with USDG collateral: the shared stack (MarketRegistryV2, TrionPriceVerifierV2, FundingEpochsV2, RiskV2, FixingCouncilV2) and the CMPT perp modules are in overdrive/deployments/v2/4663.json; the CMPT option stack activates at the time listed on the status page and is recorded in the verified 4663.options.json written by the finalizer. The CMPT perpetual is deployed but not listed, so the live product is CMPT capped options only. GRID, DRAM, NAND, HASH and DPIN have no contracts on 4663, and TOKN derivatives are disabled by construction in the deploy scripts. The 4663.*.dryrun.json files are pre-cutover simulations kept as history; they are not consumed by any loader. Local development uses a throwaway chain 31337 with a valueless test token (see Local development).

Guards that the code now enforces

Known limits at launch

Source trail: docs/spec/V2_ARCHITECTURE.md §§1, 3.5, 4; overdrive/deployments/v2/4663.json, 4663.perps.json; overdrive/deployments/v2/reviewed/4663.cmpt-options-approval.md (markSource: "index"); overdrive/exchange/matcher/src/main.ts (marketStateLoader), server.ts (/v2/mark-evidence, /v1/oracle/*), config.ts, canonical-prices.ts, index-feed.ts, mark-evidence.ts; overdrive/exchange/core/src/deployments.ts (parseVerification, loadV2DeploymentsFromDisk), v2-bindings.ts; overdrive/exchange/core/scripts/finalize-perps-v2.ts, finalize-options-v2.ts; overdrive/exchange/oracle/src/publisher.ts, signer.ts, v2-runtime.ts; overdrive/exchange/web/src/v2-config.ts, wallet.ts, pages/options.ts, pages/liquidity.ts; overdrive/deployments/v2/README.md.

Repository-owned documentation · September 2026 · Educational material, not investment advice and not an audit.