Skip to main content

When to Refund

Refunds are needed when:
  • You deposited tokens but didn’t receive BTC
  • The swap timed out (service didn’t complete)
  • Network issues prevented swap completion

Check Swap Status


No timelock wait required. The server cosigns the refund and submits it on-chain - gasless for you.
This works precisely when you have funded the EVM HTLC but the swap subsequently failed (e.g. the server couldn’t pay the Lightning invoice). The server cosigns even before timelock expiry, as long as the swap is in a refundable state.
EVM refunds always return the BTC-pegged HTLC token (WBTC/tBTC), regardless of which token you originally deposited.

Option 2: Timeout-Based Refund (Fallback)

If the server is unresponsive, you can refund yourself after the HTLC timelock expires (24h on mainnet). You submit the transaction with your own EVM wallet.

Timeout-based refund over REST (without the SDK)

GET /swap/{id} returns every argument of the refund call, so you don’t need to parse the HTLC’s SwapCreated log on-chain. The fields are the same for evm_to_bitcoin, evm_to_lightning and evm_to_arkade swaps, including CCTP-bridged ones: These values describe the lock as the server recorded it when it accepted the funding. evm_htlc_locked_amount and evm_htlc_sender are null until then. evm_htlc_locked_amount is read from the SwapCreated event, so it can differ from evm_expected_sats after the DEX swap. Always pass evm_htlc_locked_amount: any other amount addresses a lock that doesn’t exist and the call reverts. The lock token is fixed per chain (tBTC on Ethereum and Arbitrum, WBTC on Polygon), so evm_htlc_token is the token of every lock funded as quoted. wbtc_address carries the same value but is deprecated; read it only from servers that don’t send evm_htlc_token yet. The table doesn’t apply to a lock the server didn’t accept as quoted. That covers a lock with status clientinvalidfunded (wrong token, claim address or timelock), and a lock that landed after the swap ended, which the server doesn’t record. Such a lock is keyed under the values it was created with, so take every argument (amount, token, sender, claimAddress, timelock) from its SwapCreated log. A lock worth well above the route’s maximum swap amount is refused: the swap moves to serverwontfund and the server doesn’t fund it. Locks slightly above the maximum (up to 5% by default) are still accepted, because the DEX leg aims above the quote on purpose. A refused lock is recorded as it exists, so refund it as above, or collaboratively right away. Which contract you call depends on evm_htlc_kind, evm_htlc_version and evm_coordinator_address:
  • HTLCErc20 v7+ / HTLCNative v2+: evm_htlc_sender is your depositor address. After evm_refund_locktime, send refund(preimageHash, amount, token, claimAddress, timelock) to evm_htlc_address from that address. Native locks drop the token argument. Anyone can also call refundFor(preimageHash, amount, token, sender, claimAddress, timelock), and the funds still go to sender.
  • HTLCErc20 up to v6: evm_htlc_sender is the coordinator (evm_coordinator_address). After evm_refund_locktime, anyone can call refundTo(preimageHash, amount, token, claimAddress, timelock) on the coordinator, and the funds always go to the depositor.
  • HTLCNative v1 with a coordinator: as above, but the native coordinator’s refundTo(preimageHash, amount, claimAddress, timelock) takes no token.
  • HTLCNative v1 without a coordinator (evm_coordinator_address is the zero address): the lock is your own. evm_htlc_sender is your address; after evm_refund_locktime, send refund(preimageHash, amount, claimAddress, timelock) to evm_htlc_address from it. Don’t send anything to the zero address: the call would succeed without refunding.
GET /swap/{id}/refund-and-swap-calldata builds the right call for the cases above.

Refund Methods Summary


Important Notes

Try collaborative first. It’s instant and gasless. Only fall back to the timeout-based refund if the server is down.
  1. Refund token - Both methods return the BTC-pegged HTLC token (WBTC/tBTC), not the originally deposited token
  2. Automatic refunds - The server also detects expired HTLCs and processes refunds automatically in the background
  3. Gas fees - Only the timeout-based refund requires gas (ETH/MATIC)