-
Notifications
You must be signed in to change notification settings - Fork 2
/
StakePrizePool.sol
72 lines (59 loc) · 2.66 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
68
69
70
71
72
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.7.0;
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "../PrizePool.sol";
contract StakePrizePool is PrizePool {
IERC20Upgradeable private stakeToken;
event StakePrizePoolInitialized(address indexed stakeToken);
/// @notice Initializes the Prize Pool and Yield Service with the required contract connections
/// @param _controlledTokens Array of addresses for the Ticket and Sponsorship Tokens controlled by the Prize Pool
/// @param _maxExitFeeMantissa The maximum exit fee size, relative to the withdrawal amount
/// @param _maxTimelockDuration The maximum length of time the withdraw timelock could be
/// @param _stakeToken Address of the stake token
function initialize (
RegistryInterface _reserveRegistry,
ControlledTokenInterface[] memory _controlledTokens,
uint256 _maxExitFeeMantissa,
uint256 _maxTimelockDuration,
IERC20Upgradeable _stakeToken
)
public
initializer
{
PrizePool.initialize(
_reserveRegistry,
_controlledTokens,
_maxExitFeeMantissa,
_maxTimelockDuration
);
stakeToken = _stakeToken;
emit StakePrizePoolInitialized(address(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 override view 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 override returns (uint256) {
return stakeToken.balanceOf(address(this));
}
function _token() internal override view returns (IERC20Upgradeable) {
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 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 override returns (uint256) {
return redeemAmount;
}
}