This guide covers common issues when implementing slippage tolerance and provides solutions for optimal transaction success rates.

Parameter Validation

Invalid Value Type

Issue: Getting validation errors when adding slippage tolerance parameter.
Error
{
  "error": "Invalid slippageTolerance: must be a positive integer"
}
Cause: Passing string, float, or negative values instead of positive integer.
❌ Wrong
const request = {
  slippageTolerance: "100"    // String
  slippageTolerance: 1.5      // Float  
  slippageTolerance: -50      // Negative
};
✅ Correct
const request = {
  slippageTolerance: 100      // Positive integer in basis points
};

Value Too High

Issue: Setting slippage tolerance above reasonable levels.
❌ Wrong
const request = {
  slippageTolerance: 1500     // 15% - extremely high
};
✅ Correct
const request = {
  slippageTolerance: 500      // 5% - more reasonable maximum
};

Quote Still Failing

Issue: Transactions still failing despite setting slippage tolerance.
ProblemLikely CauseSolution
Slippage too lowMarket moving faster than toleranceIncrease slippage tolerance
Network congestionHigh gas costs affecting executionWait for lower congestion
Large trade sizePrice impact exceeding slippageBreak into smaller trades
Volatile marketRapid price movementsUse higher slippage

Simple Retry Pattern

async function executeWithRetry(baseRequest: QuoteRequest) {
  const slippageValues = [50, 100, 200]; // 0.5%, 1%, 2%
  
  for (const slippage of slippageValues) {
    try {
      const quote = await getQuote({
        ...baseRequest,
        slippageTolerance: slippage
      });
      
      return await executeQuote(quote);
      
    } catch (error: any) {
      console.log(`Failed at ${slippage / 100}% slippage`);
      if (slippage === 200) {
        throw error; // Final attempt failed
      }
    }
  }
}

Choosing Appropriate Values

Issue: Unsure what slippage values to use for different scenarios.

Stablecoins

10-50 basis pointsUSDC ↔ USDT: 10 (0.1%)DAI ↔ USDC: 25 (0.25%)

Major Tokens

50-100 basis pointsETH ↔ USDC: 100 (1%)BTC ↔ ETH: 100 (1%)

Volatile Assets

100-500 basis pointsAltcoins: 300 (3%)New tokens: 500 (5%)

Asset Classification Helper

function getRecommendedSlippage(fromAsset: string, toAsset: string): number {
  const stablecoins = ['usdc', 'usdt', 'dai'];
  const majorTokens = ['eth', 'weth', 'btc', 'wbtc'];
  
  const isStablecoin = (asset: string) => 
    stablecoins.some(stable => asset.toLowerCase().includes(stable));
  
  const isMajor = (asset: string) =>
    majorTokens.some(major => asset.toLowerCase().includes(major));

  // Stablecoin to stablecoin
  if (isStablecoin(fromAsset) && isStablecoin(toAsset)) {
    return 25; // 0.25%
  }
  
  // Major token pairs
  if (isMajor(fromAsset) && isMajor(toAsset)) {
    return 100; // 1%
  }
  
  // Default for volatile tokens
  return 300; // 3%
}

Integration Issues

React State Management

import { useState } from 'react';

function useSlippageTolerance(defaultSlippage = 100) {
  const [slippage, setSlippage] = useState(defaultSlippage);
  
  const executeWithSlippage = async (quoteRequest: QuoteRequest) => {
    const quote = await getQuote({
      ...quoteRequest,
      slippageTolerance: slippage
    });
    
    return await executeQuote(quote);
  };
  
  return {
    slippage,
    setSlippage,
    executeWithSlippage
  };
}

Basic Error Handling

async function handleSlippageExecution(request: QuoteRequest) {
  try {
    const quote = await getQuote(request);
    return await executeQuote(quote);
    
  } catch (error: any) {
    console.error('Transaction failed:', error.message);
    
    // Suggest increasing slippage if current value is low
    const currentSlippage = request.slippageTolerance || 0;
    if (currentSlippage < 100) {
      console.log('Consider increasing slippage tolerance to 1% (100 basis points)');
    }
    
    throw error;
  }
}

Best Practices

1

Start Conservative

Begin with 1% (100 basis points) for most use cases
2

Asset-Specific Values

Use lower slippage for stablecoins, higher for volatile tokens
3

Implement Retry

Add automatic retry with progressive slippage increases
4

Monitor Performance

Track success rates and adjust defaults based on real data

Getting Help

Still Having Issues?

Use the Intercom chat widget in the bottom right corner for instant help, or email support@onebalance.io.

Share Information

Include your slippage values, error messages, and asset pair information for faster resolution.
Most issues can be resolved by starting with 100 basis points (1%) and implementing simple retry logic with higher values.