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

xINV Manager contract and deploy script #18

Open
wants to merge 2 commits into
base: master
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
64 changes: 64 additions & 0 deletions contracts/XinvManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
pragma solidity ^0.5.16;

interface Ixinv {
function _acceptAdmin() external;
function _setPendingAdmin(address payable newPendingAdmin) external;
function _setComptroller(address newComptroller) external;
function _setRewardTreasury(address newRewardTreasury) external;
function _setRewardPerBlock(uint newRewardPerBlock) external;
}

contract XinvManager {

Ixinv public xinv;
address public governance;
address public policyCommittee;
uint public maxRewardPerBlock = uint(-1);

constructor(Ixinv _xinv, address _governance, address _policyCommittee) public {
xinv = _xinv;
governance = _governance;
policyCommittee = _policyCommittee;
}

modifier onlyGov {
require(msg.sender == governance, "ONLY GOVERNANCE");
_;
}

function changeGovernance(address _governance) external onlyGov {
require(_governance != address(0), "GOVERNANCE CANNOT BE ADDRESS 0");
governance = _governance;
}

function changePolicyCommittee(address _policyCommittee) external onlyGov {
require(_policyCommittee != address(0), "POLICY COMMITTEE CANNOT BE ADDRESS 0");
policyCommittee = _policyCommittee;
}

function _acceptAdmin() external onlyGov {
xinv._acceptAdmin();
}

function _setPendingAdmin(address payable newPendingAdmin) external onlyGov {
xinv._setPendingAdmin(newPendingAdmin);
}

function _setComptroller(address newComptroller) external onlyGov {
xinv._setComptroller(newComptroller);
}

function _setRewardTreasury(address newRewardTreasury) external onlyGov {
xinv._setRewardTreasury(newRewardTreasury);
}

function _setRewardPerBlock(uint newRewardPerBlock) external {
require(msg.sender == policyCommittee || msg.sender == governance, "ONLY POLICY COMMITTEE OR GOVERNANCE");
require(newRewardPerBlock <= maxRewardPerBlock, "NEW REWARD RATE EXCEEDS MAX");
xinv._setRewardPerBlock(newRewardPerBlock);
}

function setMaxRewardPerBlock(uint _maxRewardPerBlock) external onlyGov {
maxRewardPerBlock = _maxRewardPerBlock;
}
}
20 changes: 20 additions & 0 deletions deploy/36_xinvManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = async ({
deployments,
getNamedAccounts
}) => {
console.log("36. Deploy xINV Manager")
const {deploy, get} = deployments;
const {deployer, gov} = await getNamedAccounts();
const XINV = await get('XINV');

await deploy('XinvManager', {
from: deployer,
args:[
XINV.address,
gov,
policyCommittee
]
});
};

module.exports.tags = ['XinvManager'];