Overview
Execute a swap in one function call. The SDK handles building calls, approvals, and transaction execution automatically.SDK Method
Parameters
Example
Response
Slippage Protection
Slippage is defined as a decimal (0..1 range):0.001= 0.1%0.005= 0.5%0.01= 1%
minAmount = buyAmount * (1 - slippage)
Token Approval
By default (executeApprove: true), the SDK:
- Checks the user’s current allowance for the avnu router.
- If insufficient, adds an
approvecall to the transaction. - Executes
approveandswapin a single multicall (atomic).
Best Practices
Always use fresh quotes
Always use fresh quotes
With Starknet’s block time of ~2 seconds, quotes become stale after just 1 block. Refresh quotes every block before execution.
Set appropriate slippage
Set appropriate slippage
- Stable pairs: 0.001 - 0.003 (0.1% - 0.3%)
- Regular pairs: 0.005 - 0.01 (0.5% - 1%)
- Volatile pairs: 0.01 - 0.03 (1% - 3%)
Handle failures gracefully
Handle failures gracefully
Implement retry logic with exponential backoff for network issues.