> For the complete documentation index, see [llms.txt](https://kayen-protocol.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kayen-protocol.gitbook.io/documentation/protocol-mechanics/kayenswap-v2.md).

# KAYENSWAP V2

### Dual AMM

KayenSwap's Dual AMM is based on UniV2 constant formula, with a custom implementation of a Curve-esque logic for stables. The KayenSwap AMM is the core of our ecosystem-oriented approach, designed with the following principles in mind:

1. A high degree of fluidity to tailor each protocol / market participant's needs&#x20;
2. Capital efficiency with highly effective trading efficiency.
3. De-risking Chiliz native protocols from mercenary liquidity and adapting to their needs

Dual AMM is a dual-liquidity model for both volatile and stable assets with <mark style="color:red;">**Swap Referral**</mark> for partnering protocols

1. **Constant Product**

First introduced by Vitalik’s [On Path Independence](https://vitalik.ca/general/2017/06/22/marketmakers.html), Automated Market Makers (AMM) became the steering pillars for DeFi. Uniswap utilizes the constant product formula (CPAMM), x \* y = k, where x is the quantity of token X, y is the quantity of token Y and k is a constant. Each token pool is only comprised of two assets X and Y and this formula ensures the ratio of both are equal.

<figure><img src="/files/4PhuaTX6vkzESWEWwdAw" alt="" width="188"><figcaption><p>The graphical representation of the CPAMM</p></figcaption></figure>

$$
x \* y = k
$$

2. **Constant Sum**

CPAMM has been time-tested with exchanging long tail assets, but has been inefficient for stablecoins due to high price impact. Michael Egorov’s [StableSwap - efficient mechanism for Stablecoin liquidity](https://berkeley-defi.github.io/assets/material/StableSwap.pdf) dawns the constant sum formula (CSAMM), x + y = k. The underlying invariant that empowers Curve with a minimal price slippage.

<figure><img src="/files/WdVvpqlm6sh7dm9nHBHR" alt="" width="188"><figcaption><p>The graphical representation of the CSAMM</p></figcaption></figure>

Embodying both CPAMM and CSAMM, each KayenSwap can configure its own type, depending on the expected price correlation level between the two tokens of the pair. For **volatile pairs,** composed of uncorrelated assets, based on the UniV2 model (CPAMM), the pool uses the standard constant product formula. For **stable pairs of** correlated assets, designed to maintain a 1:1 transfer ratio, the pool uses BasePool model (CSAMM).

Stable pairs are used for correlated assets, and will try to maintain a 1:1 transfer ratio as much as possible. The formula is based on the well-known Solidly curve:

$$
x^3y + xy^3 = k
$$

### <mark style="color:red;">Referral</mark>

The swap referral in design will be available for everyone. Every KayenSwap referral partner can add its referral address to each transaction made on KayenSwap through its dApp, and subsequently receives a part of their users' generated swap fees. We envision a Win/Win scenario in which **all KayenSwap actors are adequately rewarded**, thereby fostering a **fair and sustainable ecosystem**.


---

# 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://kayen-protocol.gitbook.io/documentation/protocol-mechanics/kayenswap-v2.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.
