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

# Monaco Protocol SDK v1.0.34

This is an additive release — no breaking changes. It adds custom (vanity) PitPass TraderCodes across the REST, gRPC, TypeScript, React, and MCP surfaces, so a wallet can claim a human-readable handle instead of only the wallet-derived default. It also exposes lifetime cost fields (`exitPrice`, `fundingPaid`, `feesPaid`) on terminal position rows, and hardens the MCP server so long-running agents keep their session alive and start cleanly on Node 18. Existing code keeps working unchanged; the new custom-handle methods and fields are opt-in.

## Added

### Custom (vanity) PitPass TraderCodes

A wallet can now claim a custom handle for its TraderCode instead of using only the wallet-derived default. Three new methods land across every client:

* `setTraderCode(code)` (`PUT /api/v1/pitpass/codes/me/custom`; gRPC `TraderCodeService.SetTraderCode`) — claim or edit your handle. The handle is stored exactly as entered (casing preserved), must be letter-first `[A-Za-z0-9_]` and 5–20 characters, and is validated client-side before sending; the server remains the authoritative gate. Rejections map to `409` (handle taken case-insensitively, or a recently-freed handle still in cooldown), `422` (validation, carrying a stable reason code), `429` (edit rate-limit), and `403` (the feature is disabled). Authenticated.
* `clearTraderCode()` (`DELETE /api/v1/pitpass/codes/me/custom`; gRPC `TraderCodeService.ClearTraderCode`) — drop the custom handle and revert to the wallet-derived default. Clearing also counts against the rolling-hour edit limit, so it can return `429` (rate-limited) or `403` (feature disabled). Authenticated.
* `checkTraderCodeAvailability(code)` (`GET /api/v1/pitpass/codes/available`; gRPC `TraderCodeService.CheckTraderCodeAvailability`) — a public advisory check that returns `available`, and when unavailable a `reason` (`taken`, `too_short`, `too_long`, `reserved`, `invalid_char`, or `looks_like_address`). It is rate-limited per client and returns `429` once a caller exceeds the allowance; use it to give live feedback in a claim form, not as the authoritative gate.

`getMyTraderCode()` now returns three additive fields alongside `code`: `customCode` (the handle as entered, or an empty string when the default is kept), `isCustom` (whether a custom handle is set), and `display` (the string to show users). React clients gain matching hooks — `useMyTraderCode`, `useSetTraderCode`, `useClearTraderCode`, and `useTraderCodeAvailability` — and MCP clients gain the `set_trader_code`, `clear_trader_code`, and `check_trader_code_availability` tools. See [TraderCodes](/developers/tradercodes) and the [TypeScript TraderCodes SDK](/sdk/typescript/tradercodes).

### Lifetime cost fields on terminal positions

Terminal position rows (`CLOSED`, `LIQUIDATED`, `EXPIRED`) returned by `getPositions` / `getPosition` (REST `GET /api/v1/positions`, `GET /api/v1/positions/{positionId}`; gRPC `PositionsService.ListPositions` / `GetPosition`) now carry three optional fields:

* `exitPrice` (gRPC `exit_price`) — volume-weighted average price across the position's reducing executions, so a position closed over several fills reports its true blended exit rather than the last fill or the mark at close.
* `fundingPaid` (gRPC `funding_paid`) — lifetime funding paid, summed over the position's reducing executions (signed; negative means received).
* `feesPaid` (gRPC `fees_paid`) — closing-side trading fees paid (signed; negative means rebated); fees on opening fills are not included.

All three are omitted when the position's reducing executions do not cover its whole lifetime; there is no stored substitute for them (the terminal `markPrice` still carries the settled per-row exit). Open rows are unchanged. See [Positions](/sdk/typescript/positions).

## Fixed

### MCP server keeps its session alive

The MCP server now maintains its own Monaco session, so a long-running unattended agent no longer starts failing with `401`s once the session expires. `ensureAuthenticated` is expiry-aware: it refreshes the session — falling back to a fresh login if the session is dead — when the session is expired or within 60 seconds of expiry, rather than only logging in when no session exists. Idempotent read tools are additionally wrapped so a single auth-expired response triggers exactly one recovery and retry; order-placement and fund-movement tools are deliberately never auto-retried, so a whole-handler rerun can never double-execute a mutation. Concurrent calls share a single in-flight login/refresh instead of stampeding the auth service, and re-auth reuses the configured network, capability profile, and `clientId`. Unauthenticated servers (no private key) are unchanged and never attempt a login.

### MCP server starts cleanly on Node 18

Node 18 does not expose the WebCrypto global (`globalThis.crypto`) to script files, so `@0xmonaco/core`'s session-key generation threw "Secure randomness (crypto.getRandomValues) is unavailable" on the first authenticated call when the server was launched via `npx`/`node` on Node 18. The bin now polyfills WebCrypto from `node:crypto` when the global is missing or partial (Node ≥19 and Bun natives are left untouched), so authenticated tools work across every supported Node version.

## Upgrade

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

The MCP server ships at `1.0.34` too; it runs via `npx -y @0xmonaco/mcp-server`, so restarting your assistant picks up the new version, the session keep-alive, and the Node 18 fix.

Nothing in this release is breaking. If you show TraderCodes in your UI, switch from rendering `code` directly to `display`, and read `isCustom` / `customCode` to reflect a claimed handle.


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