refundMarket
Refund a deposit on a rejected market — reclaim the funds a user deposited into a market whose listing was rejected.
import { refundMarket } from "@symmio/trading-core";
const receipt = await refundMarket(config, {
accessToken: token.accessToken,
marketAddress: rejectedMarket.contractAddress,
depositChain: rejectedMarket.chainId,
recipientAddress: account.address,
});Use it only for a market whose marketStatus is REJECTED — the service moves the deposit to recipientAddress and returns the transfer’s transaction hash.
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 refund their own deposit. 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 refundMarket 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. Note depositChain is a separate field — the chain the deposit was made on (the market’s chainId), not the chain whose listing backend is used.
Parameters
accessTokenstringrequiredBearer token from authenticateListing. Sent as Authorization: Bearer <token>. A bad
or expired token yields a 401 (see Throws).
marketAddressstringrequiredThe rejected market’s token contract address — an EVM 0x… address, or a Solana base58 address for a
Solana-deposited listing.
depositChainListingDepositChainIdrequiredThe chain the deposit was made on — the market’s chainId. Routes the refund transfer.
recipientAddressstringrequiredDestination the refunded deposit is sent to — an EVM 0x… address, or a Solana base58 address for a Solana-deposited
listing.
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<PoolRefundResult>The refund receipt. transactionHash is the on-chain hash of the refund transfer.
Mutation options
import { refundMarketMutationOptions } from "@symmio/trading-core";
import { useMutation } from "@tanstack/react-query";
const { mutateAsync } = useMutation(refundMarketMutationOptions(config));
await mutateAsync({ accessToken, marketAddress, depositChain, recipientAddress });refundMarketMutationOptions(config) returns a { mutationKey, mutationFn } bag for useMutation. It is modeled as a mutation, not a query: it moves a deposit back to the user, 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 refund action instead of erroring.REFUND_MARKET_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; the service also rejects a market that is not refundable (e.g. not rejected, or already refunded) — each surfaces with the service’s message and status as-is.
Related
getUserListingMarkets— surfaces the user’s markets and theirmarketStatus, includingREJECTED.- Listing auth — mints the
accessTokenthis write requires. useRefundMarket— the React hook.- Pools — the slice overview.