forked from neptune-mutual-blue/protocol
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStakingPoolReward.sol
33 lines (27 loc) · 1.09 KB
/
StakingPoolReward.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./StakingPoolBase.sol";
abstract contract StakingPoolReward is StakingPoolBase {
using ValidationLibV1 for IStore;
using StakingPoolCoreLibV1 for IStore;
using StakingPoolLibV1 for IStore;
constructor(IStore s) StakingPoolBase(s) {} //solhint-disable-line
function calculateRewards(bytes32 key, address account) external view override returns (uint256) {
return s.calculateRewardsInternal(key, account);
}
/**
* @dev Withdraw your staking reward. Ensure that you preiodically call this function
* or else you risk receiving no rewards as a result of token depletion in the reward pool.
*
* @custom:suppress-acl This is a publicly accessible feature
*
*/
function withdrawRewards(bytes32 key) external override nonReentrant {
s.mustNotBePaused();
s.ensureValidStakingPool(key);
(address rewardToken, uint256 rewards, uint256 platformFee) = s.withdrawRewardsInternal(key, msg.sender);
if (rewards > 0) {
emit RewardsWithdrawn(key, msg.sender, rewardToken, rewards, platformFee);
}
}
}