# Borrow System

## **Concept**

* **Why It Was Introduced**:\
  The borrowing system on XPet v2 was developed to address the challenges faced by traders in low-cap tokens, particularly in the memecoin market. These challenges include the risk of rug pulls and significant price dumps caused by early whales exiting the market. The borrow feature offers users a safer way to trade these volatile tokens by reducing exposure to extreme risks while allowing them to capitalize on trading opportunities.
* **Key Factors of the Borrowing Mechanism**:
  * **Collateral-Based Borrowing**: Users can borrow memecoins by providing collateral in **BERA**, ensuring security for both the borrower and the platform.
  * **Risk-Free Trading**: If the token price drops, borrowers can simply return the borrowed tokens, regaining their collateral without suffering significant losses.
  * **Borrowing Room**: The availability of borrowing is based on token eligibility. A token must reach a certain level of liquidity ($**BERA**deposited in its pool) to enable borrowing. Borrowing capacity is also capped at 20% of the total tokens held by users in circulation, ensuring stability and avoiding over-leveraging.

***

## **Borrow Flow**

* **Steps**:
  1. **Deposit Collateral**: Users deposit **BERA** as collateral to enable borrowing.
  2. **Borrow Tokens**: Users can borrow the desired tokens up to 80% of the value of their collateral.
  3. **Trade and Repay**: Users trade the borrowed tokens and repay them to regain their collateral. If the trade is profitable, users can repay and retain their profits.
* **Rules for Fees and Rates**:
  * **Daily Fee**: A 0.5% fee is applied to the borrowed amount daily.
  * **Borrowing Rate**: Users can borrow up to 80% of their collateral's value. Borrowing is subject to liquidation rules if the collateral value drops significantly relative to the borrowed tokens.
  * **Add Collateral**: Users can add more funds to their collateral to ensure safety and avoid liquidation.

***

## **Liquidation Events**

* **When It Occurs**:\
  Liquidation is triggered when the market value of the collateral equals the value of the borrowed tokens. This ensures that the platform can recover its funds in case of adverse market movements.
* **How to Handle It**:\
  Once liquidation occurs, users lose access to their collateral, but they retain the borrowed tokens. This setup ensures that users do not face excessive losses and still hold the tokens they traded. Adding more collateral before liquidation can prevent this event.

***

## **Add Funds**

**Increasing Collateral Safety**:\
Users can add additional **BERA** to their collateral to increase their borrowing safety margin. This reduces the risk of liquidation and provides more room for market fluctuations. However, borrowing is not allowed if the borrowing rate drops below 50% of the collateral value, ensuring a secure borrowing process.

***

## **Referral Code System**

* **How It Works**:\
  Every user on XPet v2 receives a unique referral code. When others use this code to participate in the platform, the referrer earns 10% of the $TREE rewards earned by the referred user.
* **Benefits**:
  * Encourages community growth by incentivizing referrals.
  * Offers a sustainable and rewarding way for users to engage and invite others to the platform.
