I’m creating some diagrams and graph while reading this article

Understanding SushiSwap's MasterChef staking rewards

🧱: A ↔ B ⏳ BlockRewards Staked πŸͺ™ Total πŸͺ™ StakerShare Rewards Accumulated Reward Harvest Harvest Total
A 0 to 10 10 10 100 100 100/100 = 1.0 10 10
A 10 to 15 5 5 100 500 100/500 = 0.2 1 11 β†’ 0 βœ‚οΈŽπŸŒΎπŸŒΎπŸŒΎβœ‚οΈŽ 11
B πŸ‘† πŸ‘† πŸ‘† 400 πŸ‘† 400/500 = 0.8 4 4
A 15 to 25 10 10 100 500 100/500 = 0.2 2 2
B πŸ‘† πŸ‘† πŸ‘† 400 πŸ‘† 400/500 = 0.8 8 12 β†’ 0 βœ‚οΈŽπŸŒΎπŸŒΎπŸŒΎβœ‚οΈŽ 12
A 25 to 30 5 5 100 500 100/500 = 0.2 1 3 β†’ 0 βœ‚οΈŽπŸŒΎπŸŒΎπŸŒΎβœ‚οΈŽ 14
B πŸ‘† πŸ‘† πŸ‘† 400 πŸ‘† 400/500 = 0.8 4 4 β†’ 0 βœ‚οΈŽπŸŒΎπŸŒΎπŸŒΎβœ‚οΈŽ 16

ARewards =100*{(10/100)+(5/500)+(10/500)+(5/500)}
BRewards = 400*{(5/500)+(10/500)+(5/500)}

Screen Shot 2022-07-15 at 10.31.48.png

In the codeπŸ‘‡

// View function to see pending SUSHIs on frontend.
  function pendingSushi(uint256 _pid, address _user)
    external
    view
    returns (uint256)
  {
    PoolInfo storage pool = poolInfo[_pid];
    UserInfo storage user = userInfo[_pid][_user];
    uint256 accSushiPerShare = pool.accSushiPerShare;
    uint256 lpSupply = pool.lpToken.balanceOf(address(this));
    if (block.number > pool.lastRewardBlock && lpSupply != 0) {
      uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
      uint256 sushiReward = multiplier
        .mul(sushiPerBlock)
        .mul(pool.allocPoint)
        .div(totalAllocPoint);
      accSushiPerShare = accSushiPerShare.add(
        sushiReward.mul(1e12).div(lpSupply)
      );
    }
    return user.amount.mul(accSushiPerShare).div(1e12).sub(user.rewardDebt);
  }

Awesome Resources

Understanding SushiSwap's MasterChef staking rewards