Monaco Protocol SDK v1.0.85
Error responses expose their stable code on the newAPIError.serverCode, and a deactivated account is refused with ACCOUNT_DEACTIVATED. Account frames add initial margin, withdrawable collateral and realized PnL, and order snapshot rows report origin. Risk-engine money now sits on the 6-decimal USDC grid, a margin limit order resting through the mark is charged as if it filled at the mark, and a perp limit order past the price band is rejected instead of resting. Action items: branch on serverCode / the WebSocket error code (for example ACCOUNT_DEACTIVATED), not on message text; keep margin transfer and allocation amounts to 6 decimal places and order prices at or below 100,000,000 per unit.
Added
APIError.serverCode
APIError.serverCode returns the REST error envelope’s code (for example ACCOUNT_DEACTIVATED or POST_ONLY_WOULD_CROSS), or undefined when there is none. Branch on it instead of the message. See Error Handling.
Initial margin, withdrawable collateral and realized PnL on account frames
sdk.ws.account frames and account snapshot rows may carry initialMarginRequired, withdrawableCollateral and realizedPnl (decimal strings), equal to the margin account’s fields of the same names. withdrawableCollateral is rounded toward zero at 6 decimal places. Absent means unknown, never zero, and the SDK rejects a frame whose present value is not a non-empty string. See WebSockets.
origin on order snapshot rows
Each orders snapshot row (OrderSnapshotItem) may carry origin (USER, LIQUIDATION, ADL, COPY or SYSTEM), as getOrder reports it, and every order event now carries it, USER included. useUserOrders takes origin from snapshot rows and every order frame: a frame fills in a row’s missing origin but never replaces one it holds. See useUserOrders.
React login takes options
useAuth().login(options) now forwards its options to sdk.login, so connectWebSocket: true also works from React. See useAuth.
Changed
Money on the USDC grid
Every stored USD amount in the risk engine — collateral, risk bucket allocations and draws, realized PnL, funding paid, margin requirements and order costs — is a whole number of 0.000001 USD. A publishedwithdrawableCollateral or availableOrderCollateral is exactly what its endpoint accepts, and funding settles zero-sum. Amounts with more than 6 decimals are now refused, with the message <field> exceeds supported precision for USDC (6 decimals), in these cases:
- a margin transfer between accounts, a copy-trading allocation, or a spot-margin collateral transfer of a USDC variant
- an order’s
riskBucketCollateral - a margin order on a market whose quote asset has more than 6 decimals
Margin through the mark
A margin limit order resting through the mark (a sell below the mark, or a buy above it) is charged at admission as if it filled now: its initial margin at the mark, plus the loss it would take against the mark, plus its maker fee. A sell below the mark was previously under-reserved, and a buy above it over-reserved.availableOrderCollateral and the automatic draw from the parent margin account follow the same rule. An order on its safe side of the mark is unchanged. See Perps.
Perp price band at entry
A perp limit order priced past the band on its aggressive side (a buy above the upper edge, or a sell below the lower edge) is now rejected at entry withINVALID_ORDER (“limit price is outside the price band”). This applies to every time in force, post-only orders and replacements. Deep passive prices are still allowed. A resting perp order that a mark move leaves past the band is cancelled in the same step, with terminalReason PRICE_BAND and its collateral released. See Perp price band.
Fixed
ACCOUNT_DEACTIVATED— a deactivated signing account is refused with403ACCOUNT_DEACTIVATEDon/auth/verifyand on any signed request. gRPC carries the same reason ingoogle.rpc.ErrorInfo(domainauth.0xmonaco.com). On the WebSocket, anErrorframe with codeACCOUNT_DEACTIVATEDarrives on the handshake or on revalidation, and then the socket closes. The SDK stops reconnecting and callsonReauthenticationRequired. See Session loss.- Positions snapshot serves live state — the
sdk.ws.positionssubscribe-time snapshot builds an open position from the same live state itsposition_updateframes carry, under the persisted row’sversion. A snapshot taken while persistence lagged (for example just after an hourly funding settlement) no longer replaces newer values a client already holds. On an equalversion, a snapshot row now wins on every field (it wasisolatedMarginonly). No field or wire shape changes. See Positions. - Order preview: no-fill
IOC—simulateOrderRisk,simulateParentMarginOrderRiskandsimulateRiskBucketOrderRiskreport anIOCorder that would not fill withrejectCodeINSUFFICIENT_LIQUIDITY. They previously reportedINVALID_ORDER. - Order preview: closing an isolated position flat — when that close retires the risk bucket (nothing else resting in it and no live TWAP order holding it open), the preview now reports the risk bucket as closed, with
equityAfter,initialMarginRequiredAfter,maintenanceMarginRequiredAfterandfreeCollateralAfterall"0". It previously failed. See Margin Accounts.
Upgrade
ACCOUNT_DEACTIVATED as terminal rather than retrying.
