> For the complete documentation index, see [llms.txt](https://docs.anchored.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anchored.finance/trading-api/stock-operations/deposits-and-withdrawals.md).

# Deposits & Withdrawals

Stock endpoints move ERC-20 stock tokens between wallet balance and `Stock.stockBalance`. The API surfaces `Stock.stockBalance` as `exchangeBalance`.

Cash endpoints are separate. Use `/cash/**` only for cash-token flows into or out of `Cashier`.

## Build Stock Deposit Calldata

```
POST /api/v1/stock/deposits/calldata
```

| Field          | Type            | Required | Description                        |
| -------------- | --------------- | -------- | ---------------------------------- |
| `userAddress`  | string          | Yes      | User wallet.                       |
| `tokenAddress` | string          | Yes      | Stock token contract address.      |
| `tokenAmount`  | string / number | Yes      | Human-readable stock token amount. |

The user wallet must approve `StockRouter` for the stock token before the transaction can move wallet stock into `Stock`.

## One Click Stock Deposit

```
POST /api/v1/stock/deposits/send
```

| Field          | Type            | Required | Description                        |
| -------------- | --------------- | -------- | ---------------------------------- |
| `tokenAddress` | string          | Yes      | Stock token contract address.      |
| `tokenAmount`  | string / number | Yes      | Human-readable stock token amount. |
| `gasLimit`     | number          | No       | Optional gas limit.                |

Uses API key bound `userAddress`; do not include `userAddress` in the request body.

## Record Stock Deposit Tx

```
POST /api/v1/stock/deposits/tx
```

| Field    | Type   | Required | Description            |
| -------- | ------ | -------- | ---------------------- |
| `txHash` | string | Yes      | Stock deposit tx hash. |

## Query Stock Deposits

```
GET /api/v1/stock/deposits?page=1&limit=10
GET /api/v1/stock/deposits/{operationId}
```

## Build Stock Withdrawal Calldata

```
POST /api/v1/stock/withdrawals/calldata
```

| Field          | Type            | Required | Description                        |
| -------------- | --------------- | -------- | ---------------------------------- |
| `userAddress`  | string          | Yes      | User wallet.                       |
| `tokenAddress` | string          | Yes      | Stock token contract address.      |
| `tokenAmount`  | string / number | Yes      | Human-readable stock token amount. |

Withdrawals deduct `Stock.stockBalance` and transfer ERC-20 stock tokens to the wallet.

## One Click Stock Withdrawal

```
POST /api/v1/stock/withdrawals/send
```

| Field          | Type            | Required | Description                        |
| -------------- | --------------- | -------- | ---------------------------------- |
| `tokenAddress` | string          | Yes      | Stock token contract address.      |
| `tokenAmount`  | string / number | Yes      | Human-readable stock token amount. |
| `gasLimit`     | number          | No       | Optional gas limit.                |

Uses API key bound `userAddress`; do not include `userAddress` in the request body.

## Record Stock Withdrawal Tx

```
POST /api/v1/stock/withdrawals/tx
```

| Field    | Type   | Required | Description               |
| -------- | ------ | -------- | ------------------------- |
| `txHash` | string | Yes      | Stock withdrawal tx hash. |

## Query Stock Withdrawals

```
GET /api/v1/stock/withdrawals?page=1&limit=10
GET /api/v1/stock/withdrawals/{operationId}
```

`operationId` is an API/indexer identifier for looking up the recorded stock operation. The `Stock` contract emits deposit and withdrawal events, but those events do not include a contract-native `operationId`.


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.anchored.finance/trading-api/stock-operations/deposits-and-withdrawals.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
