Skip to main content
Set a slippage tolerance or stop limit to avoid receiving less than expected on a swap due to market fluctuations:
  • A slippage tolerance lets you set the maximum percentage difference you’re willing to accept between the estimated and actual swap amount, expressed in bps (for example, 100 bps = 1%).
  • A stop limit lets you set the exact minimum amount you want to receive.
If both are configured, the stop limit takes precedence.

Prerequisites

Before you begin, ensure that you’ve: These are required so any example below runs with a valid kit and adapter.

Set slippage tolerance

This example sets a slippage tolerance of 100 bps (1%):
TypeScript
const output = await kit.swap({
  from: { adapter, chain: "Ethereum" },
  tokenIn: "USDT",
  amountIn: "1.00",
  tokenOut: "USDC",
  config: {
    // Set the slippage tolerance to 100 bps
    slippageBps: 100,
  },
});
With slippageBps as 100 as in the example, you’ll receive at least 99% of the estimated amount. Meaning if the swap rate is 1 USDT to 1 USDC, you’ll receive at least 0.99 USDC.
The slippageBps default is 300 bps. 0 represents no tolerance, which increases transaction failure rates.

Set stop limit

stopLimit defines the minimum amount of the token type specified in tokenOut that you’ll receive on a swap. This example sets a stop limit of 0.95 USDC, meaning you won’t receive any less than that on a swap:
TypeScript
const output = await kit.swap({
  from: { adapter, chain: "Ethereum" },
  tokenIn: "USDT",
  amountIn: "1.00",
  tokenOut: "USDC",
  config: {
    // Set stop limit to 0.95 USDC
    stopLimit: "0.95",
  },
});