# Algorithm

#### 1. Basic Concept

**Understanding Total Circulation**

The total circulation of the main token (hereinafter "main token") must be managed separately from the market cap. This is because some main tokens are locked when community tokens are issued.\
**Example Calculation:**

```
Actual Circulation = (Total Issued Main Tokens on EVM-compatible Chain) - (Locked Main Tokens) + (Total Base Value of Community Tokens)
```

**Main Token Valuation**

The value of the main token is calculated based on a coefficient **r**. The initial value is set to `10^18`, and this value is updated over time and through specific processes.

**Community Token Generation**

Community tokens are generated based on "r-c," which inherits the current coefficient **r** of the main token. At the time of generation, it is designed so that the value of 1 main token and 1 community token are equal.

***

#### 2. Key Variables and Their Meanings

* **r (Main Token Coefficient)**
  * **Definition:** Set to an initial value of `10^18`, and subsequently managed as an updated value (e.g., last updated coefficient).
  * **Role:** Serves as a reference value for various calculations, such as balance display and swap rate calculation.
* **r-c (Community Token Coefficient)**
  * **Definition:** Inherits the latest coefficient **r** of the main token at the time of community token generation and is managed independently thereafter.
  * **Role:** Used for balance display and exchange rate calculation of community tokens.
* **Token Base Value**
  * **Role:** Functions as a multiplier in the main token value calculation,

    ```
    Main Token Value = r × Token Base Value
    ```

    (Specific values are adjusted in each implementation)

***

#### 3. Process Flow and Mechanism

**3.1 Community Token Creation Process**

* **Flow:**
  1. The user calls the "token creation function" of the main token and requests the generation of community tokens by specifying a certain amount of main tokens.
  2. The quantity of community tokens to be generated is calculated based on the specified **exchange amount** and **dilution coefficient**.\
     \&#xNAN;*Example:*

     ```
     New Token Quantity = (Exchange Amount × Dilution Coefficient) / Initial Coefficient
     ```
  3. Using a proxy pattern or similar, an instance of the community token is deployed, and the latest coefficient **r** is inherited during initialization.
  4. As a result, the community token is managed as **r-c**, and initially, an equivalent value (swap rate) to 1 main token is established.

**3.2 Reduction Process**

* **Purpose:**\
  To gradually reduce the coefficient **r**, which indicates the value of the token, over time, aiming for supply adjustment and value stabilization of the entire ecosystem.
* **Implementation Example:**
  * **Main Token Side:**\
    At regular time intervals (e.g., every minute), the coefficient **r** is reduced to, for example, approximately 0.998 times through an internal update process. This update is reflected in the balance conversion and swap rate calculation.
  * **Community Token Side:**\
    While referring to the reduction process on the main token side, a unique update process is performed. Based on the parameters defined in the token settings (e.g., update interval, reduction rate, etc.), the community token's coefficient **r-c** is adjusted.

**3.3 Increase Process (Proof of Thanks)**

* **Purpose:**\
  To provide a mechanism to grant additional tokens as "Proof of Thanks" to users for usage actions such as token transfers.
* **Implementation Example:**\
  In the additional token grant process called during the sending and receiving of community tokens, the following elements are considered:

  * User's current balance
  * Usage ratio
  * Number of characters in the message (with a maximum character limit)

  Based on these parameters, upper limits such as the maximum increase rate and change rate are set to promote usage and simultaneously suppress a rapid increase in the total supply.

**3.4 Swap Rate Calculation and Redemption Restrictions**

* **Swap Rate Calculation:**
  * **Main Token → Community Token:**\
    Calculated using the exchange rate set for each community token and the latest coefficients of both (the updated coefficient on the main token side and the current coefficient on the community token side).
  * **Between Community Tokens:**\
    The exchange rate is indirectly determined based on the above calculation results.
  * **Community Token → Main Token:**\
    A mechanism on the main token side that manages the redeemable amount for individuals and the whole restricts redemption.
* **Redemption Restrictions:**

  * **Overall Restriction:**\
    The total amount of community tokens that can be redeemed is limited to, for example, 3% (300 BP) of the total daily supply.
  * **Individual Restriction:**\
    The amount of community tokens that each user can redeem per day is also kept within the upper limit according to the user's balance.

  This prevents rapid token exchange in the market and maintains the stability of the entire system.

***

#### 4. Summary

* **Initial Setting:**\
  The main token has an initial value of `r = 10^18`, and the community token is created as **r-c**, inheriting this **r** at the time of generation. It is designed so that the value of 1 main token and 1 community token are equal in the initial state.
* **Reduction Process:**\
  As time progresses, the coefficients of both the main token and the community token are updated by a predefined ratio (e.g., approximately 0.998 times on the main token side), and this becomes the basis for calculating the swap rate.
* **Increase Process (Proof of Thanks):**\
  A mechanism has been introduced to grant additional tokens to each user according to usage actions such as token transfers, with adjustments based on upper limits and usage status.
* **Swap and Redemption Restrictions:**\
  The exchange rate between the main token and community tokens is dynamically calculated based on the coefficient of each token and the set exchange rate, and redemption is subject to restrictions defined for the whole and for each individual.

In this way, the main token and community tokens interact with each other, and through dynamic coefficient updates, additional grants based on usage behavior, and strict redemption restrictions, the value management and stable operation of the entire token ecosystem are realized.


---

# 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://peace-coin.gitbook.io/peace-coin/technology/algorithm.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.
