Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding contracts for rewards distribution #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions DevDistributor.sol
Original file line number Diff line number Diff line change
@@ -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;
}
}
45 changes: 45 additions & 0 deletions DrainDistributor.sol
Original file line number Diff line number Diff line change
@@ -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;
}
}
34 changes: 34 additions & 0 deletions LiquidityCointroller.sol
Original file line number Diff line number Diff line change
@@ -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)));
}
}