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
| Layer | Crate | Purpose |
|---|---|---|
| 1 | algo-sdk | Strategy ABI (Algo, Actions, L2Book, AlgoState) |
| 2 | mm-types | Shared MM schemas (MmConfig, MmRiskLimits, MmHeartbeat) |
| 3 | mm-control-client | Typed REST client for /v1/mm/* and /v1/agent/* |
Template crates:
mm-algo-template: WASM MM strategy startermm-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_bpssize_1e8->quote_size_1e8order_ttl_ms->max_order_age_msskew_factor->max_skew_ratio
Validation rules:
num_levelsin1..=5min_spread_bps > 0quote_size_1e8 > 0max_position_1e8 > 0
MmRiskLimits
Canonical risk limits shared by REST control and edge deploy:
max_position_1e8 > 0max_order_notional_1e9 > 0max_order_rate > 0
MmHeartbeat
Unified heartbeat model for status and regime detection, including enriched fields like:
realized_volatility_bps_1mintrend_bps_1mintop_level_spread_bpsquote_fill_ratio_bps
Client Flow
Typical deployment/control flow:
- Build strategy from
mm-algo-templateto WASM. - Deploy via
MmControlClient::deploy(...)with typed config/risk. - Monitor via
status()andfeatures(). - Adjust in place via
adjust_config(...). - 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
| Legacy | New |
|---|---|
mm-algo-core | mm-algo-template |
mm-agent | mm-agent-template |
| Local duplicated config structs | mm_types::MmConfig |
| Ad-hoc REST wrappers | mm_control_client::MmControlClient |
Current status:
mm-algo-coreandmm-agentremain 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_versionreflects injected config version from runtime