GO PERPETUAL FUTURES ENGINE · 25 DEDICATED SERVICES

Production Go perpetual futures
& liquidation source code.

Spot order books are easy to mock; derivatives break in production when liquidations, mark-price jitter and funding settlement collide with matching latency. The ffex Go contract domain isolates each critical invariant into 25 dedicated microservices.

01 / DERIVATIVES ARCHITECTURE

Six core engines powering perpetual futures & options

Built inside exchange/go/contract and options settlement with clear domain separation and versioned internal contracts.

01 / MATCHING

Contract Order Routing & Matcher

Separate order-api, order-router, entrust, contract-matcher and execution-router maintain deterministic price-time priority per perpetual contract.

02 / MARGIN & POSITION

Cross & Isolated Position Ledger

contract-position and position cache/sync services enforce explicit margin modes, leverage tiers and immutable balance invariants with zero float drift.

03 / MARK PRICE

Index & Mark Price Protection

contract-price computes composite index and mark prices independently from thin order-book wicks to prevent artificial liquidation cascades.

04 / FUNDING RATE

Scheduled Funding Settlement

contract-clearing-fundrate executes periodic funding settlements between long and short positions with deterministic idempotency keys.

05 / LIQUIDATION

Isolated Liquidation Engine

contract-clearing-liquidation monitors margin ratios and takes over distressed positions cleanly without starving normal user order flow.

06 / ADL & OPTIONS

Auto-Deleveraging & Options Settlement

contract-clearing-reduction handles bankruptcy tail events when insurance buffers hit limits, alongside biz options-settlement for directional contracts.

02 / DERIVATIVE SAFETY INVARIANTS

Designed for volatile markets,
not bull-market happy paths.

Every design rule below directly addresses the failure modes that bankrupt un-audited exchange clones during sharp market swings.

  1. 01

    Strict single-writer per market & position

    Order books and position ledgers never race over cross-service database locks; ordering comes from explicit single-writer event streams.

  2. 02

    Liquidation decoupled from matching goroutines

    Burst liquidation checks run in clearing-liquidation and clearing-router so cascading margin calls never stall maker order cancellations.

  3. 03

    Mark price drives unrealized PnL & triggers

    Liquidation triggers follow index-anchored mark prices rather than single shallow last-trade prints.

  4. 04

    Decimal-only precision across margin & fees

    Tick size, contract multiplier, leverage, funding fees and closing PnL execute strictly with decimal arithmetic and traceable ledger entries.

  5. 05

    Event replay & safe restart recovery

    Matcher caches, position sync and market sync reconstruct consistent state from ordered event streams after pod restarts or node replacement.

03 / GO CONTRACT SERVICES

25 Go futures services + liquidity tooling

Included in the Go CEX source license alongside spot, custody and admin modules.

Execution, Order Book & Market Data

  • contract-api, contract-order-api, contract-internal-api & contract-openapi
  • contract-order-router, contract-entrust, contract-execution-router
  • contract-matcher, contract-matcher-cache & contract-matcher-sync
  • contract-market, contract-quotation-api, contract-market-websocket & user-websocket

Clearing, Risk, Position & Pricing

  • contract-position, contract-position-cache & contract-position-sync
  • contract-price (index & mark price computation)
  • contract-clearing-router & contract-clearing-fundrate
  • contract-clearing-liquidation & contract-clearing-reduction (ADL)

Risk Monitoring & Initial Liquidity

  • risk-service & risk-monitor for pre-trade checks and exposure alerts
  • marketmaker-runner + signed contract OpenAPI for external market maker integration
  • options-settlement service supporting short-cycle directional options

PERPETUAL FUTURES FAQ

Technical questions on Go perpetual futures & risk control

Does the Go futures engine support both cross margin and isolated margin?

Yes. Margin modes, leverage caps, contract specs and clearing rules are modeled explicitly across contract-position, contract-price and clearing services, with USDT-margined and coin-margined contract flows supported.

How are liquidation spikes prevented from blocking normal user orders?

Margin evaluation, liquidation takeover and ADL reduction execute in dedicated clearing services (`contract-clearing-liquidation`, `contract-clearing-reduction`) separated from the matching hot path.

How do operators bootstrap contract order-book depth at launch?

The codebase includes `fufeng-marketmaker-runner` alongside signed OpenAPI and WebSocket gateways (`contract-openapi`, `contract-market-websocket`) so you can connect internal hedging bots or external institutional liquidity providers cleanly.

Is this available standalone or as part of the full Go CEX source code?

Derivatives are normally delivered within the unified Go CEX platform together with user center, decimal ledger, wallet custody and operations admin — or scoped under joint build if you already operate part of the stack.

BOOK A TECHNICAL DEEP DIVE

Review the Go futures & clearing architecture under NDA.

Discuss contract specs, liquidation buffers, liquidity APIs and deployment sizing directly with the engineering team.