# XdYe Bar

XdYe Maker is the contract that allow XdYe holders to profit from trading fees generated on XdYe platform.&#x20;

For participating from those rewards users need to hold XdYe Token and deposit them on XdYe Bar contract.&#x20;

This contract will give them xXdYe, representing a concrete share. For understanding the reward mechanism we have created a diagram.

<figure><img src="https://1716109615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaLpsXqP00Znm3KwSX02Z%2Fuploads%2F4shytcqsQ4gyWssJ2dX9%2FGra%CC%81fico%20Cuadro%20Comparativo%20de%20Tres%20Planes%20o%20Procesos%20Moderno%20Colorido%20(2).png?alt=media&#x26;token=6bd5236c-522c-4cfd-a26b-f3692174cf8f" alt=""><figcaption><p><strong>State 1:</strong> User deposits XdYe token on XdYe Bar</p></figcaption></figure>

<figure><img src="https://1716109615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaLpsXqP00Znm3KwSX02Z%2Fuploads%2FN9Y3tuCiHLnasd9mKTYM%2FGra%CC%81fico%20Cuadro%20Comparativo%20de%20Tres%20Planes%20o%20Procesos%20Moderno%20Colorido%20(3).png?alt=media&#x26;token=0335d413-4320-40d5-b9d1-3da3d51d6db0" alt=""><figcaption><p><strong>State 2</strong>: User can now exchange xXdYe or more XdYe than he deposited</p></figcaption></figure>

In other words, XdYe Bar allow users to participate from XdYe Platform rewards in the form of more XdYe tokens. Incentivizing even more Platform token usage and its value.

**XdYe Bar** Smart Contract can be found at:&#x20;

{% embed url="<https://github.com/rogerCapone/XdYe_Smart_Contracts/blob/main/Bar.sol>" %}
XdYe Bar Contract Source Code
{% endembed %}

###

### Contract main functions

* *`enter()`*

This method allow XdYe users to deposit XDYE inside Bar contract. The Bar contract mints xXdYe to the user that is depositing XdYe, the calculation performed is pretty simple:

$$
f(amount) = (amount \* totalShares)/totalXdYe
$$

​As you can see in the formula rewards are based on total amount of deposited XdYe that Bar contract holds.&#x20;

* *`leave()`*

This method allows users to convert their shares *(xXdYe)* back into XdYe tokens collecting generated rewards.

{% hint style="warning" %}
**Attention:** If you are trying to replicate the code, be sure to consider the imports or visit the corresponding [Github Repository](https://github.com/rogerCapone/XdYe_Smart_Contracts/tree/main) in order to have the whole source code.
{% endhint %}
