Lendasat LogoLendasat Docs
Monitor Swap

Get Swap by ID

Fetch the current status and details of a specific swap using its unique identifier.

const swap = await client.getSwap(swapId);

console.log("Status:", swap.status);
console.log("Source:", swap.source_amount, swap.source_token);
console.log("Target:", swap.target_amount, swap.target_token);

Polling for Updates

Monitor a swap's progress by polling at regular intervals:

async function pollSwap(swapId: string) {
  while (true) {
    const swap = await client.getSwap(swapId, { updateStorage: true });
    console.log("Status:", swap.status);

    if (["clientredeemed", "expired", "clientrefunded", "clientfundedserverrefunded"].includes(swap.status)) {
      return swap; // Terminal state
    }

    await new Promise((r) => setTimeout(r, 3000));
  }
}

Response Fields

BTC to EVM Swap

FieldTypeDescription
idstringUnique swap identifier
statusstringCurrent swap status
sourceAmountnumberBTC amount in satoshis
targetAmountnumberStablecoin amount
targetAddressstringEVM address receiving tokens
vhtlcAddressstringArkade VHTLC address (Arkade swaps)
lnInvoicestringLightning invoice (Lightning swaps)
createdAtstringCreation timestamp
expiresAtstringExpiration timestamp

EVM to BTC Swap

FieldTypeDescription
idstringUnique swap identifier
statusstringCurrent swap status
sourceAmountnumberStablecoin amount
targetAmountnumberBTC amount in satoshis
contractAddressstringHTLC contract address
hashLockstringHTLC hash lock
timelocknumberHTLC expiration timestamp