File size: 114,351 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{
  "language": "Solidity",
  "sources": {
    "contracts/tokens/RewardEthToken.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\n\nimport \"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/SafeCastUpgradeable.sol\";\nimport \"../presets/OwnablePausableUpgradeable.sol\";\nimport \"../interfaces/IStakedEthToken.sol\";\nimport \"../interfaces/IRewardEthToken.sol\";\nimport \"../interfaces/IMerkleDistributor.sol\";\nimport \"../interfaces/IOracles.sol\";\nimport \"../interfaces/IFeesEscrow.sol\";\nimport \"./ERC20PermitUpgradeable.sol\";\n\n/**\n * @title RewardEthToken\n *\n * @dev RewardEthToken contract stores pool reward tokens.\n * If deploying contract for the first time, the `initialize` function should replace the `upgrade` function.\n */\ncontract RewardEthToken is IRewardEthToken, OwnablePausableUpgradeable, ERC20PermitUpgradeable {\n    using SafeMathUpgradeable for uint256;\n    using SafeCastUpgradeable for uint256;\n\n    // @dev Address of the StakedEthToken contract.\n    IStakedEthToken private stakedEthToken;\n\n    // @dev Address of the Oracles contract.\n    address private oracles;\n\n    // @dev Maps account address to its reward checkpoint.\n    mapping(address => Checkpoint) public override checkpoints;\n\n    // @dev Address where protocol fee will be paid.\n    address public override protocolFeeRecipient;\n\n    // @dev Protocol percentage fee.\n    uint256 public override protocolFee;\n\n    // @dev Total amount of rewards.\n    uint128 public override totalRewards;\n\n    // @dev Reward per token for user reward calculation.\n    uint128 public override rewardPerToken;\n\n    // @dev Last rewards update block number by oracles.\n    uint256 public override lastUpdateBlockNumber;\n\n    // @dev Address of the MerkleDistributor contract.\n    address public override merkleDistributor;\n\n    // @dev Maps account address to whether rewards are distributed through the merkle distributor.\n    mapping(address => bool) public override rewardsDisabled;\n\n    // @dev Address of the FeesEscrow contract.\n    IFeesEscrow private feesEscrow;\n\n    /**\n     * @dev See {IRewardEthToken-setRewardsDisabled}.\n     */\n    function setRewardsDisabled(address account, bool isDisabled) external override {\n        require(msg.sender == address(stakedEthToken), \"RewardEthToken: access denied\");\n        require(rewardsDisabled[account] != isDisabled, \"RewardEthToken: value did not change\");\n\n        uint128 _rewardPerToken = rewardPerToken;\n        checkpoints[account] = Checkpoint({\n            reward: _balanceOf(account, _rewardPerToken).toUint128(),\n            rewardPerToken: _rewardPerToken\n        });\n\n        rewardsDisabled[account] = isDisabled;\n        emit RewardsToggled(account, isDisabled);\n    }\n\n    /**\n     * @dev See {IRewardEthToken-setProtocolFeeRecipient}.\n     */\n    function setProtocolFeeRecipient(address recipient) external override onlyAdmin {\n        // can be address(0) to distribute fee through the Merkle Distributor\n        protocolFeeRecipient = recipient;\n        emit ProtocolFeeRecipientUpdated(recipient);\n    }\n\n    /**\n     * @dev See {IRewardEthToken-setProtocolFee}.\n     */\n    function setProtocolFee(uint256 _protocolFee) external override onlyAdmin {\n        require(_protocolFee < 1e4, \"RewardEthToken: invalid protocol fee\");\n        protocolFee = _protocolFee;\n        emit ProtocolFeeUpdated(_protocolFee);\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() external view override returns (uint256) {\n        return totalRewards;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) external view override returns (uint256) {\n        return _balanceOf(account, rewardPerToken);\n    }\n\n    function _balanceOf(address account, uint256 _rewardPerToken) internal view returns (uint256) {\n        Checkpoint memory cp = checkpoints[account];\n\n        // skip calculating period reward when it has not changed or when the rewards are disabled\n        if (_rewardPerToken == cp.rewardPerToken || rewardsDisabled[account]) return cp.reward;\n\n        uint256 stakedEthAmount;\n        if (account == address(0)) {\n            // fetch merkle distributor current principal\n            stakedEthAmount = stakedEthToken.distributorPrincipal();\n        } else {\n            stakedEthAmount = stakedEthToken.balanceOf(account);\n        }\n        if (stakedEthAmount == 0) return cp.reward;\n\n        // return checkpoint reward + current reward\n        return _calculateNewReward(cp.reward, stakedEthAmount, _rewardPerToken.sub(cp.rewardPerToken));\n    }\n\n    /**\n     * @dev See {ERC20-_transfer}.\n     */\n    function _transfer(address sender, address recipient, uint256 amount) internal override whenNotPaused {\n        require(sender != address(0), \"RewardEthToken: invalid sender\");\n        require(recipient != address(0), \"RewardEthToken: invalid receiver\");\n        require(block.number > lastUpdateBlockNumber, \"RewardEthToken: cannot transfer during rewards update\");\n\n        uint128 _rewardPerToken = rewardPerToken; // gas savings\n        checkpoints[sender] = Checkpoint({\n            reward: _balanceOf(sender, _rewardPerToken).sub(amount).toUint128(),\n            rewardPerToken: _rewardPerToken\n        });\n        checkpoints[recipient] = Checkpoint({\n            reward: _balanceOf(recipient, _rewardPerToken).add(amount).toUint128(),\n            rewardPerToken: _rewardPerToken\n        });\n\n        emit Transfer(sender, recipient, amount);\n    }\n\n    /**\n     * @dev See {IRewardEthToken-updateRewardCheckpoint}.\n     */\n    function updateRewardCheckpoint(address account) public override returns (bool accRewardsDisabled) {\n        accRewardsDisabled = rewardsDisabled[account];\n        if (!accRewardsDisabled) _updateRewardCheckpoint(account, rewardPerToken);\n    }\n\n    function _updateRewardCheckpoint(address account, uint128 newRewardPerToken) internal {\n        Checkpoint memory cp = checkpoints[account];\n        if (newRewardPerToken == cp.rewardPerToken) return;\n\n        uint256 stakedEthAmount;\n        if (account == address(0)) {\n            // fetch merkle distributor current principal\n            stakedEthAmount = stakedEthToken.distributorPrincipal();\n        } else {\n            stakedEthAmount = stakedEthToken.balanceOf(account);\n        }\n        if (stakedEthAmount == 0) {\n            checkpoints[account] = Checkpoint({\n                reward: cp.reward,\n                rewardPerToken: newRewardPerToken\n            });\n        } else {\n            uint256 periodRewardPerToken = uint256(newRewardPerToken).sub(cp.rewardPerToken);\n            checkpoints[account] = Checkpoint({\n                reward: _calculateNewReward(cp.reward, stakedEthAmount, periodRewardPerToken).toUint128(),\n                rewardPerToken: newRewardPerToken\n            });\n        }\n    }\n\n    function _calculateNewReward(\n        uint256 currentReward,\n        uint256 stakedEthAmount,\n        uint256 periodRewardPerToken\n    )\n        internal pure returns (uint256)\n    {\n        return currentReward.add(stakedEthAmount.mul(periodRewardPerToken).div(1e18));\n    }\n\n    /**\n     * @dev See {IRewardEthToken-updateRewardCheckpoints}.\n     */\n    function updateRewardCheckpoints(address account1, address account2) public override returns (bool rewardsDisabled1, bool rewardsDisabled2) {\n        rewardsDisabled1 = rewardsDisabled[account1];\n        rewardsDisabled2 = rewardsDisabled[account2];\n        if (!rewardsDisabled1 || !rewardsDisabled2) {\n            uint128 newRewardPerToken = rewardPerToken;\n            if (!rewardsDisabled1) _updateRewardCheckpoint(account1, newRewardPerToken);\n            if (!rewardsDisabled2) _updateRewardCheckpoint(account2, newRewardPerToken);\n        }\n    }\n\n    /**\n     * @dev See {IRewardEthToken-updateTotalRewards}.\n     */\n    function updateTotalRewards(uint256 newTotalRewards) external override {\n        require(msg.sender == oracles, \"RewardEthToken: access denied\");\n\n        newTotalRewards = newTotalRewards.add(feesEscrow.transferToPool());\n        uint256 periodRewards = newTotalRewards.sub(totalRewards);\n        if (periodRewards == 0) {\n            lastUpdateBlockNumber = block.number;\n            emit RewardsUpdated(0, newTotalRewards, rewardPerToken, 0, 0);\n            return;\n        }\n\n        // calculate protocol reward and new reward per token amount\n        uint256 protocolReward = periodRewards.mul(protocolFee).div(1e4);\n        uint256 prevRewardPerToken = rewardPerToken;\n        uint256 newRewardPerToken = prevRewardPerToken.add(periodRewards.sub(protocolReward).mul(1e18).div(stakedEthToken.totalDeposits()));\n        uint128 newRewardPerToken128 = newRewardPerToken.toUint128();\n\n        // store previous distributor rewards for period reward calculation\n        uint256 prevDistributorBalance = _balanceOf(address(0), prevRewardPerToken);\n\n        // update total rewards and new reward per token\n        (totalRewards, rewardPerToken) = (newTotalRewards.toUint128(), newRewardPerToken128);\n\n        uint256 newDistributorBalance = _balanceOf(address(0), newRewardPerToken);\n        address _protocolFeeRecipient = protocolFeeRecipient;\n        if (_protocolFeeRecipient == address(0) && protocolReward > 0) {\n            // add protocol reward to the merkle distributor\n            newDistributorBalance = newDistributorBalance.add(protocolReward);\n        } else if (protocolReward > 0) {\n            // update fee recipient's checkpoint and add its period reward\n            checkpoints[_protocolFeeRecipient] = Checkpoint({\n                reward: _balanceOf(_protocolFeeRecipient, newRewardPerToken).add(protocolReward).toUint128(),\n                rewardPerToken: newRewardPerToken128\n            });\n        }\n\n        // update distributor's checkpoint\n        if (newDistributorBalance != prevDistributorBalance) {\n            checkpoints[address(0)] = Checkpoint({\n                reward: newDistributorBalance.toUint128(),\n                rewardPerToken: newRewardPerToken128\n            });\n        }\n\n        lastUpdateBlockNumber = block.number;\n        emit RewardsUpdated(\n            periodRewards,\n            newTotalRewards,\n            newRewardPerToken,\n            newDistributorBalance.sub(prevDistributorBalance),\n            _protocolFeeRecipient == address(0) ? protocolReward: 0\n        );\n    }\n\n    /**\n     * @dev See {IRewardEthToken-claim}.\n     */\n    function claim(address account, uint256 amount) external override {\n        require(msg.sender == merkleDistributor, \"RewardEthToken: access denied\");\n        require(account != address(0), \"RewardEthToken: invalid account\");\n\n        // update checkpoints, transfer amount from distributor to account\n        uint128 _rewardPerToken = rewardPerToken;\n        checkpoints[address(0)] = Checkpoint({\n            reward: _balanceOf(address(0), _rewardPerToken).sub(amount).toUint128(),\n            rewardPerToken: _rewardPerToken\n        });\n        checkpoints[account] = Checkpoint({\n            reward: _balanceOf(account, _rewardPerToken).add(amount).toUint128(),\n            rewardPerToken: _rewardPerToken\n        });\n        emit Transfer(address(0), account, amount);\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMathUpgradeable {\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        uint256 c = a + b;\n        if (c < a) return (false, 0);\n        return (true, c);\n    }\n\n    /**\n     * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b > a) return (false, 0);\n        return (true, a - b);\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\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) return (true, 0);\n        uint256 c = a * b;\n        if (c / a != b) return (false, 0);\n        return (true, c);\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b == 0) return (false, 0);\n        return (true, a / b);\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b == 0) return (false, 0);\n        return (true, a % b);\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, \"SafeMath: addition overflow\");\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b <= a, \"SafeMath: subtraction overflow\");\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (a == 0) return 0;\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting 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(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0, \"SafeMath: division by zero\");\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0, \"SafeMath: modulo by zero\");\n        return a % b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {trySub}.\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b <= a, errorMessage);\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryDiv}.\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(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting with custom message when dividing by zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryMod}.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        return a % b;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/SafeCastUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        require(value < 2**128, \"SafeCast: value doesn\\'t fit in 128 bits\");\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        require(value < 2**64, \"SafeCast: value doesn\\'t fit in 64 bits\");\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        require(value < 2**32, \"SafeCast: value doesn\\'t fit in 32 bits\");\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        require(value < 2**16, \"SafeCast: value doesn\\'t fit in 16 bits\");\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits.\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        require(value < 2**8, \"SafeCast: value doesn\\'t fit in 8 bits\");\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        require(value >= 0, \"SafeCast: value must be positive\");\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt128(int256 value) internal pure returns (int128) {\n        require(value >= -2**127 && value < 2**127, \"SafeCast: value doesn\\'t fit in 128 bits\");\n        return int128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt64(int256 value) internal pure returns (int64) {\n        require(value >= -2**63 && value < 2**63, \"SafeCast: value doesn\\'t fit in 64 bits\");\n        return int64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt32(int256 value) internal pure returns (int32) {\n        require(value >= -2**31 && value < 2**31, \"SafeCast: value doesn\\'t fit in 32 bits\");\n        return int32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt16(int256 value) internal pure returns (int16) {\n        require(value >= -2**15 && value < 2**15, \"SafeCast: value doesn\\'t fit in 16 bits\");\n        return int16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits.\n     *\n     * _Available since v3.1._\n     */\n    function toInt8(int256 value) internal pure returns (int8) {\n        require(value >= -2**7 && value < 2**7, \"SafeCast: value doesn\\'t fit in 8 bits\");\n        return int8(value);\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        require(value < 2**255, \"SafeCast: value doesn't fit in an int256\");\n        return int256(value);\n    }\n}\n"
    },
    "contracts/presets/OwnablePausableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\n\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol\";\nimport \"../interfaces/IOwnablePausable.sol\";\n\n/**\n * @title OwnablePausableUpgradeable\n *\n * @dev Bundles Access Control, Pausable and Upgradeable contracts in one.\n *\n */\nabstract contract OwnablePausableUpgradeable is IOwnablePausable, PausableUpgradeable, AccessControlUpgradeable {\n    bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n    /**\n    * @dev Modifier for checking whether the caller is an admin.\n    */\n    modifier onlyAdmin() {\n        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), \"OwnablePausable: access denied\");\n        _;\n    }\n\n    /**\n    * @dev Modifier for checking whether the caller is a pauser.\n    */\n    modifier onlyPauser() {\n        require(hasRole(PAUSER_ROLE, msg.sender), \"OwnablePausable: access denied\");\n        _;\n    }\n\n    // solhint-disable-next-line func-name-mixedcase\n    function __OwnablePausableUpgradeable_init(address _admin) internal initializer {\n        __Context_init_unchained();\n        __AccessControl_init_unchained();\n        __Pausable_init_unchained();\n        __OwnablePausableUpgradeable_init_unchained(_admin);\n    }\n\n    /**\n     * @dev Grants `DEFAULT_ADMIN_ROLE`, `PAUSER_ROLE` to the admin account.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function __OwnablePausableUpgradeable_init_unchained(address _admin) internal initializer {\n        _setupRole(DEFAULT_ADMIN_ROLE, _admin);\n        _setupRole(PAUSER_ROLE, _admin);\n    }\n\n    /**\n     * @dev See {IOwnablePausable-isAdmin}.\n     */\n    function isAdmin(address _account) external override view returns (bool) {\n        return hasRole(DEFAULT_ADMIN_ROLE, _account);\n    }\n\n    /**\n     * @dev See {IOwnablePausable-addAdmin}.\n     */\n    function addAdmin(address _account) external override {\n        grantRole(DEFAULT_ADMIN_ROLE, _account);\n    }\n\n    /**\n     * @dev See {IOwnablePausable-removeAdmin}.\n     */\n    function removeAdmin(address _account) external override {\n        revokeRole(DEFAULT_ADMIN_ROLE, _account);\n    }\n\n    /**\n     * @dev See {IOwnablePausable-isPauser}.\n     */\n    function isPauser(address _account) external override view returns (bool) {\n        return hasRole(PAUSER_ROLE, _account);\n    }\n\n    /**\n     * @dev See {IOwnablePausable-addPauser}.\n     */\n    function addPauser(address _account) external override {\n        grantRole(PAUSER_ROLE, _account);\n    }\n\n    /**\n     * @dev See {IOwnablePausable-removePauser}.\n     */\n    function removePauser(address _account) external override {\n        revokeRole(PAUSER_ROLE, _account);\n    }\n\n    /**\n     * @dev See {IOwnablePausable-pause}.\n     */\n    function pause() external override onlyPauser {\n        _pause();\n    }\n\n    /**\n     * @dev See {IOwnablePausable-unpause}.\n     */\n    function unpause() external override onlyPauser {\n        _unpause();\n    }\n}\n"
    },
    "contracts/interfaces/IStakedEthToken.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface of the StakedEthToken contract.\n */\ninterface IStakedEthToken is IERC20Upgradeable {\n    /**\n    * @dev Function for retrieving the total deposits amount.\n    */\n    function totalDeposits() external view returns (uint256);\n\n    /**\n    * @dev Function for retrieving the principal amount of the distributor.\n    */\n    function distributorPrincipal() external view returns (uint256);\n\n    /**\n    * @dev Function for toggling rewards for the account.\n    * @param account - address of the account.\n    * @param isDisabled - whether to disable account's rewards distribution.\n    */\n    function toggleRewards(address account, bool isDisabled) external;\n\n    /**\n    * @dev Function for creating `amount` tokens and assigning them to `account`.\n    * Can only be called by Pool contract.\n    * @param account - address of the account to assign tokens to.\n    * @param amount - amount of tokens to assign.\n    */\n    function mint(address account, uint256 amount) external;\n}\n"
    },
    "contracts/interfaces/IRewardEthToken.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"./IFeesEscrow.sol\";\n\n/**\n * @dev Interface of the RewardEthToken contract.\n */\ninterface IRewardEthToken is IERC20Upgradeable {\n    /**\n    * @dev Structure for storing information about user reward checkpoint.\n    * @param rewardPerToken - user reward per token.\n    * @param reward - user reward checkpoint.\n    */\n    struct Checkpoint {\n        uint128 reward;\n        uint128 rewardPerToken;\n    }\n\n    /**\n    * @dev Event for tracking updated protocol fee recipient.\n    * @param recipient - address of the new fee recipient.\n    */\n    event ProtocolFeeRecipientUpdated(address recipient);\n\n    /**\n    * @dev Event for tracking updated protocol fee.\n    * @param protocolFee - new protocol fee.\n    */\n    event ProtocolFeeUpdated(uint256 protocolFee);\n\n    /**\n    * @dev Event for tracking whether rewards distribution through merkle distributor is enabled/disabled.\n    * @param account - address of the account.\n    * @param isDisabled - whether rewards distribution is disabled.\n    */\n    event RewardsToggled(address indexed account, bool isDisabled);\n\n    /**\n    * @dev Event for tracking rewards update by oracles.\n    * @param periodRewards - rewards since the last update.\n    * @param totalRewards - total amount of rewards.\n    * @param rewardPerToken - calculated reward per token for account reward calculation.\n    * @param distributorReward - distributor reward.\n    * @param protocolReward - protocol reward.\n    */\n    event RewardsUpdated(\n        uint256 periodRewards,\n        uint256 totalRewards,\n        uint256 rewardPerToken,\n        uint256 distributorReward,\n        uint256 protocolReward\n    );\n\n    /**\n    * @dev Function for getting the address of the merkle distributor.\n    */\n    function merkleDistributor() external view returns (address);\n\n    /**\n    * @dev Function for getting the address of the protocol fee recipient.\n    */\n    function protocolFeeRecipient() external view returns (address);\n\n    /**\n    * @dev Function for changing the protocol fee recipient's address.\n    * @param recipient - new protocol fee recipient's address.\n    */\n    function setProtocolFeeRecipient(address recipient) external;\n\n    /**\n    * @dev Function for getting protocol fee. The percentage fee users pay from their reward for using the pool service.\n    */\n    function protocolFee() external view returns (uint256);\n\n    /**\n    * @dev Function for changing the protocol fee.\n    * @param _protocolFee - new protocol fee. Must be less than 10000 (100.00%).\n    */\n    function setProtocolFee(uint256 _protocolFee) external;\n\n    /**\n    * @dev Function for retrieving the total rewards amount.\n    */\n    function totalRewards() external view returns (uint128);\n\n    /**\n    * @dev Function for retrieving the last total rewards update block number.\n    */\n    function lastUpdateBlockNumber() external view returns (uint256);\n\n    /**\n    * @dev Function for retrieving current reward per token used for account reward calculation.\n    */\n    function rewardPerToken() external view returns (uint128);\n\n    /**\n    * @dev Function for setting whether rewards are disabled for the account.\n    * Can only be called by the `StakedEthToken` contract.\n    * @param account - address of the account to disable rewards for.\n    * @param isDisabled - whether the rewards will be disabled.\n    */\n    function setRewardsDisabled(address account, bool isDisabled) external;\n\n    /**\n    * @dev Function for retrieving account's current checkpoint.\n    * @param account - address of the account to retrieve the checkpoint for.\n    */\n    function checkpoints(address account) external view returns (uint128, uint128);\n\n    /**\n    * @dev Function for checking whether account's reward will be distributed through the merkle distributor.\n    * @param account - address of the account.\n    */\n    function rewardsDisabled(address account) external view returns (bool);\n\n    /**\n    * @dev Function for updating account's reward checkpoint.\n    * @param account - address of the account to update the reward checkpoint for.\n    */\n    function updateRewardCheckpoint(address account) external returns (bool);\n\n    /**\n    * @dev Function for updating reward checkpoints for two accounts simultaneously (for gas savings).\n    * @param account1 - address of the first account to update the reward checkpoint for.\n    * @param account2 - address of the second account to update the reward checkpoint for.\n    */\n    function updateRewardCheckpoints(address account1, address account2) external returns (bool, bool);\n\n    /**\n    * @dev Function for updating validators total rewards.\n    * Can only be called by Oracles contract.\n    * @param newTotalRewards - new total rewards.\n    */\n    function updateTotalRewards(uint256 newTotalRewards) external;\n\n    /**\n    * @dev Function for claiming rETH2 from the merkle distribution.\n    * Can only be called by MerkleDistributor contract.\n    * @param account - address of the account the tokens will be assigned to.\n    * @param amount - amount of tokens to assign to the account.\n    */\n    function claim(address account, uint256 amount) external;\n}\n"
    },
    "contracts/interfaces/IMerkleDistributor.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"./IOracles.sol\";\n\n/**\n * @dev Interface of the MerkleDistributor contract.\n * Allows anyone to claim a token if they exist in a merkle root.\n */\ninterface IMerkleDistributor {\n    /**\n    * @dev Event for tracking merkle root updates.\n    * @param sender - address of the new transaction sender.\n    * @param merkleRoot - new merkle root hash.\n    * @param merkleProofs - link to the merkle proofs.\n    */\n    event MerkleRootUpdated(\n        address indexed sender,\n        bytes32 indexed merkleRoot,\n        string merkleProofs\n    );\n\n    /**\n    * @dev Event for tracking periodic tokens distributions.\n    * @param from - address to transfer the tokens from.\n    * @param token - address of the token.\n    * @param beneficiary - address of the beneficiary, the allocation is added to.\n    * @param amount - amount of tokens to distribute.\n    * @param startBlock - start block of the tokens distribution.\n    * @param endBlock - end block of the tokens distribution.\n    */\n    event PeriodicDistributionAdded(\n        address indexed from,\n        address indexed token,\n        address indexed beneficiary,\n        uint256 amount,\n        uint256 startBlock,\n        uint256 endBlock\n    );\n\n    /**\n    * @dev Event for tracking one time tokens distributions.\n    * @param from - address to transfer the tokens from.\n    * @param origin - predefined origin address to label the distribution.\n    * @param token - address of the token.\n    * @param amount - amount of tokens to distribute.\n    * @param rewardsLink - link to the file where rewards are stored.\n    */\n    event OneTimeDistributionAdded(\n        address indexed from,\n        address indexed origin,\n        address indexed token,\n        uint256 amount,\n        string rewardsLink\n    );\n\n    /**\n    * @dev Event for tracking tokens' claims.\n    * @param account - the address of the user that has claimed the tokens.\n    * @param index - the index of the user that has claimed the tokens.\n    * @param tokens - list of token addresses the user got amounts in.\n    * @param amounts - list of user token amounts.\n    */\n    event Claimed(address indexed account, uint256 index, address[] tokens, uint256[] amounts);\n\n    /**\n    * @dev Function for getting the current merkle root.\n    */\n    function merkleRoot() external view returns (bytes32);\n\n    /**\n    * @dev Function for getting the RewardEthToken contract address.\n    */\n    function rewardEthToken() external view returns (address);\n\n    /**\n    * @dev Function for getting the Oracles contract address.\n    */\n    function oracles() external view returns (IOracles);\n\n    /**\n    * @dev Function for retrieving the last total merkle root update block number.\n    */\n    function lastUpdateBlockNumber() external view returns (uint256);\n\n    /**\n    * @dev Function for upgrading the MerkleDistributor contract. The `initialize` function must be defined\n    * if deploying contract for the first time that will initialize the state variables above.\n    * @param _oracles - address of the Oracles contract.\n    */\n    function upgrade(address _oracles) external;\n\n    /**\n    * @dev Function for checking the claimed bit map.\n    * @param _merkleRoot - the merkle root hash.\n    * @param _wordIndex - the word index of te bit map.\n    */\n    function claimedBitMap(bytes32 _merkleRoot, uint256 _wordIndex) external view returns (uint256);\n\n    /**\n    * @dev Function for changing the merkle root. Can only be called by `Oracles` contract.\n    * @param newMerkleRoot - new merkle root hash.\n    * @param merkleProofs - URL to the merkle proofs.\n    */\n    function setMerkleRoot(bytes32 newMerkleRoot, string calldata merkleProofs) external;\n\n    /**\n    * @dev Function for distributing tokens periodically for the number of blocks.\n    * @param from - address of the account to transfer the tokens from.\n    * @param token - address of the token.\n    * @param beneficiary - address of the beneficiary.\n    * @param amount - amount of tokens to distribute.\n    * @param durationInBlocks - duration in blocks when the token distribution should be stopped.\n    */\n    function distributePeriodically(\n        address from,\n        address token,\n        address beneficiary,\n        uint256 amount,\n        uint256 durationInBlocks\n    ) external;\n\n    /**\n    * @dev Function for distributing tokens one time.\n    * @param from - address of the account to transfer the tokens from.\n    * @param origin - predefined origin address to label the distribution.\n    * @param token - address of the token.\n    * @param amount - amount of tokens to distribute.\n    * @param rewardsLink - link to the file where rewards for the accounts are stored.\n    */\n    function distributeOneTime(\n        address from,\n        address origin,\n        address token,\n        uint256 amount,\n        string calldata rewardsLink\n    ) external;\n\n    /**\n    * @dev Function for checking whether the tokens were already claimed.\n    * @param index - the index of the user that is part of the merkle root.\n    */\n    function isClaimed(uint256 index) external view returns (bool);\n\n    /**\n    * @dev Function for claiming the given amount of tokens to the account address.\n    * Reverts if the inputs are invalid or the oracles are currently updating the merkle root.\n    * @param index - the index of the user that is part of the merkle root.\n    * @param account - the address of the user that is part of the merkle root.\n    * @param tokens - list of the token addresses.\n    * @param amounts - list of token amounts.\n    * @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.\n    */\n    function claim(\n        uint256 index,\n        address account,\n        address[] calldata tokens,\n        uint256[] calldata amounts,\n        bytes32[] calldata merkleProof\n    ) external;\n}\n"
    },
    "contracts/interfaces/IOracles.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\n\nimport \"./IPoolValidators.sol\";\npragma abicoder v2;\n\n/**\n * @dev Interface of the Oracles contract.\n */\ninterface IOracles {\n    /**\n    * @dev Event for tracking oracle rewards votes.\n    * @param sender - address of the transaction sender.\n    * @param oracle - address of the account which submitted vote.\n    * @param nonce - current nonce.\n    * @param totalRewards - submitted value of total rewards.\n    * @param activatedValidators - submitted amount of activated validators.\n    */\n    event RewardsVoteSubmitted(\n        address indexed sender,\n        address indexed oracle,\n        uint256 nonce,\n        uint256 totalRewards,\n        uint256 activatedValidators\n    );\n\n    /**\n    * @dev Event for tracking oracle merkle root votes.\n    * @param sender - address of the transaction sender.\n    * @param oracle - address of the account which submitted vote.\n    * @param nonce - current nonce.\n    * @param merkleRoot - new merkle root.\n    * @param merkleProofs - link to the merkle proofs.\n    */\n    event MerkleRootVoteSubmitted(\n        address indexed sender,\n        address indexed oracle,\n        uint256 nonce,\n        bytes32 indexed merkleRoot,\n        string merkleProofs\n    );\n\n    /**\n    * @dev Event for tracking validators registration vote.\n    * @param sender - address of the transaction sender.\n    * @param oracles - addresses of the signed oracles.\n    * @param nonce - validators registration nonce.\n    */\n    event RegisterValidatorsVoteSubmitted(\n        address indexed sender,\n        address[] oracles,\n        uint256 nonce\n    );\n\n    /**\n    * @dev Event for tracking new or updates oracles.\n    * @param oracle - address of new or updated oracle.\n    */\n    event OracleAdded(address indexed oracle);\n\n    /**\n    * @dev Event for tracking removed oracles.\n    * @param oracle - address of removed oracle.\n    */\n    event OracleRemoved(address indexed oracle);\n\n    /**\n    * @dev Function for checking whether an account has an oracle role.\n    * @param account - account to check.\n    */\n    function isOracle(address account) external view returns (bool);\n\n    /**\n    * @dev Function for checking whether the oracles are currently voting for new merkle root.\n    */\n    function isMerkleRootVoting() external view returns (bool);\n\n    /**\n    * @dev Function for retrieving current rewards nonce.\n    */\n    function currentRewardsNonce() external view returns (uint256);\n\n    /**\n    * @dev Function for retrieving current validators nonce.\n    */\n    function currentValidatorsNonce() external view returns (uint256);\n\n    /**\n    * @dev Function for adding an oracle role to the account.\n    * Can only be called by an account with an admin role.\n    * @param account - account to assign an oracle role to.\n    */\n    function addOracle(address account) external;\n\n    /**\n    * @dev Function for removing an oracle role from the account.\n    * Can only be called by an account with an admin role.\n    * @param account - account to remove an oracle role from.\n    */\n    function removeOracle(address account) external;\n\n    /**\n    * @dev Function for submitting oracle vote for total rewards.\n    * The quorum of signatures over the same data is required to submit the new value.\n    * @param totalRewards - voted total rewards.\n    * @param activatedValidators - voted amount of activated validators.\n    * @param signatures - oracles' signatures.\n    */\n    function submitRewards(\n        uint256 totalRewards,\n        uint256 activatedValidators,\n        bytes[] calldata signatures\n    ) external;\n\n    /**\n    * @dev Function for submitting new merkle root.\n    * The quorum of signatures over the same data is required to submit the new value.\n    * @param merkleRoot - hash of the new merkle root.\n    * @param merkleProofs - link to the merkle proofs.\n    * @param signatures - oracles' signatures.\n    */\n    function submitMerkleRoot(\n        bytes32 merkleRoot,\n        string calldata merkleProofs,\n        bytes[] calldata signatures\n    ) external;\n\n    /**\n    * @dev Function for submitting registrations of the new validators.\n    * The quorum of signatures over the same data is required to register.\n    * @param depositData - an array of deposit data to register.\n    * @param merkleProofs - an array of hashes to verify whether the every deposit data is part of the merkle root.\n    * @param validatorsDepositRoot - validators deposit root to protect from malicious operators.\n    * @param signatures - oracles' signatures.\n    */\n    function registerValidators(\n        IPoolValidators.DepositData[] calldata depositData,\n        bytes32[][] calldata merkleProofs,\n        bytes32 validatorsDepositRoot,\n        bytes[] calldata signatures\n    ) external;\n}\n"
    },
    "contracts/interfaces/IFeesEscrow.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\n\n/**\n * @dev Interface of the FeesEscrow contract.\n */\ninterface IFeesEscrow {\n    /**\n    * @dev Event for tracking fees withdrawals to Pool contract.\n    * @param amount - the number of fees.\n    */\n    event FeesTransferred(uint256 amount);\n\n    /**\n    * @dev Function is used to transfer accumulated rewards to Pool contract.\n    * Can only be executed by the RewardEthToken contract.\n    */\n    function transferToPool() external returns (uint256);\n}\n"
    },
    "contracts/tokens/ERC20PermitUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// Adopted from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v3.4.0/contracts/drafts/ERC20PermitUpgradeable.sol\n\npragma solidity 0.7.5;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/drafts/IERC20PermitUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/drafts/EIP712Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/cryptography/ECDSAUpgradeable.sol\";\nimport \"./ERC20Upgradeable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n\n    mapping (address => CountersUpgradeable.Counter) private _nonces;\n\n    // solhint-disable-next-line var-name-mixedcase\n    bytes32 private _PERMIT_TYPEHASH;\n\n    /**\n     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n     *\n     * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function __ERC20Permit_init(string memory name) internal initializer {\n        __EIP712_init_unchained(name, \"1\");\n        __ERC20Permit_init_unchained();\n    }\n\n    // solhint-disable-next-line func-name-mixedcase\n    function __ERC20Permit_init_unchained() internal initializer {\n        _PERMIT_TYPEHASH = keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n    }\n\n    /**\n     * @dev See {IERC20Permit-permit}.\n     */\n    function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override {\n        // solhint-disable-next-line not-rely-on-time\n        require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n        bytes32 structHash = keccak256(\n            abi.encode(\n                _PERMIT_TYPEHASH,\n                owner,\n                spender,\n                value,\n                _nonces[owner].current(),\n                deadline\n            )\n        );\n\n        bytes32 hash = _hashTypedDataV4(structHash);\n\n        address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n        require(signer == owner, \"ERC20Permit: invalid signature\");\n\n        _nonces[owner].increment();\n        _approve(owner, spender, value);\n    }\n\n    /**\n     * @dev See {IERC20Permit-nonces}.\n     */\n    function nonces(address owner) public view override returns (uint256) {\n        return _nonces[owner].current();\n    }\n\n    /**\n     * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n        return _domainSeparatorV4();\n    }\n    uint256[49] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../utils/EnumerableSetUpgradeable.sol\";\nimport \"../utils/AddressUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable {\n    function __AccessControl_init() internal initializer {\n        __Context_init_unchained();\n        __AccessControl_init_unchained();\n    }\n\n    function __AccessControl_init_unchained() internal initializer {\n    }\n    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n    using AddressUpgradeable for address;\n\n    struct RoleData {\n        EnumerableSetUpgradeable.AddressSet members;\n        bytes32 adminRole;\n    }\n\n    mapping (bytes32 => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view returns (bool) {\n        return _roles[role].members.contains(account);\n    }\n\n    /**\n     * @dev Returns the number of accounts that have `role`. Can be used\n     * together with {getRoleMember} to enumerate all bearers of a role.\n     */\n    function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n        return _roles[role].members.length();\n    }\n\n    /**\n     * @dev Returns one of the accounts that have `role`. `index` must be a\n     * value between 0 and {getRoleMemberCount}, non-inclusive.\n     *\n     * Role bearers are not sorted in any particular way, and their ordering may\n     * change at any point.\n     *\n     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n     * you perform all queries on the same block. See the following\n     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n     * for more information.\n     */\n    function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n        return _roles[role].members.at(index);\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view returns (bytes32) {\n        return _roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) public virtual {\n        require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) public virtual {\n        require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) public virtual {\n        require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event. Note that unlike {grantRole}, this function doesn't perform any\n     * checks on the calling account.\n     *\n     * [WARNING]\n     * ====\n     * This function should only be called from the constructor when setting\n     * up the initial roles for the system.\n     *\n     * Using this function in any other way is effectively circumventing the admin\n     * system imposed by {AccessControl}.\n     * ====\n     */\n    function _setupRole(bytes32 role, address account) internal virtual {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n        _roles[role].adminRole = adminRole;\n    }\n\n    function _grantRole(bytes32 role, address account) private {\n        if (_roles[role].members.add(account)) {\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    function _revokeRole(bytes32 role, address account) private {\n        if (_roles[role].members.remove(account)) {\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n    uint256[49] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./ContextUpgradeable.sol\";\nimport \"../proxy/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    function __Pausable_init() internal initializer {\n        __Context_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal initializer {\n        _paused = false;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        require(!paused(), \"Pausable: paused\");\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        require(paused(), \"Pausable: not paused\");\n        _;\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n    uint256[49] private __gap;\n}\n"
    },
    "contracts/interfaces/IOwnablePausable.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\n\n/**\n * @dev Interface of the OwnablePausableUpgradeable and OwnablePausable contracts.\n */\ninterface IOwnablePausable {\n    /**\n    * @dev Function for checking whether an account has an admin role.\n    * @param _account - account to check.\n    */\n    function isAdmin(address _account) external view returns (bool);\n\n    /**\n    * @dev Function for assigning an admin role to the account.\n    * Can only be called by an account with an admin role.\n    * @param _account - account to assign an admin role to.\n    */\n    function addAdmin(address _account) external;\n\n    /**\n    * @dev Function for removing an admin role from the account.\n    * Can only be called by an account with an admin role.\n    * @param _account - account to remove an admin role from.\n    */\n    function removeAdmin(address _account) external;\n\n    /**\n    * @dev Function for checking whether an account has a pauser role.\n    * @param _account - account to check.\n    */\n    function isPauser(address _account) external view returns (bool);\n\n    /**\n    * @dev Function for adding a pauser role to the account.\n    * Can only be called by an account with an admin role.\n    * @param _account - account to assign a pauser role to.\n    */\n    function addPauser(address _account) external;\n\n    /**\n    * @dev Function for removing a pauser role from the account.\n    * Can only be called by an account with an admin role.\n    * @param _account - account to remove a pauser role from.\n    */\n    function removePauser(address _account) external;\n\n    /**\n    * @dev Function for pausing the contract.\n    */\n    function pause() external;\n\n    /**\n    * @dev Function for unpausing the contract.\n    */\n    function unpause() external;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/EnumerableSetUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSetUpgradeable {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping (bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) { // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n            bytes32 lastvalue = set._values[lastIndex];\n\n            // Move the last value to the index where the value to delete is\n            set._values[toDeleteIndex] = lastvalue;\n            // Update the index for the moved value\n            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n   /**\n    * @dev Returns the value stored at position `index` in the set. O(1).\n    *\n    * Note that there are no guarantees on the ordering of values inside the\n    * array, and it may change when more values are added or removed.\n    *\n    * Requirements:\n    *\n    * - `index` must be strictly less than {length}.\n    */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        require(set._values.length > index, \"EnumerableSet: index out of bounds\");\n        return set._values[index];\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n   /**\n    * @dev Returns the value stored at position `index` in the set. O(1).\n    *\n    * Note that there are no guarantees on the ordering of values inside the\n    * array, and it may change when more values are added or removed.\n    *\n    * Requirements:\n    *\n    * - `index` must be strictly less than {length}.\n    */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n   /**\n    * @dev Returns the value stored at position `index` in the set. O(1).\n    *\n    * Note that there are no guarantees on the ordering of values inside the\n    * array, and it may change when more values are added or removed.\n    *\n    * Requirements:\n    *\n    * - `index` must be strictly less than {length}.\n    */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n   /**\n    * @dev Returns the value stored at position `index` in the set. O(1).\n    *\n    * Note that there are no guarantees on the ordering of values inside the\n    * array, and it may change when more values are added or removed.\n    *\n    * Requirements:\n    *\n    * - `index` must be strictly less than {length}.\n    */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\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    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        // solhint-disable-next-line no-inline-assembly\n        assembly { size := extcodesize(account) }\n        return size > 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        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\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(address target, bytes memory data, string memory errorMessage) 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(address target, bytes memory data, uint256 value) 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(address target, bytes memory data, uint256 value, string memory errorMessage) 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        // solhint-disable-next-line avoid-low-level-calls\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(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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\n                // solhint-disable-next-line no-inline-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"
    },
    "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\nimport \"../proxy/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 GSN 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 initializer {\n        __Context_init_unchained();\n    }\n\n    function __Context_init_unchained() internal initializer {\n    }\n    function _msgSender() internal view virtual returns (address payable) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes memory) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity >=0.4.24 <0.8.0;\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 a proxied contract can't have 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 * 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 {UpgradeableProxy-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 */\nabstract contract Initializable {\n\n    /**\n     * @dev Indicates that the contract has been initialized.\n     */\n    bool 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 Modifier to protect an initializer function from being invoked twice.\n     */\n    modifier initializer() {\n        require(_initializing || _isConstructor() || !_initialized, \"Initializable: contract is already initialized\");\n\n        bool isTopLevelCall = !_initializing;\n        if (isTopLevelCall) {\n            _initializing = true;\n            _initialized = true;\n        }\n\n        _;\n\n        if (isTopLevelCall) {\n            _initializing = false;\n        }\n    }\n\n    /// @dev Returns true if and only if the function is running in the constructor\n    function _isConstructor() private view returns (bool) {\n        return !AddressUpgradeable.isContract(address(this));\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\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 `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, 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 `sender` to `recipient` 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(address sender, address recipient, uint256 amount) external returns (bool);\n\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"
    },
    "contracts/interfaces/IPoolValidators.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.7.5;\npragma abicoder v2;\n\n/**\n * @dev Interface of the PoolValidators contract.\n */\ninterface IPoolValidators {\n    /**\n    * @dev Structure for storing operator data.\n    * @param depositDataMerkleRoot - validators deposit data merkle root.\n    * @param committed - defines whether operator has committed its readiness to host validators.\n    */\n    struct Operator {\n        bytes32 depositDataMerkleRoot;\n        bool committed;\n    }\n\n    /**\n    * @dev Structure for passing information about the validator deposit data.\n    * @param operator - address of the operator.\n    * @param withdrawalCredentials - withdrawal credentials used for generating the deposit data.\n    * @param depositDataRoot - hash tree root of the deposit data, generated by the operator.\n    * @param publicKey - BLS public key of the validator, generated by the operator.\n    * @param signature - BLS signature of the validator, generated by the operator.\n    */\n    struct DepositData {\n        address operator;\n        bytes32 withdrawalCredentials;\n        bytes32 depositDataRoot;\n        bytes publicKey;\n        bytes signature;\n    }\n\n    /**\n    * @dev Event for tracking new operators.\n    * @param operator - address of the operator.\n    * @param depositDataMerkleRoot - validators deposit data merkle root.\n    * @param depositDataMerkleProofs - validators deposit data merkle proofs.\n    */\n    event OperatorAdded(\n        address indexed operator,\n        bytes32 indexed depositDataMerkleRoot,\n        string depositDataMerkleProofs\n    );\n\n    /**\n    * @dev Event for tracking operator's commitments.\n    * @param operator - address of the operator that expressed its readiness to host validators.\n    */\n    event OperatorCommitted(address indexed operator);\n\n    /**\n    * @dev Event for tracking operators' removals.\n    * @param sender - address of the transaction sender.\n    * @param operator - address of the operator.\n    */\n    event OperatorRemoved(\n        address indexed sender,\n        address indexed operator\n    );\n\n    /**\n    * @dev Constructor for initializing the PoolValidators contract.\n    * @param _admin - address of the contract admin.\n    * @param _pool - address of the Pool contract.\n    * @param _oracles - address of the Oracles contract.\n    */\n    function initialize(address _admin, address _pool, address _oracles) external;\n\n    /**\n    * @dev Function for retrieving the operator.\n    * @param _operator - address of the operator to retrieve the data for.\n    */\n    function getOperator(address _operator) external view returns (bytes32, bool);\n\n    /**\n    * @dev Function for checking whether validator is registered.\n    * @param validatorId - hash of the validator public key to receive the status for.\n    */\n    function isValidatorRegistered(bytes32 validatorId) external view returns (bool);\n\n    /**\n    * @dev Function for adding new operator.\n    * @param _operator - address of the operator to add or update.\n    * @param depositDataMerkleRoot - validators deposit data merkle root.\n    * @param depositDataMerkleProofs - validators deposit data merkle proofs.\n    */\n    function addOperator(\n        address _operator,\n        bytes32 depositDataMerkleRoot,\n        string calldata depositDataMerkleProofs\n    ) external;\n\n    /**\n    * @dev Function for committing operator. Must be called by the operator address\n    * specified through the `addOperator` function call.\n    */\n    function commitOperator() external;\n\n    /**\n    * @dev Function for removing operator. Can be called either by operator or admin.\n    * @param _operator - address of the operator to remove.\n    */\n    function removeOperator(address _operator) external;\n\n    /**\n    * @dev Function for registering the validator.\n    * @param depositData - deposit data of the validator.\n    * @param merkleProof - an array of hashes to verify whether the deposit data is part of the merkle root.\n    */\n    function registerValidator(DepositData calldata depositData, bytes32[] calldata merkleProof) external;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../math/SafeMathUpgradeable.sol\";\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}\n * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never\n * directly accessed.\n */\nlibrary CountersUpgradeable {\n    using SafeMathUpgradeable for uint256;\n\n    struct Counter {\n        // This variable should never be directly accessed by users of the library: interactions must be restricted to\n        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n        // this feature: see https://github.com/ethereum/solidity/issues/4637\n        uint256 _value; // default: 0\n    }\n\n    function current(Counter storage counter) internal view returns (uint256) {\n        return counter._value;\n    }\n\n    function increment(Counter storage counter) internal {\n        // The {SafeMath} overflow check can be skipped here, see the comment at the top\n        counter._value += 1;\n    }\n\n    function decrement(Counter storage counter) internal {\n        counter._value = counter._value.sub(1);\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/drafts/IERC20PermitUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens,\n     * given `owner`'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/drafts/EIP712Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\nimport \"../proxy/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712Upgradeable is Initializable {\n    /* solhint-disable var-name-mixedcase */\n    bytes32 private _HASHED_NAME;\n    bytes32 private _HASHED_VERSION;\n    bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n    /* solhint-enable var-name-mixedcase */\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    function __EIP712_init(string memory name, string memory version) internal initializer {\n        __EIP712_init_unchained(name, version);\n    }\n\n    function __EIP712_init_unchained(string memory name, string memory version) internal initializer {\n        bytes32 hashedName = keccak256(bytes(name));\n        bytes32 hashedVersion = keccak256(bytes(version));\n        _HASHED_NAME = hashedName;\n        _HASHED_VERSION = hashedVersion;\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view returns (bytes32) {\n        return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n    }\n\n    function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {\n        return keccak256(\n            abi.encode(\n                typeHash,\n                name,\n                version,\n                _getChainId(),\n                address(this)\n            )\n        );\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x01\", _domainSeparatorV4(), structHash));\n    }\n\n    function _getChainId() private view returns (uint256 chainId) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            chainId := chainid()\n        }\n    }\n\n    /**\n     * @dev The hash of the name parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712NameHash() internal virtual view returns (bytes32) {\n        return _HASHED_NAME;\n    }\n\n    /**\n     * @dev The hash of the version parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712VersionHash() internal virtual view returns (bytes32) {\n        return _HASHED_VERSION;\n    }\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/cryptography/ECDSAUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        // Check the signature length\n        if (signature.length != 65) {\n            revert(\"ECDSA: invalid signature length\");\n        }\n\n        // Divide the signature in r, s and v variables\n        bytes32 r;\n        bytes32 s;\n        uint8 v;\n\n        // ecrecover takes the signature parameters, and the only way to get them\n        // currently is to use assembly.\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            r := mload(add(signature, 0x20))\n            s := mload(add(signature, 0x40))\n            v := byte(0, mload(add(signature, 0x60)))\n        }\n\n        return recover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, \"ECDSA: invalid signature 's' value\");\n        require(v == 27 || v == 28, \"ECDSA: invalid signature 'v' value\");\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        require(signer != address(0), \"ECDSA: invalid signature\");\n\n        return signer;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * replicates the behavior of the\n     * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]\n     * JSON-RPC method.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n    }\n}\n"
    },
    "contracts/tokens/ERC20Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// Adopted from https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v3.4.0/contracts/token/ERC20/ERC20Upgradeable.sol\n\npragma solidity 0.7.5;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\n\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\nabstract contract ERC20Upgradeable is Initializable, IERC20Upgradeable {\n    using SafeMathUpgradeable for uint256;\n\n    mapping (address => mapping (address => uint256)) private _allowances;\n\n    string private _name;\n    string private _symbol;\n    uint8 private _decimals;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\n     * a default value of 18.\n     *\n     * To select a different value for {decimals}, use {_setupDecimals}.\n     *\n     * All three of these values are immutable: they can only be set once during\n     * construction.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function __ERC20_init(string memory name_, string memory symbol_) internal initializer {\n        __ERC20_init_unchained(name_, symbol_);\n    }\n\n    // solhint-disable-next-line func-name-mixedcase\n    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {\n        _name = name_;\n        _symbol = symbol_;\n        _decimals = 18;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\n     * called.\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual returns (uint8) {\n        return _decimals;\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `recipient` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(msg.sender, recipient, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        _approve(msg.sender, spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * Requirements:\n     *\n     * - `sender` and `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``sender``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(sender, recipient, amount);\n\n        uint256 currentAllowance = _allowances[sender][msg.sender];\n        if (sender != msg.sender && currentAllowance != uint256(-1)) {\n            _approve(sender, msg.sender, currentAllowance.sub(amount));\n        }\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));\n        return true;\n    }\n\n    /**\n     * @dev Moves tokens `amount` from `sender` to `recipient`.\n     *\n     * This is internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `sender` cannot be the zero address.\n     * - `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     */\n    function _transfer(address sender, address recipient, uint256 amount) internal virtual;\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(address owner, address spender, uint256 amount) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    uint256[44] private __gap;\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 5000000
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "libraries": {}
  }
}