Architecture overview
How Phasis is structured — on-chain Move core, Rust keeper layer, TypeScript SDK, and Next.js frontend, and how they interact.
Phasis is a fully on-chain options exchange built on Sui. The protocol is composed of five distinct layers, each with a well-defined responsibility. Nothing in the keeper or frontend layer is trusted for settlement correctness; all critical logic lives in Move.
On-chain Move core
Two Sui packages form the protocol foundation.
option_deepbook is the primary package. It contains:
user_entry— user-facing transaction entries: deposit, withdraw, place order, cancel order, close position.auth_entry— keeper and admin entries: halt market, publish settle price, settle positions, liquidate accounts, list markets and series.margin.move— the portfolio-margin stress computation (see Margin model).trading.move— order routing, fill reconciliation, fee accrual.settlement.move— intrinsic-value payout logic at expiry.
DeepBook v3 is vendored inside the package so the matching engine is co-located with the risk model — there are no cross-package trust boundaries at settlement.
Rust keeper layer
Four long-running Rust services operate the market lifecycle. They hold no privileged secrets beyond a signer keypair; any operation they perform can also be called by an alternative keeper.
| Service | Role |
|---|---|
| stress-publisher | Polls Pyth Lazer for spot prices, computes the Black–Scholes stress grid across N price scenarios, and publishes a StressSnapshot shared object on-chain roughly every 30 seconds. |
| cranker | Drives the market state machine: halts trading at the halt window, publishes the Pyth EMA settle price, iterates through user positions to pay out intrinsic value, and retires series slots for reuse. |
| liquidator | Event-driven keeper. Bootstraps a mirror of all account states, then subscribes to MarginRecomputed, Deposited, Withdrew, and StressSnapshotUpdated events. Submits liquidation PTBs when an account's free balance falls below its locked-margin requirement. |
| market-maker | Manages the Phasis LP vault. Places two-sided quotes continuously based on the current stress snapshot and cranks LP deposit/redemption requests. |
All keeper writes are Programmable Transaction Blocks (PTBs) submitted via gRPC. No JSON-RPC.
TypeScript SDK
@phasis-lab/sdk exposes a generated layer (BCS schemas and transaction builders from Move ABIs) plus a hand-authored convenience layer for reading registry state, building trade transactions, querying the orderbook, and computing margin locally.
The SDK communicates exclusively via SuiGrpcClient for reads and PTB submission. A pageEventsBackward helper fetches recent events in reverse-chronological order from Sui's GraphQL endpoint, avoiding the ascending-page starvation that affects high-throughput event streams.
Next.js frontend
The web terminal at phasis.vercel.app is a Next.js 16.2 app (React 19, App Router). Key routes:
/trade/[market]— the core trading terminal (option chain, order form, positions widget)./account— deposit, withdraw, and fee history./portfolio— portfolio margin summary and Greek aggregates./lp— Phasis LP vault: deposit/withdraw/NAV chart.
State is managed via TanStack Query. All data hooks branch on NEXT_PUBLIC_USE_MOCK so the real SDK can be toggled in without changing component code.
Data flow
User wallet
│
├─ Read path → SDK (gRPC) → Sui fullnode
│
└─ Write path → SDK (PTB) → dApp Kit (sign) → gRPC submit
Keeper daemons
├─ Event subscription → Sui GraphQL
└─ PTB submit → gRPCAll persistent state — open positions, account balances, margin locks, order books — lives in Sui shared objects. The frontend and keepers are stateless readers and signers.