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

# useWithdraw

> Hook for managing withdrawals with available balance, max withdrawable amount, and unsettled PnL.

Withdraw helper hook.

* [Tech docs](/sdks/tech-doc/modules/orderly_network_hooks#usewithdraw)

### Max withdrawable amount

`availableWithdraw` - The maximum balance that can be withdrawn at this moment (without having to settle PnL).

### Available Balance

`availableBalance` - The available balance of the account, which is equal to the amount that can be withdrawn after settling all outstanding unsettled PnL.

### Unsettled PnL

`unsettledPnL` - Amount of PnL that has not been settled into the account balance yet. Balance will be available to withdraw once PnL has been settled (if positive).

All of the above data can be retrieved through `useWithdraw`.

```typescript theme={null}
const { withdraw, isLoading, availableWithdraw, unsettledPnL } = useWithdraw();
```

### Example

```tsx theme={null}
const { withdraw, availableWithdraw, isLoading } = useWithdraw();
const account = useAccountInstance();

const res = await withdraw();
return (
  <button
    onClick={async () => {
      await withdraw({
        chainId: Number(account.chainId),
        amount: availableWithdraw.toString(),
        token: "USDC",
        allowCrossChainWithdraw: false
      });
    }}
  >
    Withdraw all
  </button>
);
```
