Skip to content

Commit

Permalink
Merge 74ebe37 into 33c4593
Browse files Browse the repository at this point in the history
  • Loading branch information
nitika-goel committed Jun 5, 2020
2 parents 33c4593 + 74ebe37 commit ccd1974
Show file tree
Hide file tree
Showing 16 changed files with 2,249 additions and 760 deletions.
573 changes: 350 additions & 223 deletions contracts/Governance.sol

Large diffs are not rendered by default.

450 changes: 264 additions & 186 deletions contracts/ProposalCategory.sol

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions contracts/mocks/GovernanceMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// /* Copyright (C) 2017 GovBlocks.io

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/ */

pragma solidity 0.5.7;

import "../Governance.sol";


contract GovernanceMock is Governance {
function _initiateGovernance() external {
allVotes.push(ProposalVote(address(0), 0, 0));
totalProposals = 1;
// allProposal.push(ProposalStruct(address(0), now));
allDelegation.push(DelegateVote(address(0), address(0), now));
tokenHoldingTime = 1 * 7 days;
maxDraftTime = 2 * 7 days;
maxVoteWeigthPer = 5;
maxFollowers = 40;
roleIdAllowedToCatgorize = uint(MemberRoles.Role.AdvisoryBoard);
specialResolutionMajPerc = 75;
}

}
138 changes: 138 additions & 0 deletions contracts/mocks/ProposalCategoryMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/* Copyright (C) 2017 GovBlocks.io
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/ */
pragma solidity 0.5.7;

import "../ProposalCategory.sol";


contract ProposalCategoryMock is ProposalCategory {
function proposalCategoryInitiate() public {
require(!constructorCheck);
constructorCheck = true;
_addInitialCategories("Uncategorized", "", "MR", 60, 15, 1, 0); //0
_addInitialCategories("Add new member role", "QmQFnBep7AyMYU3LJDuHSpTYatnw65XjHzzirrghtZoR8U",
"MR", 60, 15, 1, 0);
_addInitialCategories("Update member role", "QmXMzSViLBJ22P9oj51Zz7isKTRnXWPHZcQ5hzGvvWD3UV",
"MR", 60, 15, 1, 0);
_addInitialCategories("Add new category", "QmUq9Rb6rWFHZXjVtyzh7AWGDeyVFtDHKiP5fJpgnuinQ7", "PC",
60, 15, 1, 0);
_addInitialCategories("Edit category", "QmQmvfBiCLfe5jPdq69iRBRRdnSHSroJQ4SG8DhtkXcLfQ", //4
"PC", 60, 15, 1, 0);
_addInitialCategories(
"Upgrade a contract Implementation",
"Qme4hGas6RuDYk9LKE2XkK9E46LNeCBUzY12DdT5uQstvh",
"MS",
50,
15,
2,
80
);

// --------------------------------------------------------------------------------------------- //
_addInitialCategories("Implement Emergency Pause", "QmZSaEsvTCpy357ZSrPYKqby1iaksBwPdKCGWzW1HpgSpe",
"MS", 0, 15, 1, 0);
_addInitialCategories("Extend or Switch Off Emergency Pause", "Qmao6dD8amq4kxsAheWn5gQX22ABucFFGRvnRuY1VqtEKy",
"MS", 50, 15, 2, 0);
_addInitialCategories("Burn Claims Assessor Bond", "QmezNJUF2BM5Nv9EMnsEKUmuqjvdySzvQFvhEdvFJbau3k", //8
"TF", 80, 15, 1, 0);
_addInitialCategories("Pause Claim Assessor Voting for 3 days",
"QmRBXh9NGoGV7U7tTurKPhL4bzvDc9n23QZYidELpBPVdg", "CD", 60, 15, 1, 0);
_addInitialCategories("Changes to Capital Model", "", "EX", 50, 15, 2, 60);
_addInitialCategories("Changes to Pricing Model", "", "EX", 50, 15, 2, 60);
_addInitialCategories("Withdraw funds to Pay for Support Services",
"QmZQhJunZesYuCJkdGwejSATTR8eynUgV8372cHvnAPMaM", "P1", 50, 15, 2, 80);
// _addInitialCategories("Change to Authorities", "", "EX", 80, 15, 2); //no func yet
_addInitialCategories("Add Investment Asset", "Qmd66GdYtn1BYmZTB1op1Fbfkq6uywMpow5LRmG2Twbzjb", //13
"PD", 50, 15, 2, 60);
_addInitialCategories("Edit Investment Asset min and max holding percentages",
"QmXwyffmk7rYGHE7p4g3oroJkmyEYAn6EffhZu2MCNcJGA",
"PD", 50, 15, 2, 60);
_addInitialCategories("Update Investment Asset Status", "QmZkxcC82WFRvnBahLT3eQ95ZSGMxuAyCYqxvR3tSyhFmB",
"PD", 50, 15, 2, 60);
_addInitialCategories("Change AB Member", "QmUBjPDdSiG3pRMqkVzZA2WaqiksT7ixNd3gPQwngGmF9x",
"MR", 50, 15, 2, 0);
_addInitialCategories("Add Currency Asset", "QmYtpNuTdProressqZwEmN7cFtyyJvhFBrqr6xnxQGWrPm", //17
"PD", 50, 15, 2, 0);
_addInitialCategories("Any other Item", "", "EX", 50, 15, 2, 80);
_addInitialCategories("Special Resolution", "", "EX", 75, 0, 2, 0);
_addInitialCategories("Update Token Parameters", "QmbfJTXyLTDsq41U4dukHbagcXef8bRfyMdMqcqLd9aKNM",
"TD", 50, 15, 2, 60);
_addInitialCategories("Update Risk Assessment Parameters", "QmUHvBShLpDwPWAsWcZvbUJfVGyXYscybi5ASmF6ectxSo",
//21
"TD", 50, 15, 2, 60);
_addInitialCategories("Update Governance Parameters", "QmdFDVEaZnJxXncFczTW6EvrcgR3jBfuPWftR7PfkPfqqT",
"GV", 50, 15, 2, 60);
_addInitialCategories("Update Quotation Parameters", "QmTtSbBp2Cxaz8HzB4TingUozr9AW91siCfMjjyzf8qqAb",
"QD", 50, 15, 2, 60);
_addInitialCategories("Update Claims Assessment Parameters", "QmPo6HPydwXEeoVdwBpwGeZasFnmFwZoTsQ93Bg5pFtQg6",
"CD", 50, 15, 2, 60);
_addInitialCategories("Update Investment Module Parameters", "QmYSUJBJD9hUevydfdF34rGFG7bBQhMrxh2ga9XfeAkdEM",
//25
"PD", 50, 15, 2, 60);
_addInitialCategories("Update Capital Model Parameters", "QmaQH6AdvBdgrW4xdzcMHa7gNyYSGa2fz7gBuuic2hLkZQ",
"PD", 50, 15, 2, 60);
_addInitialCategories("Update Address Parameters", "QmPfXySkeDFbdMvZyD35y1hiB4g6ZXLSEHfS7JjS6e1VKL",
"MS", 50, 15, 2, 60);
_addInitialCategories("Update Owner Parameters", "QmTEmDA1ECmGPfh5x3co1GmjXQCp3zisUP6rnLQjWmW8nu", //28
"MS", 50, 15, 3, 0);
_addInitialCategories("Release new smart contract code", "QmSStfVwXF1TzDPCseVtMydgdF1xmzqhMtfpUg9Btx7tUp",
"MS", 50, 15, 2, 80);
_addInitialCategories("Edit Currency Asset Address", "QmahwCzxmUX1QEjgczmA2NF4Nxtx839eRLCXbBFeFCm3cF",
"PD", 50, 15, 3, 60);
_addInitialCategories("Edit Currency Asset baseMin", "QmeFSwZ21d7XabxVc7eiNKbtfEXUuD8qQXkeHZ5To1vo4t",
"PD", 50, 15, 2, 60);
_addInitialCategories("Edit Investment Asset Address and decimal",
"QmRpztKqva2ud5xz9CQeb562bRQt2VEBPnjaWEPwN8q3vf",
"PD", 50, 15, 3, 60);
}

function _addInitialCategories(
string memory _name,
string memory _actionHash,
bytes2 _contractName,
uint _majorityVotePerc,
uint _quorumPerc,
uint _memberRoleToVote,
uint _categoryABReq
)
internal
{
uint[] memory allowedToCreateProposal = new uint[](1);
uint[] memory stakeIncentive = new uint[](4);
if (_memberRoleToVote == 3) {
allowedToCreateProposal[0] = 3;
} else {
allowedToCreateProposal[0] = 2;
}
stakeIncentive[0] = 0;
stakeIncentive[1] = 0;
stakeIncentive[2] = _categoryABReq;
if (_quorumPerc == 0) {//For special resolutions
stakeIncentive[3] = 1;
} else {
stakeIncentive[3] = 0;
}
_addCategory(
_name,
_memberRoleToVote,
_majorityVotePerc,
_quorumPerc,
allowedToCreateProposal,
604800,
_actionHash,
address(0),
_contractName,
stakeIncentive
);
}

}
4 changes: 3 additions & 1 deletion migrations/3_deploy_nexusmutual.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ const Pool2 = artifacts.require('Pool2');
const PoolData = artifacts.require('PoolDataMock');
const Quotation = artifacts.require('Quotation');
const QuotationDataMock = artifacts.require('QuotationDataMock');
const GovernanceMock = artifacts.require('GovernanceMock');
const Governance = artifacts.require('Governance');
const ProposalCategory = artifacts.require('ProposalCategory');
const ProposalCategory = artifacts.require('ProposalCategoryMock');
const MemberRoles = artifacts.require('MemberRoles');
const FactoryMock = artifacts.require('FactoryMock');
const DSValue = artifacts.require('NXMDSValueMock');
Expand Down Expand Up @@ -41,6 +42,7 @@ module.exports = function(deployer, network, accounts) {
await deployer.deploy(Quotation);
await deployer.deploy(QuotationDataMock, QE, founderAddress);
await deployer.deploy(Governance);
await deployer.deploy(GovernanceMock);
await deployer.deploy(ProposalCategory);
await deployer.deploy(MemberRoles);
await deployer.deploy(NXMaster, tk.address);
Expand Down
13 changes: 9 additions & 4 deletions migrations/4_initialize_nexusmutual.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const PoolData = artifacts.require('PoolDataMock');
const Quotation = artifacts.require('Quotation');
const QuotationDataMock = artifacts.require('QuotationDataMock');
const MemberRoles = artifacts.require('MemberRoles');
const GovernanceMock = artifacts.require('GovernanceMock');
const Governance = artifacts.require('Governance');
const ProposalCategory = artifacts.require('ProposalCategory');
const ProposalCategory = artifacts.require('ProposalCategoryMock');
const FactoryMock = artifacts.require('FactoryMock');

const QE = '0x51042c4d8936a7764d18370a6a0762b860bb8e07';
Expand All @@ -42,7 +43,7 @@ module.exports = function(deployer, network, accounts) {
const cd = await ClaimsData.deployed();
const mcr = await MCR.deployed();
const dsv = await DSValue.deployed();
const gov = await Governance.deployed();
const gov = await GovernanceMock.deployed();
let propCat = await ProposalCategory.deployed();
const mr = await MemberRoles.deployed();
const factory = await FactoryMock.deployed();
Expand All @@ -69,12 +70,16 @@ module.exports = function(deployer, network, accounts) {
await nxms.addNewVersion(addr);
let pcAddress = await nxms.getLatestAddress('0x5043');
pc = await ProposalCategory.at(pcAddress);
let gvAddress = await nxms.getLatestAddress('0x4756');
let gv = await GovernanceMock.at(gvAddress);
gv._initiateGovernance();
await pc.proposalCategoryInitiate();
await pc.updateCategoryActionHashes();
const dai = await DAI.deployed();
// await qd.changeCurrencyAssetAddress('0x444149', dai.address);
// await qd.changeInvestmentAssetAddress('0x444149', dai.address);
await pl1.sendEther({ from: Owner, value: POOL_ETHER });
await pl2.sendEther({ from: Owner, value: POOL_ETHER }); //
await pl1.sendEther({from: Owner, value: POOL_ETHER});
await pl2.sendEther({from: Owner, value: POOL_ETHER}); //
await mcr.addMCRData(
13000,
'100000000000000000000',
Expand Down
35 changes: 26 additions & 9 deletions test/01_NXMaster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ const FactoryMock = artifacts.require('FactoryMock');

const QE = '0xb24919181daead6635e613576ca11c5aa5a4e133';
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
const Exchange_0x = web3.eth.accounts[17];
var Exchange_0x;

const { ether, toHex, toWei } = require('./utils/ethTools');
const { assertRevert } = require('./utils/assertRevert');
const {ether, toHex, toWei} = require('./utils/ethTools');
const {assertRevert} = require('./utils/assertRevert');
const gvProp = require('./utils/gvProposal.js').gvProposal;
const setTriggerActionTime = require('./utils/gvProposal.js')
.setTriggerActionTime;
const encode = require('./utils/encoder.js').encode;
const getValue = require('./utils/getMCRPerThreshold.js').getValue;

Expand All @@ -35,6 +37,8 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

let accounts = [];

let nxms;
let nxmtk;
let tf;
Expand Down Expand Up @@ -70,9 +74,22 @@ contract('NXMaster', function([
govVoter4
]) {
// const fee = ether(0.002);
accounts = [
owner,
newOwner,
member,
nonMember,
anotherAccount,
govVoter1,
govVoter2,
govVoter3,
govVoter4
];
Exchange_0x = accounts[17];

const fee = toWei(0.002);
const poolEther = ether(2);
const founderAddress = web3.eth.accounts[19];
const founderAddress = accounts[19];
const INITIAL_SUPPLY = ether(1500000);
const pauseTime = new web3.utils.BN(2419200);

Expand Down Expand Up @@ -176,7 +193,7 @@ contract('NXMaster', function([
await nxms.getLatestAddress(toHex('MR'))
);
let oldGv = await Governance.at(await nxms.getLatestAddress(toHex('GV')));
await pl1.sendEther({ from: owner, value: poolEther });
await pl1.sendEther({from: owner, value: poolEther});
let actionHash = encode(
'updateOwnerParameters(bytes8,address)',
'OWNER',
Expand Down Expand Up @@ -256,13 +273,13 @@ contract('NXMaster', function([

describe('when called by unauthorised source', function() {
it('1.9 should not be able to add a new version', async function() {
await assertRevert(nxms.addNewVersion(addr, { from: anotherAccount }));
await assertRevert(nxms.addNewVersion(addr, {from: anotherAccount}));
});

it('1.10 should not be able to change master address', async function() {
newMaster = await NXMaster.new(nxmtk.address);
await assertRevert(
nxms.changeMasterAddress(newMaster.address, { from: anotherAccount })
nxms.changeMasterAddress(newMaster.address, {from: anotherAccount})
);
});
});
Expand All @@ -285,7 +302,7 @@ contract('NXMaster', function([
isInternal.should.equal(false);
});
it('1.16 should return true if member', async function() {
await memberRoles.payJoiningFee(member, { from: member, value: fee });
await memberRoles.payJoiningFee(member, {from: member, value: fee});
await memberRoles.kycVerdict(member, true);
const isMember = await nxms.isMember(member);
isMember.should.equal(true);
Expand Down Expand Up @@ -321,7 +338,7 @@ contract('NXMaster', function([
// const updatePauseTime = pauseTime.addn(new web3.utils.BN(60));
const updatePauseTime = pauseTime.toNumber() + 60;
await assertRevert(
nxms.updatePauseTime(updatePauseTime, { from: newOwner })
nxms.updatePauseTime(updatePauseTime, {from: newOwner})
);
let pauseTime1 = await nxms.getPauseTime();
updatePauseTime.should.be.not.equal(pauseTime1.toNumber());
Expand Down
Loading

0 comments on commit ccd1974

Please sign in to comment.