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

# Monaco Protocol SDK v0.7.8

## Withdrawal Flow

The withdrawal flow has been updated to use a pre-signed calldata path through
the backend. `sdk.vault.withdraw()` now posts to `/api/v1/withdrawals` to receive
gateway-signed calldata and a `withdrawalIndex`, then submits the transaction
on-chain via the wallet client.

### Return type change

`withdraw()` now returns `WithdrawResult` instead of `TransactionResult`:

```typescript theme={null}
interface WithdrawResult extends TransactionResult {
  withdrawalIndex: number;
}
```

Store `withdrawalIndex` — you need it to retry a failed submission.

### New method: `retryWithdrawal`

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

// If the on-chain submission fails or is dropped, retry without
// allocating a new withdrawal slot:
await sdk.vault.retryWithdrawal(withdrawalIndex);
```

`retryWithdrawal` fetches the same gateway-signed calldata originally issued for
that index and resubmits it. Safe to call multiple times — the matching engine
is idempotent against duplicate submissions of a settled withdrawal.

### Migration

```diff theme={null}
- const result = await sdk.vault.withdraw(assetId, amount);
- console.log(result.hash);
+ const result = await sdk.vault.withdraw(assetId, amount);
+ console.log(result.hash);
+ console.log(result.withdrawalIndex); // new — store for retry
```

If you only use `hash` or `status` from the return value, no code change is
required. The new `withdrawalIndex` field is additive.

***

## Position Endpoints — `position_id` Body Rejection

The API gateway now rejects unknown fields in JSON request bodies. As a result,
`position_id` is no longer accepted in the body of:

* `POST /api/v1/positions/{id}/close`
* `POST /api/v1/positions/{id}/add-margin`
* `POST /api/v1/positions/{id}/reduce-margin`

The position ID must be in the URL path only. **SDK callers are unaffected** —
the TypeScript SDK has always derived the path from the `positionId` argument
and never included it in the body.

**If you call these endpoints directly over HTTP**, remove `position_id` from the
request body:

```diff theme={null}
// close
- POST /api/v1/positions/{id}/close
- { "position_id": "...", "close_type": "MARKET" }
+ POST /api/v1/positions/{id}/close
+ { "close_type": "MARKET" }

// add margin
- POST /api/v1/positions/{id}/add-margin
- { "position_id": "...", "amount": "200", "asset": "USDC" }
+ POST /api/v1/positions/{id}/add-margin
+ { "amount": "200", "asset": "USDC" }

// reduce margin
- POST /api/v1/positions/{id}/reduce-margin
- { "position_id": "...", "amount": "100" }
+ POST /api/v1/positions/{id}/reduce-margin
+ { "amount": "100" }
```

***

## Upgrade

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


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