Skip to main content

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 tokenIn in 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

See Error Handling for a comprehensive reference.