Created
May 10, 2021 20:49
-
-
Save percybolmer/be1ed75fbdc09fbe7404d8cf9c71e953 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @notice | |
* calculateTotalAvailableRewards will iterate all stakes made by a account | |
* and summerize the total unclaimed rewards | |
* | |
*/ | |
function calculateTotalAvailableRewards(address _staker) public view returns(uint256){ | |
uint256 total_reward; | |
// Itterate all stakes from the address and calculate their reward for each stake | |
Stake[] memory user_stakes = stakes[stakeHolders[_staker]]; | |
for(uint256 i = 0; i<user_stakes.length; i++) { | |
// Skip any stake that is actually stopped or empty | |
if(user_stakes[i].amount == 0 || user_stakes[i].until != 0){ | |
continue; | |
} | |
total_reward = total_reward + calculateStakeReward(user_stakes[i]); | |
} | |
return total_reward; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment