# MNX documentation MNX is a publicly available derivatives exchange on MegaETH. It offers perpetual swaps on equities, exchange-traded funds, crypto, commodities, and compute; numeric futures, including company valuations; and binary prediction markets. Orders are matched off-chain, with collateral held in smart contracts and trades settled on MegaETH. These docs cover exchange mechanics, contract specifications, trading guides, and the public API. Use testnet for development. Production uses real funds. ## Platform mechanics - The API market types are perpetual, future (numeric futures, including valuation futures), and binary_future. Perpetuals have no expiry; numeric and binary futures settle under each market's published terms. Binary outcomes normally resolve to 0 or 1, with tie or partial outcomes where the terms provide them. A zero resolution currently settles at 1 wei (10^-18 in the market's quoted price units) for both numeric and binary futures; see the market specifications. - Positions use isolated margin in USDM: each market position has its own collateral. Read market-specific leverage, tick size, quantity step, order-size limits, price bands, and fees from GET /v0/markets in the environment you trade in. - Matching uses a Frequent Batch Auction, roughly every 200 milliseconds by default. Each batch has one uniform clearing price. Better-priced orders have priority, and allocation at the last price level that trades is pro rata (in proportion to remaining size), with rounding rules described in the order guide. - Some new markets without an outside price open with an opening auction (auction_end and opened_at in the market config): the market lists at a price the exchange chose, and before the close only limit orders inside a collar around it are accepted (409 pre_open or auction_price_outside_collar otherwise, and 409 auction_book_full past 2,000 orders) while the book is sealed; from the close new orders and API cancels are refused for up to 24 hours (409 auction_closed) and the book route publishes the result set at the close (price, matched quantity, imbalance, outcome), which the exchange plans again if orders are cancelled before the opening batch trades (revised_at); the oracle then moves to that price and the opening batch fills every crossing order at exactly that price. A held result may instead be extended into a later auction. - Oracle prices govern margin checks, liquidation eligibility, and price bands. Mark prices govern displayed unrealized profit and loss and conditional-order triggers. Numeric and binary futures use oracles derived from internal order books before settlement; read the oracle methodology for each market's sources, limits, and exceptions. - Funding applies only to perpetuals, during each market's funding_session. Equity funding follows the relevant trading session; markets with continuous references can fund around the clock. Numeric and binary futures have no periodic funding payments. ## How MNX works - [Markets and margin](/guides/markets-and-margin) — market types, prices, collateral, funding, liquidation, and risk controls - [Placing orders](/guides/placing-orders) — uniform-price batch auctions, sizing, order types, reduce-only orders, take-profit and stop-loss protection, lifecycle, fills, retries, and cancellation - [Trading fees](/guides/fees) — standard fee defaults and how fees appear on fills: - Makers: 0% for perpetuals, numeric/valuation futures, and binary futures. - Perpetual takers: 5 basis points (0.05%) of fill notional (price × quantity). - Numeric/valuation futures takers: 20 basis points (0.20%) of fill notional. - Binary futures takers: fee in USDM = quantity × c × p × (1 − p), with standard coefficient c = 0.02 and fill price p between 0 and 1. This is not a flat 2% notional fee. At p = 0.10 ($0.10 or 10%), 10% × 90% × 2% = 0.18% of the $1 payout, or $0.0018 per contract ($1.80 for 1,000 contracts). At p = 0.50, 1,000 contracts cost 5 USDM. - Read the current maker_fee/taker_fee and exact *_fee_e18_raw parameters from GET /v0/markets for the environment you trade in. Interpret them using the market type: notional rates for perpetual/future, coefficients for binary_future. Market-specific settings and fee-free periods can differ; per-market contract values govern. The fee and fee_e18_raw fields on fills report actual charges. - Trading fees apply to fills, including closes; placement and cancellation have no trading fee. MNX charges no deposit fee. Relayed withdrawals carry a separate fee: read withdrawal_fee_e18_raw from GET /v0/account/withdraw/config. On-chain transactions you send yourself require gas. ## Contract specifications - Market specifications: [mainnet](https://docs.mnx.fi/contracts/market-specs) and [testnet](https://docs.testnet.mnx.fi/contracts/market-specs) — contract terms for markets listed in each environment; GET /v0/markets on the corresponding API returns the listed markets - [Oracle methodology](/contracts/oracle-methodology) — price-source ladders, foreign-exchange conversion, cadence, staleness, and delayed-feed risks - [AI Council Resolution](/contracts/ai-council-resolution) — resolve a market using the median numerical answer from three top AI models, with at most one per organization - [Valuation futures](/contracts/valuation-futures) — settlement rules for the OPENAI, ANTHROPIC, DEEPSEEK, and MOONSHOT valuation futures - [Equity perpetual corporate actions](/contracts/equity-perp-corporate-actions) — treatment of splits, dividends, trading halts, acquisitions, and delistings ## API guides and reference - [Bot quickstart, plain Markdown](/guides/bot-quickstart.md) — complete zero-to-order guide with runnable Node.js source; preferred for AI agents and terminal clients - [Bot quickstart, HTML](/guides/bot-quickstart) — the same testnet guide rendered as a page: browser account setup, API key, faucet, MarginBank deposit, EIP-712 typed order signing, verification, and cleanup; or signing up from code with one wallet signature, a trading key and signed tokens, and switching a leaked key off - [Getting started](/guides/getting-started) — base URLs, response shapes, request limits, exact raw integers, public wallet portfolios, and read-after-write bookmarks - [Authentication and signing](/guides/authentication) — signing up from code, signed tokens and their exact texts, API keys, Privy identity tokens, delegated trading keys with their lifetimes and switch-off, and the exact EIP-712 order struct, flag packing, integer scaling, and signature suffix - [Builder codes](/guides/builder-codes) — how an app earns a share of the trading fee on the orders it places: registration by MNX, the optional builder field on order placement, earnings on the fee the chain charged (a trader's active referral takes the fill instead), public builder terms and totals, and payouts - [WebSockets](/guides/websockets) — real-time market and account updates, subscription authorization, snapshots, additive order-book deltas, and reconnect recovery - [API reference](/reference) — rendered public API reference - [OpenAPI 3.1 JSON](/openapi-public.json) — machine-readable public API specification Testnet documentation is at https://docs.testnet.mnx.fi. Testnet can run a newer release and a different market list; use the reference and market parameters for your target environment. ## Security - [Security audits](/security/audits) — independent audit reports, including the Centennial Systems smart contract audit PDF and its reviewed scope; historical findings and responses do not attest to current deployment or remediation - [Security bug bounty](/security/bug-bounty) — scope, eligibility, exclusions, and rewards from $5,000 to $100,000 for qualifying financial impacts or unauthorized access to production. Availability issues qualify only under the policy's rules for blocked withdrawals or lasting losses. Report privately by email with the report in the message body; attachments are never opened. Theft or permanent freezing of liquidity-vault principal and vault insolvency are critical impacts; the vault is currently closed to external depositors. - [Mainnet scope inventory](/security/mainnet-scope.json) — dated shared-contract and vault-account inventory with block number, deployed code hashes, and proxy implementations; market contracts are in scope by rule; read the policy for scope rules - [Known-issue commitments](/security/known-issues-hashes.json) — salted SHA-256 commitments to published entries of the private known-issues register, with a dated change history; the policy explains how to verify an entry when a report is rejected as known - [Public smart contract source](https://github.com/mnx-markets/contracts) — Solidity source and reproducible builds; its README maps builds to mainnet contracts ## Legal - [Terms of Service](/terms) — MNX Markets mainnet terms - [Testnet Terms of Service](/testnet-terms) — MNX Markets testnet terms - [Privacy Policy](/privacy) — MNX Markets privacy policy ## Public endpoints - Testnet API: https://api.testnet.mnx.fi - Testnet MegaETH JSON-RPC: https://carrot.megaeth.com/rpc - Testnet chain ID: 6343 - Production API (mainnet, real funds; use only deliberately): https://api.app.mnx.fi - Production chain ID: 4326 (MegaETH mainnet) - Public REST paths begin with /v0/. WebSockets use /ws on the same API host: wss://api.testnet.mnx.fi/ws or wss://api.app.mnx.fi/ws. - Successful REST responses are the documented JSON object or array directly, without a wrapper envelope. Respect request limits and Retry-After delays; see the getting-started guide for JSON API errors and HTML errors from the edge rate limiter. - Shareable wallet portfolios intentionally use unauthenticated read-only routes for wallet-to-public-profile lookup, margin totals, enriched current positions, realized profit and loss, and historical portfolio snapshots. See [Public wallet portfolios](/guides/getting-started#public-wallet-portfolios) for the exact endpoints and public/private boundary. Per-user orders and fills, withdrawals, and private WebSocket account topics still require authentication. ## Order lifecycle and client consistency - POST /v0/orders accepts an order into the book; it does not confirm a fill. Its fills array is empty at placement. Follow the order's fills and terminal status rather than assuming an accepted order executed. - Market orders are immediate-or-cancel at their auction attempt. Limit orders can rest until filled, cancelled, or expired. Post-only and fill-or-kill orders, and immediate-or-cancel limit orders, are unsupported. After a batch abort, wait for the order's own outcome before replacing it: some market orders get one retry, and triggered take-profit/stop-loss legs and reduce-only stop-market orders return to the book. - Use POST /v0/orders/estimate before signing to size by dollars, available margin, Max, or a percentage of a position. Placement accepts quantity or exact quantity_e18_raw, not sizing intents or USD budgets. For binary sells, TARGET_VALUE counts contracts closing a long at price and contracts opening a short at 1 minus price; TARGET_NOTIONAL always uses quantity times price. - Reduce-only orders cannot open or grow a position. Take-profit and stop-loss orders are always reduce-only and trigger on the mark price. The order guide covers protection for a whole position and bracket legs attached to an entry order. - A cancel cannot undo quantity already matched by a sealed batch. A cancel response with status cancel_pending_finalize removes only the unmatched rest; matched quantity can still settle. Read the final order status and fills, even after a successful cancel request. - Single-order retries reuse the same signed order. Bulk placement (up to 50 orders) and bulk cancellation (up to 100 hashes) require a client_request_id on every request; reuse the same value when retrying that request. Cancellations need request authentication, with no separate cancellation signature. See the order guide for retry retention windows, is_duplicate, and terminal-order behavior. - Reads can trail accepted writes. Pass returned read_after.shard_id and read_after.shard_seq as read_after_shard_id and read_after_shard_seq on GET routes that support them. For order-book WebSocket updates, subscribe first, obtain subscription_read_after, fetch a snapshot at that floor, and apply only buffered deltas newer than the snapshot response's own read_after. Resubscribe and rebuild from snapshots after reconnecting; follow the WebSocket guide's deduplication, depth, and refresh rules. ## Bot requirements that are easy to miss 1. Complete browser account setup and API-key creation first. Send `Authorization: Key ` for bot HTTP requests or `Authorization: Bearer ` for browser requests. An EIP-712 signature from the owner wallet or a registered trading session key separately authorizes each order. Private WebSocket subscriptions carry the credential in the SUBSCRIBE message's authorization field; a handshake header alone does not authenticate them. Rotating or revoking an API key closes the WebSocket connections it authenticated (close code 4401, reason api_key_revoked); reconnect and subscribe with the new key. 2. POST /v0/testnet/faucet sends test USDM and testnet gas to the wallet; it takes the API key, a Privy session or the wallet's own token. It does not deposit collateral into the exchange. 3. Fetch addresses from GET /v0/contracts/shared, then call collateral-token approve and MarginBank depositToBank. 4. Wait for GET /v0/balance/:user_id/margin to reflect the confirmed chain deposit before placing an order. 5. Fields ending in _e18_raw are exact integer strings scaled by 10^18. Use arbitrary-precision integers, never floating point, for signing and exact arithmetic. Keep human-readable request values numerically identical; if both quantity and quantity_e18_raw are sent, they must match exactly. 6. Use the target chain ID and the market's trader_address as the EIP-712 verifyingContract. Order-signature v2 includes uint8 triggerCondition and domain version 2.0. Append one byte to the 65-byte signature that matches how you signed: 00 after signTypedData, or 01 after signing the typed-data hash's 32 bytes as a personal message with signMessage. A mismatched pair fails verification. Send JSON signature_type: 1 either way. Trading-key registration is different: sign its forward request with signTypedData and append nothing. 7. Sign and send the same salt and future expiration_seconds. Expiry is mandatory, measured against the exchange clock: at most 30 days ahead for TAKE_PROFIT_* and STOP_LOSS_* types, and 14 days for every other order type, including STOP_MARKET, STOP_LIMIT, and other reduce-only orders. Every order expires; there is no good-til-cancelled order. 8. Respect tick size, quantity step, and market limits. Orders without reduce_only must meet the $5 minimum order value, including ordinary closing orders; binary sells use quantity times (1 minus price). Reduce-only orders are exempt from the $5 minimum. The order guide explains the remaining size rules and exact full-close exception. 9. Verify the returned order_id/order_hash. Cancel any resting test order, handle cancel_pending_finalize, and confirm a terminal status with no active order remaining. Never use a production private key or real funds in a test bot.