thirdweb API: Custom Slippage Tolerance

thirdweb API: Custom Slippage Tolerance

You can now specify custom slippage tolerance on the /bridge/swap endpoint. With the slippageToleranceBps parameter, you can specify how many basis points in slippage your swap can tolerate. Warning: Lower slippage tolerance values could result in reverted swaps.

Without this value specified, it will continue to use the default behavior of automatically calculated slippage tolerance.

curl https://api.thirdweb.com/v1/bridge/swap \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'x-client-id: YOUR_SECRET_TOKEN' \
  --data '{
  "exact": "input",
  "tokenIn": {
    "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
    "chainId": 42161,
    "amount": "100"
  },
  "tokenOut": {
    "address": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
    "chainId": 42161,
    "minAmount": "80"
  },
  "from": "0xEfc38EF8C09535b25e364b6d1a7C406D3972f2A9",
  "slippageToleranceBps": 50
}'

Payments API

This parameter is also available directly on the payments API. Learn more in the API reference.