File size: 53,717 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
{
  "language": "Solidity",
  "sources": {
    "/contracts/Crowdsale.sol": {
      "content": "pragma solidity ^0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/EnumerableSet.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\n\nimport \"./libraries/TransferHelper.sol\";\n\nimport \"./interfaces/IUniswapV2Pair.sol\";\nimport \"./interfaces/IVesting.sol\";\nimport \"./interfaces/IERC20.sol\";\n\ncontract CrowdSale is Context, Ownable, ReentrancyGuard {\n    using SafeMath for uint256;\n    using Address for address;\n    using EnumerableSet for EnumerableSet.AddressSet;\n\n    struct StableCoinLP {\n        IUniswapV2Pair pair;\n        uint256 tokenIndex;\n        uint256 decimals;\n    }\n\n    struct PresaleInfo {\n        uint256 tokenPrice;\n        uint256 maxSpendPerBuyer;\n        uint256 amount;\n        uint256 hardcap;\n        uint256 softcap;\n        uint256 startBlock;\n        uint256 endBlock;\n        IERC20 token;\n        IERC20[] baseToken;\n        bool withETH;\n    }\n\n    struct PresaleStatus {\n        bool whitelistOnly;\n        bool forceFailed;\n        bool paused;\n        bool vested;\n        uint256 lockID;\n        mapping(address => uint256) totalBaseCollected;\n        uint256 totalETHCollected;\n        uint256 totalETHValueCollected;\n        uint256 totalETHWithdrawn;\n        mapping(address => uint256) totalBaseWithdrawn;\n        uint256 totalTokensSold;\n        uint256 numBuyers;\n    }\n\n    struct BuyerInfo {\n        mapping(address => uint256) baseDeposited;\n        uint256 ethDeposited;\n        uint256 depositedValue;\n        uint256 tokensOwed;\n        uint256 withdrawAmount;\n    }\n\n    PresaleInfo public INFO;\n    PresaleStatus public STATUS;\n    IVesting public VESTING;\n    mapping(address => BuyerInfo) public BUYERS;\n    EnumerableSet.AddressSet private WHITELIST;\n    EnumerableSet.AddressSet private BASE_TOKENS;\n    address[] public stableCoins;\n    uint256 public PRICE_DECIMALS = 6;\n    mapping (address => StableCoinLP) private stableCoinsLPs;\n\n    event Deposit(address indexed user, uint256 amount, address baseToken);\n\n    constructor() public {\n        // WETH-USDC LP\n        stableCoins.push(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);\n        IUniswapV2Pair USDC_WETH_Pair = IUniswapV2Pair(0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc);\n        uint tokenIndex0 = USDC_WETH_Pair.token0() == stableCoins[0] ? 0 : 1;\n        stableCoinsLPs[stableCoins[0]] = StableCoinLP(USDC_WETH_Pair, tokenIndex0, 6);\n        // WETH-DAI LP\n        stableCoins.push(0x6B175474E89094C44Da98b954EedeAC495271d0F);\n        IUniswapV2Pair WETH_DAI_Pair = IUniswapV2Pair(0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11);\n        uint tokenIndex1 = WETH_DAI_Pair.token0() == stableCoins[1] ? 0 : 1;\n        stableCoinsLPs[stableCoins[1]] = StableCoinLP(WETH_DAI_Pair, tokenIndex1, 18);\n        // WETH-USDT LP\n        stableCoins.push(0xdAC17F958D2ee523a2206206994597C13D831ec7);\n        IUniswapV2Pair WETH_USDT_Pair = IUniswapV2Pair(0x0d4a11d5EEaaC28EC3F61d100daF4d40471f1852);\n        uint tokenIndex2 = WETH_USDT_Pair.token0() == stableCoins[2] ? 0 : 1;\n        stableCoinsLPs[stableCoins[2]] = StableCoinLP(WETH_USDT_Pair, tokenIndex2, 6);\n    }\n\n    function getETHPrice() public view returns (uint256 price) {\n        for(uint i = 0; i < stableCoins.length; i++) {\n            StableCoinLP memory lp = stableCoinsLPs[stableCoins[i]];\n            (uint112 reserve0, uint112 reserve1,) = lp.pair.getReserves();\n            uint256 _price;\n            if(reserve0 == 0 || reserve1 == 0) {\n                _price = 0;\n            } else {\n                uint256 decimalsDifferences = 18 - lp.decimals;\n                if(lp.tokenIndex == 0) {\n                    _price = uint256(reserve0).mul(10**(18 + decimalsDifferences)).div(uint256(reserve1));\n                } else {\n                    _price = uint256(reserve1).mul(10**(18 + decimalsDifferences)).div(uint256(reserve0));\n                }\n            }\n            price += _price;\n        }\n        price = price / stableCoins.length;\n    }\n\n    function init(\n        address _token,\n        address[] memory _baseToken,\n        uint256 _softcap,\n        uint256 _hardcap,\n        uint256 _price,\n        uint256 _maxSpend,\n        uint256 _startBlock,\n        uint256 _endBlock,\n        uint256 _amount,\n        bool _withETH,\n        uint256 _vesting\n    ) external onlyOwner {\n        for(uint256 i = 0; i < _baseToken.length; i++) {\n            INFO.baseToken.push(IERC20(_baseToken[i]));\n            BASE_TOKENS.add(_baseToken[i]);\n        }\n\n        INFO.token = IERC20(_token);\n        INFO.softcap = _softcap;\n        INFO.hardcap = _hardcap;\n        INFO.tokenPrice = _price;\n        INFO.maxSpendPerBuyer = _maxSpend;\n        INFO.startBlock = _startBlock;\n        INFO.endBlock = _endBlock;\n        INFO.amount = _amount;\n        INFO.withETH = _withETH;\n        VESTING = IVesting(_vesting);\n    }\n\n    function getTotalCollectedValue() public view returns (uint256) {\n        uint256 totalCollected = STATUS.totalETHValueCollected;\n        for(uint256 i = 0; i < INFO.baseToken.length; i++) {\n            address _baseToken = address(INFO.baseToken[i]);\n            totalCollected = totalCollected.add(STATUS.totalBaseCollected[_baseToken]);\n        }\n\n        return totalCollected;\n    }\n\n    function _isValidBaseToken(address baseToken) internal view returns (bool) {\n        return BASE_TOKENS.contains(baseToken);\n    }\n\n    function presaleStatus() public view returns (uint256) {\n        if (STATUS.forceFailed) {\n            return 3; // FAILED - force fail\n        }\n        if(STATUS.paused) {\n            return 4; // PAUSED - Wait for admin resume\n        }\n\n        if(INFO.startBlock == 0) {\n            return 0;\n        }\n        uint256 _totalCollected = getTotalCollectedValue();\n        if ((block.number > INFO.endBlock) && (_totalCollected < INFO.softcap)) {\n            return 3; // FAILED - softcap not met by end block\n        }\n        if (_totalCollected >= INFO.hardcap) {\n            return 2; // SUCCESS - hardcap met\n        }\n        if ((block.number > INFO.endBlock) && (_totalCollected >= INFO.softcap)) {\n            return 2; // SUCCESS - end block and soft cap reached\n        }\n        if ((block.number >= INFO.startBlock) && (block.number <= INFO.endBlock)) {\n            return 1; // ACTIVE - deposits enabled\n        }\n        return 0; // NOT STARTED - awaiting start block\n    }\n\n    function userDeposit (uint256 _amount, address _baseToken) external payable nonReentrant {\n        require(presaleStatus() == 1, 'NOT ACTIVE'); // ACTIVE\n        if (STATUS.whitelistOnly) {\n            require(WHITELIST.contains(_msgSender()), 'NOT WHITELISTED');\n        }\n        bool isETH = _baseToken == address(0);\n        if(isETH) {\n            require(INFO.withETH, \"NOT ALLOWED TO PARTICIPATE WITH ETH\");\n        } else {\n            require(_isValidBaseToken(_baseToken), \"INVALID BASE TOKEN\");\n        }\n\n        uint256 ethPrice = getETHPrice();\n\n        BuyerInfo storage buyer = BUYERS[msg.sender];\n        uint256 amount_in = isETH ? msg.value : _amount;\n        uint256 amountInValue = isETH ? amount_in.mul(ethPrice).div(10 ** 30) : _amount;\n        uint256 allowance = INFO.maxSpendPerBuyer.sub(buyer.depositedValue);\n        uint256 _totalCollected = getTotalCollectedValue();\n        uint256 remaining = INFO.hardcap.sub(_totalCollected);\n        allowance = allowance > remaining ? remaining : allowance;\n        if (amountInValue > allowance) {\n            amountInValue = allowance;\n            amount_in = isETH ? allowance.mul(10**30).div(ethPrice) : allowance;\n        }\n        uint256 tokensSold = amountInValue.mul(10 ** PRICE_DECIMALS).div(INFO.tokenPrice).mul(10 ** 12);\n\n        require(tokensSold > 0, 'ZERO TOKENS');\n        if (buyer.depositedValue == 0) {\n            STATUS.numBuyers++;\n        }\n        if(isETH) {\n            buyer.ethDeposited = buyer.ethDeposited.add(amount_in);\n            buyer.depositedValue = buyer.depositedValue.add(amountInValue);\n            STATUS.totalETHCollected = STATUS.totalETHCollected.add(amount_in);\n            STATUS.totalETHValueCollected = STATUS.totalETHValueCollected.add(amountInValue);\n\n        } else {\n            buyer.baseDeposited[_baseToken] = buyer.baseDeposited[_baseToken].add(amount_in);\n            buyer.depositedValue = buyer.depositedValue.add(amount_in);\n            STATUS.totalBaseCollected[_baseToken] = STATUS.totalBaseCollected[_baseToken].add(amount_in);\n        }\n        buyer.tokensOwed = buyer.tokensOwed.add(tokensSold);\n        STATUS.totalTokensSold = STATUS.totalTokensSold.add(tokensSold);\n\n        // return unused ETH\n        if (isETH && amount_in < msg.value) {\n            msg.sender.transfer(msg.value.sub(amount_in));\n        }\n        // deduct non ETH token from user\n        if (!isETH) {\n            TransferHelper.safeTransferFrom(_baseToken, msg.sender, address(this), amount_in);\n        }\n\n        emit Deposit(msg.sender, amount_in, _baseToken);\n    }\n\n    function getUserWithdrawable(address _user) public view returns (uint256) {\n        if(!STATUS.vested) {\n            return 0;\n        }\n\n        (,,, uint256 tokensWithdrawn,,,,,,) = VESTING.getLock(STATUS.lockID);\n\n        uint256 withdrawable = VESTING.getWithdrawableTokens(STATUS.lockID);\n        if(withdrawable == 0) {\n            return 0;\n        }\n\n        uint256 userWithdrawable = tokensWithdrawn\n            .add(withdrawable)\n            .mul(BUYERS[_user].tokensOwed)\n            .div(STATUS.totalTokensSold)\n            .sub(BUYERS[_user].withdrawAmount);\n\n        return userWithdrawable;\n\n    }\n\n    function userWithdrawAMFI() external nonReentrant {\n        require(presaleStatus() == 2, 'NOT SUCCESS');\n        require(STATUS.vested, \"NOT FINALIZED\");\n\n        uint256 withdrawableAmount = getUserWithdrawable(_msgSender());\n        require(withdrawableAmount > 0, \"ZERO TOKEN\");\n\n        BuyerInfo storage buyer = BUYERS[_msgSender()];\n\n        uint256 beforeBalance = INFO.token.balanceOf(address(this));\n        VESTING.withdraw(STATUS.lockID, withdrawableAmount);\n        uint256 amount = INFO.token.balanceOf(address(this)) - beforeBalance;\n\n        buyer.withdrawAmount = buyer.withdrawAmount.add(amount);\n\n        TransferHelper.safeTransfer(address(INFO.token), _msgSender(), amount);\n    }\n\n    function userWithdrawBaseTokens () external nonReentrant {\n        require(presaleStatus() == 3, 'NOT FAILED'); // FAILED\n        BuyerInfo storage buyer = BUYERS[msg.sender];\n        for(uint256 i = 0; i < INFO.baseToken.length; i++) {\n            address _baseToken = address(INFO.baseToken[i]);\n\n            uint256 baseRemainingDenominator = STATUS.totalBaseCollected[_baseToken];\n            uint256 remainingBaseBalance = INFO.baseToken[i].balanceOf(address(this));\n            uint256 tokensOwed = remainingBaseBalance.mul(buyer.baseDeposited[_baseToken]).div(baseRemainingDenominator);\n            if(tokensOwed > 0) {\n                STATUS.totalBaseWithdrawn[_baseToken] = STATUS.totalBaseWithdrawn[_baseToken].add(buyer.baseDeposited[_baseToken]);\n                buyer.baseDeposited[_baseToken] = 0;\n                TransferHelper.safeTransferBaseToken(_baseToken, msg.sender, tokensOwed, true);\n            }\n        }\n    }\n\n    function userWithdrawETHTokens() external nonReentrant {\n        require(presaleStatus() == 3, 'NOT FAILED'); // FAILED\n        BuyerInfo storage buyer = BUYERS[msg.sender];\n        uint256 baseRemainingDenominator = STATUS.totalETHCollected;\n        uint256 remainingBaseBalance = INFO.withETH ? address(this).balance : 0;\n        uint256 tokensOwed = remainingBaseBalance.mul(buyer.ethDeposited).div(baseRemainingDenominator);\n        if(tokensOwed > 0) {\n            STATUS.totalETHWithdrawn = STATUS.totalETHWithdrawn.add(buyer.ethDeposited);\n            buyer.ethDeposited = 0;\n            TransferHelper.safeTransferBaseToken(address(0), msg.sender, tokensOwed, false);\n        }\n\n    }\n\n    function ownerWithdrawTokens() external onlyOwner {\n        require(presaleStatus() == 3, \"NOT FAILED\"); // FAILED\n        TransferHelper.safeTransfer(address(INFO.token), owner(), INFO.token.balanceOf(address(this)));\n    }\n\n    function finalizedCrowdSale(uint256 cliffEndEmission, uint256 endEmission) external onlyOwner {\n        require(presaleStatus() == 2, 'NOT SUCCESS'); // SUCCESS\n        require(!STATUS.vested, \"FINALIZED ALREADY\");\n        require(cliffEndEmission < endEmission, \"INVALID LOCK END DATE\");\n        require(block.timestamp < cliffEndEmission, \"INVALID CLIFF END DATE\");\n\n        TransferHelper.safeApprove(address(INFO.token), address(VESTING), STATUS.totalTokensSold);\n\n        VESTING.lockCrowdsale(\n            address(this),\n            STATUS.totalTokensSold,\n            block.timestamp,\n            block.timestamp + cliffEndEmission,\n            block.timestamp + endEmission\n        );\n\n        STATUS.lockID = VESTING.getUserLockIDAtIndex(address(this), 0);\n        STATUS.vested = true;\n    }\n\n    function forceFail() external onlyOwner {\n        STATUS.forceFailed = true;\n    }\n\n    function togglePause() external onlyOwner {\n        STATUS.paused = !STATUS.paused;\n    }\n\n    function updateMaxSpendLimit(uint256 _maxSpend) external onlyOwner {\n        INFO.maxSpendPerBuyer = _maxSpend;\n    }\n\n    function updateBlocks(uint256 _startBlock, uint256 _endBlock) external onlyOwner {\n        require(INFO.startBlock > block.number, \"ALREADY STARTED\");\n        require(_endBlock.sub(_startBlock) > 0, \"INVALID BLOCKS\");\n        INFO.startBlock = _startBlock;\n        INFO.endBlock = _endBlock;\n    }\n\n    function setWhitelistFlag(bool _flag) external onlyOwner {\n        STATUS.whitelistOnly = _flag;\n    }\n\n    function editWhitelist(address[] memory _users, bool _add) external onlyOwner {\n        if (_add) {\n            for (uint i = 0; i < _users.length; i++) {\n                WHITELIST.add(_users[i]);\n            }\n        } else {\n            for (uint i = 0; i < _users.length; i++) {\n                WHITELIST.remove(_users[i]);\n            }\n        }\n    }\n\n    function getWhitelistedUsersLength () external view returns (uint256) {\n        return WHITELIST.length();\n    }\n\n    function getWhitelistedUserAtIndex (uint256 _index) external view returns (address) {\n        return WHITELIST.at(_index);\n    }\n\n    function getUserWhitelistStatus (address _user) external view returns (bool) {\n        return WHITELIST.contains(_user);\n    }\n}\n"
    },
    "/contracts/libraries/TransferHelper.sol": {
      "content": "pragma solidity 0.6.12;\n\n/**\n    helper methods for interacting with ERC20 tokens that do not consistently return true/false\n    with the addition of a transfer function to send eth or an erc20 token\n*/\nlibrary TransferHelper {\n    function safeApprove(address token, address to, uint value) internal {\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');\n    }\n\n    function safeTransfer(address token, address to, uint value) internal {\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED');\n    }\n\n    function safeTransferFrom(address token, address from, address to, uint value) internal {\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');\n    }\n\n    // sends ETH or an erc20 token\n    function safeTransferBaseToken(address token, address payable to, uint value, bool isERC20) internal {\n        if (!isERC20) {\n            to.transfer(value);\n        } else {\n            (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));\n            require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED');\n        }\n    }\n}\n"
    },
    "/contracts/interfaces/IVesting.sol": {
      "content": "pragma solidity ^0.6.12;\npragma experimental ABIEncoderV2;\n\ninterface IVesting {\n    struct LockParams {\n        address owner;\n        uint256 amount;\n        uint256 startEmission;\n        uint256 cliffEndEmission;\n        uint256 endEmission;\n    }\n\n    function getLock (uint256 _lockID) external view returns (uint256, address, uint256, uint256, uint256, uint256, uint256, uint256, uint256, address);\n    function convertSharesToTokens (uint256 _shares) external view returns (uint256);\n    function convertTokensToShares (uint256 _tokens) external view returns (uint256);\n    function getTokenLocksLength () external view returns (uint256);\n    function getTokenLockIDAtIndex (uint256 _index) external view returns (uint256);\n    function getUserLocksLength (address _user) external view returns (uint256);\n    function getUserLockIDAtIndex (address _user, uint256 _index) external view returns (uint256);\n    function getWithdrawableTokens (uint256 _lockID) external view returns (uint256);\n    function getWithdrawableShares (uint256 _lockID) external view returns (uint256);\n    function transferLockOwnership (uint256 _lockID, address payable _newOwner) external;\n    function lockCrowdsale (address owner, uint256 amount, uint256 startEmission, uint256 cliffEndEmission, uint256 endEmission) external;\n    function withdraw (uint256 _lockID, uint256 _amount) external;\n\n}\n"
    },
    "/contracts/interfaces/IUniswapV2Pair.sol": {
      "content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n    event Approval(address indexed owner, address indexed spender, uint value);\n    event Transfer(address indexed from, address indexed to, uint value);\n\n    function name() external pure returns (string memory);\n    function symbol() external pure returns (string memory);\n    function decimals() external pure returns (uint8);\n    function totalSupply() external view returns (uint);\n    function balanceOf(address owner) external view returns (uint);\n    function allowance(address owner, address spender) external view returns (uint);\n\n    function approve(address spender, uint value) external returns (bool);\n    function transfer(address to, uint value) external returns (bool);\n    function transferFrom(address from, address to, uint value) external returns (bool);\n\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n    function PERMIT_TYPEHASH() external pure returns (bytes32);\n    function nonces(address owner) external view returns (uint);\n\n    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n    event Mint(address indexed sender, uint amount0, uint amount1);\n    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n    event Swap(\n        address indexed sender,\n        uint amount0In,\n        uint amount1In,\n        uint amount0Out,\n        uint amount1Out,\n        address indexed to\n    );\n    event Sync(uint112 reserve0, uint112 reserve1);\n\n    function MINIMUM_LIQUIDITY() external pure returns (uint);\n    function factory() external view returns (address);\n    function token0() external view returns (address);\n    function token1() external view returns (address);\n    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n    function price0CumulativeLast() external view returns (uint);\n    function price1CumulativeLast() external view returns (uint);\n    function kLast() external view returns (uint);\n\n    function mint(address to) external returns (uint liquidity);\n    function burn(address to) external returns (uint amount0, uint amount1);\n    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n    function skim(address to) external;\n    function sync() external;\n\n    function initialize(address, address) external;\n}\n"
    },
    "/contracts/interfaces/IERC20.sol": {
      "content": "pragma solidity 0.6.12;\n\ninterface IERC20 {\n    event Approval(address indexed owner, address indexed spender, uint value);\n    event Transfer(address indexed from, address indexed to, uint value);\n\n    function decimals() external view returns (uint8);\n    function totalSupply() external view returns (uint);\n    function balanceOf(address owner) external view returns (uint);\n    function allowance(address owner, address spender) external view returns (uint);\n\n    function approve(address spender, uint value) external returns (bool);\n    function transfer(address to, uint value) external returns (bool);\n    function transferFrom(address from, address to, uint value) external returns (bool);\n}\n"
    },
    "@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    constructor () internal {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and make it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        // On the first call to nonReentrant, _notEntered will be true\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n\n        _;\n\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/EnumerableSet.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 EnumerableSet {\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/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\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 Context {\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}\n"
    },
    "@openzeppelin/contracts/utils/Address.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 Address {\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    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.delegatecall(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/math/SafeMath.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 SafeMath {\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/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../utils/Context.sol\";\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor () internal {\n        address msgSender = _msgSender();\n        _owner = msgSender;\n        emit OwnershipTransferred(address(0), msgSender);\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        emit OwnershipTransferred(_owner, address(0));\n        _owner = address(0);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n}\n"
    }
  },
  "settings": {
    "remappings": [],
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "evmVersion": "istanbul",
    "libraries": {},
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    }
  }
}