# Adding Liquidity

## 1. Initial Liquidity Provision (Setting the Price)

<figure><img src="https://2726550812-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjMO51gfM0FaNC6SfYbCR%2Fuploads%2FOn8FUtfPjulnhjX4P0Ox%2FV1%20(2).png?alt=media&#x26;token=b2fb7862-688f-4f50-832c-54a23e095525" alt=""><figcaption></figcaption></figure>

When you are the first person to provide liquidity for the **BT/ITL** pair, you define the initial exchange rate.

* **Variables:** Let x be the amount of **BT** and y be the amount of **ITL**.&#x20;
* **Price Discovery:** The initial price of **BT** is determined by the ratio of your deposited&#x20;

  $$
  P\_{BT} = \frac{\Delta y\_{init}}{\Delta x\_{init}}
  $$
* **LP Token Calculation:** To prevent "inflation attacks" on small pools, the protocol burns the first **1,000 wei** of LP tokens (L<sub>min</sub>):

  $$
  L\_{initial} = \sqrt{\Delta x\_{init} \cdot \Delta y\_{init}} - L\_{min}
  $$

$$
\textbf{Example: }
\text{If you deposit } 100 , BT , (\Delta x)
\text{ and } 1 , ITL , (\Delta y),
\text{ the starting price is } 0.01 , ITL/BT
$$

## 2. Subsequent Liquidity (Maintaining the Ratio)

Once the pool is established, new liquidity providers must deposit tokens in the exact same ratio as the current reserves to avoid changing the market price during the deposit.

* **The Constraint:**&#x20;

  $$
  \frac{\Delta x}{x} = \frac{\Delta y}{y}
  $$
* **LP Token Issuance:** You receive LP tokens proportional to your share of the total reserves:&#x20;

  $$
  L\_{minted} = \min \left( \frac{\Delta x}{x} \cdot L\_{total}, \frac{\Delta y}{y} \cdot L\_{total} \right)
  $$

$$
\text{Where } x \text{ and } y \text{ are the current reserves of BT and ITL, and } L\_{total} \text{ is the total supply of LP tokens.}
$$

## 3. The "K" Invariant (Constant Product)

Adding liquidity increases the depth of the pool by increasing the constant product k.&#x20;

$$
\begin{aligned}
\textbf{Pre-deposit:} \quad & k\_{old} = x \cdot y \\
\textbf{Post-deposit:} \quad & k\_{new} = (x + \Delta x)(y + \Delta y) \\
\textbf{Market Impact:} \quad & k\_{new} > k\_{old}, \\
& \text{the pool becomes more resilient to price swings,} \\
& \text{meaning future traders will experience less slippage.}
\end{aligned}
$$

## 4. Mathematical Risk: Impermanent Loss (IL)

LPs face "Impermanent Loss" if the price of BT diverges from its price at the time of deposit. The loss relative to simply holding the tokens is:&#x20;

$$
IL = \frac{2\sqrt{r}}{1 + r} - 1
$$

$$
\text{where } r = \frac{P\_{new}}{P\_{old}} \text{ is the price ratio}
$$

**Note:** This loss is called **impermanent** because it disappears if the price returns to the original ratio. but it must be offset by the 0.3% trading fees to ensure profitavility.

## 5. Adding Liquidity with Native ITL

Since the core engine operates on two ERC-20 tokens, when providing **native ITL**, the Router contract automatically wraps it into **WITL (Wrapped ITL)**.

* **Technical Logic:** The contract calculates the required BT amount based on the ITL sent:

  $$
  \Delta x = \frac{\Delta y \cdot x}{y}
  $$

The Router pulls the **BT** from your wallet, wraps your **ITL** into **WITL**, and transfers both to the Pair contract to mint your LP tokens.

$$
P\_{BT} = \frac{\Delta y\_{init}}{\Delta x\_{init}}
$$
