diff --git a/DevDistributor.sol b/DevDistributor.sol new file mode 100644 index 0000000..8b35ad6 --- /dev/null +++ b/DevDistributor.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.6.12; + +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/math/SafeMath.sol"; + +interface IMasterVampire { + function updateDevAddress(address _devAddress) external; +} + +contract DevDistributor is Ownable { + using SafeMath for uint256; + using SafeERC20 for DraculaToken; + DraculaToken public dracula; + + IMasterVampire constant MASTER_VAMPIRE = IMasterVampire(0xD12d68Fd52b54908547ebC2Cd77Ec6EbbEfd3099); + + uint256 public rewardShare; + address public rewardPool; + address public devAddress; + + constructor(DraculaToken _draculaToken, address _rewardPool) public { + dracula = _draculaToken; + rewardShare = 500; + rewardPool = _rewardPool; + devAddress = 0xa896e4bd97a733F049b23d2AcEB091BcE01f298d; + } + + function distribute() external { + uint256 devDrcBalance = dracula.balanceOf(address(this)); + dracula.transfer(rewardPool, devDrcBalance.mul(rewardShare).div(1000)); + dracula.transfer(devAddress, devDrcBalance.mul(1000 - rewardShare).div(1000)); + } + + function changeDev(address dev) external onlyOwner { + MASTER_VAMPIRE.updateDevAddress(dev); + } + + function changeReward(uint256 _rewardShare) external onlyOwner { + rewardShare = _rewardShare; + } +} \ No newline at end of file diff --git a/DrainDistributor.sol b/DrainDistributor.sol new file mode 100644 index 0000000..a9e9586 --- /dev/null +++ b/DrainDistributor.sol @@ -0,0 +1,45 @@ +// 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 IMasterVampire { + function updateDrainAddress(address _drainAddress) external; +} + +interface ILpCointroller { + function addLiquidity(uint256 amount) external; +} + +contract DrainDistributor is Ownable { + using SafeMath for uint256; + IERC20 constant weth = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); + IMasterVampire constant MASTER_VAMPIRE = IMasterVampire(0xD12d68Fd52b54908547ebC2Cd77Ec6EbbEfd3099); + + uint256 public rewardShare; + address public rewardPool; + address public lpCointroller; + + constructor(address _rewardPool, address _lpCointroller) public { + rewardShare = 150; + rewardPool = _rewardPool; + lpCointroller = _lpCointroller; + } + + function distribute() external { + uint256 drainWethBalance = weth.balanceOf(address(this)); + weth.transfer(rewardPool, drainBalance.mul(rewardShare).div(1000)); + ILpCointroller(lpCointroller).addLiquidity(drainBalance.mul(1000 - rewardShare).div(1000)); + } + + function changeReward(uint256 _rewardShare) external onlyOwner { + rewardShare = _rewardShare; + } + + function changeLp(address _lpCointroller) external onlyOwner { + lpCointroller = _lpCointroller; + } +} diff --git a/LiquidityCointroller.sol b/LiquidityCointroller.sol new file mode 100644 index 0000000..f4a0ab2 --- /dev/null +++ b/LiquidityCointroller.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT + +pragma solidity 0.6.12; + +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin/contracts/math/SafeMath.sol"; +import "../../interfaces/IUniswapV2Pair.sol"; +import "../../libraries/UniswapV2Library.sol"; +import "../../interfaces/IUniswapV2Router02.sol"; + +contract LiquidityCointroller { + using SafeMath for uint256; + IERC20 constant dracula = IERC20(0xb78B3320493a4EFaa1028130C5Ba26f0B6085Ef8); + IERC20 constant weth = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); + IUniswapV2Pair constant drcWethPair = IUniswapV2Pair(0x276e62c70e0b540262491199bc1206087f523af6); + IUniswapV2Router02 constant uniRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); + // token 0 - Dracula + // token 1 - weth + + constructor() public { + dracula.approve(address(uniRouter), uint256(-1)); + } + + function addLiquidity() external { + uint256 halfWethBalance = weth.balanceOf(address(this)).div(2); + weth.transfer(address(drcWethPair), halfWethBalance); + (uint256 draculaReserve, uint256 wethReserve) = drcWethPair.getReserves(); + uint256 amountOutput = UniswapV2Library.getAmountOut(halfWethBalance, draculaReserve, wethReserve); + drcWethPair.swap(uint256(0), amountOutput, address(this), new bytes(0)); + uint256 quoteAmount = UniswapV2Library.quote(halfWethBalance, draculaReserve, wethReserve); + uniRouter.addLiquidity(address(dracula), address(weth), quoteAmount, quoteAmount, halfWethBalance, dead); + dracula.burn(dracula.balanceOf(address(this))); + } +}