Execute Batch Swap
Learn how to execute multiple token swaps in a single transaction using Fibrous Router SDK
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 Finance uses slippage settings to prevent you from losing money; there is no need to increase your slippage when you spot an arbitrage opportunity.
Fibrous Finance is still in alpha version. Please make sure you have adjusted your slippage properly.
Generate transaction data for calling the Fibrous Finance 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 Frontend
Here’s how to execute batch swaps using the Argent wallet on frontend:
Usage on Backend
For backend implementations on Starknet:
The swap call returns a transaction object with the following structure:
Important Notes
- All swaps in a batch must succeed for the transaction to be successful
- Make sure to have sufficient balance for all tokens being swapped
- Approve all tokens before executing the batch swap
- Consider gas costs for multiple swaps in a single transaction
- Monitor the transaction status for all swaps in the batch
- Handle errors appropriately for each swap in the batch