# Mechanism

## 🪄 The Bonding Curve (Exponential)

The bonding curve mechanism used in KaiaFun initially follows an **Exponential** model. The equation for this curve is:

$$
P(x) = P\_0 \cdot e^{k \cdot x}
$$

Where:

* $$P(x)$$ is the price of the token at a given point
* $$P\_0$$ is the initial price
* $$k$$ is a constant that determines the steepness of the curve
* $$x$$ is the percentage of tokens sold (ranging from 0 to 1)

The value of $$k$$ can be derived from the initial and target prices:

$$
k = \ln(\frac{P\_{\text{target}}}{P\_0})
$$

## 💸 Valuation

### Initial Price

The optimal initial token price is 0.0000183 KAIA per token.

$$
P\_{\text{Token}\_\text{initial}/\text{KAIA}} = 0.0000183 \text{ KAIA}
$$

### Total Supply

Token total supply remains 1 Billion.

$$
T\_s = 1,000,000,000
$$

With 18 decimal places matching the native token, it is defined in base units as:

$$
T\_{\text{s}\_\text{units}} = 1,000,000,000 \times 10^{18}
$$

### Initial Virtual Liquidity

#### Token Reserves

80% of the total supply, equivalent to 800,000,000 tokens, is reserved into the virtual pool and tradeable via the bonding curve. The remaining 20%, constituting 200,000,000 tokens, is deployed to the DEX upon migration.

Therefore initial reserves for the token ($$R\_{t\_{initial}}$$) is:

$$
R\_{t\_{initial}} = T\_s \times \frac{80}{100} = 800,000,000
$$

### Initial Market Cap

Initial market cap can be calculated as:

$$
\text{Market Cap}*{\text{Token}*\text{final}} = T\_s \times P\_{\text{Token}*\text{initial}/\text{KAIA}} \times P*\text{KAIA/USD} \ = 1,000,000,000 \times 0.0000183 \text{ KAIA} \times 0.127 \text{ USD} \approx 2,324.1 \text{ USD}
$$

Where:

* $$T\_s$$ is the total supply of KAIA tokens
* $$P\_{\text{Token}\_\text{initial}/\text{KAIA}}$$ is the initial price of the token
* $$P\_\text{KAIA/USD}$$ is the price of KAIA in USD

## 📈 Price/Profit Projection on the Time of Migration (1/2)

### Migration Threshold

The migration threshold is set at 546,614 KAIA, which is equivalent to approximately $69,420 at a KAIA price of $0.127. This specific value was chosen as a meme number using the constants at the time of protocol deployment.

$$
\text{Migration Threshold}\_\text{KAIA} = 546,614 \text{ KAIA}
$$

$$
\text{Migration Threshold}\_\text{USD} \approx 546,614 \times 0.127 = 69,419.978 \text{ USD} \approx 69,420 \text{ USD}
$$

Using the exponential bonding curve model, we can calculate various metrics at the time of migration:

### Final Token Price

The final token price when the migration threshold is reached:

$$
P\_{\text{Token}\_\text{final}/\text{KAIA}} = 0.000546614173228346 \text{ KAIA}
$$

### Total KAIA Raised

The total amount of KAIA raised through the bonding curve:

$$
\Delta R\_b \approx 124,424.78 \text{ KAIA}
$$

In production, this value can contain a small margin of error due to the approximate operations performed in smart contracts.

### CPMM model after migration

After reaching the migration threshold, the system transitions from the exponential bonding curve to a Constant Product Market Maker (CPMM, or CPAMM) model for the DEX. The CPMM follows the equation:

$$
x \* y = k
$$

Where:

* $$x$$ represents the base token reserves (e.g. Wrapped KAIA)
* $$y$$ represents the token reserves (i.e. Newly launched token on top of KaiaFun)
* $$k$$ is a constant

The price of the token at any point can be calculated as:

$$
P = \frac{x}{y}
$$

For buying tokens:

$$
\Delta y = y - \frac{k}{x + \Delta x}
$$

For selling tokens:

$$
\Delta x = x - \frac{k}{y + \Delta y}
$$

Where:

* $$\Delta x$$ is the amount of base tokens added or removed
* $$\Delta y$$ is the amount of tokens bought or sold

To maintain price continuity during this transition, we need to calculate the appropriate KAIA liquidity to deploy to the DEX that matches the final price in the bonding curve.

### Migrated KAIA Liquidity

The amount of KAIA needed for DEX liquidity is calculated to match the final price in the bonding curve after migration to CPMM:

$$
R\_{b\_{final}} = P\_{\text{Token}*\text{final}/\text{KAIA}} \times (T\_s - R*{t\_{initial}}) \approx 109,322.83464567 \text{ KAIA}
$$

This ensures that the initial price in the CPMM DEX matches the final price of the exponential bonding curve, providing a smooth transition for traders.

### Liquidity Fees

The amount of KAIA remaining after DEX deployment:

$$
\text{Remaining KAIA} = \Delta R\_b - R\_{b\_{final}} \approx 15,101.946011 \text{ KAIA}
$$

## 🧮 Mathematical Analysis (2/2)

### Price Increase

We can calculate the percentage increase in token price from initial to final:

$$
\text{Price Increase} = \frac{P\_{\text{Token}*\text{final}/\text{KAIA}} - P*{\text{Token}*\text{initial}/\text{KAIA}}}{P*{\text{Token}\_\text{initial}/\text{KAIA}}} \times 100% \ = \frac{0.000546614173228346 - 0.0000183}{0.0000183} \times 100% \approx 2,886.96%
$$

### Market Cap at Migration

The market cap at the time of migration can be calculated as:

$$
\text{Market Cap}*\text{KAIA} = T\_s \times P*{\text{Token}\_\text{final}/\text{KAIA}} \ = 1,000,000,000 \times 0.000546614173228346 = 546,614.173228346 \text{ KAIA}
$$

Assuming a KAIA market price of $0.127, the market cap in USD is:

$$
\text{Market Cap}\_\text{USD} = 546,614.173228346 \times 0.127 \approx 69,419.9999999999 \text{ USD}
$$

Which matches the target market cap.

### Bonding Curve Constant

We can calculate the constant $$k$$ that defines our exponential curve:

$$
k = \ln(\frac{P\_{\text{Token}*\text{final}/\text{KAIA}}}{P*{\text{Token}\_\text{initial}/\text{KAIA}}}) \ = \ln(\frac{0.000546614173228346}{0.0000183}) \approx 3.396842143109809886
$$


---

# 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://docs.kaiafun.io/kaiafun/mechanism.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.
