> ## 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.6.1

# Monaco Protocol SDK v0.6.1

## Simulate Fees Improvements

This release improves the `/api/v1/fees/simulate` endpoint and SDK to support the 100% balance slider on the frontend and accurate fee estimation for market orders.

***

## New Features

### max\_quantity — 100% Balance Slider Support

`simulateFees()` now returns `max_quantity`: the maximum quantity the authenticated user can buy at the given price, already accounting for fees. Use this directly as the value for a 100% balance slider instead of computing `available_balance / price` (which ignores fees and causes insufficient balance errors).

```typescript theme={null}
const fees = await sdk.fees.simulateFees({
  trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
  side: "BUY",
  price: "68000.00",
  quantity: "0.001",
});

// Use max_quantity for the 100% slider value
console.log(`Max quantity you can buy: ${fees.max_quantity}`);
console.log(`Max quantity (raw units): ${fees.max_quantity_raw}`);
```

**New response fields:**

| Field | Type | Description |
| - | - | - |
| `max_quantity` | `string \| null` | Maximum affordable quantity at the given price, after fees |
| `max_quantity_raw` | `string \| null` | Same value in raw (smallest unit) format |

***

### Market Order Slippage Buffer

Pass `order_type: "MARKET"` to get a slippage-adjusted `buy_order_lock_amount`. This reflects the worst-case execution cost for a market order instead of the exact-price calculation, preventing false "affordable" signals when the actual fill price differs due to slippage.

```typescript theme={null}
// LIMIT — exact price fee calculation
const limitFees = await sdk.fees.simulateFees({
  trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
  side: "BUY",
  price: "68000.00",
  quantity: "0.001",
  order_type: "LIMIT",
});

// MARKET — includes 5% slippage buffer in buy_order_lock_amount
const marketFees = await sdk.fees.simulateFees({
  trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
  side: "BUY",
  price: "68000.00",
  quantity: "0.001",
  order_type: "MARKET",
});

console.log(`LIMIT lock:  ${limitFees.buy_order_lock_amount}`);
console.log(`MARKET lock: ${marketFees.buy_order_lock_amount}`); // higher — includes slippage
console.log(`Slippage tolerance: ${marketFees.slippage_tolerance_bps} bps`);

// Custom slippage tolerance (0–1000 bps)
const customSlippage = await sdk.fees.simulateFees({
  trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
  side: "BUY",
  price: "68000.00",
  quantity: "0.001",
  order_type: "MARKET",
  slippage_tolerance_bps: 300, // 3%
});
```

**New request params:**

| Param | Type | Description |
| - | - | - |
| `order_type` | `"LIMIT" \| "MARKET"` (optional) | Defaults to `LIMIT` behaviour if omitted |
| `slippage_tolerance_bps` | `number` (optional, 0–1000) | Only valid with `order_type: "MARKET"`. Default: `500` (5%) |

**New response field:**

| Field | Type | Description |
| - | - | - |
| `slippage_tolerance_bps` | `number \| null` | Slippage tolerance used in the calculation, echoed back. `null` for LIMIT orders |

***

## Updated Types

**`SimulateFeeParams`** (`@0xmonaco/types`):

* Added `order_type?: "LIMIT" | "MARKET"`
* Added `slippage_tolerance_bps?: number` (0–1000, MARKET only)

**`SimulateFeeResponse`** (`@0xmonaco/types`):

* Added `max_quantity: string | null`
* Added `max_quantity_raw: string | null`
* Added `slippage_tolerance_bps: number | null`

***

## Upgrade Instructions

```bash theme={null}
# NPM
npm install @0xmonaco/core@0.6.1 @0xmonaco/types@0.6.1 @0xmonaco/react@0.6.1

# Bun
bun add @0xmonaco/core@0.6.1 @0xmonaco/types@0.6.1 @0xmonaco/react@0.6.1
```

No breaking changes. All new params and response fields are optional or nullable.

***

*For complete documentation, see the [Fees API reference](https://docs.0xmonaco.com/api-reference/fees/simulate-fees-for-an-order-before-placing-it).*


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