Skip to main content

getAllWithdrawQueueRequests(owner)

Fetches all withdrawal-queue requests for a given owner address. Returns an array of request objects. Each request includes status metadata and two executable actions:

  • cancel(): cancels the request (when cancelable: true)
  • claim(): claims the withdrawal (when claimable: true)

The returned cancel() and claim() functions are write actions and require a wallet client with an account.

Signature​

getAllWithdrawQueueRequests(owner: Address): Promise<
{
recipient: `0x${string}`;
epoch: number;
epochState: "inactive" | "active" | "processing" | "processed";
claimable: boolean;
cancelable: boolean;
cancel: () => Promise<TxResult>;
claim: () => Promise<TxResult>;
amount: bigint;
version: 2;
vaultAddress: string;
chainId: number | undefined;
timestamp: number | undefined;
}[]
>;

Returns​

An array of withdrawal-queue requests:

  • recipient: address where the underlying is sent when claimed.
  • epoch: epoch index for the request.
  • epochState: current epoch status (inactive, active, processing, processed).
  • claimable: whether claim() can be called right now.
  • cancelable: whether cancel() can be called right now.
  • amount: requested amount in vault share units.
  • version: always 2 for these requests.
  • vaultAddress, chainId: identify the vault and network.
  • timestamp: request timestamp when available.
  • cancel(), claim(): callable functions that send transactions. Each resolves { hash, wait }, where wait(confirmations?) resolves a viem TransactionReceipt and throws when the transaction reverts.

Parameters​

  • owner (Address, required): the wallet address whose withdrawal requests you want to load.

Example​

import { getVault } from "@concrete-xyz/sdk";
import { createPublicClient, createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";

async function main() {
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const transport = http(process.env.RPC_URL!);
const publicClient = createPublicClient({ chain: mainnet, transport });
const walletClient = createWalletClient({ account, chain: mainnet, transport });

const vault = getVault("v2", "0xYourVault", 1, publicClient, walletClient);

const owner = account.address;
const requests = await vault.getAllWithdrawQueueRequests(owner);

// Render list
for (const r of requests) {
console.log({
recipient: r.recipient,
epoch: r.epoch,
epochState: r.epochState,
amount: r.amount.toString(),
claimable: r.claimable,
cancelable: r.cancelable,
vaultAddress: r.vaultAddress,
chainId: r.chainId,
version: r.version,
});
}

// Claim the first claimable request (if any)
const firstClaimable = requests.find((r) => r.claimable);
if (firstClaimable) {
console.log("Claiming request in epoch", firstClaimable.epoch);
const tx = await firstClaimable.claim();
const receipt = await tx.wait();
console.log("Claim confirmed:", receipt.transactionHash);
return;
}

// Otherwise, cancel the first cancelable request (if any)
const firstCancelable = requests.find((r) => r.cancelable);
if (firstCancelable) {
console.log("Canceling request in epoch", firstCancelable.epoch);
const tx = await firstCancelable.cancel();
const receipt = await tx.wait();
console.log("Cancel confirmed:", receipt.transactionHash);
return;
}

console.log("No claimable or cancelable requests found.");
}

main().catch((err) => {
console.error("Failed:", err);
process.exit(1);
});