# ATD (Automated Token Distributor)

## Overview

The Automated Token Distributor (ATD) is a core component of VALOR's token distribution strategy. This document explains the ATD’s budget distribution mechanisms.

{% hint style="info" %}
The below models can be updated due to the balance update
{% endhint %}

## 1. Budget Distribution

ATD’s budget distribution framework employs a probabilistic approach based on a standard normal distribution to allocate resources effectively across various tokens and market segments.

### Key Definitions and Variables

* **Normal Distribution (PDF)**: A probability distribution function used to allocate budgets fairly, with a mean of 0 and a standard deviation of 1.
* **Budget Allocation Ratios**: Ratios are derived from the PDF to determine the portion of the total budget allocated to each token.
* **Total Budget**: It is set at 110% of the inflow over 12 hours. It is rounded down to 9 decimal places, and the remainder is discarded.

### Process Explanation

1. **Total Budget Calculation**:
   1. Case 1 (Accumulated Inflow < Accumulated Outflow):
      * The total budget is set at 110% of the inflow over the past 12 hours plus any carried-over budget&#x20;

        $$
        B\_{total} = \left\lfloor (1.1 \times Inflow) \times 10^9 \right\rfloor / 10^9
        $$

        * Here, $$Inflow$$ is the inflow over the past 12 hours.
   2. Case 2 (Accumulated Inflow > Accumulated Outflow):
      * The total budget is set at sum of each sSPL supply and ideal price.

        $$
        B\_{total} = \sum S \times P\_{idl}
        $$
      * Maximum budget = (Accumulated Inflow - Accumulated Outflow) \* 1.1

2. **Random Factor Generation**:
   * Generate a random number within the range of \[-0.5, 0.5] from a normal distribution with a mean of 0 and a standard deviation of 1. This controls the variability in budget allocation.
   * Calculate the probability density $$p(x\_i)$$ for each random factor $$x\_i$$. This density influences how the budget is divided. The probability density function is:

     $$
     p(x\_i) = \frac{1}{\sqrt{2\pi}} e^{-\frac{x\_i^2}{2}}
     $$

3. **Budget Allocation**:
   * Convert these densities into budget allocation ratios:

     $$
     R\_i = \frac{p(x\_i)}{\sum\_{j=1}^{9} p(x\_j)}
     $$
   * Allocate the total budget to various tokens using these ratios:

     $$
     B\_i = \left\lfloor R\_i \times B\_{total} \times 10^9 \right\rfloor / 10^9
     $$

## 2. Price Setting

The ATD's price-setting mechanism dynamically adjusts token prices around an ideal price to reflect market values.

### Key Definitions and Variables

* **Ideal Price (**$$P\_{idl}$$**)**: The target price for the tokens.
* **Reference Price (**$$P\_{ref}$$**)**: The market price of the token in Black Market.
* **Next Price (**$$P\_{nxt}$$**)**: The price of the token after adjustment.
* **Standard Deviation (**$$\sigma$$**)**: Controls the spread of price values around $$P\_{idl}$$.

{% hint style="success" %}
These variables will be initialized on the procurement creation
{% endhint %}

### Standard Deviation Calculation

The standard deviation $$\sigma$$ is calculated as:

$$
\sigma = \sqrt{\frac{P\_{idl}^2}{2 \ln(10)}}
$$

This calculation determines the range of price fluctuations around the ideal price $$P\_{idl}$$, adjusting for market volatility.

### Price Determination Model

#### Random Price Determination Model

This model dynamically calculates the next token price using a probability distribution function centered on $$P\_{idl}$$.

**Detailed Process**

1. **Define Price Range**:
   * Establish the effective price range for the next pricing cycle:

     $$
     \text{Effective Price Range} = \[P\_{ref} \times 0.9, P\_{ref} \times 1.4]
     $$
2. **Generate PDF**:
   * Create a normal distribution centered on $$P\_{idl}$$ with the calculated $$\sigma$$.
3. **Calculate Area Under Curve**:
   * Determine the total probability area under the PDF within the defined range:

     $$
     A = \int\_{P\_{ref} \times 0.9}^{P\_{ref} \times 1.4} f(x) , dx
     $$
4. **Generate Random Factor and Set Next Price**:
   * Select a random value within the range \[0, A], and determine the corresponding price using the inverse cumulative distribution function (CDF):

     $$
     P\_{nxt} = f^{-1}(r)
     $$
   * Here, $$f^{-1}$$ is the inverse function of the CDF, accurately determining the price corresponding to the random value $$r$$.
5. **Final Quantity Adjustment**:

   * Calculate the maximum quantity that can be purchased with the allocated budget:

     $$
     Q\_i = \left\lfloor \frac{B\_i}{P\_{nxt}} \right\rfloor
     $$
   * Round down to ensure accurate quantity calculation. (If $$Q\_i < 1$$, set $$Q\_i$$ to 1)
   * Adjust the final price using the actual quantity purchased:

     $$
     P\_{final} = \left\lfloor \frac{B\_i}{Q\_i} \times 10^3 \right\rfloor / 10^3
     $$
   * The final price $$P\_{final}$$ is rounded down to 3 decimal places.

   $$
   B\_i^\text{new} = B\_i - (Q\_i \times P\_{final})
   $$

## Data

| Token                   | Ideal Price ($VALOR) |
| ----------------------- | -------------------- |
| Voodoo Doll ($VD)       | 5.5515               |
| Gold Teeth ($GT)        | 6.8204               |
| JB Whiskey ($JBW)       | 10.3219              |
| Canteen ($CT)           | 11.2677              |
| G Badge ($GB)           | 13.2835              |
| Holy Water ($HW)        | 21.7118              |
| Used Engine ($UE)       | 35.9697              |
| Enhanced Bullet ($EB)   | 57.8595              |
| Oil Lighter Case ($OLC) | 72.0052              |

## Examples

### PDF and simulation when the ideal price is 2.28

<figure><img src="https://165396892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyn01bJhpVHjehvGT4I37%2Fuploads%2FslbDOPGKcnCNab2Ivs7s%2FPDF_Case_1_Final_Attempt.png?alt=media&#x26;token=1e81c6b7-0206-4e1f-8070-2bc732812c50" alt=""><figcaption></figcaption></figure>

<div><figure><img src="https://165396892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyn01bJhpVHjehvGT4I37%2Fuploads%2FrWocnthsTFKO0LIB7dzF%2FPrice_simulation_1.png?alt=media&#x26;token=5b341e70-71ef-4544-b81d-73a944749a20" alt=""><figcaption></figcaption></figure> <figure><img src="https://165396892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyn01bJhpVHjehvGT4I37%2Fuploads%2Fu7CtH7Mma5MRQb9H8To0%2FPrice_simulation_2.png?alt=media&#x26;token=9baf74f0-3684-41b6-8d40-cd09b7a74ac4" alt=""><figcaption></figcaption></figure> <figure><img src="https://165396892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyn01bJhpVHjehvGT4I37%2Fuploads%2FuiGRW0jwxBarCbYWHcfq%2FPrice_simulation_3.png?alt=media&#x26;token=37e06075-106f-4490-b9f4-37565d30c1e6" alt=""><figcaption></figcaption></figure></div>

### PDF and simulation when the ideal price is 50.4

<figure><img src="https://165396892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyn01bJhpVHjehvGT4I37%2Fuploads%2FDBCNBciRJROD8tVxzOty%2FPDF_Case_2_Final_Attempt.png?alt=media&#x26;token=b03a402c-d0e5-4b59-a06c-c64f0785bf64" alt=""><figcaption></figcaption></figure>

<div><figure><img src="https://165396892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyn01bJhpVHjehvGT4I37%2Fuploads%2FwSUjp07L0MtRPE51UYrX%2FPrice_simulation_1.png?alt=media&#x26;token=5f8ae6b4-c694-4af7-b1d8-80db87f44303" alt=""><figcaption></figcaption></figure> <figure><img src="https://165396892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyn01bJhpVHjehvGT4I37%2Fuploads%2F3zGNZX4iJaluYlrv3w44%2FPrice_simulation_2.png?alt=media&#x26;token=22430e3e-3904-4699-bfd1-022dfb5c37a2" alt=""><figcaption></figcaption></figure> <figure><img src="https://165396892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fyn01bJhpVHjehvGT4I37%2Fuploads%2FQNaMHZt9rUeXX7pYwwEM%2FPrice_simulation_3.png?alt=media&#x26;token=d0ed2d61-9bc6-4b13-a2a7-2cce58d1c76f" alt=""><figcaption></figcaption></figure></div>
