MMashDiv

Exchange Engine 6.6.2

23 November 2026

TRADINGORDERSSTOP ORDERSOCOFEESCHARTSWITHDRAWALS

Ecosystem v6.6.2

Release Date: November 23, 2026 Tags: TRADING, ORDERS, STOP ORDERS, OCO, FEES, CHARTS, WITHDRAWALS

Overview

Fills charge fees at execution price, OCO stops retire cleanly when their limit leg closes, IOC and FOK orders settle before answering, charts answer second-precision ranges, and EVM/UTXO withdrawals protect broadcast transactions against double-refunds. Traders and auditors reported over-held fees on limit fills, stale OCO stop legs remaining armed, transient IOC/FOK responses returning before settlement, missing average fill prices, empty candlestick responses on Unix-second queries, and withdrawal edge cases around broadcast tracking and fee settings. Each fix is implemented in both the Node engine and the Rust trading/API services.

Requires Core v6.8.9 for the updated trade panel type=HISTORY consumer and pre-coercion input validation.

Update Instructions

pnpm updator

No schema change, no seeder, no .env change. The backend restarts at the end so the matching engine, Scylla queries, and withdrawal queue pick up the changes.


Added

Single-order lookup and unified Ecosystem order history

  • Added GET /api/ecosystem/order/[id] so callers and trading connectors can retrieve a single authenticated Ecosystem order by ID with computed execution cost and trade-weighted average price.
  • Added type=HISTORY, type=ALL, status alias support, and symbol=BASE/QUOTE query filtering to GET /api/ecosystem/order, combining closed, cancelled, and failed stop orders in one deduplicated list (matched by Core v6.8.9's trade panels).

Explicit stop trigger direction checks

  • Added triggerDirection validation across Ecosystem stop and OCO order placement in Node and Rust (400 on invalid values, 422 when a declared direction conflicts with the market reference price).

Changed

Execution-price maker/taker fees and limit-only residual re-basing

Buyer quote holds are sized at limit price, which can be higher than the fill's execution price. Calculating fees off the held ratio charged buyers as if they had filled at their limit price rather than the matched price, while re-basing non-limit orders risked distorting banded market-buy holds.

  • Changed fill settlement (deriveFillShare) in Node and Rust to read the market's maker/taker fee rates and compute buyer and seller fees directly from execution cost ((cost * rate) / (100 * SCALE)), clamped to the buyer's proportional fee hold and seller proceeds.
  • Changed the fallback fee calculation (when market fee rates are unavailable) to re-base LIMIT orders only, leaving MARKET buy banded-cap holds untouched.

Immediate-or-Cancel and Fill-or-Kill settlement and book exclusion

Previously, IOC and FOK orders could appear briefly in resting orderbook depth or return from placement before the matching cycle finished settling them.

  • Changed aggregated orderbook depth (restsInAggregatedBook) in Node and Rust to exclude IOC and FOK orders so transient orders never rest in book snapshots.
  • Changed IOC and FOK order placement to wait for the active matching cycle (flushOrderCycle in Node, deferred_ioc in Rust) so the HTTP response and WebSocket broadcast reflect the settled fill or cancellation state.

Average fill price persisted and backfilled on terminal orders

  • Changed match settlement and Scylla projection in Node and Rust to compute and persist the volume-weighted average fill price on each fill (including rollback restoration if a fill aborts).
  • Changed terminal filled order deserialization (descaleOrderRow in Node, eco_trading and order GET serializers in Rust) to fall back to trade-weighted average price and executed cost when average is unset on older rows.

Fixed

Empty chart history on second-precision timestamps

Testers querying GET /api/ecosystem/chart over standard Unix-second windows received [] across every range while live prices worked normally, because the candle store indexes millisecond timestamps.

  • Fixed GET /api/ecosystem/chart to trim symbol and normalize Unix-second from and to timestamps (>= 1e9 and < 1e12) to milliseconds before fetching historical candles.

OCO stop legs remaining armed after the limit leg closed

  • Fixed Ecosystem order cancellation and fill settlement (in Node stop monitors/cancel routes and in the Rust StopOrders / eco_orders gRPC service) to automatically retire an armed OCO stop sibling (OCO_SIBLING_GONE) when its target limit leg fills or cancels, and to cancel armed stops ahead of door orders in Rust cancel_all so cancelled counts remain exact.

Withdrawal fee clamping, EVM broadcast tracking, and UTXO deposit atomicity

  • Fixed calculateWithdrawalFee to treat non-finite fee settings as 0 and clamp negative percentage or minimum fee values at 0 so misconfigured fee rows cannot reduce the debited amount below zero or yield NaN.
  • Fixed EVM native and token withdrawals to store status: "PROCESSING" and trxId via an onBroadcast hook the moment the RPC accepts the transaction, retry recording move metadata safely, and escalate unknown confirmation states (WITHDRAWAL_STATUS_UNKNOWN) instead of risking a false failure refund; UTXO deposits now persist spendable ecosystemUtxo rows inside the credit database transaction and stalled unconfirmed withdrawals alert admins once after 30 minutes without re-broadcasting.