Sequence/docs

MM 3-Layer Stack

Sequence MM is now organized into three public layers so clients can build with normal Rust tooling and no central-coordinator internals.


Layer Model

LayerCratePurpose
1algo-sdkStrategy ABI (Algo, Actions, L2Book, AlgoState)
2mm-typesShared MM schemas (MmConfig, MmRiskLimits, MmHeartbeat)
3mm-control-clientTyped REST client for /v1/mm/* and /v1/agent/*

Template crates:

  • mm-algo-template: WASM MM strategy starter
  • mm-agent-template: Native MM agent starter

What Changed

Before:

  • MM config types were duplicated across strategy and agent code
  • API payloads used weakly typed config values
  • Edge MM control handlers were partial/stubbed

Now:

  • One canonical MM schema layer (mm-types)
  • Typed client methods for deploy/adjust/halt/status/agent endpoints
  • Working runtime config injection and heartbeat-driven status

Canonical Types

MmConfig

MmConfig is the canonical strategy config:

  • #[repr(C)], 56-byte layout for WASM boundary
  • JSON serde for REST use
  • Alias normalization for legacy names:
    • spread_bps -> min_spread_bps
    • size_1e8 -> quote_size_1e8
    • order_ttl_ms -> max_order_age_ms
    • skew_factor -> max_skew_ratio

Validation rules:

  • num_levels in 1..=5
  • min_spread_bps > 0
  • quote_size_1e8 > 0
  • max_position_1e8 > 0

MmRiskLimits

Canonical risk limits shared by REST control and edge deploy:

  • max_position_1e8 > 0
  • max_order_notional_1e9 > 0
  • max_order_rate > 0

MmHeartbeat

Unified heartbeat model for status and regime detection, including enriched fields like:

  • realized_volatility_bps_1min
  • trend_bps_1min
  • top_level_spread_bps
  • quote_fill_ratio_bps

Client Flow

Typical deployment/control flow:

  1. Build strategy from mm-algo-template to WASM.
  2. Deploy via MmControlClient::deploy(...) with typed config/risk.
  3. Monitor via status() and features().
  4. Adjust in place via adjust_config(...).
  5. Halt with halt(...) if needed.

Minimal usage:

rust
use mm_control_client::MmControlClient;
use mm_types::{MmConfig, MmRiskLimits};
 
let cc = MmControlClient::new("https://api.sequencemkts.com", "seq_live_...");
 
let cfg = MmConfig::default();
let risk = MmRiskLimits::default();
 
// Deploy
let wasm_bytes: Vec<u8> = std::fs::read("algo_btc_usd.wasm")?;
let deployed = cc.deploy("kraken", "BTC-USD", &wasm_bytes, cfg, risk).await?;
 
// Adjust config
let mut next = cfg;
next.version += 1;
cc.adjust_config(&deployed.algo_id, next).await?;

Migration Guide

LegacyNew
mm-algo-coremm-algo-template
mm-agentmm-agent-template
Local duplicated config structsmm_types::MmConfig
Ad-hoc REST wrappersmm_control_client::MmControlClient

Current status:

  • mm-algo-core and mm-agent remain available for transition
  • New development should target template crates

Runtime Behavior Changes

The MM runtime path now enforces stricter behavior:

  • Invalid/malformed order types are rejected rather than guessed
  • Risk-rejected actions are neutralized before OMS submission
  • MM status config_version reflects injected config version from runtime