Skip to main content
Withdrawals are routed through the WithdrawQueue flow.
Recommended sequence: prepareWithdrawalAuthorization() then prepareWithdrawal().

Step 1: Check Authorization

import {
  prepareWithdrawalAuthorization,
  isWithdrawApprovalAuth,
} from "@paxoslabs/amplify-sdk";

const auth = await prepareWithdrawalAuthorization({
  yieldType: "CORE",
  wantAsset: USDC,
  withdrawAmount: "10.0",
  userAddress,
  chainId: 1,
});

if (isWithdrawApprovalAuth(auth)) {
  const approvalHash = await walletClient.writeContract(auth.txData);
  await publicClient.waitForTransactionReceipt({ hash: approvalHash });
}

Step 2: Submit Withdrawal Order

import { prepareWithdrawal } from "@paxoslabs/amplify-sdk";

const txData = await prepareWithdrawal({
  yieldType: "CORE",
  wantAsset: USDC,
  withdrawAmount: "10.0",
  userAddress,
  chainId: 1,
});

const hash = await walletClient.writeContract(txData);

Optional Low-Level APIs

Checking Withdrawal Status

After submitting a withdrawal order, use getWithdrawalRequests to poll for status updates:
import { getWithdrawalRequests } from "@paxoslabs/amplify-sdk";

const { withdrawalRequests } = await getWithdrawalRequests({
  userAddress,
  chainId: 1,
  status: "PENDING",
});

for (const request of withdrawalRequests) {
  console.log(`${request.id}: ${request.status}${request.orderAmount}`);
}

Withdrawal Request Statuses

StatusDescription
PENDINGOrder submitted, awaiting fulfillment by vault operator
COMPLETEOrder fulfilled, stablecoins sent to user
PENDING_REFUNDOrder is being refunded
REFUNDEDVault shares returned to user
Withdrawal orders are fulfilled by the vault operator, typically within 24 hours of submission. Use getWithdrawalRequests to display current status to users.

Canceling a Withdrawal

Withdrawal requests with a PENDING status can be canceled and refunded to the user in a specified asset. This uses a two-step process: retrieve the withdrawal requests, then submit the cancellation.

Step 1: Retrieve Withdrawal Requests

Use getWithdrawalRequests to fetch pending requests for a given user address:
import {
  getWithdrawalRequests,
  prepareCancelWithdrawOrderTxData,
} from "@paxoslabs/amplify-sdk";

const { withdrawalRequests } = await getWithdrawalRequests({
  userAddress,
  chainId: 1,
  status: "PENDING",
});

Step 2: Submit Cancellation

Prepare and send the transaction to cancel a specific pending withdrawal request:
const requestToCancel = withdrawalRequests[0];

const txData = await prepareCancelWithdrawOrderTxData({
  yieldType: "CORE",
  wantAsset: refundTokenAddress,
  chainId: requestToCancel.chainId,
  orderIndex: BigInt(requestToCancel.orderIndex),
});

const hash = await walletClient.writeContract(txData);
Only the order owner can cancel their withdrawal request. The wantAsset specifies the token the user will receive as a refund.

Smart Wallet Behavior

In auto mode, smart wallets are routed to approval mode so approve + withdraw can be batched atomically.