# Introduction to DexAggregator

DexAggregator is a powerful Go-based API service that integrates **KyberSwap's intelligent routing algorithm** with custom **DexAggregator smart contracts**. It provides developers with optimal token swap routes and ready-to-use encoded transaction data for seamless DeFi integration.

## Why DexAggregator?

* 🔄 **Optimal Routes** - Leverages KyberSwap's aggregator to find the best swap rates across 100+ DEXes
* ⚡ **Ready-to-Use** - Returns ABI-encoded calldata ready for direct smart contract execution
* 🛡️ **Slippage Protection** - Built-in minAmountOut calculation with customizable tolerance
* 🌐 **Multi-Chain** - Supports BSC, Ethereum, and easily extensible to any EVM chain
* 🎯 **Multiple Strategies** - Simple, Batch, Multi-Hop, and Parallel Multi-Hop swaps
* 🔍 **Gas Estimation** - On-chain gas estimation for accurate transaction costs

## Features

### Automatic Route Building

Query KyberSwap's aggregator API, filter to trusted adapters, and automatically encode the optimal route into smart contract calldata.

### Custom Route Support

Manually define swap paths with specific adapters and token routes for advanced use cases and testing.

### Four Swap Types

* **Simple Swap**: Direct swap through a single DEX
* **Batch Swap**: Split liquidity across multiple DEXes
* **Multi-Hop Swap**: Sequential swaps through intermediate tokens
* **Parallel Multi-Hop**: Complex parallel routing with internal hop chains

### Smart Contract Integration

Pre-configured adapter contracts for:

* UniswapV2 / V3 / V4
* PancakeSwapV2 / V3
* And more...

## Quick Example

```bash
# Get optimal route and encoded calldata
curl -X POST https://your-api.com/api/v1/route/build \
  -H "Content-Type: application/json" \
  -d '{
    "chain": "bsc",
    "tokenIn": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
    "tokenOut": "0x55d398326f99059fF775485246999027B3197955",
    "amountIn": "1000000000000000000",
    "sender": "0xYourAddress",
    "recipient": "0xYourAddress",
    "slippageTolerance": 50
  }'
```

**Response includes:**

* ✅ Optimal route details
* ✅ Expected output amount
* ✅ Minimum output with slippage protection
* ✅ ABI-encoded `executorData` ready for contract call
* ✅ Gas estimation

## Use Cases

### DeFi Applications

Integrate optimal swap rates directly into your dApp without building routing logic.

### Trading Bots

Programmatically execute swaps at the best rates across multiple DEXes.

### Portfolio Managers

Efficiently rebalance portfolios with minimal slippage and gas costs.

### Cross-DEX Arbitrage

Identify and execute profitable arbitrage opportunities across different protocols.

## Architecture

```
Client App → DexAggregator API → KyberSwap Aggregator
                ↓
        Route Transformer
                ↓
        ABI Encoder
                ↓
        Smart Contract Execution
```

The service acts as a bridge between KyberSwap's powerful routing and your custom DexAggregator smart contracts, handling all the complex transformations and encoding automatically.

## Getting Started

Ready to integrate? Jump to our [Quickstart Guide](https://doc.iqe.me/getting-started/quickstart) to make your first API call in under 5 minutes.

For detailed API specifications, see the [API Reference](https://doc.iqe.me/api-reference/api-reference).

***

{% hint style="success" %}
**Open Source**

DexAggregator is open source and available on [GitHub](https://github.com/YourOrg/DexAggregator-go-server). Contributions are welcome!
{% endhint %}

{% hint style="info" %}
**Need Help?**

* 📖 Check our [FAQ](https://doc.iqe.me/getting-started/faq)
* 🐛 [Report Issues](https://github.com/YourOrg/DexAggregator-go-server/issues)
* 💬 Join our community discussions
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.iqe.me/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
