Complete Swap
Claim via Gelato
Complete a BTC to EVM swap using Gelato relay for gasless claiming. This is the recommended way to claim stablecoins.
How it works:
- Your swap reaches
ServerFundedstatus (HTLC is ready) - SDK signs a meta-transaction with your preimage
- Gelato submits the transaction on your behalf
- You receive stablecoins without paying gas
Claim Swap
Claim your stablecoins with a single SDK call:
const claimResult = await client.claim(swapId);
if (claimResult.success) {
console.log("Claimed! TX:", claimResult.txHash);
} else {
console.error("Claim failed:", claimResult.message);
}Complete Flow Example
End-to-end example from swap creation to claiming:
// 1. Create swap
const result = await client.createLightningToEvmSwap({
targetAddress: "0xYourPolygonAddress",
targetToken: "usdc_pol",
targetChain: "polygon",
sourceAmount: 100000,
});
console.log("Pay invoice:", result.response.ln_invoice);
// 2. Wait for ServerFunded
let swap = await client.getSwap(result.response.id);
while (swap.status !== "serverfunded") {
await new Promise((r) => setTimeout(r, 3000));
swap = await client.getSwap(result.response.id);
}
// 3. Claim (gasless on Polygon)
const claim = await client.claim(result.response.id);
console.log("Claimed:", claim.success, claim.txHash);When to Use Gelato
| Swap Type | Use Gelato? | Notes |
|---|---|---|
| BTC → Polygon | Yes | Recommended, gasless |
| BTC → Ethereum | No | Use WalletConnect, user pays gas |
| Lightning → Polygon | Yes | Recommended, gasless |
| Lightning → Ethereum | No | Use WalletConnect, user pays gas |
| On-chain → Polygon | Yes | Recommended, gasless |
| On-chain → Ethereum | No | Use WalletConnect, user pays gas |
Ethereum swaps require a wallet: Gelato Relay is only available for Polygon. For Ethereum destinations, you must connect a wallet and pay gas fees to claim your tokens. See Claim with WalletConnect.
Important Notes
Gasless on Polygon: You don't need any MATIC to claim on Polygon. LendaSwap pays all gas fees via Gelato relay.
- Automatic preimage - SDK retrieves the preimage from local storage
- No gas required (Polygon only) - LendaSwap covers gas via Gelato for Polygon swaps
- Wait for ServerFunded - Only call
claim()after the swap is inServerFundedstatus - One-time claim - Once claimed, the swap is complete