Monaco Protocol SDK v0.7.0
Perpetuals on Monaco
Monaco’s first-class perp surface ships with v0.7.0. The SDK gains two new top-level modules —sdk.marginAccounts and sdk.positions — plus perp helpers on sdk.market, perp options on sdk.trading, a new usePositions React hook, and a conditional_order_update WebSocket event for TP/SL lifecycle.
Spot trading is unchanged. All existing spot endpoints, hooks, and patterns continue to work as in v0.6.x.
New Features
Margin Accounts
A margin account is the reusable parent collateral account that backs isolated perp buckets. Each parent holds a single collateral asset (USDC by default) and exposes equity, margin requirements, free collateral, and unrealized PnL. New module:sdk.marginAccounts
MarginAccountSummary:
Positions
A position is the open exposure on a perp pair backed by a margin account. Thesdk.positions module covers the full lifecycle — open (via order placement), modify isolated margin, attach TP/SL, close (full or partial), inspect risk.
New module: sdk.positions
Position:
closePosition accepts { closeType: "MARKET" | "LIMIT" | "IOC" } plus optional limitPrice, quantity (for partial close), and slippageToleranceBps.
Perp options on placeLimitOrder / placeMarketOrder
Existing order placement methods now accept perp options. Spot order placement continues to work unchanged — the new options are additive.
Perp market data on sdk.market
Real-time perp metrics are available through the existing sdk.market module.
getPerpMarketConfig, getPerpMarketSummary, getMarkPrice, getIndexPrice, getFundingState, getOpenInterest, listFundingHistory.
Standalone conditional orders
In addition to attaching TP/SL throughattachPositionTpSl, conditional orders can be created standalone via sdk.trading:
"ACTIVE" | "TRIGGERING" | "TRIGGERED" | "CANCELLED" | "EXPIRED" | "FAILED".
conditional_order_update WebSocket event
TP/SL lifecycle updates stream over the existing authenticated websocket.
reason is one of "created" | "cancelled" | "triggered" | "failed" | "oco_cancelled".
React: usePositions hook
useMarket is extended with getPerpMarketConfig, getPerpMarketSummary, getMarkPrice, getIndexPrice, getFundingState, listFundingHistory, getOpenInterest.
useTrade’s placeLimitOrder and placeMarketOrder accept the same perp options shown above. useTrade also exposes createConditionalOrder, cancelConditionalOrder, listConditionalOrders.
Breaking Changes
Pagination standardized to page / page_size
limit, offset, and skip query parameters have been removed across all paginated endpoints in favor of page / page_size. total_count was renamed to total. total_pages was added to GetUserBalancesResponse.
@0xmonaco/mcp-server: the get-trades MCP tool parameters changed from skip/limit to page/page_size.
Order.trading_pair → Order.trading_pair_id
Trading-pair identifier fields have been standardized across the API.
GetPaginatedOrdersParams.trading_pair → .trading_pair_id. WebSocket events: tradingPair → symbol on order events.
Flattened response shapes (trades & market)
Thedata wrapper has been removed from trades and market responses.
PaginatedTradingPairs interface has been removed; pagination fields (page, page_size, total, total_pages) now live directly on the response.
Removed success field from response types
HTTP status codes already convey success/failure. The redundant success boolean has been dropped from:
BatchCancelOrdersResponse,BatchCancelResultBatchCreateOrdersResponse,BatchCreateResultBatchReplaceOrdersResponse,BatchReplaceResultGetTradingPairsResponse,GetTradingPairResponseGetCandlestickResponse
total_failed === 0 or inspect individual result error fields.
Close-position requests
position_id is now only accepted in the URL path, not the request body.
New Types
The following types are now exported from@0xmonaco/types:
Margin Accounts — MarginAccountSummary, ListMarginAccountsParams, ListMarginAccountsResponse, EnsureParentMarginAccountRequest, EnsureParentMarginAccountResponse, GetAvailableCollateralParams, GetAvailableCollateralResponse, TransferCollateralRequest, TransferCollateralResponse, GetMarginAccountMovementsParams, GetMarginAccountMovementsResponse, MarginAccountMovement, SimulateOrderRiskRequest, SimulateOrderRiskResponse, MarginAccountsAPI.
Positions — Position, PositionStatus, ClosePositionType, ListPositionsParams, ListPositionsResponse, GetPositionResponse, ClosePositionRequest, ClosePositionResponse, PositionRisk, AddPositionMarginRequest, ReducePositionMarginRequest, PositionMarginResponse, TpSlLeg, AttachPositionTpSlRequest, AttachPositionTpSlResponse, ListPositionHistoryParams, ListPositionHistoryResponse, PositionHistoryEvent, PositionsAPI.
Market (perp) — PerpMarketConfig, PerpMarketSummary, MarkPrice, IndexPrice, IndexComponent, FundingState, FundingRecord, ListFundingHistoryParams, ListFundingHistoryResponse, OpenInterest, RiskTier.
Conditional orders — ConditionalOrderConditionType, ConditionalOrderTriggerSource, ConditionalOrderState, CreateConditionalOrderParams, CreateConditionalOrderResponse, CancelConditionalOrderResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ConditionalOrderEvent, ConditionalOrderEventData, ConditionalOrderEventReason.
Trading — PositionSide, TradingMode. Order gains margin_account_id, position_side, leverage, reduce_only, position_id fields.
Upgrade Instructions
- Replace
limit/offset/skipwithpage/page_sizein any paginated calls. - Update field reads:
Order.trading_pair→.trading_pair_id,ProfileOrder.trading_pair→.symbol. - Update WebSocket order-event handlers reading
tradingPair→symbol. - Unwrap
datafrom market and trades responses (response.data.data→response.trading_pairs). - Drop reads of
successon batch / trading-pair / candlestick responses; checktotal_failedor HTTP status instead.
For complete documentation, see Perpetuals (perps), Perps Accounts, Positions, Margin Accounts SDK reference, and Positions SDK reference.

