> ## 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, withdrawals and transfers through Lean cover Polymarket and Hyperliquid only. Fund your
Kalshi and Polymarket US accounts on those venues directly.

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 |

Supported assets include USDC, USDT, ETH and DAI on Polygon, Base, Arbitrum, Optimism, Ethereum,
BSC and Solana. 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.
* [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.
* Only one Hyperliquid withdrawal runs at a time for an account. Another one started before it
  settles 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.
* 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.

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

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.