/
YDVRewardsDistributor.sol
36 lines (29 loc) · 1.12 KB
/
YDVRewardsDistributor.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract YDVRewardsDistributor is AccessControl, Ownable {
using SafeERC20 for IERC20;
using Address for address;
IERC20 public rewardToken;
address[] public ydvs;
bytes32 public constant YDV_REWARDS = keccak256("YDV_REWARDS");
constructor(address _rally) public {
rewardToken = IERC20(_rally);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
function transferReward(uint256 _amount) external {
require (hasRole(YDV_REWARDS, msg.sender), "only ydv rewards");
rewardToken.safeTransfer(msg.sender, _amount);
}
function addYDV(address _ydv) external onlyOwner {
grantRole(YDV_REWARDS, _ydv);
ydvs.push(_ydv);
}
function ydvsLength() external view returns (uint256) {
return ydvs.length;
}
}