> For the complete documentation index, see [llms.txt](https://docs.ecko.finance/eckodao/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecko.finance/eckodao/eckodex/how-to-swap/x-swap.md).

# X-Swap

### X-Swap

A fork of [kadenaswap](https://github.com/kadena-io/kadenaswap) (a Uniswap V2 port to pact), with support for global exchange fees (equivalent to Uniswap's `_mintFee`) and time-weighted average price oracle data, with support for tracking the TWAP of longer swap paths like `[tokenA coin tokenB]`.

The code is in the `kadenaswap/` directory and the following are the main files:

* `exchange.pact`: The core of the exchange, represents all the pairs and includes code for adding and removing liquidity, swapping, oracles, and more.
* `tokens.pact`: Simple module for keeping track of liquidity tokens across all pairs. Each token is identified by a key, and has a similar interface to `fungible-v2` modules.
* `gas-station/gas-station.pact`: Module for managing the gas station that is used with the exchange.
* `exchange.repl`, `oracle.repl` and `gas-station/gas-station.repl`: Test files.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ecko.finance/eckodao/eckodex/how-to-swap/x-swap.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
