When a swap cannot be completed after the user has sent funds, Layerswap automatically initiates a refund. The refund is always processed on the source chain in the source token. Gas fees for processing the refund transaction are deducted from the refund amount.Documentation Index
Fetch the complete documentation index at: https://docs.layerswap.io/llms.txt
Use this file to discover all available pages before exploring further.
When does a refund happen?
Common scenarios that trigger a refund:- Quote expiration: The user’s deposit arrived after the original quote expired, and Layerswap could not obtain a valid new quote.
- Insufficient liquidity: The solver does not have enough liquidity to complete the transaction.
- Provider execution failure: A swap provider (e.g. a DEX) encountered an error during execution.
- Destination chain unavailability: The destination chain is unavailable due to an RPC outage or chain reorganization.
Refund statuses
When a refund is initiated, the swap transitions torefund_pending. Once the refund transaction is confirmed on-chain, the status changes to refunded. See the Swap lifecycle for the full status flow.
Refund address
You can provide arefund_address when creating a swap. This must be a valid address on the source network. If the swap route involves a swap provider, the refund address is required.
Identifying a refund transaction
A refunded swap will have a transaction withtype: "refund" in its transactions array:
status: "refunded" and a refund transaction in the transactions array:
refund transaction shows the on-chain transfer back to the user in the original source token.