Overview
Starkzap lets users swap one token for another through pluggable swap providers. The SDK supports AVNU (DEX aggregator) and Ekubo (concentrated liquidity AMM). You get a quote, optionally set slippage tolerance, and execute the swap in one call. What users can do with swaps:- 📊 Get quotes - See how much they will receive before swapping (amount out, price impact)
- 🔄 Execute swaps - Exchange tokens in a single transaction with optional slippage protection
- 🏪 Choose providers - Use AVNU for aggregated routes or Ekubo for concentrated liquidity
- 📦 Batch with other actions - Run a swap then use the transaction builder for follow-up operations
The wallet fills
chainId and takerAddress from the connected wallet when you call getQuote() or swap(). You only need to pass tokenIn, tokenOut, and amountIn (and optionally slippageBps or provider).Configuration
Registering swap providers
Register one or more swap providers when connecting the wallet (or at runtime). If you register multiple providers, set a default sogetQuote() and swap() work without specifying provider on each request.
At connect / onboard:
Token presets
Use the SDK token presets fortokenIn and tokenOut so addresses and decimals match the chain:
Getting a quote
Callwallet.getQuote() with the swap input. The wallet uses the default swap provider unless you pass provider:
Quote shape
Executing a swap
Use the same request shape as the quote. The wallet resolves the provider and builds the swap calls, then executes them. Minimal swap:Providers
List and switch providers:
Batching with other operations
Use the transaction builder’s.swap() method to batch a swap with other operations in a single atomic transaction:
wallet.swap():
Best practices
- Always get a quote first and show users the expected amount out and price impact before executing.
- Set slippage (
slippageBps) for volatile pairs or large sizes to avoid failed transactions. - Use token presets from
getPresets(chainId)ormainnetTokens/sepoliaTokensso token addresses and decimals match the chain. - Handle chain mismatch — ensure the wallet’s chain matches the swap provider’s supported chains (AVNU and Ekubo support mainnet and Sepolia).
Troubleshooting
”No default swap provider configured”
Register at least one swap provider and callsetDefaultSwapProvider(providerId) (or pass defaultSwapProviderId when connecting). Alternatively, pass provider: "avnu" or provider: "ekubo" on every getQuote() / swap() call.
Chain or provider mismatch
Ensure the wallet is on a chain supported by the chosen provider (e.g.SN_MAIN or SN_SEPOLIA). If you see a chain mismatch error, align the SDK network config with the RPC/wallet chain.
Swap returned no calls
The provider could not build a route for the pair or amount. Try a different provider, a smaller amount, or another token pair.Next steps
- DCA — Recurring buys (Dollar-Cost Averaging) with AVNU or Ekubo
- Bitcoin, Stablecoins, and Tokens — Token presets and amounts
- Transactions — Execution options and fee modes
- Tx Builder — Batching transfers and other operations
- API Reference — Full method signatures