-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathStakingPools.sol
More file actions
49 lines (41 loc) · 1.71 KB
/
Copy pathStakingPools.sol
File metadata and controls
49 lines (41 loc) · 1.71 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./StakingPoolInfo.sol";
contract StakingPools is StakingPoolInfo {
using ValidationLibV1 for IStore;
using StakingPoolCoreLibV1 for IStore;
using StakingPoolLibV1 for IStore;
constructor(IStore s) StakingPoolInfo(s) {} //solhint-disable-line
/**
* @dev Deposit your desired amount of tokens to the specified staking pool.
* When you deposit, you receive rewards if tokens are still available in the reward pool.
*
* @custom:suppress-acl This is a publicly accessible feature
*
*/
function deposit(bytes32 key, uint256 amount) external override nonReentrant {
s.mustNotBePaused();
s.ensureValidStakingPoolInternal(key);
(address stakingToken, address rewardToken, uint256 rewards, uint256 rewardsPlatformFee) = s.depositInternal(key, amount);
emit Deposited(key, msg.sender, stakingToken, amount);
if (rewards > 0) {
emit RewardsWithdrawn(key, msg.sender, rewardToken, rewards, rewardsPlatformFee);
}
}
/**
* @dev Withdraw your desired amount of tokens from the staking pool.
* When you withdraw, you receive rewards if tokens are still available in the reward pool.
*
* @custom:suppress-acl This is a publicly accessible feature
*
*/
function withdraw(bytes32 key, uint256 amount) external override nonReentrant {
s.mustNotBePaused();
s.ensureValidStakingPoolInternal(key);
(address stakingToken, address rewardToken, uint256 rewards, uint256 rewardsPlatformFee) = s.withdrawInternal(key, amount);
emit Withdrawn(key, msg.sender, stakingToken, amount);
if (rewards > 0) {
emit RewardsWithdrawn(key, msg.sender, rewardToken, rewards, rewardsPlatformFee);
}
}
}