For the complete documentation index, see llms.txt. This page is also available as Markdown.

Swap

Deprecated. Same-chain swap example, kept for reference.

Same-chain swaps are deprecated. They were executed through Allbridge Core liquidity pools, which are no longer in use. The example below is kept for reference only.

// initiate transfer
const swapParams: SwapParams = {
  amount: amount,
  fromAccountAddress: fromAddress,
  toAccountAddress: toAddress,
  sourceToken: sourceTokenInfo,
  destinationToken: destinationTokenInfo,
  minimumReceiveAmount: await sdk.getAmountToBeReceived(amount, sourceTokenInfo, destinationTokenInfo),
};
const rawTransactionTransfer = await sdk.bridge.rawTxBuilder.send(swapParams) as RawEvmTransaction;

console.log(`Swaping ${amount} ${sourceTokenInfo.symbol}`);
const txReceipt = await sendRawTransaction(rawTransactionTransfer);
console.log("tx id:", txReceipt.transactionHash);

Full example

Last updated