# JavStakeX

### General Description

The **JavStakeX** contract is an upgradable staking platform designed to allow users to stake tokens in various pools and earn rewards. It incorporates features such as reward configuration, fee structures and integration with terms and conditions agreements.

#### Key Features:

* Multi-token staking pools with adjustable reward parameters.
* Dynamic pool creation and configuration.
* Reward distribution with support for ERC20 tokens.
* Integration with terms and conditions for user actions.
* Burn mechanics for token handling.
* Support for NFTs to boost rewards through the "Infinity Pass" feature.

### Contract State Variables

#### Core Pool Structures:

1. **PoolInfo\[]** `poolInfo`: Stores details for each pool, such as:
   * Base and reward tokens.
   * Accumulated rewards per share.
   * Total shares in the pool.
2. **PoolFee\[]** `poolFee`: Defines fee structures for each pool, including deposit, withdraw, and claim fees.
3. **mapping(uint256 => mapping(address => UserInfo))** `userInfo`: Tracks user-specific staking information such as shares and reward debts.
4. **mapping(address => TokenPrecisionInfo)** `tokensPrecision`: Holds precision configurations for base and reward tokens.

### Core Functionalities

User Staking and Rewards

1. **stake(uint256 \_pid, uint256 \_amount)**: Allows users to stake tokens in a specific pool.
2. **unstake(uint256 \_pid, uint256 \_amount)**: Allows users to withdraw their staked tokens.
3. **claim(uint256 \_pid)**: Claims rewards from a specific pool for the user.
4. **claimAll()**: Claims rewards from all pools for the user.

#### Reward Distribution

1. **addRewards(uint256 \_pid, uint256 \_amount)**: Adds rewards to a specified pool. Only callable by the rewards distributor.
2. **pendingReward(uint256 \_pid, address \_user)**: Returns the pending reward amount for a user in a specific pool.
3. **apr(uint256 \_pid)**: Calculates the annual percentage rate (APR) for a specific pool.

#### Migration and Burn Functions (<mark style="color:red;">will be deleted after base migration</mark>)

1. **burnTokens(uint256 \_pid, address \_holder)**: Burns all staked tokens of a user in a specified pool. Only callable by the migrator.&#x20;
2. **makeMigration(uint256 \_pid, uint256 \_amount, address \_holder)**: Facilitates token migration for a user. Only callable by the migrator.
