cancelWithdraw
Cancel a queued LP withdrawal — remove a pending withdrawal from a pool’s withdrawal queue before it settles. The authed write that undoes a withdrawLp, keyed by the withdrawal’s id.
import { cancelWithdraw } from "@symmio/trading-core";
const receipt = await cancelWithdraw(config, {
accessToken: token.accessToken,
withdrawId: pendingWithdrawal.transactionId,
});The withdrawId is the transactionId of a still-PENDING withdraw row from getPoolTransactions. On success the shares return to the user’s available balance, so refetch getUserProfit to see availableLpAmount rise and pendingWithdrawLpAmount fall.
This is a REST write against the listing backend, not a contract call, and it is authed: the accessToken from
authenticateListing is sent as an Authorization: Bearer <token> header, and a user may
only cancel their own withdrawal. The backend is resolved from the config before the request, so a target without Pools
fails immediately and without any network traffic — see resolveListingService.
No solver id
Pool listing is chain-level — one listing backend is served per chain — so cancelWithdraw takes only an optional chainId and no solverId. Pass a chainId to target a specific deployment’s listing backend; omit it to use the config’s default chain.
Parameters
accessTokenstringrequiredBearer token from authenticateListing. Sent as Authorization: Bearer <token>. A bad
or expired token yields a 401 (see Throws).
withdrawIdstringrequiredId of the queued withdrawal to cancel — the transactionId of the pending withdraw row from
getPoolTransactions, whose status is still PENDING.
chainIdnumberoptionalTarget chain id. Defaults to the config’s defaultChainId. Selects which chain’s listing backend is used. There is
no solverId — listing is resolved at chain level.
Returns
Promise<PoolCancelWithdrawResult>The cancellation receipt. transactionId is the affected withdrawal’s id, echoed by the service; status is its
resulting status (e.g. "canceled"), carried through as the service’s raw string.
Mutation options
import { cancelWithdrawMutationOptions } from "@symmio/trading-core";
import { useMutation } from "@tanstack/react-query";
const { mutateAsync } = useMutation(cancelWithdrawMutationOptions(config));
await mutateAsync({ accessToken, withdrawId: pending.transactionId });cancelWithdrawMutationOptions(config) returns a { mutationKey, mutationFn } bag for useMutation. It is modeled as a mutation, not a query: it removes a queued withdrawal and returns the shares to the user’s available balance, so it is a one-shot write, not cached data.
Throws
LISTING_NOT_CONFIGURED— aSymmError(kind: "config") when the chain has nolistingbackend configured. Gate withsupportsListingServiceto hide the cancel action instead of erroring.CANCEL_WITHDRAW_FAILED— the request itself failed. Any axios failure becomes aSymmApiErrorcarryingstatus,statusText,responseData,urlandmethod; a non-axios throw becomes a plainSymmError(kind: "api"). A401means theaccessTokenwas missing, malformed, or expired; a404an unknown id; and the service rejects a withdrawal that has already settled — each surfaces with the service’s message and status as-is.
Related
withdrawLp— the write this undoes.getPoolTransactions— supplies the pending withdrawal’stransactionId.getUserProfit— the balances to refetch after a cancel.useCancelWithdraw— the React hook.- Pools — the slice overview.