Execute a Swap
This guide walks through the complete 5-step process to execute a token swap on Kroko DEX.Overview
Prerequisites
Step 1: Approve Token to Permit2
Each token only needs to be approved to Permit2 once. We recommend approving the maximum amount.Step 2: Permit2 Approve Universal Router
Grant the Universal Router permission to spend your token through Permit2.Step 3: Get Quote
Fetch the optimal swap route and expected output.Step 4: Get Swap Calldata
Request the encoded transaction data from the Swap API.Step 5: Execute the Swap
Send the transaction using the calldata from the API.Native KAS Swaps
When selling native KAS, the flow is the same except:- Use the WKAS address as
tokenInin the API calls - Skip Steps 1 and 2 (no approval needed for native KAS)
- The API returns a non-zero
value— include it in the transaction
Error Handling
| Error | Cause | Solution |
|---|---|---|
TRANSFER_FROM_FAILED | Missing approval or insufficient balance | Check Steps 1 & 2 |
EXPIRED | Deadline passed | Use a longer deadline or resubmit |
V3_INVALID_AMOUNT_OUT | Slippage exceeded | Increase slippage tolerance |
No route found | No liquidity path exists | Check token addresses and pool existence |
ACTION_REJECTED (code 4001) | User rejected in wallet | No action needed |