# Farm with Leverage

The pop-up box for adding amounts will be shown when clicking the **‘Farm’** button. The amounts users put will be equally divided into two groups in order to add a liquidity pool on PancakeSwap.&#x20;

For example, in the BNB-USDT, there are 6 cases;

1. Add **BNB** only x1  - no leverage, no destruction occurred.
2. Add **USDT** only x1 - no leverage, no destruction occurred.
3. Add **BNB** with leverage  x1 x1.5 x2 x2.5  with minimum borrowed amounts of 0.2 BNB.
4. Add **BNB** and **USDT** with leverage  x1 x1.5 x2 x2.5 (the system will calculate how much USDT users put equal to how much BNB amount) with minimum borrowed amounts of 0.2 BNB.   &#x20;
5. Add **BNB** and **USDT** only x1  - no leverage, no destruction occurred.
6. Add **USDT** only with leverage  x1 x1.5 x2 x2.5 (the system will calculate how much USDT users put equal to how much BNB amount) with minimum borrowed amounts of 0.2 BNB.

![](https://2223290131-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWXh2hL0GBQR3Ak_8bv%2F-McOH8DIRh5Fj-woxNAi%2F-McOIVW_BxLjKLvyW5ei%2FScreen%20Shot%202564-06-17%20at%2016.28.50.png?alt=media\&token=85e5454d-a3df-4d05-8ca1-4c3c4b271e47)

## 🧾Total Debt

The total amount of loan user takes on price leverage.

$$
Total Debt=Leverage Price−Cost
$$

\
Leverage price can be calculated from the total input price (in BNB) and leverage.

$$
Leverage Price=Total Input Price∗Leverage
$$

Total input price can easily get from the BNB input field, but in case the user enters a number in the alternative token input field, the token will be converted to BNB via PancakeSwap protocol.

## 🧾**Slippage and Trading Fees**

Slippage or price impact is the difference between the market price and estimated price due to trade size. The value can be calculated from the following equation.

Price Impact Calculation:

$$
{Price}\space{Impact}=\frac{(\frac{{reserve0}*{token1}}{reserve1}-\frac{{reserve0}*{token1}}{reserve1+token1})}{\frac{{reserve0}\*{token1}}{reserve1}}\*100
$$

For further detail, the market price is the ratio between reserve0 and reserve1 (The amount of token0 and token1 stored in a pool)**.**

$$
Market\ Price=\frac{reserve0}{reserve1}
$$

The estimated price due to trade size is the market price with the additional token.

$$
Estimated\ Price=\frac{reserve0}{reserve1+token1}
$$

So, we can find the slippage value from the difference between the market price and estimated price due to trade size.

$$
Slippage=∣Market Price−Estimated Price∣
$$

Now, the top equation could be simplified like this;

$$
Price\ Impact=\frac{Slippage}{Market\ Price}\times100
$$

## 🧾**Trading Fees Calculation (7 Days Avg.)**

$$
Trading fee APR =\frac{(oneDayVolumeUSD - volume7D)}{totalLiquidity \times(\frac{365}7)} \times100\times(\frac{0.25}{100})
$$
