HexRewards is an innovative smart contract designed to provide additional incentives for Hex stakers. By leveraging the power of the Hex staking system, HexRewards offers a unique opportunity for users to earn additional rewards based on their staking length of time. This white paper will explore the key features and benefits of the HexRewards contract, providing a comprehensive overview for potential users.
To ensure the integrity of the rewarding system, HexRewards implements a stake ID protection mechanism. "New" stakes with a stakeID greater than the STAKEID_PROTECTION value (817340) are eligible for claiming rewards only after "Registering". This protection helps prevent abuse and ensures that the supply of the token doesn't grow infinitly. "Old" active stakes that have a stakeID lower than or equal to 817340 are eligible for claiming rewards without the need of "Registering" first.
HexRewards introduces a tiered system based on the amount of Hex staked for "New" stakes with a stake ID after the STAKEID_PROTECTION value (817340). There are nine tiers, each with a maximum number of stakes allowed (MAX_STAKES_PER_TIER = 369). The 9 tiers also have a Hex Stake Size requirement. Users can claim their stake by clicking on the "Register" button on the site which then calls the claimStake function in the contract, providing their stake index. The contract will determine the appropriate tier based on the Hex staked amount and register the stake accordingly consuming one of the available seats or slots of that tier. Once a tier has been consumed, where all the seats are "Registered" for that tier, then no more stakes can be "Registered" for that tier.
The contract defines a constant REWARD_PER_DAY = 0.00001 HXR, which represents the base reward amount earned per day of staking. The actual reward earned depends on the duration of the stake and whether it is a 5555-day stake or not.
For active stakes with a duration of 5555 days (MAX_STAKE_DAYS), the reward per day is multiplied by a factor of 10. If the 5555 day stake has finished all 5555 days, the user is to go to the Hex website and call the "Good Accounting" function to show the stake has completed its term. Then the normal reward per day for HXR is multiplied by a factor of 100 when "Claimed".
For stakes with a duration less than 5555 days, the reward per day remains unchanged if the stake is still active. If the stake has finished all days for the stake, the user is to go to the Hex website and call the "Good Accounting" function to prove the stake has completed its term. Then the reward per day of HXR is multiplied by a factor of 10 when "Claimed".
Users can claim their rewards by calling the claimReward function at any time while the stake is active. The contract checks if the stake is eligible for rewards and calculates the reward amount based on the consumed days and stake duration. The reward is then minted to the user's address, and the claimed amount is recorded in the claimed mapping. If the user ends the stake on the Hex website, or calls the "Emergency End Stake" function, the HXR contract will not be able to find that Hex stake anymore and will not be able to reward that Hex stake any HXR tokens.
When the Hex stake has reached the full term of the stake, the user is to go to the Hex website and call the "Good Accounting" function to show the stake has completed its term. Then the user can call the claimReward function in the HXR contract to claim the 10x bonus reward. The reward is then minted to the user's address, and the claimed amount is recorded in the claimed mapping. If the user ends the stake on the Hex website, or calls the "Emergency End Stake" function, or ends the stake before claiming the HXR reward, the HXR contract will not be able to find that Hex stake anymore and will not be able to reward that Hex stake any HXR tokens.
The Return function in the HexRewards contract allows users to return their previously claimed rewards in exchange for higher rewards at a later date. By returning the claimed rewards along with an additional fee, users can re-activate their stake and accumulate more HXR tokens based on the extended time their stake has been active. This feature provides flexibility, enabling users to optimize their reward strategy based on their stake progress and investment goals. Be mindful of the agressiveness of the fee. The fee is calculated by looking at the current number of days you've already consumed, then it multiplies that number of days times the daily HXR reward amount and adds an additional 30% on top. So when you claim, as each day passes, the return fee increases such that by 170 days after you've claimed, the return amount would equate to the entire 10x bonus you would have received had you waited to claim instead. There would be no point returning your claim after 170 days.
Stake Duration: 1000 days
You claim rewards at day 100 of your 1000-day stake, receiving 0.001 HXR calculated as follows:
You decide to return the claim on the same day you claimed, you return 0.0013 HXR:
You decide to return the rewards 100 days after you claimed (200 days consumed of your Hex stake). The return amount is HXR calculated as follows:
Upon completing the full 1000-day stake: First call the "Good Accounting" function for the stake on Hex.com website. Then the final claim reward is calculated as a 10x bonus:
Flexibility: The "Claim", "Return", and "Claim" cycle can be repeated an unlimited number of times for the same stake, as long as it is active (not ended), allowing you to optimize your reward strategy based on stake progress and changes in your investment approach.
There is a critical interaction issue between HEX's stake management system and HexRewards' reward tracking mechanism. This issue stems from how HEX manages its stake array and how HexRewards tracks claimed rewards.
When you end a stake in HEX, the contract uses a "pop-and-swap" mechanism for efficiency:
HexRewards tracks claimed rewards by stake index: mapping(address => mapping(uint256 => uint256)) claimed
When a stake moves to a new index position due to pop-and-swap, it may inherit the claim status of the previous stake at that index. This can result in:
Before ending any stake (except your last one), create a "sacrificial" stake:
The HexRewards interface includes automatic protection:
HexRewards offers an exciting opportunity for Hex stakers to earn additional rewards based on their staking activity. With its tiered system, stake protection, and flexible reward calculation, HexRewards aims to incentivize long-term staking and provide a rewarding experience for users. By leveraging the power of smart contracts and the Hex staking system, HexRewards seeks to enhance the value proposition for Hex stakers and contribute to the growth and adoption of the Hex ecosystem.
Users should be aware of the pop-and-swap interaction and use the provided protection mechanisms to ensure they can always claim their earned rewards. The small cost of maintaining a sacrificial stake is negligible compared to the potential loss of rewards on larger stakes.