Calculating the reward for staking and farming
So far, we’ve learned that the block number is the time unit for reward calculation. The more blocks generated after a user deposits the staked token, the more reward the user can earn, so long as the staking term hasn’t ended and the deposit amount doesn’t change. In this section, we will dive into the mathematics of reward calculation. The staking pool smart contract will use the formulas and parameters that we will discuss in this section.
Reward per block, starting block, and ending block
When deploying the staking smart contract, the deployer should plan for the staking terms based on how many reward tokens the deployer can offer. Here, we need to set each staking pool with the following three parameters:
- Reward per block: The total amount of reward tokens distributed to all users who participate in the staking
- Starting block: The starting block number of the staking period
- Ending block:...