Withdraw funds from a provider perps account.
The examples on this page use Hyperliquid (provider: 'hyperliquid'). Withdrawal mechanics (supported assets, destination chains, and processing times) vary by provider.
Overview
PerpsClient.withdraw() is a single-call helper that builds the withdrawal payload, requests the user’s wallet signature, and submits the signed action — all in one call. It dispatches through the same createAction → sign → executeAction pipeline documented in Actions, but consumers do not have to compose the steps manually.
Withdrawals are user-signed only. Agents cannot initiate withdrawals — this is a protocol-level constraint. The user’s wallet is prompted on every withdrawal, regardless of the account’s signing mode.
Hyperliquid: Withdrawal processing typically takes 3–4 minutes. The bridge transfer from Hyperliquid L1 to Arbitrum is asynchronous.
Using PerpsClient (recommended)
const { results } = await perps.withdraw({
provider: 'hyperliquid',
address: userAddress,
withdrawal: {
destination: userAddress, // Address to receive withdrawn funds
amount: '100.0',
},
});
const [result] = results;
if (result.success) {
console.log('Withdrawal submitted successfully');
} else {
console.error(`Withdrawal failed: ${result.error}`);
}
Withdrawal submission returns 202 Accepted. Processing is asynchronous — for Hyperliquid, this typically takes 3–4 minutes via the Arbitrum bridge. Poll getAccount() to verify the balance change.
PerpsClient.withdraw
Build, sign (with the user’s wallet), and submit a withdrawal in a single call.
const response = await perps.withdraw(params);
Parameters: WithdrawParams
| Field | Type | Required | Description |
|---|
provider | string | Yes | Provider identifier |
address | string | Yes | User’s wallet address (account owner) |
withdrawal | WithdrawalParams | Yes | Withdrawal details |
WithdrawalParams:
| Field | Type | Required | Description |
|---|
destination | string | Yes | Destination address for the withdrawal |
amount | string | Yes | Amount to withdraw (e.g., "100.0") |
Returns: ExecuteActionResponse — { results: ActionResult[] }. The array contains a single result for the WITHDRAWAL action:
| Field | Type | Description |
|---|
results[i].action | ActionType | ActionType.WITHDRAWAL |
results[i].success | boolean | Whether the withdrawal was accepted |
results[i].error | string? | Error message (if failed) |
Using Service Functions (advanced)
For complete control over the create/sign/execute steps — for example, to surface the typed-data payload in a confirmation dialog before requesting the signature — call the lower-level createAction / executeAction service functions directly. See Actions for the full create → sign → execute pattern.
import { createAction, executeAction, ActionType } from '@lifi/perps-sdk';
const { actions } = await createAction(client, {
provider: 'hyperliquid',
address: userAddress,
action: ActionType.WITHDRAWAL,
params: {
destination: userAddress,
amount: '100.0',
},
});
const signedActions = await Promise.all(
actions.map(async (a) => ({
action: a.action,
typedData: a.typedData,
signature: await walletClient.signTypedData({ ...a.typedData }),
})),
);
const { results } = await executeAction(client, {
provider: 'hyperliquid',
address: userAddress,
action: ActionType.WITHDRAWAL,
actions: signedActions,
});
const [result] = results;
console.log(result.action, result.success ? 'OK' : result.error);
API Reference: POST /createAction, POST /executeAction