forked from Dracula-Protocol/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrainDistributor.sol
67 lines (57 loc) · 2.08 KB
/
DrainDistributor.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: MIT
pragma solidity 0.6.12;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
interface ILpController {
function addLiquidity(uint256 amount) external;
}
interface IRewardPool {
function fundPool(uint256 reward) external;
}
/**
* @title Receives rewards from MasterVampire via drain and redistributes to RewardPool
*/
contract DrainDistributor is Ownable {
using SafeMath for uint256;
IERC20 constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
uint256 public rewardPoolShare;
address public rewardPool;
address public lpController;
/**
* @notice Construct the contract
* @param rewardPool_ address of the reward pool
* @param lpController_ address of the LP controller
*/
constructor(address rewardPool_, address lpController_) public {
rewardPoolShare = 100;
rewardPool = rewardPool_;
lpController = lpController_;
}
/**
* @notice Distributes drained rewards to RewardPool and DRC/ETH LP
*/
function distribute() external {
uint256 drainWethBalance = WETH.balanceOf(address(this));
uint256 rewardPoolAmt = drainWethBalance.mul(rewardPoolShare).div(1000);
uint256 lpAmt = drainWethBalance.sub(rewardPoolAmt);
WETH.approve(rewardPool, rewardPoolAmt);
IRewardPool(rewardPool).fundPool(rewardPoolAmt);
WETH.approve(lpController, lpAmt);
ILpController(lpController).addLiquidity(lpAmt);
}
/**
* @notice Changes the reward percentage distributed to reward pool
* @param rewardPoolShare_ percentage using decimal base of 1000 ie: 10% = 100
*/
function changeRewardShare(uint256 rewardPoolShare_) external onlyOwner {
rewardPoolShare = rewardPoolShare_;
}
/**
* @notice Changes the address of the LP controller
* @param lpController_ the new address
*/
function changeLp(address lpController_) external onlyOwner {
lpController = lpController_;
}
}