Execute Swap
Learn how to execute token swaps using Fibrous Router SDK
Execute 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.
Usage on EVM Networks (Base, Scroll)
Here’s how to execute a swap on EVM-compatible networks like Base and Scroll:
Usage on Starknet
For Starknet, the process is slightly different due to its unique architecture:
Alternative Backend Usage on Starknet
If you’re implementing this on the backend for Starknet:
The swap call returns a transaction object with the following structure:
Important Notes
- Always handle errors appropriately in production code
- Set a reasonable slippage value based on your trading strategy
- Make sure to have sufficient balance and approved tokens before executing swaps
- Monitor transaction status and implement proper error handling
- Consider implementing retry mechanisms for failed transactions
- Keep private keys secure and never expose them in your code