> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lean.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Funding

> How money reaches each venue, and the one deposit route to avoid.

Each venue keeps its own balance: USDC in Hyperliquid spot, pUSD on Polymarket, and USD on Kalshi
and Polymarket US. `GET /v1/balances` shows them all. Lean routes an order to the venues that can
pay for it, so fund the venues you want orders to reach.

Deposits and withdrawals through Lean cover Polymarket and Hyperliquid only. Live
[transfers](https://docs.lean.xyz/transfers.md) move cash between Polymarket, Hyperliquid and Lighter. Fund your Kalshi
and Polymarket US accounts on those venues directly.

`GET /v1/balances` and `GET /v1/positions` cover Kalshi, Polymarket, Polymarket US and
Hyperliquid. Cash moved to Lighter and Lighter positions don't appear there; check them in the
Lean app.

A test key needs no funding. It trades against simulated balances. See
[Test mode and live mode](https://docs.lean.xyz/test-mode.md).

## Deposit through Lean's addresses only

Send funds only to the deposit addresses Lean gives the trading account. Each address bridges into
the right balance for you:

| Venue | Route | Lands as |
| - | - | - |
| Hyperliquid | Relay | USDC in Hyperliquid spot |
| Polymarket | Polymarket bridge | pUSD on Polygon |

The accepted tokens differ by chain and venue.
[List deposit assets](https://docs.lean.xyz/api-reference/deposits/list-deposit-assets.md) returns every chain and token
each venue accepts right now, with the minimum for each. The Polymarket bridge sets a minimum
deposit per asset, and a deposit below it may not be credited. Relay publishes no fixed minimum for Hyperliquid deposits, and neither does a pUSD
transfer straight to the Polymarket wallet.

> [!WARNING]
>
> Never send funds to Hyperliquid's own bridge. A deposit there lands in Hyperliquid perps, not in
> spot where Lean's orders trade, so it is not available to the API.

## Network fees

A deposit is an ordinary token transfer: the sender pays that network's usual fee. After that, you
need no gas. Hyperliquid orders are signed actions with no gas, and Polymarket actions are paid for
by Polymarket's relayer.

## Deposits through the API

* [List deposit assets](https://docs.lean.xyz/api-reference/deposits/list-deposit-assets.md) shows the chains and tokens
  each venue accepts. `min_deposit_usd` is the route's minimum, or `null` when the route
  publishes none.
* [Get deposit addresses](https://docs.lean.xyz/api-reference/deposits/list-deposit-addresses.md) returns your addresses,
  and [Create deposit addresses](https://docs.lean.xyz/api-reference/deposits/create-deposit-addresses.md) creates any
  that are missing. Creating is idempotent.
* [List deposits](https://docs.lean.xyz/api-reference/deposits/list-deposits.md) shows the latest deposits to your
  addresses on a venue, newest first, with each one's `status`: `detected` once the funds reach
  the address, `processing` while they move, then `completed` when the venue is credited,
  `failed`, or `refunded` to the sender. It lists deposits that go through Relay or the Polymarket
  bridge. pUSD sent straight to your Polymarket wallet is credited at once and is not listed. A
  test key reads an empty list.
* [Get balances](https://docs.lean.xyz/api-reference/account/list-balances.md) shows funds once they arrive.

## Withdrawals through the API

A key can withdraw only when it was created for it. Create the key in the Lean app under
Settings, API keys, or with [Create an API key](https://docs.lean.xyz/api-reference/api-keys/create-api-key.md), and send:

* `scopes` with `withdraw`. A key without it is refused with `403 FORBIDDEN`. The `withdraw` scope
  is separate from `trade`, so a key that trades cannot withdraw unless you add it.
* `maxWithdrawalMicros`, the largest single withdrawal, and `dailyWithdrawalLimitMicros`, the total
  the key may withdraw in any rolling 24 hours. Both are optional and in millionths of a dollar.
  Leave one out for no limit of that kind. When you set both, the daily limit must be at least the
  single one.

A withdrawal names where the money comes from, where it goes and how much moves:

* `source` is the venue and the asset held there.
* `destination` is the chain, the asset and the address paid.
* `amount` is how much of the source asset leaves the venue.

Each venue pays out USDC, on any of the chains the Lean app withdraws to:

| `source` | `destination` asset |
| - | - |
| `polymarket`, `pusd` | `usdc` |
| `hyperliquid`, `usdc` | `usdc` |

`destination.chain` is one of `polygon`, `arbitrum`, `base`, `optimism`, `ethereum`, `bsc` or
`solana`. The address must suit the chain: a `0x` address for every chain except `solana`, which
takes a Solana address. Any other pair, or an address the chain cannot take, is refused with
`400 VALIDATION_ERROR`, and the message says what is supported.

A live withdrawal sends real funds:

* The venue's fee comes out of the amount. The response gives `fee` and `net_amount`, the amount the
  destination is quoted to receive. Both come from the venue's quote when the withdrawal is made,
  so the amount that arrives can differ slightly.
* The account must have trading enabled. Creating a live key that can trade or withdraw in the
  Lean app enables it for the whole account, so there is nothing else to switch on. If it isn't
  enabled, the withdrawal is refused with `403 FORBIDDEN` and `details.reason`
  `ACCOUNT_NOT_DELEGATED`.
* Pausing trading for the key or its account also pauses its withdrawals. A paused key's withdrawal
  is refused with `503 FEATURE_DISABLED` and `details.reason` `TRADING_PAUSED`.
* Each withdrawal is submitted to the venue once. It starts `pending` and becomes `completed` once
  the venue pays it, or `failed` when the venue refuses it. A failed withdrawal pays nothing, even
  though it still shows the quoted `fee` and `net_amount`, and `failure_reason` says why. Read it back with
  [Get a withdrawal](https://docs.lean.xyz/api-reference/withdrawals/retrieve-withdrawal.md) to follow it.
* A Polymarket withdrawal is `completed` once the pUSD has left the account for Polymarket's
  bridge. The bridge then pays the USDC on the chain you named, usually within a few minutes, so
  check the destination before relying on the funds. A Hyperliquid withdrawal is `completed` once
  the USDC has arrived on the chain you named.
* A Hyperliquid withdrawal waits for any other transfer on the account to finish. That includes
  another withdrawal, a live transfer and a transfer started in the Lean app. While one is in
  progress, a new withdrawal is refused with `409 CONFLICT` and `details.reason`
  `WITHDRAWAL_IN_PROGRESS`.

A test withdrawal takes simulated cash from a venue's test balance, moves no real funds, charges no
fee and is `completed` at once.

```bash theme={"dark"}
curl -sS -X POST "$LEAN_API_URL/v1/withdrawals" \
  -H "Authorization: Bearer $LEAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source": { "venue": "polymarket", "asset": "pusd" },
    "destination": {
      "chain": "polygon",
      "asset": "usdc",
      "address": "<the address to pay>"
    },
    "amount": "25",
    "client_withdrawal_id": "payout-2026-11-10"
  }'
```

The response echoes `source`, `destination` and `amount`, and adds `fee`, `net_amount`, `status`
and `failure_reason`. [Get a withdrawal](https://docs.lean.xyz/api-reference/withdrawals/retrieve-withdrawal.md) and
[List withdrawals](https://docs.lean.xyz/api-reference/withdrawals/list-withdrawals.md) return the same fields.

* `client_withdrawal_id` makes the call safe to repeat. Sending the same request again returns the
  first withdrawal and takes nothing more. Reusing the ID with a different venue, amount or
  destination is refused with `409 CONFLICT`, and `details.withdrawal_id` names the first one.
  While trading is paused, a repeat is refused with `503 FEATURE_DISABLED` like a new withdrawal.
  Read the first one with [Get a withdrawal](https://docs.lean.xyz/api-reference/withdrawals/retrieve-withdrawal.md) or
  [List withdrawals](https://docs.lean.xyz/api-reference/withdrawals/list-withdrawals.md) instead.
* A withdrawal over the key's single limit, over its daily limit or over the venue's available cash
  is refused with `422 VALIDATION_ERROR`. See [Errors](https://docs.lean.xyz/errors.md#details-reason-on-422).
* [List withdrawals](https://docs.lean.xyz/api-reference/withdrawals/list-withdrawals.md) shows the account's withdrawals
  in the key's mode, newest first, with `next_cursor` for the next page and an optional `venue`
  filter. [Get a withdrawal](https://docs.lean.xyz/api-reference/withdrawals/retrieve-withdrawal.md) reads one by `id`.
* [Reset test mode](https://docs.lean.xyz/api-reference/test-mode/reset-test-mode.md) deletes the test withdrawals and
  gives their cash back.

## Convert USDC to pUSD

Polymarket trades only with pUSD. USDC or USDC.e sent straight to the account's Polymarket wallet,
instead of through a deposit address, sits there without counting as cash until it is converted.

* [Get convertible balances](https://docs.lean.xyz/api-reference/account/get-convertible-balances.md) shows the `usdc`
  and `usdc_e` waiting in the wallet.
* [Convert to pUSD](https://docs.lean.xyz/api-reference/account/convert-to-pusd.md) converts the whole balance of one
  `source_asset`, `usdc` or `usdc_e`, into the same amount of pUSD. It needs the trade scope.

```bash theme={"dark"}
curl -sS -X POST "$LEAN_API_URL/v1/conversions" \
  -H "Authorization: Bearer $LEAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "source_asset": "usdc_e" }'
```

The response has `venue`, `source_asset`, `amount_usd`, `status`, `transaction_id`,
`failure_reason` and `livemode`.

* USDC.e converts in one transaction: `settled` once it confirms, `submitted` while it is on its
  way. USDC goes through Polymarket's bridge, so it is always `submitted` and its pUSD shows in
  [Get balances](https://docs.lean.xyz/api-reference/account/list-balances.md) a few minutes later.
* `failed` converted nothing, and `failure_reason` says why.
* The bridge has a minimum for USDC. A smaller balance is refused with `422 VALIDATION_ERROR` and
  `details.reason` `BELOW_MINIMUM`, and the message names the minimum.
* An empty balance is refused with `422 VALIDATION_ERROR` and `details.reason`
  `NOTHING_TO_CONVERT`. One conversion runs at a time per account; another sent while one is
  settling is refused with `409 CONFLICT` and `details.reason` `CONVERSION_IN_PROGRESS`.
* A live conversion needs trading enabled for the account in the Lean app, and is refused with
  `403 FORBIDDEN` and `details.reason` `ACCOUNT_NOT_DELEGATED` otherwise. It follows the trading
  pause and the key's allowed venues.
* When Lean cannot reach Polymarket's relayer, a conversion is refused with `503 FEATURE_DISABLED`
  and no `details.reason`, and nothing is submitted. Try again later.
* A test key's cash is always pUSD, so it reads zero for both and a conversion is refused with
  `NOTHING_TO_CONVERT`.

## Using funds on either venue

You don't need to move funds between venues. Lean routes each order to the best venue, and when
the cash is on the other venue, `POST /v1/orders` moves it and buys in the same call. See
[Paying from the other venue](https://docs.lean.xyz/orders.md#paying-from-the-other-venue). To sign that payment yourself,
see [Advanced: self-signed routed orders](https://docs.lean.xyz/routed-orders.md).

To move cash between your own venues without an order, use [Transfers](https://docs.lean.xyz/transfers.md). They work with
test keys and live keys.

Shares can't move between venues. A sell is placed on the venues that hold the shares.


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