> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/account-and-funds.md).

# Account & funds

Setup, deposit, delegation, and the withdrawal endpoints.

Setup and funds movement. These submit to your **Solana RPC**. Simple builders return `{ "transactionBase64": "…" }`; withdrawal/settlement builders add a `receipt` PDA to poll. Shared conventions: [Conventions](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/conventions.md). Background: [Funds lifecycle](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/concepts/funds-lifecycle.md).

| Method | Path                                                                                                   |
| ------ | ------------------------------------------------------------------------------------------------------ |
| `POST` | `/transaction-builder/deposit` · `/deposit-direct`                                                     |
| `POST` | `/transaction-builder/init-basket` · `/init-deposit-ledger`                                            |
| `POST` | `/transaction-builder/delegate-basket`                                                                 |
| `POST` | `/transaction-builder/withdraw` · `/custody-settlement` · `/withdrawal-settle` · `/request-withdrawal` |

***

## Deposit

`POST /transaction-builder/deposit`

One-shot deposit that conditionally bundles any missing setup (basket, deposit ledger, delegation, trade vault).

| Field         | Type   | Req | Description                              |
| ------------- | ------ | --- | ---------------------------------------- |
| `owner`       | string | ✓   | Owner wallet pubkey (signer / fee payer) |
| `tokenSymbol` | string | ✓   | Token to deposit (e.g. `USDC`, `SOL`)    |
| `amount`      | string | ✓   | Amount, UI units                         |

***

## Deposit (direct) <a href="#deposit-direct" id="deposit-direct"></a>

`POST /transaction-builder/deposit-direct`

Lower-level deposit — no bundled setup. Source ATA and token program are derived from the mint; native SOL is wrapped automatically.

| Field          | Type   | Req | Description                                              |
| -------------- | ------ | --- | -------------------------------------------------------- |
| `owner`        | string | ✓   | Deposit destination                                      |
| `fundingOwner` | string | —   | Funding wallet (signer / fee payer). Defaults to `owner` |
| `tokenMint`    | string | ✓   | SPL mint to deposit                                      |
| `amount`       | string | ✓   | Amount, UI units                                         |

***

## Init basket / deposit ledger

`POST /transaction-builder/init-basket` — creates the owner's Basket PDA. `POST /transaction-builder/init-deposit-ledger` — creates the owner's deposit-ledger PDA.

Both take `{ "owner": "…", "payer"?: "…" }` (`payer` defaults to `owner`) → `{ "transactionBase64": "…" }`.

***

## Delegate basket

`POST /transaction-builder/delegate-basket`

Delegates the basket so it can be traded (one-time per wallet). `{ "owner": "…", "payer"?: "…" }` (`payer` defaults to `owner`) → `{ "transactionBase64": "…" }`.

***

## Withdraw

`POST /transaction-builder/withdraw`

Single-call withdrawal. The client supplies a fee payer that **must differ from `owner`** and co-signs the returned transaction with both keys. Task walkthrough: [Withdraw funds](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/withdraw-funds.md).

| Field                   | Type   | Req | Description                                                   |
| ----------------------- | ------ | --- | ------------------------------------------------------------- |
| `owner`                 | string | ✓   | Owner wallet pubkey                                           |
| `tokenSymbol`           | string | ✓   | Token to withdraw (e.g. `USDC`, `SOL`)                        |
| `amount`                | string | ✓   | Amount, UI units                                              |
| `feePayer`              | string | ✓   | Client-owned fee payer. **Must differ from `owner`**          |
| `feePayerTopUpLamports` | number | —   | Optional `owner → feePayer` top-up (lamports) for escrow rent |

**Response** — `WithdrawResponseDto`

| Field                       | Description                                              |
| --------------------------- | -------------------------------------------------------- |
| `transactionBase64`         | Unsigned tx — client co-signs owner + fee-payer slots    |
| `receipt`                   | Withdrawal-escrow receipt PDA to poll for completion     |
| `custodySettlementRequired` | `true` → call `custody-settlement` first, then retry     |
| `isNativeSol`               | `true` → released funds arrive as WSOL; unwrap afterward |

***

## Custody settlement

`POST /transaction-builder/custody-settlement`

Settles a custody's trade vault ahead of a withdrawal it can't otherwise cover. Call when `withdraw` returns `custodySettlementRequired: true`, then retry.

`{ "owner": "…", "tokenSymbol": "USDC" }` → `{ "transactionBase64": "…", "receipt": "…" }`.

***

## Withdrawal settle

`POST /transaction-builder/withdrawal-settle`

Resumes/finalizes a pending withdrawal that didn't complete automatically.

`{ "owner": "…", "tokenMint": "…" }` → `{ "transactionBase64": "…" }`.

***

## Request withdrawal

`POST /transaction-builder/request-withdrawal`

Lower-level request step — locks `amount` of `tokenMint` and delegates it for automatic release. Like `withdraw`, needs a `feePayer` distinct from `owner`.

`{ "owner", "tokenMint", "amount", "feePayer" }` → `{ "transactionBase64": "…", "receipt": "…" }`.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/account-and-funds.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
