# The Foundry

This is a gameplay feature where players are rewarded for providing liquidity to the Alloy Token and AVAX pair.

{% hint style="warning" %}
Players always retain custody of their LP tokens. Once connected to the **Alloy Space** game, LP tokens are recognized in a players' wallet. **Do not send your LP tokens anywhere**.
{% endhint %}

Players holding LP tokens make a choice every **3 days** on how they would like to be awarded. There are currently two choices from within **The Foundry**, and only one can be utilized at a given time:

<img src="https://2111160599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffggipod3jU8OdLSacyrb%2Fuploads%2FpDoXxs1ZLwP4iKZ4OMyo%2Fcurrency_alloy.png?alt=media&#x26;token=ccb0aacf-5a91-4214-929b-0577a42c004e" alt="" data-size="original"> **Smelter Protection** - *Halt Part Degradation* of a subset of collected Alloy Parts

<img src="https://2111160599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffggipod3jU8OdLSacyrb%2Fuploads%2FpDoXxs1ZLwP4iKZ4OMyo%2Fcurrency_alloy.png?alt=media&#x26;token=ccb0aacf-5a91-4214-929b-0577a42c004e" alt="" data-size="original"> **Smelter Extraction** - *Get proportionally rewarded* from a pool of smelting Alloy Token

### Smelter Protection

The **Purity** assigned to an **Alloy Part** degrades slowly when collected as an NFT into a player's **inventory**. When this decreases, so will the combined **Alloy Value** of the **Alloy Construct** that the part is assembled into.

The **Alloy Value** of individual **Alloy Parts** has an impact on the **Alloy Construct** in two ways:

1. **Selling** - When choosing to *sell* the Alloy Construct, the Construct Alloy Value determines the Offer Price for that Alloy Construct. A higher Alloy Value results in a higher Offer Price.
2. **Collecting** - When choosing to *collect* the **Alloy Construct** (by rejecting the **Offer Price**), the **Alloy Value** helps determine the [***Construct Grade***](https://alloy-space.gitbook.io/alloy-space/nft-parts/alloy-constructs-utility#construct-class) of the newly minted **Alloy Construct**. A higher **Alloy Value** results in a higher grade, *which also demands a higher price in the **Alloy Market.***

{% hint style="info" %}
*Construct **Alloy Value** and **Construct Grade** will have an undisclosed impact on future gameplay.*
{% endhint %}

If a player chooses to activate the **Smelter Protection**, a protection formula will apply to a number of **Alloy Parts** currently held in the player's inventory. After a 2-day cooling period, the parts will be protected from degradation for 3 days, and then the cooling period starts again.

{% hint style="info" %}
The greater the % of the LP that a player holds (excluding the Alloy LP allocations), the greater the proportion of a player's inventory they can protect. This scales by the **square root of LP % \* 100,** instead of linearly, which benefits smaller LP Providers.
{% endhint %}

> **NUMBER OF PARTS PROTECTED** = ROUND( SQRT( % total LP provided \* 100 ) \* PROTECTION MULTIPLIER ) / 100 \* ( # PARTS IN INVENTORY ) + 1

#### Smelter Protection Example table (with protection multiplier = 5):

| Player | # Parts Inventory | % of total LP \* 100 (excluding Alloy LP) | sqrt    | round(sqrt \* PM) / 100 | # parts to protect |
| ------ | ----------------- | ----------------------------------------- | ------- | ----------------------- | ------------------ |
| 1      | 63                | 50.000                                    | 7.07107 | 35%                     | 24                 |
| 2      | 25                | 5.000                                     | 2.23607 | 11%                     | 4                  |
| 3      | 53                | 3.000                                     | 1.73205 | 9%                      | 6                  |

### Smelter Extraction

{% hint style="info" %}
When part [**Processing** ](https://alloy-space.gitbook.io/alloy-space/alloy-fabrication/the-processing)fails for any player in the game, a small tax of 4.5% of the **recycle amount** gets sent to the **Foundry** smart contract.
{% endhint %}

By activating this option, those who help run **The Smelter** (by holding LP) get to keep the extracted Alloy Token. The **Smelter** extracts the token every 3 days and proportionally rewards those who held LP for those 3 days. A snapshot of the LP position is taken at the moment of distribution.

#### Retooling

Once **Smelter Extraction** is activated, there is a retooling period of **9 days** to begin extraction from the **Smelter**.

Anytime a player removes their LP, the retooling period is again required.

#### Refining & Cooling

After the **Retooling** period, there is a 3-day period of **Refining** followed by a 2-day period of **cooling**.

**Refining** - This is the 3-day waiting period to collect the extracted **Alloy** token. During this period, the other **Foundry** option cannot be selected. *Removing LP tokens at any time during this period immediately makes award collection impossible (even if* immediately *added again).*

**Cooling** - This is the 2-day waiting period to begin **Refining** again.

{% hint style="success" %}
In other words, when a player is awarded after 3 days, they will not be able to extract again for 2 days. A player can collect from the taxes in the **Smelter** every 5 days - 3 days waiting to extract, 2 days off.
{% endhint %}

> The extraction formula is as follows for a Foundry pool containing $$X$$ total Alloy token at time of distribution for $$N$$​ LP providers, having 100 \* LP % shares of $$L\_i,\ i=1\ldots N$$​.

**Alloy token reward for** $$i$$**th LP provider:** $$X\_i = \frac{\sqrt{L\_i}}{\sum\_{j=1}^N \sqrt{L\_j}} X$$

​We will also include a throttle variable on the Smelter in case this becomes a source of price instability.
