-
Notifications
You must be signed in to change notification settings - Fork 49
/
StakePrizePool.sol
67 lines (55 loc) · 2.82 KB
/
StakePrizePool.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.6;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./PrizePool.sol";
/**
* @title PoolTogether V4 StakePrizePool
* @author PoolTogether Inc Team
* @notice The Stake Prize Pool is a prize pool in which users can deposit an ERC20 token.
* These tokens are simply held by the Stake Prize Pool and become eligible for prizes.
* Prizes are added manually by the Stake Prize Pool owner and are distributed to users at the end of the prize period.
*/
contract StakePrizePool is PrizePool {
/// @notice Address of the stake token.
IERC20 private stakeToken;
/// @dev Emitted when stake prize pool is deployed.
/// @param stakeToken Address of the stake token.
event Deployed(IERC20 indexed stakeToken);
/// @notice Deploy the Stake Prize Pool
/// @param _owner Address of the Stake Prize Pool owner
/// @param _stakeToken Address of the stake token
constructor(address _owner, IERC20 _stakeToken) PrizePool(_owner) {
require(address(_stakeToken) != address(0), "StakePrizePool/stake-token-not-zero-address");
stakeToken = _stakeToken;
emit Deployed(_stakeToken);
}
/// @notice Determines whether the passed token can be transferred out as an external award.
/// @dev Different yield sources will hold the deposits as another kind of token: such a Compound's cToken. The
/// prize strategy should not be allowed to move those tokens.
/// @param _externalToken The address of the token to check
/// @return True if the token may be awarded, false otherwise
function _canAwardExternal(address _externalToken) internal view override returns (bool) {
return address(stakeToken) != _externalToken;
}
/// @notice Returns the total balance (in asset tokens). This includes the deposits and interest.
/// @return The underlying balance of asset tokens
function _balance() internal view override returns (uint256) {
return stakeToken.balanceOf(address(this));
}
/// @notice Returns the address of the ERC20 asset token used for deposits.
/// @return Address of the ERC20 asset token.
function _token() internal view override returns (IERC20) {
return stakeToken;
}
/// @notice Supplies asset tokens to the yield source.
/// @param _mintAmount The amount of asset tokens to be supplied
function _supply(uint256 _mintAmount) internal pure override {
// no-op because nothing else needs to be done
}
/// @notice Redeems asset tokens from the yield source.
/// @param _redeemAmount The amount of yield-bearing tokens to be redeemed
/// @return The actual amount of tokens that were redeemed.
function _redeem(uint256 _redeemAmount) internal pure override returns (uint256) {
return _redeemAmount;
}
}