Skip to main content

Monaco Protocol SDK v1.1.0

This release removes the never-implemented GTD time in force, sends only spot balances on the balances WebSocket channel, has margin order admission top a risk bucket up to its initial margin, judges an order’s leverage bracket and open-interest cap together with the risk bucket’s other resting orders on the same side, keeps a batch replace’s originals resting when the parent margin account cannot fund the replacements, and leaves your quotes in place when a fill-or-kill order is killed. Action items: replace any "GTD" time in force with "GTC" and expirationDate; read margin collateral from the account channel, not from balances.

Breaking

GTD is removed from TimeInForce

"GTD" is removed from the TimeInForce union in @0xmonaco/types, and TimeInForce::Gtd from the Rust gRPC SDK. In the protos, TIME_IN_FORCE_GTD is gone and value 4 and its name are reserved. GTD was never implemented and every order carrying it was rejected, so no working order changes: only code that names the value stops compiling. For an order that expires at a set time, send "GTC" with expirationDate (TimeInForce::Gtc with expiration_date in Rust). A request that still sends "GTD" is rejected with 400 Invalid timeInForce: Time in force must be GTC, IOC, or FOK. See Trading.

Changed

Margin admission tops a risk bucket up to its initial margin

On a risk bucket below its initial margin, an order that leaves an order opening a position on it, itself or one already resting, draws that gap from the parent margin account together with its own requirement, so the risk bucket lands at its initial margin. When the parent margin account cannot fund both, the order is refused if it adds to what the risk bucket requires, and goes through without the draw if it adds nothing, such as a replace to a smaller order or a flip no larger than the position. An order that only closes is never refused for margin, unless it leaves another resting order opening a position the parent margin account cannot fund. availableOrderCollateral on such a risk bucket is the parent headroom less the gap. Once only closes rest in a risk bucket, the whole automatic draw returns to the parent margin account, and a transfer-out through a risk bucket can take the draw its orders no longer need in one step. No request or response shape changed. See Order lifecycle and Perps collateral.

Leverage brackets and open-interest caps count your resting orders

Whether an order opens a position, the leverage bracket it is checked against and the open-interest cap now count the risk bucket’s other resting orders on the same side of the pair, which fill one after another: a flip or an add split across several orders is judged as one order of the same total. The leverage bracket values the projected position at the mark price. An order that opens nothing always passes the market caps, reduce-only or not. See Perpetual Futures.

A batch replace keeps its originals on a margin refusal

When every replacement in a batch replace is a resting perps limit order on one margin account, and none would cross the book once the batch’s own originals leave it, each risk bucket’s replacements are judged together before any original is cancelled, as one replace of that risk bucket’s orders. When the parent margin account cannot fund what they add, every item in that risk bucket reports the insufficient-initial-margin rejection and every original keeps resting. Any other batch places item by item, as before. See Order lifecycle.

Fixed

The balances channel carries spot balances only

Every balance_update on the balances channel (sdk.ws.balances) now holds one spot balance row: available, locked and total, their raw forms, and the row’s version when the producer stamps one. A deposit routed into margin collateral, a perpetual fill and its fee or rebate, a funding settlement, a liquidation and an auto-deleveraging close send no balance_update. Before, these sent frames whose total was the margin collateral, or for a margin deposit the deposited amount, under the collateral token, so a client applying them overwrote its spot balance with a margin figure. Read margin collateral and equity from the account channel (sdk.ws.account), which carries it with a subscribe-time snapshot. useUserBalances in @0xmonaco/react now keeps the spot balance. margin_deposit, funding, liquidation and adl stay in BalanceUpdateReason so existing code that names them compiles, but the server does not send them. The event shape is unchanged. See WebSockets.

A killed fill-or-kill order leaves your quotes

Under the CANCEL_MAKER self-trade prevention mode, a fill-or-kill order is checked against third-party depth only, and your own orders in its fill path are cancelled only if it fills. Before, those orders were cancelled first and stayed cancelled when the order was killed. See Self-trade prevention.

Upgrade