/
StashTokenWrapper.sol
62 lines (46 loc) · 1.61 KB
/
StashTokenWrapper.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
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import "./interfaces/IBooster.sol";
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';
contract StashTokenWrapper {
using SafeERC20 for ERC20;
address public constant booster = address(0xF403C135812408BFbE8713b5A23a04b3D48AAE31);
address public token;
address public rewardPool;
bool public isInvalid;
constructor() public{}
function init(address _token, address _rewardpool) external{
require(token == address(0), "init");
token = _token;
rewardPool = _rewardpool;
}
function name() external view returns (string memory) {
return ERC20(token).name();
}
function symbol() external view returns (string memory) {
return ERC20(token).symbol();
}
function decimals() external view returns (uint8) {
return ERC20(token).decimals();
}
function totalSupply() public view returns (uint256) {
return ERC20(token).balanceOf(address(this));
}
function balanceOf(address _account) external view returns (uint256) {
if(_account == rewardPool){
return totalSupply();
}
return 0;
}
function transfer(address _recipient, uint256 _amount) external returns (bool) {
if(msg.sender == rewardPool){
ERC20(token).safeTransfer(_recipient, _amount);
}
return true;
}
function setInvalid(bool _isInvalid) external{
require(IBooster(booster).owner() == msg.sender, "!owner");
isInvalid = _isInvalid;
}
}