Monaco Protocol SDK v0.5.5
Batch Cancel Orders & Order Status Simplification
This release introduces batch order cancellation for efficient multi-order management and simplifies order statuses by removing deprecated intermediate states.New Features
Batch Cancel Orders
Cancel multiple orders in a single API call, or cancel all active orders at once. Core SDK:- New Method:
sdk.trading.batchCancelOrders()for cancelling multiple orders efficiently - Cancel All: Use
{ cancelAll: true }to cancel all active orders for the user - Detailed Results: Returns individual success/failure status for each order
- Emergency position exit (cancel all orders instantly)
- Bulk order management for market makers
- Portfolio rebalancing with clean slate
- Efficient cleanup of stale orders
Real-time Order Tracking
Track all your orders in real-time with the newuseUserOrders React hook. Automatically syncs with WebSocket for instant order updates.
React SDK:
- New Hook:
useUserOrders()for real-time order tracking - Automatic Sync: Fetches initial orders via REST, then subscribes to WebSocket updates
- Smart Deduplication: Merges REST and WebSocket data without duplicates
- Manual Refresh: Built-in
refresh()function for on-demand updates
- Real-time order status updates (placed, filled, cancelled, etc.)
- Automatic state management with configurable history limit
- Authentication-aware (requires valid JWT token)
- Built-in error handling and retry support
Breaking Changes
Order Status Simplification
ThePENDING and ACKNOWLEDGED order statuses have been removed from the API. Orders now transition directly to SUBMITTED status.
What Changed:
PENDING or ACKNOWLEDGED statuses, update your code:
- Simplifies order lifecycle
- Reduces intermediate states that caused confusion
- Improves consistency across REST and WebSocket APIs
- Orders now have a cleaner state machine
Breaking Change: vault.getBalance() Deprecated
Thevault.getBalance() method has been deprecated and no longer functions. Use the Profile API for balance queries instead.
What Changed:
- Profile API provides more detailed balance information (available, locked, total)
- Consolidates balance queries with other profile data
- Improves performance with backend optimizations
- Simplifies SDK architecture by removing duplicate functionality
sdk.vault.getBalance(assetId) with sdk.profile.getUserBalanceByAssetId(assetId):
Breaking Change: TypeScript Type Updates
Several TypeScript interfaces have been updated for better consistency and to expose raw balance fields. These are breaking changes if you’re using TypeScript.GetUserBalancesResponse: Pagination Field Renamed
What Changed:
AccountBalance: New Required Fields
What Changed:
asset_id- Asset UUID for API operationsavailable_balance_raw- Available balance in raw format (wei/smallest unit)locked_balance_raw- Locked balance in raw format (wei/smallest unit)
- Enables precise balance calculations without floating-point errors
- Provides asset_id for direct use in deposit/withdraw operations
- Matches backend API response structure
LedgerMovement: Extended Metadata
What Changed:
The LedgerMovement interface has been extended with additional fields:
- More accurate representation of on-ledger movements
- Aligns with WebSocket event payloads
- Provides raw values for precise calculations
MarketMetadata: Nullable Fields
What Changed:
MarketMetadata fields are now nullable to reflect API behavior for markets without trade history:
MarketMetadata fields:
- Accurately represents markets that haven’t had any trades yet
- Prevents displaying misleading zero or undefined values
- Matches actual API response behavior
API Reference
New Endpoint:POST /api/v1/orders/batch-cancel- Cancel multiple orders in a single request
cancel_all(boolean) - Set totrueto cancel all active orders
Upgrade Instructions
- Update your dependencies:
-
Update balance queries:
- Replace
sdk.vault.getBalance(assetId)withsdk.profile.getUserBalanceByAssetId(assetId) - Update response handling to use new balance structure (available_balance, locked_balance, total_balance)
- See Account Vault for examples
- Replace
-
Update order status checks:
- Remove checks for
PENDINGstatus - Remove checks for
ACKNOWLEDGEDstatus - Use
SUBMITTEDas the initial active order state
- Remove checks for
-
Consider using batch cancel:
- Replace loops calling
cancelOrder()withbatchCancelOrders() - Use
cancelAll: truefor emergency exits
- Replace loops calling
-
Handle nullable MarketMetadata fields:
- Add null checks when accessing
last_price,high_24h,low_24h, etc. - Markets without trade history will return
nullfor these fields
- Add null checks when accessing
-
Test your flows:
- Verify balance queries work correctly
- Verify order status transitions work correctly
- Test batch cancellation with multiple orders
- Test handling of new markets with no trade history
For complete documentation, see Order Management.

