Lendasat LogoLendasat Docs
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:

  1. Your swap reaches ServerFunded status (HTLC is ready)
  2. SDK signs a meta-transaction with your preimage
  3. Gelato submits the transaction on your behalf
  4. 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 TypeUse Gelato?Notes
BTC → PolygonYesRecommended, gasless
BTC → EthereumNoUse WalletConnect, user pays gas
Lightning → PolygonYesRecommended, gasless
Lightning → EthereumNoUse WalletConnect, user pays gas
On-chain → PolygonYesRecommended, gasless
On-chain → EthereumNoUse 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.

  1. Automatic preimage - SDK retrieves the preimage from local storage
  2. No gas required (Polygon only) - LendaSwap covers gas via Gelato for Polygon swaps
  3. Wait for ServerFunded - Only call claim() after the swap is in ServerFunded status
  4. One-time claim - Once claimed, the swap is complete