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

Amount and fee calculations

To calculate and get info about the receive amount, one has to call getAmountToBeReceived method.

const amountToBeReceived = await sdk.getAmountToBeReceived(amount, sourceToken, destinationToken);
console.log(
  "Send %d %s and %d %s (gas fee) on %s to receive %d %s on %s",
  amount,
  sourceToken.symbol,
  gasFeeOptions.native.int,
  sourceChainMinUnit,
  sourceToken.chainSymbol,
  amountToBeReceived,
  destinationToken.symbol,
  destinationToken.chainSymbol
);

If you selected pay with stables:

const gasFeeOptions = await sdk.getGasFeeOptions(sourceToken, destinationToken, Messenger.ALLBRIDGE);

const floatGasFeeAmount = gasFeeOptions.stablecoin.float;
console.log(
  "Send %d %s and %d %s (gas fee) on %s to receive %d %s on %s",
  amount,
  sourceToken.symbol,
  floatGasFeeAmount,
  sourceToken.symbol,
  sourceToken.chainSymbol,
  amountToBeReceived,
  destinationToken.symbol,
  destinationToken.chainSymbol
);

If you want to calculate how much you need to send to receive a specific amount use a getAmountToSend method:

If you want to receive additional data about fees, select getAmountToBeReceivedAndGasFeeOptions or getAmountToSendAndGasFeeOptions method instead:

Full example

Last updated