System overview
The platform trades realized-variance perpetual contracts for MON and ETH. The order price is annualized variance. It is not the spot price of MON or ETH. Each market holds its own collateral and has its own book and funding state.
Components
| Path | Responsibility |
|---|---|
contracts/src/ | Matching, collateral, funding, margin, and liquidation |
packages/shared/src/ | ABIs, EIP-712 action definitions, and data validation |
services/src/ | Relayer, event index, HTTP API, and SSE notices |
web/src/ | Next.js terminal, portfolio page, wallet actions, and the demo page |
scripts/ | Deployment, maker quotes, taker orders, observations, and shocks |
simulation/ | Python accounting reference and economic research |
+---------------------------------+
| Web application (Next.js) |
| main wallet + session key |
+---+-------------+-----------+---+
wallet | | signed | snapshots
transactions | | actions | and history
| v v
| +---------+ +-----------------+
| | Relayer | | Indexer and API |
| +----+----+ +--------^--------+
v v | events
+----------------------------------------------------------+
| Chain |
| SessionRegistry Market (ETH) Market (MON) |
| TestUSDC TestOracle |
+------------------------------^---------------------------+
| quote + signed observation
+---------+----------+
| Test operator |
| (quote loop) |
+--------------------+The service does not match orders. Contracts decide execution and enforce risk checks. The indexer supplies event history. The terminal polls API snapshots. The API also supports SSE notices. A production database is not present. The indexer stores its state in an atomic JSON file.
Contracts
| Contract | Responsibility |
|---|---|
Market, one for each asset | Book, maker ladders, collateral, accounts, funding index, and risk checks |
QueuedMarket | A Market with an on-chain FIFO queue of IOC requests and the combined call quoteAndTake |
SessionRegistry | Market-scoped session authorization, expiry, and exposure limits |
TestOracle | The owner of this contract is the oracle signer. It can also store price records. |
TestUSDC | Test collateral with a public mint function |
The test oracle does not verify external price feeds. The MON market can use a synthetic price while native testnet MON pays transaction gas. These are different uses of the name MON.
See the contract reference for functions, events, and constants.
Data paths
| Action | Path | Wallet prompt |
|---|---|---|
| Mint test USDC, approve, deposit, withdraw | Web application to the token and the market | Yes |
| Authorize or revoke a session | Web application to SessionRegistry | Yes |
| Place or cancel an order | Session key signs EIP-712 data. POST /actions on the relayer. The relayer calls placeOrderWithSig or cancelWithSig. | No |
| Read book, trades, account, and history | HTTP API. The API reads live state from the contract and history from the index. | No |
| Move the maker quotes and submit an observation | The operator loop calls quote on each market | No (script key) |
Units
| Value | Representation |
|---|---|
| Market quote, position size, cash, funding, and margin | Integer with 18 decimals |
| TestUSDC transfer, deposit, and withdrawal amount | Integer with 6 decimals |
| Oracle price | Integer with 18 decimals |
| Maker ladder size | Integer in units of 0.01 contracts |
| Timestamp | Unix seconds |
| Large integer in JSON | Decimal string |
One contract has a multiplier of 100 USDC per annualized variance unit. The funding horizon is seven calendar days. The year basis is 365 days.
Time rules of a market
A market gets its observation interval at deployment. Two limits come from that interval:
| Value | Rule | 60-second market | 300-second market | 10-second market |
|---|---|---|---|---|
| Observation interval | Constructor input, at most 600 seconds | 60 s | 300 s | 10 s |
Gap limit (maxGap) | 3 intervals | 180 s | 900 s | 30 s |
Mark age limit (maxMarkAge) | 2 intervals | 120 s | 600 s | 20 s |
| Receipt delay limit | Fixed | 5 s | 5 s | 5 s |
The local deployment uses 60 seconds by default. The Hedging demo uses 10 seconds. The Monad testnet script uses 300 seconds.
Market states
| State | Cause | Effect |
|---|---|---|
| Observation due | The block time is at or after the next boundary | Fills wait. Orders that do not cross can rest. Cancellation stays available. |
| Mark frozen | Missing depth, one owner on a side, a wide spread, an old mark, or an oracle halt | Withdrawals and liquidations wait. Matching continues. A fill that adds exposure must pass the margin check at the last mark and at its own price. |
| Oracle halted | No accepted observation within the gap limit plus the receipt delay | New orders, withdrawals, and liquidations wait. Cancellation stays available. A new observation clears the halt. |