> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xmonaco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# V0.2.0

# Monaco Protocol SDK v0.2.0

## Trading Enhancements & Real-time Data

This release introduces significant trading improvements including market order slippage protection, advanced limit order features, and real-time order event streaming via WebSocket.

### What's New

**WebSocket Real-time Data Streaming**

* **Live Order Updates**: Real-time streaming of order status changes with event types (OrderPlaced, OrderMatched, OrderPartiallyFilled, OrderFilled, OrderCancelled, OrderRejected, OrderExpired)
* **OHLCV Data Streaming**: Real-time candlestick data across 6 timeframes (1m, 5m, 15m, 1h, 4h, 1d)
* **Automatic Reconnection**: Built-in exponential backoff and connection health monitoring
* **Multiple Subscriptions**: Subscribe to events for specific trading pairs and intervals simultaneously

**Market Order Slippage Protection**

* **Slippage Tolerance**: Set maximum acceptable price deviation (0.1% to 10%)
* **Automatic Price Protection**: Orders reject if slippage exceeds specified tolerance
* **Enhanced Order Response**: Added `actual_slippage_bps` and `max_slippage_bps` to match results
* **Backend Validation**: Server-side slippage validation with configurable limits

**Limit Order Enhancements**

* **Good Till Cancel (GTC)**: Automatic 90-day default expiration for limit orders
* **Custom Expiration Dates**: Set specific expiration dates for limit orders

### Technical Details

**WebSocket Real-time Data**

Subscribe to real-time order events:

```typescript theme={null}
// Connect and subscribe to order events
await sdk.websocket.orders.connect();
sdk.websocket.orders.subscribeToOrderEvents('ETH-USD', 'SPOT', (event) => {
  console.log('Event:', event.eventType, 'Order:', event.orderId);
});
```

Subscribe to real-time OHLCV candlestick data:

```typescript theme={null}
// Connect and subscribe to 1-minute candles
await sdk.websocket.ohlcv.connect();
sdk.websocket.ohlcv.subscribeToOHLCV('ETH-USD', 'SPOT', '1m', (event) => {
  console.log('Price:', event.candlestick.c, 'Volume:', event.candlestick.v);
});
```

WebSocket features automatic reconnection, heartbeat monitoring, and JWT authentication. See [WebSocket documentation](https://docs.0xmonaco.com/websocket) and [OHLCV documentation](https://docs.0xmonaco.com/ohlcv) for complete details.

**Market Orders with Slippage Protection**

Market orders now accept an optional `slippageTolerance` parameter:

```typescript theme={null}
const order = await sdk.trading.placeMarketOrder(
  'ETH-USD',
  'BUY',
  '1.0',
  { slippageTolerance: 0.01 }  // 1% max slippage
);
```

The SDK converts decimal tolerance to basis points and sends to backend. Orders are rejected with "Slippage tolerance exceeded" error if insufficient liquidity exists within bounds.

**Limit Orders with GTC and Custom Expiration**

Limit orders now support custom expiration dates:

```typescript theme={null}
const order = await sdk.trading.placeLimitOrder(
  'ETH-USD',
  'BUY',
  '1.0',
  '2500.00',
  {
    expirationDate: '2025-12-31T23:59:59Z'  // Custom expiration
  }
);
```

Orders default to 90-day expiration if no `expirationDate` is provided.

### Packages Updated

* `@0xmonaco/core@0.2.0`
* `@0xmonaco/types@0.2.0`
* `@0xmonaco/react@0.2.0`
* `@0xmonaco/contracts@0.1.6`
* `@0xmonaco/utils@0.1.5`

### Installation

```bash theme={null}
npm install @0xmonaco/core@0.2.0
npm install @0xmonaco/react@0.2.0  # For React applications
```

### Migration Notes

This is a backward-compatible release. Existing orders continue to work unchanged:

* Market orders without `slippageTolerance` work as before, but we recommend adding slippage protection for volatile markets
* Limit orders automatically receive 90-day GTC expiration if no `expirationDate` is specified
* WebSocket is an optional feature - existing REST API usage remains unchanged

### Documentation

* [WebSocket API](https://docs.0xmonaco.com/websocket) - Real-time order events streaming
* [OHLCV Data](https://docs.0xmonaco.com/ohlcv) - Real-time candlestick data streaming
* [Order Management](https://docs.0xmonaco.com/developers/trade.md) - Market, limit, cancel, and replace order documentation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.