Skip to main content

Execute Batch Swap

Slippage is an important concept in trading that can have a significant impact on your trading outcomes. It refers to the difference between the expected price of a trade and the actual price at which the trade is executed. Slippage can occur in various market conditions and for several reasons, and it’s crucial for traders to be aware of its potential effects.Fibrous uses slippage settings to prevent you from losing money; there is no need to increase your slippage when you spot an arbitrage opportunity.Fibrous is still in alpha version. Please make sure you have adjusted your slippage properly.
Generate transaction data for calling the Fibrous Router contract to execute multiple swaps in a single transaction.

Basic Setup

First, let’s set up the router and get the token information:

Usage on Backend

For backend implementations on Starknet:
The swap call returns a transaction object with the following structure:

Important Notes

  1. All swaps in a batch must succeed for the transaction to be successful
  2. Make sure to have sufficient balance for all tokens being swapped
  3. Approve all tokens before executing the batch swap
  4. Consider gas costs for multiple swaps in a single transaction
  5. Monitor the transaction status for all swaps in the batch
  6. Handle errors appropriately for each swap in the batch