Skip to main content

Overview

Execute a swap in one function call. The SDK handles building calls, approvals, and transaction execution automatically.

SDK Method

Parameters

InvokeSwapParams
required

Example

Response

Slippage Protection

Slippage is defined as a decimal (0..1 range):
  • 0.001 = 0.1%
  • 0.005 = 0.5%
  • 0.01 = 1%
The SDK automatically calculates the minimum received amount: minAmount = buyAmount * (1 - slippage)

Token Approval

By default (executeApprove: true), the SDK:
  1. Checks the user’s current allowance for the avnu router.
  2. If insufficient, adds an approve call to the transaction.
  3. Executes approve and swap in a single multicall (atomic).

Best Practices

With Starknet’s block time of ~2 seconds, quotes become stale after just 1 block. Refresh quotes every block before execution.
  • 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%)
Implement retry logic with exponential backoff for network issues.