withdrawFunds
Initiate a withdrawal from active positions to user's EOA. Supports both full and partial withdrawals. Processed asynchronously by backend.
Funds are always withdrawn to the Safe owner's address (the userAddress parameter).
Supported assets:
- USDC (default): 6 decimals
- WETH: 18 decimals
Signature
withdrawFunds(userAddress: string, chainId: SupportedChainId, amount?: string, assetType?: "USDC" | "WETH"): Promise<WithdrawResponse>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userAddress | string | ✅ | User's EOA address (owner of the Safe) |
chainId | SupportedChainId | ✅ | Chain to withdraw from |
amount | string | ❌ | Amount to withdraw (omit for full withdrawal) |
assetType | "USDC" | "WETH" | ❌ | Asset to withdraw (default: "USDC") |
Returns
Withdraw response with status message
Return Type
interface WithdrawResponse {
success: boolean;
message: string;
txHash?: string;
type: 'full' | 'partial';
amount: string;
}
Example
Withdraw USDC (default)
// Full USDC withdrawal (withdrawn to user's EOA)
const result = await sdk.withdrawFunds("0xUser...", 42161);
console.log(result.message); // "Withdrawal request sent"
// Partial withdrawal of 50 USDC (6 decimals)
const partial = await sdk.withdrawFunds(
"0xUser...",
42161,
"50000000" // 50 USDC = 50 * 10^6
);
console.log(partial.type); // "partial"
Withdraw WETH
// Full WETH withdrawal
const result = await sdk.withdrawFunds("0xUser...", 8453, undefined, "WETH");
console.log(result.message); // "Withdrawal request sent"
// Partial withdrawal of 0.25 WETH (18 decimals)
const partial = await sdk.withdrawFunds(
"0xUser...",
8453,
"250000000000000000", // 0.25 WETH = 0.25 * 10^18
"WETH"
);
console.log(partial.type); // "partial"