> For the complete documentation index, see [llms.txt](https://docs.javsphere.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.javsphere.com/engineering/smart-contracts/javstakex.md).

# 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.javsphere.com/engineering/smart-contracts/javstakex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
