{
  "language": "Solidity",
  "sources": {
    "contracts/stake/Stake.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';\nimport '../libraries/SignedSafeMath.sol';\nimport '../interfaces/IStake.sol';\nimport './CandidateRegistry.sol';\nimport './Pools.sol';\n\n/// @dev Stake contract\n/// @author Alexandas\ncontract Stake is IStake, CandidateRegistry, Pools, ReentrancyGuardUpgradeable {\n\n\tusing SignedSafeMath for int256;\n\n\t/// @dev return `Election` contract\n\tIElection public override election;\n\n\t/// @dev return `MajorCandidates` contract\n\tIMajorCandidates public override majorCandidates;\n\n\t/// @dev return `Slasher` contract\n\tISlasher public override slasher;\n\n\tuint256 public minStake;\n\n\tuint256 public stakeFrozenPeriod;\n\n\tmapping(address => uint256) public lastStakeTimestamp;\n\n\tmapping(address => uint256) internal voteRewardCoefs;\n\n\tmodifier onlyElection() {\n\t\trequire(msg.sender == address(election), 'Stake: caller must be Election contract');\n\t\t_;\n\t}\n\n\tmodifier onlyMajorCandidates() {\n\t\trequire(msg.sender == address(majorCandidates), 'Stake: caller must be MajorCandidates contract');\n\t\t_;\n\t}\n\n\tmodifier onlySlasher() {\n\t\trequire(msg.sender == address(slasher), 'Stake: caller must be Slasher contract');\n\t\t_;\n\t}\n\n\t/// @dev proxy initialize function\n\t/// @param token ERC20 token address\n\t/// @param rewarder `Rewarder` contract\n\t/// @param _election `Election` contract \n\t/// @param _majorCandidates `MajorCandidates` contract\n\t/// @param _slasher `Slasher` contract\n\t/// @param _stakeFrozenPeriod stake frozen period\n\t/// @param _minStake minimum stake for candidate\n\t/// @param rewardPerSecond reward generated per second\n\tfunction initialize(\n\t\tIERC20 token,\n\t\tIRewarder rewarder,\n\t\tIElection _election,\n\t\tIMajorCandidates _majorCandidates,\n\t\tISlasher _slasher,\n\t\tuint256 _stakeFrozenPeriod,\n\t\tuint256 _minStake,\n\t\tuint256 rewardPerSecond\n\t) external initializer {\n\t\t_setToken(token);\n\t\t_setRewarder(rewarder);\n\t\t_setElection(_election);\n\t\t_setMajorCandidates(_majorCandidates);\n\t\t_setSlasher(_slasher);\n\t\t_setStakeFrozenPeriod(_stakeFrozenPeriod);\n\t\t_setMinStake(_minStake);\n\t\t_setRewardPerSecond(rewardPerSecond);\n\t\t_setMaxCoef(1e6);\n\t\t_setAccPrecision(1e12);\n\t\t_addPool(Types.Grade.Major, 750);\n\t\t_addPool(Types.Grade.Secondary, 250);\n\t}\n\n\t/// @dev candidate stake tokens\n\t/// @param amount token amount\n\tfunction stake(uint256 amount) external override {\n\t\t_stake(msg.sender, msg.sender, amount);\n\t}\n\n\t/// @dev register a candidate and stake tokens\n\t/// @param amount token amount\n\t/// @param manifest node manifest\n\tfunction registerAndStake(uint256 amount, string memory manifest) external override {\n\t\t_register(msg.sender, manifest);\n\t\t_stake(msg.sender, msg.sender, amount);\n\t}\n\n\tfunction _stake(\n\t\taddress user,\n\t\taddress _candidate,\n\t\tuint256 amount\n\t) internal {\n\t\trequire(isCandidateRegistered(_candidate), 'Stake: candidate is not registered');\n\t\tTypes.CandidateInfo storage candidate = candidates[_candidate];\n\t\tTypes.PoolInfo memory pool = updatePool(candidate.grade);\n\t\trequire(amount + candidate.amount >= minStake, 'Stake: total amount is less than minimum stake');\n\t\ttoken.transferFrom(user, address(this), amount);\n\t\tcandidate.amount = candidate.amount + amount;\n\t\tcandidate.rewardDebt = candidate.rewardDebt + int256(amount * pool.accPerShare / ACC_PRECISION);\n\t\tlastStakeTimestamp[_candidate] = block.timestamp;\n\t\temit Stake(user, _candidate, amount);\n\t}\n\n\t/// @dev candidate quit from the protocol\n\t/// @param to token receiver\n\tfunction quit(address to) external override nonReentrant {\n\t\trequire(isStakeUnfrozen(msg.sender), 'Stake: stake is frozen currently');\n\t\trequire(!slasher.slashExists(msg.sender), 'Stake: slash exists');\n\t\t_quit(msg.sender, to);\n\t}\n\n\tfunction _quit(address _candidate, address to) internal {\n\t\tTypes.CandidateInfo memory candidate = candidates[_candidate];\n\t\t_withdrawAndClaim(_candidate, candidate.amount, to);\n\t\tif (majorCandidates.exists(_candidate)) {\n\t\t\tmajorCandidates.remove(_candidate);\n\t\t}\n\t\tdelete candidates[_candidate];\n\t\tdelete manifestMap[candidate.manifest];\n\t\temit Quit(candidate.grade, _candidate);\n\t}\n\n\t/// @dev candidate claim reward from the protocol\n\t/// @param to token receiver\n\tfunction claim(address to) external override nonReentrant {\n\t\t_allocate(msg.sender);\n\t\trewarder.mint(to, candidates[msg.sender].allocation);\n\t}\n\n\tfunction isStakeUnfrozen(address candidate) public view returns(bool) {\n\t\treturn block.timestamp > stakeFrozenPeriod + lastStakeTimestamp[candidate];\n\t}\n\n\t/// @dev candidate withdraw the tokens and claim reward from the protocol\n\t/// @param amount token amount\n\t/// @param to token receiver\n\tfunction withdrawAndClaim(uint256 amount, address to) external override nonReentrant {\n\t\trequire(isStakeUnfrozen(msg.sender), 'Stake: stake is frozen currently');\n\t\t_withdrawAndClaim(msg.sender, amount, to);\n\t}\n\n\tfunction _withdrawAndClaim(address _candidate, uint256 amount, address to) internal {\n\t\tTypes.CandidateInfo storage candidate = candidates[_candidate];\n\t\tTypes.PoolInfo memory pool = updatePool(candidate.grade);\n\t\tint256 accumulated = int256(candidate.amount * pool.accPerShare / ACC_PRECISION);\n\t\tuint256 _pending = (accumulated - candidate.rewardDebt).toUInt256();\n\t\tcandidate.rewardDebt = accumulated - int256(amount * pool.accPerShare / ACC_PRECISION);\n\t\tcandidate.amount = candidate.amount - amount;\n\t\tuint256 currentAllocation = candidate.allocation;\n\t\tuint256 pendingAllocation = _allocateReward(_candidate, _pending);\n\t\tcandidate.allocation = 0;\n\t\trewarder.mint(to,  currentAllocation + pendingAllocation);\n\t\ttoken.transfer(to, amount);\n\t\temit Claimed(_candidate, to, currentAllocation + pendingAllocation);\n\t\temit Withdrawn(_candidate, to, amount);\n\t}\n\n\tfunction _setMinStake(uint256 amount) internal {\n\t\tminStake = amount;\n\t\temit MinStakeUpdated(amount);\n\t}\n\n\tfunction _setStakeFrozenPeriod(uint256 period) internal {\n\t\tstakeFrozenPeriod = period;\n\t\temit StakeFrozenPeriodUpdated(period);\n\t}\n\n\tfunction _setMajorCandidates(IMajorCandidates _majorCandidates) internal {\n\t\tmajorCandidates = _majorCandidates;\n\t\temit IMajorCandidatesUpdated(_majorCandidates);\n\t}\n\n\t/// @dev upgrade a candidate\n\t/// @param candidate candidate address\n\tfunction upgrade(address candidate) external override onlyMajorCandidates {\n\t\t_onCandidateGradeChanged(candidate, Types.Grade.Major);\n\t\temit Upgrade(candidate, Types.Grade.Secondary, Types.Grade.Major);\n\t}\n\n\t/// @dev downgrade a candidate\n\t/// @param candidate candidate address\n\tfunction downgrade(address candidate) external override onlyMajorCandidates {\n\t\t_onCandidateGradeChanged(candidate, Types.Grade.Secondary);\n\t\temit Downgrade(candidate, Types.Grade.Major, Types.Grade.Secondary);\n\t}\n\n\t// make sure pool updated and reward allocated\n\tfunction _onCandidateGradeChanged(address _candidate, Types.Grade grade) internal {\n\t\t_allocate(_candidate);\n\t\tTypes.CandidateInfo storage candidate = candidates[_candidate];\n\t\tcandidate.grade = grade;\n\t\tTypes.PoolInfo memory pool = updatePool(grade);\n\t\tcandidate.rewardDebt = int256(candidate.amount * pool.accPerShare / ACC_PRECISION);\n\t}\n\n\t/// @dev set allocate the reward to voters from the candidate\n\t/// @param candidate candidate address\n\tfunction voterAllocate(address candidate) external override onlyElection {\n\t\t_allocate(candidate);\n\t}\n\n\tfunction _allocate(address _candidate) internal {\n\t\tif (isCandidateRegistered(_candidate)) {\n\t\t\tTypes.CandidateInfo storage candidate = candidates[_candidate];\n\t\t\tTypes.PoolInfo memory pool = updatePool(candidate.grade);\n\t\t\tint256 accumulated = int256(candidate.amount * pool.accPerShare / ACC_PRECISION);\n\t\t\tuint256 _pending = (accumulated - candidate.rewardDebt).toUInt256();\n\t\t\tcandidate.rewardDebt = accumulated;\n\t\t\tuint256 allocation = _allocateReward(_candidate, _pending);\n\t\t\tif (allocation > 0) {\n\t\t\t\tcandidate.allocation = candidate.allocation + allocation;\n\t\t\t\temit CandidateAllocated(_candidate, allocation);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction _allocateReward(\n\t\taddress _candidate,\n\t\tuint256 _pending\n\t) internal returns(uint256 pendingAllocation) {\n\t\tif (_pending > 0) {\n\t\t\tpendingAllocation = _pending;\n\t\t\tif (voteRewardCoef(_candidate) > 0 && election.voteSupply(_candidate) > 0) {\n\t\t\t\tuint256 allocation = _pending * voteRewardCoef(_candidate) / MAXCOEF;\n\t\t\t\telection.onAllocate(_candidate, allocation);\n\t\t\t\tpendingAllocation = _pending - allocation;\n\t\t\t\temit VoterAllocated(_candidate, allocation);\n\t\t\t}\n\t\t}\n\t}\n\n\t/// @dev set voter slash reward coefficient\n\t/// @param coef voter reward coefficient\n\tfunction setVoteRewardCoef(uint256 coef) external override {\n\t\t_setVoteRewardCoef(msg.sender, coef);\n\t}\n\n\tfunction _setVoteRewardCoef(address candidate, uint256 coef) internal {\n\t\trequire(coef > 0 && coef <= MAXCOEF, 'Stake: invalid coef');\n\t\trequire(isCandidateRegistered(candidate), 'Stake: candidate is not registered');\n\t\t_allocate(candidate);\n\t\tvoteRewardCoefs[candidate] = coef;\n\t\temit VoteRewardCoefUpdated(coef);\n\t}\n\n\tfunction _setElection(IElection _election) internal {\n\t\telection = _election;\n\t\temit ElectionUpdated(_election);\n\t}\n\n\tfunction _pendingReward(address _candidate) internal view returns (uint256 pending) { \n\t\tTypes.CandidateInfo storage candidate = candidates[_candidate];\n\t\tTypes.PoolInfo memory pool = pools[candidate.grade];\n\t\tuint256 accPerShare = pool.accPerShare;\n\t\tuint256 lpSupply = token.balanceOf(address(this));\n\t\tif (block.timestamp > pool.lastRewardTime && lpSupply != 0) {\n\t\t\tuint256 time = block.timestamp - pool.lastRewardTime;\n\t\t\tuint256 reward = time * rewardPerSecond * pool.allocPoint / totalAllocPoint;\n\t\t\taccPerShare = accPerShare + (reward * ACC_PRECISION / lpSupply);\n\t\t}\n\t\tpending = int256(int256(candidate.amount * accPerShare / ACC_PRECISION) - candidate.rewardDebt).toUInt256();\n\t}\n\n\t/// @dev return pending candidate allocation\n\t/// @param _candidate candidate address\n\t/// @return pendingAllocation pending candidate allocation\n\tfunction pendingCandidateAllocation(address _candidate) public view override returns (uint256 pendingAllocation) {\n\t\tif (voteRewardCoef(_candidate) > 0 && election.voteSupply(_candidate) > 0) {\n\t\t\tuint256 pending = _pendingReward(_candidate);\n\t\t\tpendingAllocation = pending * (MAXCOEF - voteRewardCoef(_candidate)) / MAXCOEF;\n\t\t}\n\t}\n\t\n\t/// @dev return pending voters allocation for a specific candidate\n\t/// @param _candidate candidate address\n\t/// @return pendingAllocation pending voters allocation\n\tfunction pendingVoterAllocation(address _candidate) public view override returns (uint256 pendingAllocation) {\n\t\tif (voteRewardCoef(_candidate) > 0 && election.voteSupply(_candidate) > 0) {\n\t\t\tuint256 pending = _pendingReward(_candidate);\n\t\t\tpendingAllocation = pending * voteRewardCoef(_candidate) / MAXCOEF;\n\t\t}\n\t}\n\n\t/// @dev return pending reward for a specific candidate\n\t/// @param _candidate candidate address\n\t/// @return pending reward for the candidate\n\tfunction pendingReward(address _candidate) public view override returns (uint256 pending) {\n\t\tpending = pendingCandidateAllocation(_candidate) + candidates[_candidate].allocation;\n\t}\n\n\t/// @dev return voter reward coefficient for a specific candidate\n\t/// @param candidate candidate address\n\t/// @return coef voter reward coefficient\n\tfunction voteRewardCoef(address candidate) public view override returns (uint256) {\n\t\treturn voteRewardCoefs[candidate];\n\t}\n\n\tfunction _setSlasher(ISlasher _slasher) internal {\n\t\tslasher = _slasher;\n\t\temit SlasherUpdated(_slasher);\n\t}\n\n\t/// @dev draft a slash for a candidate\n\t/// @param _candidate candidate address\n\t/// @param amount slash amount\n\t/// @return pendingSlash real slash amount\n\tfunction draftSlash(address _candidate, uint256 amount) external override onlySlasher returns(uint256 pendingSlash) {\n\t\tTypes.CandidateInfo storage candidate = candidates[_candidate];\n\t\trequire(candidate.amount > 0, 'Stake: zero stake amount');\n\t\tif (candidate.amount < amount) {\n\t\t\t_quit(_candidate, _candidate);\n\t\t} else {\n\t\t\tpendingSlash = amount;\n\t\t\tTypes.PoolInfo memory pool = updatePool(candidate.grade);\n\t\t\tcandidate.rewardDebt = candidate.rewardDebt - int256(amount * pool.accPerShare / ACC_PRECISION);\n\t\t\tcandidate.amount = candidate.amount - amount;\n\n\t\t\temit DraftSlash(_candidate, pendingSlash);\n\t\t}\n\t}\n\n\t/// @dev reject a slash for a candidate\n\t/// @param _candidate candidate address\n\t/// @param pendingSlash real slash amount\n\tfunction rejectSlash(address _candidate, uint256 pendingSlash) external override onlySlasher {\n\t\tTypes.CandidateInfo storage candidate = candidates[_candidate];\n\t\tTypes.PoolInfo memory pool = updatePool(candidate.grade);\n\t\tcandidate.rewardDebt = candidate.rewardDebt + int256(pendingSlash * pool.accPerShare / ACC_PRECISION);\n\t\tcandidate.amount = candidate.amount + pendingSlash;\n\n\t\temit RejectSlash(_candidate, pendingSlash);\n\t}\n\t\n\t/// @dev executed a slash for a candiate\n\t/// @param _candidate candidate address\n\t/// @param slash slash amount\n\t/// @param beneficiaries slash reward beneficiaries\n\t/// @param amounts slash reward amounts\n\t/// @param burned burned amount\n\tfunction executeSlash(\n\t\taddress _candidate,\n\t\tuint256 slash,\n\t\taddress[] memory beneficiaries,\n\t\tuint256[] memory amounts,\n\t\tuint256 burned\n\t) external override onlySlasher {\n\t\trequire(beneficiaries.length == amounts.length, 'Stake: invalid params');\n\t\tfor(uint8 i = 0; i < beneficiaries.length; i++) {\n\t\t\ttoken.transfer(beneficiaries[i], amounts[i]);\n\t\t}\n\t\ttoken.burn(burned);\n\t\temit ExcuteSlash(_candidate, slash, beneficiaries, amounts, burned);\n\t}\n\n\tfunction majorCandidateManifests() external view returns(string[] memory manifests) {\n\t\taddress[] memory candidates = majorCandidates.majorCandidateList();\n\t\tmanifests = new string[](candidates.length);\n\t\tfor (uint256 i = 0; i < candidates.length; i++) {\n\t\t\tTypes.CandidateInfo memory candidate = candidateInfo(candidates[i]);\n\t\t\tmanifests[i] = candidate.manifest;\n\t\t}\n\t}\n\n}\n"
    },
    "contracts/libraries/SignedSafeMath.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nlibrary SignedSafeMath {\n    int256 constant private _INT256_MIN = -2**255;\n\n    /**\n     * @dev Returns the multiplication of two signed integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(int256 a, int256 b) internal pure returns (int256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n        if (a == 0) {\n            return 0;\n        }\n\n        require(!(a == -1 && b == _INT256_MIN), 'SignedSafeMath: multiplication overflow');\n\n        int256 c = a * b;\n        require(c / a == b, 'SignedSafeMath: multiplication overflow');\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two signed integers. Reverts on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(int256 a, int256 b) internal pure returns (int256) {\n        require(b != 0, 'SignedSafeMath: division by zero');\n        require(!(b == -1 && a == _INT256_MIN), 'SignedSafeMath: division overflow');\n\n        int256 c = a / b;\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two signed integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(int256 a, int256 b) internal pure returns (int256) {\n        int256 c = a - b;\n        require((b >= 0 && c <= a) || (b < 0 && c > a), 'SignedSafeMath: subtraction overflow');\n\n        return c;\n    }\n\n    /**\n     * @dev Returns the addition of two signed integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(int256 a, int256 b) internal pure returns (int256) {\n        int256 c = a + b;\n        require((b >= 0 && c >= a) || (b < 0 && c < a), 'SignedSafeMath: addition overflow');\n\n        return c;\n    }\n\n    function toUInt256(int256 a) internal pure returns (uint256) {\n        require(a >= 0, 'Integer < 0');\n        return uint256(a);\n    }\n}"
    },
    "contracts/interfaces/IStake.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport './IElection.sol';\nimport './IMajorCandidates.sol';\nimport './ISlasher.sol';\nimport './IPools.sol';\nimport './ICandidateRegistry.sol';\n\n/// @dev Stake interface\n/// @author Alexandas\ninterface IStake is IPools, ICandidateRegistry {\n\n\t/// @dev emit when `Election` contract changed\n\t/// @param election `Election` contract address\n\tevent ElectionUpdated(IElection election);\n\n\t/// @dev emit when `MajorCandidates` contract updated\n\t/// @param majorCandidates `MajorCandidates` contract \n\tevent IMajorCandidatesUpdated(IMajorCandidates majorCandidates);\n\n\t/// @dev emit when `Slasher` contract updated\n\t/// @param slasher `Slasher` contract \n\tevent SlasherUpdated(ISlasher slasher);\n\n\t/// @dev emit when minimum stake updated\n\t/// @param amount minimum stake\n\tevent MinStakeUpdated(uint256 amount);\n\n\t/// @dev emit when stake frozen period updated\n\t/// @param period stake frozen period\n\tevent StakeFrozenPeriodUpdated(uint256 period);\n\n\t/// @dev emit when a candidate upgraded\n\t/// @param candidate candidate address\n\t/// @param fromGrade from grade\n\t/// @param toGrade to grade\n\tevent Upgrade(address candidate, Types.Grade fromGrade, Types.Grade toGrade);\n\n\t/// @dev emit when a candidate downgraded\n\t/// @param candidate candidate address\n\t/// @param fromGrade from grade\n\t/// @param toGrade to grade\n\tevent Downgrade(address candidate, Types.Grade fromGrade, Types.Grade toGrade);\n\n\t/// @dev emit when a candidate staked tokens\n\t/// @param from token consumer\n\t/// @param candidate candidate address\n\t/// @param amount token amount\n\tevent Stake(address from, address candidate, uint256 amount);\n\n\t/// @dev emit when a candidate withdraw tokens\n\t/// @param candidate candidate address\n\t/// @param to token receiver\n\t/// @param amount token amount\n\tevent Withdrawn(address candidate, address to, uint256 amount);\n\n\t/// @dev emit when a candidate claimed reward\n\t/// @param candidate candidate address\n\t/// @param to token receiver\n\t/// @param pending token amount\n\tevent Claimed(address candidate, address to, uint256 pending);\n\n\t/// @dev emit when a candidate quit from the protocol\n\t/// @param grade candidate grade\n\t/// @param candidate candidate address\n\tevent Quit(Types.Grade grade, address candidate);\n\n\t/// @dev emit when a candidate allocate reward for the voters\n\t/// @param candidate candidate address\n\t/// @param amount token amount\n\tevent VoterAllocated(address candidate, uint256 amount);\n\n\t/// @dev emit when the reward for a candidate\n\t/// @param candidate candidate address\n\t/// @param amount token amount\n\tevent CandidateAllocated(address candidate, uint256 amount);\n\n\t/// @dev emit when the vote reward coefficient updated\n\t/// @param coef vote reward coefficient\n\tevent VoteRewardCoefUpdated(uint256 coef);\n\n\t/// @dev emit when drafted a slash\n\t/// @param candidate candidate address\n\t/// @param pendingSlash pending slash amount\n\tevent DraftSlash(address candidate, uint256 pendingSlash);\n\n\t/// @dev emit when rejected a slash\n\t/// @param candidate candidate address\n\t/// @param pendingSlash pending slash amount\n\tevent RejectSlash(address candidate, uint256 pendingSlash);\n\n\t/// @dev emit when executed a slash\n\t/// @param candidate candidate address\n\t/// @param pendingSlash pending slash amount\n\t/// @param beneficiaries slash reward beneficiaries\n\t/// @param amounts slash reward amounts\n\t/// @param burned burned amount\n\tevent ExcuteSlash(address candidate, uint256 pendingSlash, address[] beneficiaries, uint256[] amounts, uint256 burned);\n\n\t/// @dev return `Election` contract\n\tfunction election() external view returns(IElection);\n\n\t/// @dev return `MajorCandidates` contract\n\tfunction majorCandidates() external view returns(IMajorCandidates);\n\n\t/// @dev return `Slasher` contract\n\tfunction slasher() external returns(ISlasher);\n\n\t/// @dev candidate stake tokens\n\t/// @param amount token amount\n\tfunction stake(uint256 amount) external;\n\n\t/// @dev register a candidate and stake tokens\n\t/// @param amount token amount\n\t/// @param manifest node manifest\n\tfunction registerAndStake(uint256 amount, string memory manifest) external;\n\n\t/// @dev candidate quit from the protocol\n\t/// @param to token receiver\n\tfunction quit(address to) external;\n\n\t/// @dev candidate claim reward from the protocol\n\t/// @param to token receiver\n\tfunction claim(address to) external;\n\n\t/// @dev candidate withdraw the tokens and claim reward from the protocol\n\t/// @param amount token amount\n\t/// @param to token receiver\n\tfunction withdrawAndClaim(uint256 amount, address to) external;\n\n\t/// @dev return pending reward for a specific candidate\n\t/// @param candidate candidate address\n\t/// @return pending reward for the candidate\n\tfunction pendingReward(address candidate) external view returns (uint256 pending);\n\n\t/// @dev set voter slash reward coefficient\n\t/// @param coef voter reward coefficient\n\tfunction setVoteRewardCoef(uint256 coef) external;\n\n\t/// @dev set allocate the reward to voters from the candidate\n\t/// @param candidate candidate address\n\tfunction voterAllocate(address candidate) external;\n\n\t/// @dev return voter reward coefficient for a specific candidate\n\t/// @param candidate candidate address\n\t/// @return coef voter reward coefficient\n\tfunction voteRewardCoef(address candidate) external view returns (uint256 coef);\n\n\t/// @dev return pending voters allocation for a specific candidate\n\t/// @param candidate candidate address\n\t/// @return pending pending voters allocation\n\tfunction pendingVoterAllocation(address candidate) external view returns (uint256 pending);\n\n\t/// @dev return pending candidate allocation\n\t/// @param candidate candidate address\n\t/// @return pending pending candidate allocation\n\tfunction pendingCandidateAllocation(address candidate) external view returns (uint256 pending);\n\n\t/// @dev upgrade a candidate\n\t/// @param candidate candidate address\n\tfunction upgrade(address candidate) external;\n\n\t/// @dev downgrade a candidate\n\t/// @param candidate candidate address\n\tfunction downgrade(address candidate) external;\n\n\t/// @dev draft a slash for a candidate\n\t/// @param candidate candidate address\n\t/// @param amount slash amount\n\t/// @return pendingSlash real slash amount\n\tfunction draftSlash(address candidate, uint256 amount) external returns(uint256 pendingSlash);\n\n\t/// @dev reject a slash for a candidate\n\t/// @param candidate candidate address\n\t/// @param pendingSlash real slash amount\n\tfunction rejectSlash(address candidate, uint256 pendingSlash) external;\n\n\t/// @dev executed a slash for a candiate\n\t/// @param candidate candidate address\n\t/// @param slash slash amount\n\t/// @param beneficiaries slash reward beneficiaries\n\t/// @param amounts slash reward amounts\n\t/// @param burned burned amount\n\tfunction executeSlash(\n\t\taddress candidate, \n\t\tuint256 slash,\n\t\taddress[] memory beneficiaries, \n\t\tuint256[] memory amounts,\n\t\tuint256 burned\n\t) external;\n}"
    },
    "contracts/stake/CandidateRegistry.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport '../interfaces/ICandidateRegistry.sol';\n\n/// @dev Candidate registry contract\n/// @author Alexandas\ncontract CandidateRegistry is ICandidateRegistry {\n\n\tmapping(address => Types.CandidateInfo) internal candidates;\n\n\t/// @dev return a candidate address for a specific node manifest\n\tmapping(string => address) public override manifestMap;\n\n\t/// @dev register a candidate with node manifest\n\t/// @param manifest node manifest\n\tfunction register(string memory manifest) external override {\n\t\t_register(msg.sender, manifest);\n\t}\n\n\tfunction _register(address candidate, string memory manifest) internal {\n\t\trequire(candidates[candidate].grade == Types.Grade.Null, 'CandidateRegistry: candidate exists');\n\t\trequire(manifestMap[manifest] == address(0), 'CandidateRegistry: manifest exists');\n\t\tmanifestMap[manifest] = candidate;\n\t\tcandidates[candidate].grade = Types.Grade.Secondary;\n\t\tcandidates[candidate].manifest = manifest;\n\t\temit Register(candidate);\n\t}\n\n\t/// @dev return a candidate\n\t/// @param candidate candidate address\n\t/// @return candidate information\n\tfunction candidateInfo(address candidate) public view override returns (Types.CandidateInfo memory) {\n\t\treturn candidates[candidate];\n\t}\n\n\t/// @dev return whether a candidate is registered\n\t/// @param candidate candidate address\n\t/// @return whether the candidate is registered\n\tfunction isCandidateRegistered(address candidate) public view override returns (bool) {\n\t\treturn candidates[candidate].grade != Types.Grade.Null;\n\t}\n\n\t/// @dev return grade of a candidate\n\t/// @param candidate candidate address\n\t/// @return candidate grade\n\tfunction gradeOf(address candidate) public view override returns (Types.Grade) {\n\t\treturn candidates[candidate].grade;\n\t}\n\n}\n"
    },
    "contracts/stake/Pools.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport '../interfaces/IPools.sol';\n\n/// @dev Pools contract\n/// @author Alexandas\ncontract Pools is IPools {\n\n\t/// @dev return ERC20 token address\n\tIERC20 public override token;\n\n\t/// @dev return `Rewarder` contract address\n\tIRewarder public override rewarder;\n\n\t/// @dev return precision for shares\n\tuint256 public override ACC_PRECISION;\n\n\t/// @dev return max coefficient\n\tuint256 public override MAXCOEF;\n\n\t/// @dev return total pools allocation points\n\tuint256 public override totalAllocPoint;\n\n\t/// @dev return reward generated for per second\n\tuint256 public override rewardPerSecond;\n\n\tmapping(Types.Grade => Types.PoolInfo) internal pools;\n\n\tfunction _addPool(\n\t\tTypes.Grade grade,\n\t\tuint256 allocPoint\n\t) internal {\n\t\trequire(pools[grade].allocPoint == 0, 'Pools: pool exists');\n\t\ttotalAllocPoint = totalAllocPoint + allocPoint;\n\t\tpools[grade] = Types.PoolInfo({ allocPoint: allocPoint, lastRewardTime: block.timestamp, accPerShare: 0 });\n\t\temit AddPool(grade);\n\t}\n\n\t/// @dev update a specific pool\n\t/// @param grade pool grade\n\t/// @return pool pool info\n\tfunction updatePool(Types.Grade grade) public override returns (Types.PoolInfo memory pool) {\n\t\trequire(poolExists(grade), 'Pools: nonexistent pool');\n\t\tpool = pools[grade];\n\t\tif (block.timestamp > pool.lastRewardTime) {\n\t\t\tuint256 lpSupply = token.balanceOf(address(this));\n\t\t\tif (lpSupply > 0) {\n\t\t\t\tuint256 time = block.timestamp - pool.lastRewardTime;\n\t\t\t\tuint256 reward = time * rewardPerSecond * pool.allocPoint / totalAllocPoint;\n\t\t\t\tpool.accPerShare = pool.accPerShare + (reward * ACC_PRECISION / lpSupply);\n\t\t\t}\n\t\t\tpool.lastRewardTime = block.timestamp;\n\t\t\tpools[grade] = pool;\n\t\t}\n\t\temit PoolUpdated(grade);\n\t}\n\n\t/// @dev return a specific pool\n\t/// @param grade pool grade\n\t/// @return pool pool info\n\tfunction poolInfo(Types.Grade grade) public view override returns (Types.PoolInfo memory) {\n\t\treturn pools[grade];\n\t}\n\n\tfunction poolExists(Types.Grade grade) public view returns (bool) {\n\t\treturn pools[grade].allocPoint != 0;\n\t}\n\n\tfunction _setRewardPerSecond(uint256 _rewardPerSecond) internal {\n\t\trewardPerSecond = _rewardPerSecond;\n\t\temit RewardPerSecondUpdated(_rewardPerSecond);\n\t}\n\n\tfunction _setToken(IERC20 _token) internal {\n\t\ttoken = _token;\n\t\temit TokenUpdated(_token);\n\t}\n\n\tfunction _setRewarder(IRewarder _rewarder) internal {\n\t\trewarder = _rewarder;\n\t\temit RewarderUpdated(_rewarder);\n\t}\n\n\tfunction _setMaxCoef(uint256 _maxCoef) internal {\n\t\tMAXCOEF = _maxCoef;\n\t\temit MaxCoefUpdated(_maxCoef);\n\t}\n\n\tfunction _setAccPrecision(uint256 _precision) internal {\n\t\tACC_PRECISION = _precision;\n\t\temit PrecisionUpdated(_precision);\n\t}\n\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        // On the first call to nonReentrant, _notEntered will be true\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n\n        _;\n\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
    },
    "contracts/interfaces/IElection.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport './IRewarder.sol';\nimport './IStake.sol';\nimport './IMajorCandidates.sol';\nimport './IERC20.sol';\n\n/// @dev Election contract interface\n/// @author Alexandas\ninterface IElection {\n\n\t/// @dev emit when ERC20 token address updated\n\t/// @param token ERC20 token address\n\tevent TokenUpdated(IERC20 token);\n\n\t/// @dev emit when `Rewarder` contract updated\n\t/// @param rewarder `Rewarder` contract \n\tevent RewarderUpdated(IRewarder rewarder);\n\n\t/// @dev emit when `Stake` contract updated\n\t/// @param stake `Stake` contract \n\tevent StakeUpdated(IStake stake);\n\n\t/// @dev emit when `MajorCandidates` contract updated\n\t/// @param majorCandidates `MajorCandidates` contract \n\tevent MajorCandidatesUpdated(IMajorCandidates majorCandidates);\n\n\t/// @dev emit when shares updated for a specific candidate\n\t/// @param candidate candidate address\n\tevent ShareUpdated(address candidate);\n\n\t/// @dev emit when voter voted for a candidate\n\t/// @param candidate candidate address\n\t/// @param voter voter address\n\t/// @param amount token amount\n\tevent Vote(address candidate, address voter, uint256 amount);\n\n\t/// @dev emit when voter claimed the reward\n\t/// @param candidate candidate address\n\t/// @param voter voter address\n\t/// @param to receiver address\n\t/// @param amount reward amount\n\tevent Claimed(address candidate, address voter, address to, uint256 amount);\n\n\t/// @dev emit when voter withdrawn the votes\n\t/// @param candidate candidate address\n\t/// @param voter voter address\n\t/// @param to receiver address\n\t/// @param amount reward amount\n\tevent Withdrawn(address candidate, address voter, address to, uint256 amount);\n\n\t/// @dev voter vote a specific candidate\n\t/// @param candidate candidate address\n\t/// @param voter voter address\n\t/// @param amount reward amount\n\t/// @param anchor anchor candidate address\n\t/// @param maxSlippage maximum rank change value for the candidate from the anchor candidate\n\tfunction vote(\n\t\taddress candidate,\n\t\taddress voter,\n\t\tuint256 amount,\n\t\taddress anchor,\n\t\tuint256 maxSlippage\n\t) external;\n\n\t/// @dev voter claim reward for a specific candidate\n\t/// @param candidate candidate address\n\t/// @param to receiver address\n\tfunction claim(address candidate, address to) external;\n\n\t/// @dev voter withdraw reward for a specific candidate\n\t/// @param candidate candidate address\n\t/// @param amount reward amount\n\t/// @param to receiver address\n\t/// @param anchor anchor candidate address\n\t/// @param maxSlippage maximum rank change value for the candidate from the anchor candidate\n\tfunction withdraw(\n\t\taddress candidate,\n\t\tuint256 amount,\n\t\taddress to,\n\t\taddress anchor,\n\t\tuint256 maxSlippage\n\t) external;\n\n\t/// @dev voter withdraw votes and claim reward for a specific candidate\n\t/// @param candidate candidate address\n\t/// @param amount reward amount\n\t/// @param to receiver address\n\t/// @param anchor anchor candidate address\n\t/// @param maxSlippage maximum rank change value for the candidate from the anchor candidate\n\tfunction withdrawAndClaim(\n\t\taddress candidate,\n\t\tuint256 amount,\n\t\taddress to,\n\t\taddress anchor,\n\t\tuint256 maxSlippage\n\t) external;\n\n\t/// @dev candidate allocate reward for the voters\n\t/// @param candidate candidate address\n\t/// @param amount reward amount\n\tfunction onAllocate(address candidate, uint256 amount) external;\n\n\t/// @dev return ERC20 token address\n\tfunction token() external view returns(IERC20);\n\n\t/// @dev return `Rewarder` contract address\n\tfunction rewarder() external view returns(IRewarder);\n\n\t/// @dev return `Stake` contract address\n\tfunction stake() external view returns(IStake);\n\n\t/// @dev return `MajorCandidates` contract address\n\tfunction majorCandidates() external view returns(IMajorCandidates);\n\n\t/// @dev return precision for shares\n\tfunction ACC_PRECISION() external view returns(uint256);\n\n\t/// @dev return votes for a specific candidate\n\t/// @param candidate candidate address\n\t/// @return votes for a specific candidate\n\tfunction voteSupply(address candidate) external view returns(uint256);\n\n\t/// @dev pending reward for a voter given a candidate\n\t/// @param candidate candidate address\n\t/// @param voter voter address\n\t/// @return pending pending reward\n\tfunction pendingReward(address candidate, address voter) external view returns (uint256 pending);\n\n}\n"
    },
    "contracts/interfaces/IMajorCandidates.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport './IElection.sol';\nimport './IStake.sol';\n\n/// @dev MajorCandidates interface\n/// @author Alexandas\ninterface IMajorCandidates {\n\n\t/// @dev emit when max major candidates changed\n\t/// @param max max major candidates\n\tevent MaxMajorCandidateUpdated(uint256 max);\n\n\t/// @dev emit when `Election` contract changed\n\t/// @param election `Election` contract address\n\tevent ElectionUpdated(IElection election);\n\n\t/// @dev emit when `Stake` contract updated\n\t/// @param stake `Stake` contract \n\tevent StakeUpdated(IStake stake);\n\n\t/// @dev emit when a candidate insert or update in the sorted list\n\t/// @param candidate candidate address\n\t/// @param amount candidate votes\n\tevent UpsetCandidate(address candidate, uint256 amount);\n\n\t/// @dev emit when a candidate removed from the sorted list\n\t/// @param candidate candidate address\n\tevent RemoveCandidate(address candidate);\n\n\t/// @dev insert or update a candidate in the sorted list\n\t/// @param candidate candidate address\n\t/// @param amount candidate votes\n\t/// @param anchor anchor candidate address\n\t/// @param maxSlippage maximum rank change value for the candidate from the anchor candidate\n\tfunction upsetCandidateWithAnchor(\n\t\taddress candidate,\n\t\tuint256 amount,\n\t\taddress anchor,\n\t\tuint256 maxSlippage\n\t) external;\n\n\t/// @dev emit removed a candidate from the sorted list\n\t/// @param candidate candidate address\n\tfunction remove(address candidate) external;\n\n\t/// @dev return max major candidates\n\tfunction MAX_MAJOR_CANDIDATES() external view returns(uint256);\n\n\t/// @dev return `Election` contract address\n\tfunction election() external view returns(IElection);\n\n\t/// @dev return `Stake` contract address\n\tfunction stake() external view returns(IStake);\n\n\t/// @dev return whether a candidate is existed in the sorted list\n\t/// @param candidate candidate address\n\t/// @return whether the candidate is existed in the sorted list\n\tfunction exists(address candidate) external view returns (bool);\n\n\t/// @dev return whether a candidate is a major candidate\n\t/// @param candidate candidate address\n\t/// @return existed the candidate is a major candidate\n\tfunction isMajor(address candidate) external view returns(bool existed);\n\n\t/// @dev return all major candidates\n\t/// @return majors all major candidates\n\tfunction majorCandidateList() external view returns(address[] memory majors);\n\n\n}\n"
    },
    "contracts/interfaces/ISlasher.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport '../libraries/Types.sol';\nimport './IMajorCandidates.sol';\nimport './IStake.sol';\n\n/// @dev Slasher interface\n/// @author Alexandas\ninterface ISlasher {\n\n\t/// @dev emit when governance address updated\n\t/// @param governance governance address\n\tevent GovernanceUpdated(address governance);\n\n\t/// @dev emit when `Stake` contract updated\n\t/// @param stake `Stake` contract \n\tevent StakeUpdated(IStake stake);\n\n\t/// @dev emit when `MajorCandidates` contract updated\n\t/// @param majorCandidates `MajorCandidates` contract \n\tevent MajorCandidatesUpdated(IMajorCandidates majorCandidates);\n\n\t/// @dev emit when default slash amount updated\n\t/// @param amount slash amount\n\tevent DefaultSlashAmountUpdated(uint256 amount);\n\n\t/// @dev emit when public notice period updated\n\t/// @param period public notice period\n\tevent PublicNoticePeriodUpdated(uint256 period);\n\n\t/// @dev emit when max coefficient updated\n\t/// @param maxCoef max coefficient\n\tevent MaxCoefUpdated(uint256 maxCoef);\n\n\t/// @dev emit when drafter slash reward coefficient updated\n\t/// @param drafterCoef drafter slash reward coefficient\n\tevent DrafterCoefUpdated(uint64 drafterCoef);\n\n\t/// @dev emit when validator slash reward coefficient updated\n\t/// @param validatorCoef validator slash reward coefficient\n\tevent ValidatorCoefUpdated(uint256 validatorCoef);\n\n\t/// @dev emit when executor slash reward coefficient updated\n\t/// @param executorCoef executor slash reward coefficient\n\tevent ExecutorCoefUpdated(uint256 executorCoef);\n\n\t/// @dev emit when slash drafted\n\t/// @param nonce slash number\n\t/// @param candidate candidate address\n\t/// @param slashBlock slashed block in posc\n\t/// @param manifest node manifest\n\t/// @param accuracy posc accuracy\n\tevent DraftSlash(uint256 nonce, address candidate, uint64 slashBlock, string manifest, uint64 accuracy);\n\n\t/// @dev emit when slash drafted\n\t/// @param nonce slash number\n\tevent RejectSlash(uint256 nonce);\n\n\t/// @dev emit when slash drafted\n\t/// @param nonce slash number\n\tevent ExecuteSlash(uint256 nonce, address executor);\n\n\t/// @dev return `Stake` contract address\n\tfunction stake() external view returns(IStake);\n\n\t/// @dev return `MajorCandidates` contract address\n\tfunction majorCandidates() external view returns(IMajorCandidates);\n\n\t/// @dev return default slash amount\n\tfunction defaultSlashAmount() external view returns(uint256);\n\n\t/// @dev return public notice period\n\tfunction publicNoticePeriod() external view returns(uint256);\n\n\t/// @dev return current slash nonce\n\tfunction nonce() external view returns(uint256);\n\n\t/// @dev return max coefficient\n\tfunction MAXCOEF() external view returns(uint64);\n\n\t/// @dev return drafter slash reward coefficient\n\tfunction drafterCoef() external view returns(uint64);\n\n\t/// @dev return validator slash reward coefficient\n\tfunction validatorCoef() external view returns(uint64);\n\n\t/// @dev return executor slash reward coefficient\n\tfunction executorCoef() external view returns(uint64);\n\n\t/// @dev return slash information at a specific nonce\n\t/// @param _nonce nonce number\n\t/// @return slash information\n\tfunction getSlashAt(uint256 _nonce) external view returns(Types.SlashInfo memory);\n\n\t/// @dev return nonce given a candidate if the candidate is in slashing\n\t/// @param candidate candidate address\n\t/// @return nonce number\n\tfunction nonceOf(address candidate) external view returns(uint256);\n\n\t/// @dev set drafter slash reward coefficient\n\t/// @param _drafterCoef drafter slash reward coefficient\n\tfunction setDrafterCoef(uint64 _drafterCoef) external;\n\n\t/// @dev set validator slash reward coefficient\n\t/// @param _validatorCoef validator slash reward coefficient\n\tfunction setValidatorCoef(uint64 _validatorCoef) external;\n\n\t/// @dev set executor slash reward coefficient\n\t/// @param _executorCoef executor slash reward coefficient\n\tfunction setExecutorCoef(uint64 _executorCoef) external;\n\n\t/// @dev draft a slash\n\t/// @param slashBlock slashed block in posc\n\t/// @param manifest node manifest\n\t/// @param accuracy posc accuracy\n\t/// @param signatures major candidates signatures\n\tfunction draft(uint64 slashBlock, string memory manifest, uint64 accuracy, bytes[] memory signatures) external;\n\n\t/// @dev reject a slash\n\t/// @param manifest node manifest\n\tfunction reject(string memory manifest) external;\n\n\t/// @dev execute a slash\n\t/// @param manifest node manifest\n\tfunction execute(string memory manifest) external;\n\n\t/// @dev return whether candidate is in slashing\n\t/// @param candidate candidate address\n\t/// @return whether candidate is in slashing\n\tfunction slashExists(address candidate) external view returns(bool);\n\n\t/// @dev check whether signatures is valid\n\t/// @param hash message hash\n\t/// @param signatures signatures for major candidates\n\t/// @param signers major candidate signers\n\tfunction checkNSignatures(bytes32 hash, bytes[] memory signatures) external view returns(address[] memory signers);\n\n}\n"
    },
    "contracts/interfaces/IPools.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport './IERC20.sol';\nimport './IRewarder.sol';\nimport '../libraries/Types.sol';\n\n/// @dev Pools interface\n/// @author Alexandas\ninterface IPools {\n\n\t/// @dev emit when ERC20 Token contract updated\n\t/// @param token ERC20 Token contract\n\tevent TokenUpdated(IERC20 token);\n\n\t/// @dev emit when `Rewarder` contract updated\n\t/// @param rewarder `Rewarder` contract \n\tevent RewarderUpdated(IRewarder rewarder);\n\n\t/// @dev emit when `rewardPerSecond` updated\n\t/// @param rewardPerSecond reward generated for per second\n\tevent RewardPerSecondUpdated(uint256 rewardPerSecond);\n\n\t/// @dev emit when shares precision updated\n\t/// @param precision shares precision\n\tevent PrecisionUpdated(uint256 precision);\n\n\t/// @dev emit when max coefficient updated\n\t/// @param maxCoef max coefficient\n\tevent MaxCoefUpdated(uint256 maxCoef);\n\n\t/// @dev emit when add a pool\n\t/// @param grade pool grade\n\tevent AddPool(Types.Grade grade);\n\n\t/// @dev emit when pool updated\n\t/// @param grade pool grade\n\tevent PoolUpdated(Types.Grade grade);\n\n\t/// @dev return ERC20 token address\n\tfunction token() external view returns(IERC20);\n\n\t/// @dev return `Rewarder` contract address\n\tfunction rewarder() external view returns(IRewarder);\n\n\t/// @dev return precision for shares\n\tfunction ACC_PRECISION() external view returns(uint256);\n\n\t/// @dev return max coefficient\n\tfunction MAXCOEF() external view returns(uint256);\n\n\t/// @dev return total pools allocation points\n\tfunction totalAllocPoint() external view returns(uint256);\n\n\t/// @dev return reward generated for per second\n\tfunction rewardPerSecond() external view returns(uint256);\n\n\t/// @dev update a specific pool\n\t/// @param grade pool grade\n\t/// @return pool pool info\n\tfunction updatePool(Types.Grade grade) external returns (Types.PoolInfo memory pool);\n\n\t/// @dev return a specific pool\n\t/// @param grade pool grade\n\t/// @return pool pool info\n\tfunction poolInfo(Types.Grade grade) external view returns(Types.PoolInfo memory);\n\n}\n"
    },
    "contracts/interfaces/ICandidateRegistry.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport '../libraries/Types.sol';\n\n/// @dev Candidate registry interface\n/// @author Alexandas\ninterface ICandidateRegistry {\n\n\t/// @dev emit when candidate registered\n\t/// @param candidate candidate address\n\tevent Register(address candidate);\n\n\t/// @dev register a candidate with node manifest\n\t/// @param manifest node manifest\n\tfunction register(string memory manifest) external;\n\n\t/// @dev return a candidate\n\t/// @param candidate candidate address\n\t/// @return candidate information\n\tfunction candidateInfo(address candidate) external view returns(Types.CandidateInfo memory);\n\n\t/// @dev return a candidate address for a specific node manifest\n\t/// @param manifest node manifest\n\t/// @return candidate address\n\tfunction manifestMap(string memory manifest) external view returns(address);\n\n\t/// @dev return whether a candidate is registered\n\t/// @param candidate candidate address\n\t/// @return whether the candidate is registered\n\tfunction isCandidateRegistered(address candidate) external view returns (bool);\n\n\t/// @dev return grade of a candidate\n\t/// @param candidate candidate address\n\t/// @return candidate grade\n\tfunction gradeOf(address candidate) external view returns (Types.Grade);\n\n}\n"
    },
    "contracts/interfaces/IRewarder.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol';\nimport './IERC20.sol';\n\n/// @dev Rewarder interface\n/// @author Alexandas\ninterface IRewarder {\n\n\t/// @dev emit when ERC20 token address updated\n\t/// @param token ERC20 token address\n\tevent TokenUpdated(IERC20 token);\n\n\t/// @dev emit when auth address updated\n\t/// @param auth authorized address\n\tevent AuthUpdated(address auth);\n\n\t/// @dev emit when reward minted\n\t/// @param from authorized address\n\t/// @param to receiver address\n\t/// @param amount token amount\n\tevent Minted(address from, address to, uint256 amount);\n\n\t/// @dev return ERC20 token address\n\tfunction token() external view returns(IERC20);\n\n\t/// @dev mint reward to receiver\n\t/// @param to receiver address\n\t/// @param amount token amount\n\tfunction mint(address to, uint256 amount) external;\n\n}"
    },
    "contracts/interfaces/IERC20.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol';\n\n/// @dev Burnable ERC20 Token interface\n/// @author Alexandas\ninterface IERC20 is IERC20Upgradeable {\n\n\t/// @dev burn tokens\n\t/// @param amount token amount\n\tfunction burn(uint256 amount) external;\n\n\t/// @dev burn tokens\n\t/// @param account user address\n\t/// @param amount token amount\n\tfunction burnFrom(address account, uint256 amount) external;\n\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
    },
    "contracts/libraries/Types.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nlibrary Types {\n\n\tenum Grade {\n\t\tNull,\n\t\tMajor,\n\t\tSecondary\n\t}\n\n\tstruct CandidateInfo {\n\t\tGrade grade;\n\t\tuint256 amount;\n\t\tint256 rewardDebt;\n\t\tuint256 allocation;\n\t\tstring manifest;\n\t}\n\n\tstruct PoolInfo {\n\t\tuint256 accPerShare;\n\t\tuint256 lastRewardTime;\n\t\tuint256 allocPoint;\n\t}\n\n\tenum SlashStatus {\n\t\tDrafted,\n\t\tRejected,\n\t\tExecuted\n\t}\n\n\tstruct SlashInfo {\n\t\taddress candidate;\n\t\taddress drafter;\n\t\taddress[] validators;\n\t\tuint256 amount;\n\t\tuint256 timestamp;\n\t\tSlashStatus status;\n\t}\n\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n     * initialization step. This is essential to configure modules that are added through upgrades and that require\n     * initialization.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "contracts/mocks/MockStake.sol": {
      "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.8.0;\n\nimport '../stake/Stake.sol';\n\n/// @dev Test Stake contract\n/// @author Alexandas\ncontract MockStake is Stake {\n\n\tfunction init(\n\t\tIERC20 token,\n\t\tIRewarder rewarder,\n\t\tIElection election,\n\t\tIMajorCandidates majorCandidates,\n\t\tISlasher slasher,\n\t\tuint256 stakeFrozenPeriod,\n\t\tuint256 minStake,\n\t\tuint256 rewardPerSecond\n\t) external {\n\t\t_setToken(token);\n\t\t_setRewarder(rewarder);\n\t\t_setElection(election);\n\t\t_setMajorCandidates(majorCandidates);\n\t\t_setSlasher(slasher);\n\t\t_setStakeFrozenPeriod(stakeFrozenPeriod);\n\t\t_setMinStake(minStake);\n\t\t_setRewardPerSecond(rewardPerSecond);\n\t\t_setMaxCoef(1e6);\n\t\t_setAccPrecision(1e12);\n\t\t_addPool(Types.Grade.Major, 750);\n\t\t_addPool(Types.Grade.Secondary, 250);\n\t}\n\n}"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200,
      "details": {
        "yul": false
      }
    },
    "outputSelection": {
      "*": {
        "*": [
          "storageLayout",
          "abi",
          "evm.bytecode",
          "evm.deployedBytecode",
          "evm.methodIdentifiers",
          "metadata",
          "devdoc",
          "userdoc",
          "evm.gasEstimates"
        ],
        "": [
          "ast"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    }
  }
}