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

# KayenFi V2

KayenFi V2's Dual AMM is based on the [UniV2 constant formula](https://developers.uniswap.org/docs/protocols/v2/concepts/pricing#how-are-prices-determined), with a custom implementation of a [Curve](https://www.curve.finance/)-esque logic for stable pairs.

The KayenFi V2 AMM is the core of our ecosystem-oriented approach, designed with the following principles in mind:

* A high degree of fluidity to tailor each protocol / market participant's needs
* Capital efficiency with highly effective trading efficiency
* 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 **Swap Referral** for partnering protocols. Each KayenFi V2 can configure its pool type depending on the expected price correlation level between the two tokens of the pair.

#### 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/a4aeabca6e235da64b01c517f20e1d9b016d44ac" alt="The graphical representation of the CPAMM" width="375"><figcaption><p>The graphical representation of the CPAMM</p></figcaption></figure>

#### Constant Sum (Stable)

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) introduces the [constant sum formula](https://docs.curve.finance/protocol/pool/compare-amm#stableswap-concentrated-liquidity-for-pegged-assets) (CSAMM), `x + y = k`. This invariant is what empowers Curve with minimal price slippage for highly correlated assets.

<img src="/files/4704dcb13eeadb5991c5dc3f2ed9eec76b0a5db8" alt="The graphical representation of the CSAMM" width="375">

Stable pairs are used for correlated assets and will try to maintain a 1:1 transfer ratio as much as possible.

The formula for the stable curve is based on the well-known [Solidly curve](https://docs.solidly.com/voting-system/basics):

`x^3 y + x y^3 = k`

<details>

<summary><strong>Referral</strong></summary>

The swap referral design is available for everyone. Every KayenFi referral partner can add its referral address to each transaction made on KayenFi through its dApp, and subsequently receives a part of their users' generated swap fees.&#x20;

This creates a win/win scenario in which **all KayenFi actors are adequately rewarded, fostering a fair and sustainable ecosystem**.

</details>
