Last active
August 6, 2021 11:28
-
-
Save percybolmer/a1f441eed854cf0bb8c66173af794b9c 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 | |
* hasStake is used to check if a account has stakes and the total amount along with all the seperate stakes | |
*/ | |
function hasStake(address _staker) public view returns(StakingSummary memory){ | |
// totalStakeAmount is used to count total staked amount of the address | |
uint256 totalStakeAmount; | |
// Keep a summary in memory since we need to calculate this | |
StakingSummary memory summary = StakingSummary(0, stakeholders[stakes[_staker]].address_stakes); | |
// Itterate all stakes and grab amount of stakes | |
for (uint256 s = 0; s < summary.stakes.length; s += 1){ | |
uint256 availableReward = calculateStakeReward(summary.stakes[s]); | |
summary.stakes[s].claimable = availableReward; | |
totalStakeAmount = totalStakeAmount+summary.stakes[s].amount; | |
} | |
// Assign calculate amount to summary | |
summary.total_amount = totalStakeAmount; | |
return summary; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment