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

# V1.0.3

# Monaco Protocol SDK v1.0.3

This release adds closed position execution history, conditional cross liquidation prices across positions and risk simulations, and fixes vault withdrawal early-return and fee-tier volume unit reporting.

## Added

### Closed position execution history

`positions.listPositionHistory` now accepts an optional `reductionOnly` parameter. When set to `true`, the response includes only reductions, closes, and liquidations — filtering out opens, partial fills, funding, and margin-change events.

Each reduction row now carries immutable per-execution close facts computed by the backend:

| Field | Type | Description |
| - | - | - |
| `entryPrice` | string | Position's average entry price at the time of close |
| `allocatedInitialMargin` | string | Initial margin committed to the position when it was opened |
| `fundingPaid` | string | Cumulative funding charges paid over the position's life |
| `netRealizedPnl` | string | Realized PnL net of fees and funding at close |
| `realizedRoe` | string | Return on equity (net PnL ÷ allocated initial margin) |
| `positionSide` | string | `"LONG"` or `"SHORT"` |

Use `executionPrice` (the fill price at close) rather than `markPrice` when calculating realized returns. The backend computes `netRealizedPnl` and `realizedRoe` for you — no mark-price approximation needed.

```typescript theme={null}
const history = await sdk.positions.listPositionHistory({
  positionId,
  reductionOnly: true,
});

for (const event of history.events) {
  console.log(`Closed at ${event.price}, net PnL: ${event.netRealizedPnl}, ROE: ${event.realizedRoe}`);
}
```

## Changed

### Conditional cross liquidation prices

Positions and risk simulations now expose liquidation price estimates for cross-margin positions.

**Positions** — `listPositions`, `getPosition`, and `getPositionRisk` return `liquidationPrice` for all positions including cross. For cross positions the value is **conditional**: only the target position's mark moves while all other marks in the same cross risk bucket are held fixed. Other position marks, funding, realized PnL, fees/reserves, and collateral can all change the actual liquidation threshold. An absent or blank value means unavailable — never zero.

**Risk simulations** — `simulateOrderRisk`, `simulateParentMarginOrderRisk`, and `simulateRiskBucketOrderRisk` now return:

* `freeCollateralAfter`: string — projected free collateral after the simulated fill
* `estimatedLiquidationPrice?`: string — conditional per-position estimate for the target position; same conditional semantics as above

Cross simulations with `marginMode: "CROSS"` require `selectedTradingPairIds`. All three simulation endpoints accept an optional `reduceOnly` boolean that restricts the simulation to shrinking an existing exposure.

```typescript theme={null}
const sim = await sdk.positions.simulateRiskBucketOrderRisk({
  marginMode: "CROSS",
  selectedTradingPairIds: [tradingPairId],
  side: "LONG",
  positionSide: "LONG",
  orderType: "LIMIT",
  price: "50000",
  quantity: "0.1",
  leverage: "10",
});

console.log(`Free collateral after: ${sim.freeCollateralAfter}`);
if (sim.estimatedLiquidationPrice) {
  console.log(`Conditional liq price: ${sim.estimatedLiquidationPrice}`);
}
```

## Fixed

### `vault.withdraw` with `autoWait: false` returned too late

`vault.withdraw(assetId, amount, false)` previously blocked for up to 5 minutes polling for the merkle proof before returning. The proof is never ready at initiation time — so the wallet signing prompt was never shown and the balance appeared stuck.

`vault.withdraw(..., false)` now returns immediately after the withdrawal is registered:

```typescript theme={null}
const { withdrawalIndex, status } = await sdk.vault.withdraw(assetId, amount, false);
// status === 'awaiting_proof'

// Later, once the proof is confirmed (poll or webhook):
await sdk.vault.retryWithdrawal(withdrawalIndex);
```

Use `retryWithdrawal(withdrawalIndex)` to complete the on-chain submission once the merkle proof is available. The `withdrawalIndex` is stable across retries.

### `fees.getMyFeeTier` volume fields now in whole USD

`getMyFeeTier` previously returned `weightedVolume14d`, `spotVolume14d`, and `perpVolume14d` in raw on-chain micro-USDC units (10⁶× too large), which caused every user to resolve to a higher fee tier than their actual 14-day volume warranted.

All three fields now return whole-USD values — e.g. `"5000000"` means $5 M, not $5. Fee tier resolution is now correct.

## Upgrade

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

All changes are additive or fixes — no existing field names, endpoint paths, or authentication requirements changed.


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