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

# Monaco Protocol SDK v0.8.20

This release improves cross-margin order placement, hardens fee simulation accuracy, and fixes three correctness bugs: stale balances after spot fills, collateral not freed after a downward order replace, and an incorrect error code on unauthorized sub-account spending-limit reads.

## Changed

### Cross margin auto-resolved on order placement

`POST /api/v1/orders` and `POST /api/v1/orders/batch-create` with `marginMode: "CROSS"` now automatically provision or expand the cross risk bucket without any extra setup step:

* **No active cross bucket** — the API resolves the deterministic cross risk bucket, estimates the required order collateral, and forwards the bucket and collateral amount to matching-engine admission automatically.
* **Active cross bucket missing the requested pair** — the API adds the `tradingPairId` to the cross bucket's scope before forwarding the order.

No request or response fields changed. Existing `marginMode: "ISOLATED"` flows and cross orders placed against a fully-configured bucket are unaffected.

### Sub-account spending limit unauthorized read returns 404

`GET /api/v1/accounts/sub-accounts/{subAccountId}/limits` now returns **404 Not Found** (gRPC `NOT_FOUND`) when the sub-account belongs to a different master, instead of **403 Forbidden** (`PERMISSION_DENIED`). This matches the behavior of the create, update, and delete limit RPCs and makes an unauthorized read indistinguishable from a nonexistent sub-account. No request or response fields changed.

## Fixed

### `balances` WebSocket missing spot-fill updates

`sdk.ws.balances()` (WebSocket channel `balances`) now emits a `trade`-reason balance update to both the maker and taker when a spot order fills. Previously the channel only pushed updates on deposits, withdrawals, and collateral transfers, so live balance state went stale after spot trading. No subscription or message-shape changes; the update now arrives where it was already documented to arrive.

### `simulateFees` used flat fee rate instead of your tier rate

`sdk.trading.simulateFees` now quotes your **tier-resolved** taker fee — the rate the ledger actually debits — instead of the trading pair's flat fee column. The affected response fields are `monacoTakerFee`, `totalTakerFees`, and `takerTotalPayment`. If your account is on a tier whose rate exceeds the flat column the estimate was previously under-quoted; no request or response fields changed.

### Isolated margin replace to lower notional left collateral stale

Replacing an isolated margin order with a lower notional now immediately returns the freed collateral delta to the parent account. The following reads now reflect the correct `freeCollateral` right after the replace:

* `sdk.marginAccounts.getMarginAccountSummary`
* `sdk.marginAccounts.getParentMarginAccountSummary`
* `sdk.marginAccounts.getAvailableCollateral`

Previously the risk bucket's allocated collateral was not adjusted on replace, so `freeCollateral` stayed at its pre-replace value until the order was eventually cancelled or filled.

## Upgrade

```bash theme={null}
npm install @0xmonaco/core@0.8.20 @0xmonaco/types@0.8.20 @0xmonaco/react@0.8.20
# or bun
bun add @0xmonaco/core@0.8.20 @0xmonaco/types@0.8.20 @0xmonaco/react@0.8.20
```

This release is fully backwards-compatible — no request or response fields changed across all five fixes and improvements.


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