forked from calvinheath/wheat-v1-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMasterChefAdmin.sol
82 lines (69 loc) · 3.18 KB
/
MasterChefAdmin.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
73
74
75
76
77
78
79
80
81
82
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.6.0;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { CustomMasterChef } from "./CustomMasterChef.sol";
import { FeeCollector } from "./FeeCollector.sol";
import { RewardCompoundingStrategyToken } from "./RewardCompoundingStrategyToken.sol";
contract MasterChefAdmin is Ownable, ReentrancyGuard
{
address public immutable masterChef;
constructor (address _masterChef) public
{
masterChef = _masterChef;
}
function addToWhitelist(address _address) external onlyOwner nonReentrant
{
CustomMasterChef(masterChef).addToWhitelist(_address);
}
function removeFromWhitelist(address _address) external onlyOwner nonReentrant
{
CustomMasterChef(masterChef).removeFromWhitelist(_address);
}
function updateCakePerBlock(uint256 _cakePerBlock) external onlyOwner nonReentrant
{
CustomMasterChef(masterChef).updateCakePerBlock(_cakePerBlock);
}
function updateMultiplier(uint256 _multiplierNumber) external onlyOwner nonReentrant
{
CustomMasterChef(masterChef).updateMultiplier(_multiplierNumber);
}
function add(uint256 _allocPoint, address _lpToken, bool _withUpdate) external onlyOwner nonReentrant
{
CustomMasterChef(masterChef).add(_allocPoint, IERC20(_lpToken), _withUpdate);
}
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) external onlyOwner nonReentrant
{
CustomMasterChef(masterChef).set(_pid, _allocPoint, _withUpdate);
}
function addRewardCompoundingStrategy(string memory _name, string memory _symbol, uint8 _decimals,
address _masterChef, uint256 _pid, address _routingToken, uint256 _allocPoint,
address _buyback, address _exchange, address _dev, address _treasury) external onlyOwner nonReentrant
{
address _owner = msg.sender;
address _collector = new_FeeCollector(_masterChef, _pid, _buyback, _treasury);
address _strategy = LibMasterChefAdmin.new_RewardCompoundingStrategyToken(_name, _symbol, _decimals, _masterChef, _pid, _routingToken, _dev, _treasury, _collector);
RewardCompoundingStrategyToken(_strategy).setExchange(_exchange);
CustomMasterChef(masterChef).add(_allocPoint, IERC20(_strategy), false);
if (_masterChef == masterChef) {
CustomMasterChef(masterChef).addToWhitelist(_collector);
CustomMasterChef(masterChef).addToWhitelist(_strategy);
}
Ownable(_collector).transferOwnership(_owner);
Ownable(_strategy).transferOwnership(_owner);
}
function new_FeeCollector(address _masterChef, uint256 _pid, address _buyback, address _treasury) internal returns (address _address)
{
return address(new FeeCollector(_masterChef, _pid, _buyback, _treasury));
}
}
library LibMasterChefAdmin
{
function new_RewardCompoundingStrategyToken(string memory _name, string memory _symbol, uint8 _decimals,
address _masterChef, uint256 _pid, address _routingToken,
address _dev, address _treasury, address _collector) public returns (address _address)
{
return address(new RewardCompoundingStrategyToken(_name, _symbol, _decimals, _masterChef, _pid, _routingToken, _dev, _treasury, _collector));
}
}