Error Handling
This guide covers common errors you’ll encounter when integrating with Kroko DEX and how to handle them.API Errors
When an API call fails, the response includes an error message:| Error | Cause | Solution |
|---|---|---|
No route found | No liquidity path between the tokens | Verify token addresses; check that pools exist |
Invalid token address | Malformed address | Use checksummed or lowercase hex addresses |
Amount must be positive | Zero or negative amount | Provide a valid positive amount string |
Invalid tradeType | tradeType is not 0 or 1 | Use 0 (Exact Input) or 1 (Exact Output) |
Transaction Errors
On-Chain Reverts
These errors occur when the transaction is submitted but reverts on-chain:| Error | Cause | Solution |
|---|---|---|
TRANSFER_FROM_FAILED | Insufficient token approval or balance | Check Permit2 approval (Steps 1 & 2) and token balance |
EXPIRED | Transaction deadline exceeded | Use a longer deadline or resubmit quickly |
V3_INVALID_AMOUNT_OUT | Output below minAmountOut (slippage) | Increase slippage tolerance or reduce trade size |
INSUFFICIENT_ETH | Not enough native KAS sent as value | Ensure value matches the required input amount |
Wallet Errors
Approval Errors
Common issues with the approval flow:| Symptom | Cause | Fix |
|---|---|---|
| Swap fails after successful approval | Approved wrong contract | Ensure Step 1 approves Permit2 (not Universal Router) |
| Permit2 approval succeeds but swap fails | Permit2 sub-approval expired | Check expiration and re-approve if needed |
| ”Insufficient allowance” | Amount approved is less than swap amount | Approve MaxUint256 (Step 1) or MaxUint160 (Step 2) |
Checking Approval State
Best Practices
Pre-flight Checks
Before executing a swap, verify:Retry Strategy
- API errors: Safe to retry immediately (transient network issues)
- On-chain reverts: Do NOT retry blindly — diagnose the cause first
- User rejection: Do not retry — wait for user to initiate again
- Slippage errors: Re-fetch the quote (price may have changed) and retry with fresh calldata