Skip to content
Merged
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
17 changes: 15 additions & 2 deletions contracts/MarketRegistryNew.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ contract MarketRegistryNew is MarketRegistry {
uint256 plotStakeForRewardPoolShare;
uint256 rewardPoolShareThreshold;

mapping(address => MarketCreationRewardUserData) private marketCreationRewardUserData; //Of user
mapping(address => MarketCreationRewardData) private marketCreationRewardData; //Of user
mapping(address => MarketCreationRewardUserData) internal marketCreationRewardUserData; //Of user
mapping(address => MarketCreationRewardData) internal marketCreationRewardData; //Of user
mapping(uint256 => bool) internal marketCreationPausedOfType;
event MarketCreatorRewardPoolShare(address indexed createdBy, address indexed marketAddress, uint256 plotIncentive, uint256 ethIncentive);
event MarketCreationReward(address indexed createdBy, address marketAddress, uint256 plotIncentive, uint256 gasUsed, uint256 gasCost, uint256 gasPriceConsidered, uint256 gasPriceGiven, uint256 maxGasCap, uint256 rewardPoolSharePerc);
event ClaimedMarketCreationReward(address indexed user, uint256 ethIncentive, uint256 plotIncentive);
Expand All @@ -67,6 +68,7 @@ contract MarketRegistryNew is MarketRegistry {
* @param _marketCurrencyIndex the index of market currency.
*/
function createMarket(uint256 _marketType, uint256 _marketCurrencyIndex) public payable{
require(!marketCreationPausedOfType[_marketType]);
uint256 gasProvided = gasleft();
address penultimateMarket = marketCreationData[_marketType][_marketCurrencyIndex].penultimateMarket;
if(penultimateMarket != address(0)) {
Expand Down Expand Up @@ -120,6 +122,14 @@ contract MarketRegistryNew is MarketRegistry {
);
}

/**
* @dev Toggle Market creation of `_marketType` Type.
*/
function toggleMarketCreationType(uint256 _marketType, bool _flag) external onlyAuthorizedToGovern {
require(marketCreationPausedOfType[_marketType] != _flag);
marketCreationPausedOfType[_marketType] = _flag;
}

/**
* @dev Get market reward pool share percent to be rewarded to market creator
*/
Expand Down Expand Up @@ -298,4 +308,7 @@ contract MarketRegistryNew is MarketRegistry {
}
}

function addInitialMarketTypesAndStart(uint64 _marketStartTime, address _ethMarketImplementation, address _btcMarketImplementation) external {
revert("Deprecated");
}
}
91 changes: 90 additions & 1 deletion test/24_UpgradedCreationIncentive.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const MockWeth = artifacts.require("MockWeth");
const MarketUtility = artifacts.require("MarketUtility");
const MockConfig = artifacts.require("MockConfig");
const Governance = artifacts.require("Governance");
const ProposalCategory = artifacts.require("ProposalCategory");
const MockUniswapRouter = artifacts.require("MockUniswapRouter");
const MockUniswapV2Pair = artifacts.require("MockUniswapV2Pair");
const MockUniswapFactory = artifacts.require('MockUniswapFactory');
Expand Down Expand Up @@ -43,7 +44,7 @@ contract("MarketUtility", async function([user1, user2, user3, user4, user5, use
plotusNewInstance, governance,
mockUniswapV2Pair,
mockUniswapFactory, weth,
chainlinkGasAgg;
chainlinkGasAgg, pc;
before(async () => {
masterInstance = await OwnedUpgradeabilityProxy.deployed();
masterInstance = await Master.at(masterInstance.address);
Expand All @@ -55,6 +56,8 @@ contract("MarketUtility", async function([user1, user2, user3, user4, user5, use
memberRoles = await MemberRoles.at(memberRoles);
governance = await masterInstance.getLatestAddress(web3.utils.toHex("GV"));
governance = await Governance.at(governance);
pc = await masterInstance.getLatestAddress(web3.utils.toHex("PC"));
pc = await ProposalCategory.at(pc);
MockUniswapRouterInstance = await MockUniswapRouter.deployed();
mockUniswapFactory = await MockUniswapFactory.deployed();
plotusNewInstance = await Plotus.at(plotusNewAddress);
Expand Down Expand Up @@ -1041,6 +1044,92 @@ contract("MarketUtility", async function([user1, user2, user3, user4, user5, use
assert.equal((newBalanceEth/1e18).toFixed(2), (oldBalanceEth/1e18 + ethExpectedForMarket3).toFixed(2));
tx = await assertRevert(plotusNewInstance.claimCreationRewardV2(100, {from:user2}));
});

it('Should Add category to pause market creation of particular type of market', async function() {
await increaseTime(604800);
let c1 = await pc.totalCategories();
//proposal to add category
let actionHash = encode1(
["string", "uint256", "uint256", "uint256", "uint256[]", "uint256", "string", "address", "bytes2", "uint256[]", "string"],
[
"Pause",
1,
50,
50,
[1],
86400,
"QmZQhJunZesYuCJkdGwejSATTR8eynUgV8372cHvnAPMaM",
nullAddress,
toHex("PL"),
[0, 0, 0, 1],
"toggleMarketCreationType(uint256,bool)",
]
);
let p1 = await governance.getProposalLength();
await governance.createProposalwithSolution("Add new member", "Add new member", "Addnewmember", 3, "Add new member", actionHash);
await governance.submitVote(p1.toNumber(), 1);
await governance.closeProposal(p1.toNumber());
let cat2 = await pc.totalCategories();
assert.notEqual(c1.toNumber(), cat2.toNumber(), "category not updated");
});

it('Should pause market creation of particular type of market', async function() {
await plotusNewInstance.createMarket(0,0);
await increaseTime(604800);
let c1 = await pc.totalCategories();
//proposal to add category
actionHash = encode1(
["uint256","bool"],
[
0, true
]
);
let p1 = await governance.getProposalLength();
await governance.createProposalwithSolution("Add new member", "Add new member", "Addnewmember", c1 - 1, "Add new member", actionHash);
await governance.submitVote(p1.toNumber(), 1);
await governance.closeProposal(p1.toNumber());
assert.equal((await governance.proposalActionStatus(p1.toNumber()))/1, 3)
let cat2 = await pc.totalCategories();
assert.notEqual(c1, cat2, "category not updated");
await assertRevert(plotusNewInstance.createMarket(0,0));
});

it('Should not execute if market is already paused', async function() {
await increaseTime(604800);
let c1 = await pc.totalCategories();
//proposal to add category
actionHash = encode1(
["uint256","bool"],
[
0, true
]
);
let p1 = await governance.getProposalLength();
await governance.createProposalwithSolution("Add new member", "Add new member", "Addnewmember", c1 - 1, "Add new member", actionHash);
await governance.submitVote(p1.toNumber(), 1);
await governance.closeProposal(p1.toNumber());
assert.equal((await governance.proposalActionStatus(p1.toNumber()))/1, 1)
});

it('Should resume market creation of particular type of market', async function() {
await increaseTime(604800);
await assertRevert(plotusNewInstance.createMarket(0,0));
await increaseTime(604800);
let c1 = await pc.totalCategories();
//proposal to add category
actionHash = encode1(
["uint256","bool"],
[
0, false
]
);
let p1 = await governance.getProposalLength();
await governance.createProposalwithSolution("Add new member", "Add new member", "Addnewmember", c1 - 1, "Add new member", actionHash);
await governance.submitVote(p1.toNumber(), 1);
await governance.closeProposal(p1.toNumber());
assert.equal((await governance.proposalActionStatus(p1.toNumber()))/1, 3)
await plotusNewInstance.createMarket(0,0);
});

it('Should update MAXRPSP variable', async function() {
await updateParameter(20, 2, 'MAXRPSP', plotusNewInstance, 'configUint', 5000);
Expand Down