> ## Documentation Index
> Fetch the complete documentation index at: https://docs.krokoswap.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Protocol Overview

> Architecture and design of the Kroko DEX

# Protocol Overview

Kroko DEX is a decentralized exchange on the Kasplex blockchain that combines two proven AMM models — **V2 (constant product)** and **V3 (concentrated liquidity)** — under a unified routing layer.

## Architecture

```mermaid theme={null}
flowchart TD
    A[User Wallet] --> B[Permit2]
    B --> C[Universal Router]
    C --> D[V2 Pool]
    C --> E[V3 Pool]
    F[Swap API] -.->|calldata| C

    style C fill:#00D1D9,color:#fff
    style F fill:#f5f5f5,stroke:#999,stroke-dasharray: 5 5
```

### Components

| Component            | Role                                                                                                              |
| -------------------- | ----------------------------------------------------------------------------------------------------------------- |
| **V2 Pools**         | Constant-product AMM (`x * y = k`). Simple, gas-efficient, full-range liquidity.                                  |
| **V3 Pools**         | Concentrated liquidity AMM. LPs choose a price range, improving capital efficiency.                               |
| **Universal Router** | Executes swaps across V2 and V3 in a single transaction. Supports multi-hop and split routes.                     |
| **Permit2**          | Token approval manager. Users approve tokens once to Permit2, then grant per-spender permissions with expiration. |
| **Swap API**         | Off-chain routing engine that finds optimal paths and generates transaction calldata.                             |

## How a Swap Works

1. **Approve** — User approves their token to the Permit2 contract (one-time per token)
2. **Permit** — User grants the Universal Router permission via Permit2 (one-time per token)
3. **Quote** — Frontend requests an optimal route from the Swap API
4. **Calldata** — Frontend requests encoded transaction data from the Swap API
5. **Execute** — User sends the transaction to the Universal Router

The routing engine automatically selects the best path — single-hop or multi-hop, V2 or V3 or mixed — based on available liquidity and price impact.

## V2 vs V3

| Feature            | V2                         | V3                                     |
| ------------------ | -------------------------- | -------------------------------------- |
| Liquidity range    | Full range (0 to infinity) | Custom price range                     |
| Fee                | Fixed 0.3%                 | Selectable: 0.01%, 0.05%, 0.3%, 1%     |
| LP token           | Fungible ERC-20            | Non-fungible ERC-721 (NFT)             |
| Capital efficiency | Lower                      | Higher (up to 4000x for narrow ranges) |
| Complexity         | Simple                     | Advanced                               |
| Best for           | Stable pairs, passive LPs  | Active LPs seeking higher returns      |

## Native Token

Kasplex's native currency is **KAS** (18 decimals). Since AMM contracts require ERC-20 tokens, KAS is wrapped as **WKAS** for on-chain operations. The Universal Router handles wrapping and unwrapping automatically — users interact with native KAS directly.

See [Native Token Handling](/concepts/native-token) for details.
