cancelOrder() on the WithdrawQueue contract directly. It covers both direct cancellation (you submit the transaction) and meta-transaction cancellation (a relayer submits on your behalf).
How Cancellations Work
When you submitted a withdrawal order, the WithdrawQueue locked your vault shares and minted an ERC-721 NFT to your address representing ownership of the order. To cancel:Find your pending orders
Enumerate your order NFTs using the ERC-721 enumerable interface, then
filter by
PENDING status.msg.sender holds the NFT for the given order.
Only orders with
PENDING status (value 1) can be cancelled. Once an order
has been fulfilled or is being processed, it cannot be cancelled.What You’ll Need
| Requirement | Description |
|---|---|
| Contract address | withdrawQueueAddress — see Vault Discovery |
| ABI | Provided below |
| RPC endpoint | An Ethereum node URL |
| Private key or wallet | The same wallet that submitted the withdrawal order |
| Order index | From the OrderSubmitted event or NFT enumeration (shown below) |
ABI Reference
Contract Method Reference
cancelOrder(orderIndex)
| Parameter | Type | Description |
|---|---|---|
orderIndex | uint256 | Index of the order to cancel. Get this from the OrderSubmitted event or by enumerating order NFTs. |
cancelOrderWithSignature(orderIndex, deadline, cancelSignature)
For meta-transaction support — a relayer can cancel on behalf of the order owner.
| Parameter | Type | Description |
|---|---|---|
orderIndex | uint256 | Index of the order to cancel |
deadline | uint256 | Unix timestamp after which the signature expires |
cancelSignature | bytes | EIP-712 signature from the order owner (see Meta-Transaction Cancellation below) |
ERC-721 Enumeration (finding your orders)
The WithdrawQueue is an ERC-721 contract. Each withdrawal order is represented by an NFT.| Method | Returns | Description |
|---|---|---|
balanceOf(owner) | uint256 | Number of order NFTs held by the address |
tokenOfOwnerByIndex(owner, index) | uint256 | The order index (token ID) at the given position |
ownerOf(tokenId) | address | The current owner of a specific order NFT |
getOrderStatus(orderIndex) | uint8 | The order’s current status (see status table below) |
Order Statuses
| Value | Status | Cancellable? |
|---|---|---|
0 | NOT_FOUND | No |
1 | PENDING | Yes |
2 | COMPLETE | No |
3 | COMPLETE_PRE_FILLED | No |
4 | PENDING_REFUND | No |
5 | COMPLETE_REFUNDED | No |
6 | FAILED_TRANSFER_REFUNDED | No |
Direct Cancellation Walkthrough
Find your order NFTs (read)
Get the number of order NFTs held by your address.If
orderCount is 0, you have no orders to cancel.Enumerate and filter pending orders (read)
Loop through your NFTs and check each order’s status.For each Only orders with
i from 0 to orderCount - 1:status == 1 (PENDING) can be cancelled.Cancel the order (transaction)
Call The contract:
cancelOrder() for each pending order you want to cancel.- Verifies that
msg.senderowns the order NFT - Returns the locked vault shares to the
refundReceiveraddress (set during order submission) - Burns the order NFT
If you already know the
orderIndex (e.g., you saved it from the
OrderSubmitted event when you submitted the withdrawal), you can skip
Steps 1–2 and go directly to cancellation. Just verify the order is still
PENDING first.Meta-Transaction Cancellation
For relayer or gasless cancellation, the order owner signs an EIP-712 message off-chain and anyone can submit the transaction.EIP-712 Type
Walkthrough
Build the EIP-712 typed data (off-chain)
EIP-712 Domain:
Cancel message:
| Field | Value |
|---|---|
name | "WithdrawQueue" |
chainId | Chain ID (e.g., 1) |
verifyingContract | WithdrawQueue address |
| Field | Value |
|---|---|
orderIndex | The order to cancel |
deadline | Unix timestamp (e.g., now + 1 hour) |
queueAddress | WithdrawQueue address |
chainId | Chain ID (e.g., 1) |
Sign the typed data (off-chain)
The order owner signs the EIP-712 typed data using their wallet’s
signTypedData method. This produces a 65-byte signature.Troubleshooting
OnlyOrderOwnerCanCancel
OnlyOrderOwnerCanCancel
Your wallet doesn’t own this order’s NFT. Only the original submitter (or
whoever holds the NFT) can cancel.
InvalidOrderType
InvalidOrderType
The order isn’t in
PENDING status. Check getOrderStatus() — only status
1 is cancellable.InvalidOrderIndex
InvalidOrderIndex
The order index doesn’t exist. Verify it from the
OrderSubmitted event or
NFT enumeration.SignatureExpired
SignatureExpired
The deadline in
cancelOrderWithSignature has passed. Generate a fresh
signature with a future deadline.Next Steps
- Direct Deposits — Deposit tokens into a vault
- Direct Withdrawals — Submit a withdrawal order
- Vault Queries & Monitoring — Read APY, TVL, check balances, and monitor withdrawal status
- SDK Withdrawals Guide — Cancel via the Amplify SDK instead