> For the complete documentation index, see [llms.txt](https://ocx.gitbook.io/ocx-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ocx.gitbook.io/ocx-doc/ocx/api/wallet.md).

# wallet

Query balances, transfer between buckets, and initiate withdrawals.

## GET /wallet/balance

Returns your balances across all buckets.

**Auth**: required.

**Response**

```json
{
  "onchainDepositTotal":    "1000.00",
  "tradableBalance":        "980.00",
  "walletBalance":          "500.00",
  "perpsBalance":           "300.00",
  "optionsBalance":         "180.00",
  "pendingWithdrawalTotal": "20.00"
}
```

| Field                    | Meaning                                          |
| ------------------------ | ------------------------------------------------ |
| `onchainDepositTotal`    | Cumulative deposits credited on-chain.           |
| `tradableBalance`        | Total funds available for trading or withdrawal. |
| `walletBalance`          | Idle funds in the `wallet` bucket.               |
| `perpsBalance`           | Collateral in the `perps` bucket.                |
| `optionsBalance`         | Collateral in the `options` bucket.              |
| `pendingWithdrawalTotal` | Funds locked for an in-flight withdrawal.        |

## GET /wallet/assets

Per-asset breakdown of your spot inventory (available + locked).

**Auth**: required.

**Response**

```json
[
  {
    "asset":     "USDC",
    "bucket":    "spot",
    "available": "100.00",
    "locked":    "5.00",
    "total":     "105.00"
  }
]
```

## POST /wallet/transfer

Move funds between buckets. Instant, no fee.

**Auth**: required (session, JWT, or `trade`-scoped API key).

**Request**

```json
{
  "from":   "wallet",
  "to":     "perps",
  "amount": "100"
}
```

`from` and `to` are one of `wallet | perps | options | spot`. They must differ.

**Response**

```json
{
  "walletBalance":  "400.00",
  "perpsBalance":   "400.00",
  "optionsBalance": "180.00"
}
```

**Errors**

| Status | `code`                 | When                           |
| ------ | ---------------------- | ------------------------------ |
| 400    | `INVALID_AMOUNT`       | Amount ≤ 0 or malformed        |
| 400    | `SAME_BUCKET`          | `from == to`                   |
| 422    | `INSUFFICIENT_BALANCE` | Source bucket lacks the amount |

## POST /wallet/withdraw

Submit a withdrawal request. Funds are withdrawn to the wallet you signed in with.

**Auth**: required (session, JWT, or `trade`-scoped API key).

**Request**

```json
{ "amount": "100" }
```

**Response**

```json
{ "withdrawalId": "01HW..." }
```

**Errors**

| Status | `code`                 | When                                       |
| ------ | ---------------------- | ------------------------------------------ |
| 400    | `INVALID_AMOUNT`       | Amount ≤ 0 or malformed                    |
| 422    | `INSUFFICIENT_BALANCE` | `tradableBalance` doesn't cover the amount |

## GET /wallet/history

Recent ledger entries. Default 100 most recent.

**Auth**: required.

**Response**

```json
[
  {
    "id":        "01HW...",
    "type":      "deposit",
    "amount":    "100.00",
    "txHash":    "0x...",
    "createdAt": "2026-04-24T12:00:00Z"
  }
]
```

`type` values: `deposit`, `withdraw`, `trade`, `pnl`, `fee`, `transfer`.

## GET /wallet/settlements

Deposit and withdrawal settlements with processing status.

**Auth**: required.

**Query**

| Parameter | Type                                                                                  | Description      |
| --------- | ------------------------------------------------------------------------------------- | ---------------- |
| `kind`    | `deposit` / `withdraw`                                                                | Filter by kind   |
| `status`  | `pending` / `processing` / `sent` / `confirmed` / `failed` / `insufficient_liquidity` | Filter by status |
| `limit`   | number (1–200, default 100)                                                           | Max rows         |

**Response**

```json
[
  {
    "id":             "01HW...",
    "kind":           "withdraw",
    "status":         "sent",
    "asset":          "USDC",
    "amount":         "100.00",
    "txHash":         "0x...",
    "withdrawalId":   "01HW...",
    "walletAddress":  "0xYourAddress",
    "network":        "base-sepolia",
    "chainId":        84532,
    "error":          null,
    "metadata":       {},
    "settledAt":      "2026-04-24T12:05:00Z",
    "createdAt":      "2026-04-24T12:04:00Z",
    "updatedAt":      "2026-04-24T12:05:00Z"
  }
]
```

## GET /wallet/settlements/:id

Fetch a single settlement by ID.

**Auth**: required.

**Response**: same shape as a single item in `/wallet/settlements`.

**Errors**

| Status | When                                        |
| ------ | ------------------------------------------- |
| 404    | Settlement not found or not owned by caller |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ocx.gitbook.io/ocx-doc/ocx/api/wallet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
