How to calculate staking rewards?

Hello guys, I have some confuse

Assuming there are two types of ERC20 tokens, $A and $B, stake $A to get $B.

The total number of $B in each time period is fixed, for example, 10 $B can be mint per hour (or minute), and rewards will be evenly distributed according to the number of staking.
The calculation rule is hour_rewards = total_mint_one_hour * (user_staking / total_staking)

But the contract cannot be settled in real time, how to realize settlement and display real time settlement on the front end?

Thanks all.

Hi, welcome! :wave:

I think there are some contracts have achieve this, such as synthetix/StakingRewards.sol

Thanks bro, thats really helpful to me.