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

# Clearing a wallet

> Clear a wallet with send max, the transfer API, or the withdrawal API, and see what each network leaves behind.

Anchorage Digital has no separate operation for sweeping a wallet. Every way to clear one works the same way underneath: it requests exactly the wallet's available balance and takes the network fee out of that amount. That's true of send max on a withdrawal in our apps, `POST /v2/transactions/withdrawal`, and `POST /v2/transfers`. Some networks then reach exactly zero. Others keep a small fee difference, a reserve, or both.

## How to clear a wallet

### With the transfer API

1. Read the asset's `availableBalance` from `GET /v2/wallets/{walletId}`.
2. Send that exact string as `amount`, with `deductFeeFromAmountIfSameType: true`.
3. Leave out `useGasStation`. The API rejects it combined with `deductFeeFromAmountIfSameType`, as described in [Gas station API](https://docs.anchorage.com/knowledge-base/platform/developers/gas-station-api.md#combine-with-deductfeefromamountifsametype).

`deductFeeFromAmountIfSameType` defaults to `false`. A full-balance transfer without it fails, because nothing is left to pay the fee.

Transfers need no quorum approval and run from a queue, so the fee is priced soon after your request. That matters on Bitcoin-family networks and Avalanche P-Chain, covered below.

### With the withdrawal API

The withdrawal API has no `deductFeeFromAmountIfSameType` field. Instead, the fee comes out of the amount when `amount` exactly equals the wallet's available balance at the moment the request is created. For any other amount, the fee is added on top.

1. Read the asset's `availableBalance` from `GET /v2/wallets/{walletId}`.
2. Send that exact string as `amount`.
3. Get quorum approval as usual.

If the balance changes between your read and your request, for example because a deposit lands or a hold changes, the fee is added on top and the withdrawal fails for insufficient funds. Read the balance again and resubmit. Only one withdrawal can be in flight per wallet, as described in [Crypto withdrawals](https://docs.anchorage.com/knowledge-base/platform/developers/move-money/withdraw/crypto.md).

### With send max in the apps

A send max withdrawal is processed exactly like a withdrawal API request for the full available balance. Everything in the section above applies: the fee comes out of the amount, the withdrawal needs quorum approval, and the fee is priced when the withdrawal is created, not when it's signed.

Send max has the same timing risk. If a deposit lands or a hold changes between opening the withdrawal and submitting it, the amount no longer equals the balance. The fee then goes on top, and the withdrawal fails for insufficient funds. Start the withdrawal again to pick up the new balance.

### Tokens

A token send moves the exact full token amount every way you send it, and `deductFeeFromAmountIfSameType` has no effect. The fee is paid separately in the network's native asset, so any leftover collects in the native balance, not the token balance.

## What each network leaves behind

Whether a wallet reaches zero comes down to two questions. Does the network charge exactly the fee we sign, and does it require a reserve to stay behind? We price the fee when the operation is created and don't re-price it at signing, except on Bitcoin-family networks.

Reserves are already excluded from `availableBalance`, so a full-balance send never touches them. [Network reserve requirements](https://docs.anchorage.com/knowledge-base/platform/users/network-reserves.md) lists the reserve on each network.

### Networks that reach zero

| Network | What can still go wrong |
| :- | :- |
| Cosmos chains (ATOM, OSMO, TIA, NTRN, DYDX, and others) | Staked, unbonding, and vesting funds stay |
| AR, STX | Stacking-locked STX stays |
| HYPE on HyperCore | Rounding below 0.00000001 HYPE |
| ROSE | 0.1 ROSE stays while you have an active delegation |
| AVAX P-Chain | The send fails rather than leaving dust |
| ADA | The send fails if any UTXO also holds tokens |
| BTC, LTC, DOGE, BCH | Usually exact, with the exceptions below |
| ZEC | A change output comes back more often |

**Cosmos chains** charge the full fee written into the transaction, regardless of the gas used.

**Avalanche P-Chain** charges exactly the fee in the transaction. A full-balance send fails if the wallet holds more than 256 UTXOs, stakeable-locked UTXOs, or UTXOs with more than one owner. If the gas price rises while a withdrawal waits for quorum approval, the network rejects the transaction, so a transfer is the safer choice here.

**Cardano (ADA)** reaches zero only when every UTXO holds ADA alone. ADA held in a UTXO that also carries tokens counts toward your balance but can't be spent on its own, so a full-balance request fails.

**Bitcoin-family networks** price a full-balance send when it's created and select coins again at signing. When the leftover is too small to be worth a change output, it goes to the miner fee and the wallet reaches zero. For native SegWit Bitcoin, that cutoff is roughly 680 satoshis. Two things can still leave a balance:

* **The fee rate falls sharply before signing.** The difference comes back to the wallet as change, often a few thousand satoshis. A withdrawal that waits hours for quorum approval is the likely case.
* **The wallet holds very small UTXOs.** Inputs worth less than the fee to spend them are skipped and stay in the wallet.

**Zcash (ZEC)** only sends the leftover to the fee when it's below the network's dust limit, so it keeps a change output more often than Bitcoin.

### Networks that leave a reserve

These networks charge exactly the fee we sign, so your available balance reaches zero. The protocol reserve stays in the wallet's total balance.

| Network | What stays |
| :- | :- |
| SOL, FOGO | Rent for the wallet and each token account |
| XRP | Base reserve plus 0.2 XRP per ledger object |
| DOT | 0.01 DOT existential deposit, plus small fee variance |

**Solana and Fogo** keep the wallet's rent-exempt minimum. Token accounts stay open after a token sweep, so their rent stays too.

**XRP Ledger** reserves can only be recovered by deleting the account, and Anchorage Digital doesn't support account deletion.

**Polkadot (DOT)** sends always keep the existential deposit. The fee charged can also differ slightly from the estimate in either direction.

### Networks that refund part of the fee

On these networks we sign a maximum fee, take all of it from the amount, and the network charges less. The difference returns to the wallet, so a small balance stays behind after every full-balance send.

| Network | Typical leftover per send |
| :- | :- |
| EVM networks (ETH, Base, Arbitrum, Optimism, Polygon, BNB Smart Chain, and others) | Most of the maximum fee |
| XLM | About 0.09999 XLM, plus the reserve |
| SUI | About 0.1 SUI |
| APT, MOVE | About 0.05 APT or MOVE |
| FLOW | About 0.01 FLOW, plus the reserve |
| NEAR | About 0.008 NEAR |
| TRX | 0.03 to 0.3 TRX |
| HBAR | Fractions of a cent in HBAR |
| STRK, FIL | Most of the maximum fee |

**EVM networks** price the maximum fee well above the current network fee, so transactions still confirm if fees spike. On OP Stack networks and Scroll, the layer 1 data fee estimate is also padded. The unused part is refunded to the wallet.

**Stellar (XLM)** bids a 0.1 XLM fee by default, and the network usually charges about 0.00001 XLM.

**NEAR** leaves about 0.0002 NEAR instead when the send creates the destination account.

A second full-balance send can't clear this leftover. What's left is the maximum fee minus the actual fee, so it's always smaller than the next maximum fee. A second request reserves the full maximum fee again, leaves nothing to send, and fails.

### Canton Coin

Canton Coin (CC) can't currently be sent in full. The network charges its fees on top of the amount sent, so a full-balance request fails. Leave a buffer in the wallet.

## Risks on every network

* **The balance changes before your request lands.** A late deposit, a new compliance hold, or another pending operation can change it. A transfer then fails or leaves the difference behind. A withdrawal, send max included, adds the fee on top and fails.
* **Some funds aren't in `availableBalance`.** Held, staked, unbonding, and vesting funds stay behind. See [Account hierarchy](https://docs.anchorage.com/knowledge-base/platform/developers/account-hierarchy.md) for what each balance includes.
* **Gas station is turned on for your organization.** If the gas station is enabled by default for a network, a transfer turns off `deductFeeFromAmountIfSameType` and the fee is charged on top.
* **Queued transfers.** The funds can be gone by the time the queue reaches your transfer, and then it fails. See [When a transfer queues](https://docs.anchorage.com/knowledge-base/platform/developers/move-money/transfers-vs-withdrawals#when-a-transfer-queues).

For how fees are estimated in general, see [Network and gas fees](https://docs.anchorage.com/knowledge-base/platform/developers/network-gas-fees.md).


## Related topics

- [Wallets](https://docs.anchorage.com/knowledge-base/porto/vaults-wallets/wallets.md)
- [Wallet details for a wallet](https://docs.anchorage.com/knowledge-base/porto/api-reference/v2/wallets/wallet-details-for-a-wallet.md)
- [Get Wallet](https://docs.anchorage.com/knowledge-base/porto/api-reference/v3/wallets/get-wallet.md)
- [Wallet recovery](https://docs.anchorage.com/knowledge-base/porto/vaults-wallets/wallet-recovery.md)
