File size: 59,417 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
{
  "language": "Solidity",
  "sources": {
    "contracts/presale-pool/PreSaleFactory.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.7.1;\n\nimport \"../interfaces/IPool.sol\";\nimport \"./PreSalePool.sol\";\nimport \"../libraries/Ownable.sol\";\nimport \"../libraries/Pausable.sol\";\nimport \"../libraries/Initializable.sol\";\n\ncontract PreSaleFactory is Ownable, Pausable, Initializable {\n    // Array of created Pools Address\n    address[] public allPools;\n    // Mapping from User token. From tokens to array of created Pools for token\n    mapping(address => mapping(address => address[])) public getPools;\n\n    event PresalePoolCreated(\n        address registedBy,\n        address indexed token,\n        address indexed pool,\n        uint256 poolId\n    );\n\n    function initialize() external initializer {\n        paused = false;\n        owner = msg.sender;\n    }\n\n    /**\n     * @notice Get the number of all created pools\n     * @return Return number of created pools\n     */\n    function allPoolsLength() public view returns (uint256) {\n        return allPools.length;\n    }\n\n    /**\n     * @notice Get the created pools by token address\n     * @dev User can retrieve their created pool by address of tokens\n     * @param _creator Address of created pool user\n     * @param _token Address of token want to query\n     * @return Created PreSalePool Address\n     */\n    function getCreatedPoolsByToken(address _creator, address _token)\n        public\n        view\n        returns (address[] memory)\n    {\n        return getPools[_creator][_token];\n    }\n\n    /**\n     * @notice Retrieve number of pools created for specific token\n     * @param _creator Address of created pool user\n     * @param _token Address of token want to query\n     * @return Return number of created pool\n     */\n    function getCreatedPoolsLengthByToken(address _creator, address _token)\n        public\n        view\n        returns (uint256)\n    {\n        return getPools[_creator][_token].length;\n    }\n\n    /**\n     * @notice Register ICO PreSalePool for tokens\n     * @dev To register, you MUST have an ERC20 token\n     * @param _token address of ERC20 token\n     * @param _offeredCurrency Address of offered token\n     * @param _offeredCurrencyDecimals Decimals of offered token\n     * @param _offeredRate Conversion rate for buy token. tokens = value * rate\n     * @param _wallet Address of funding ICO wallets. Sold tokens in eth will transfer to this address\n     * @param _signer Address of funding ICO wallets. Sold tokens in eth will transfer to this address\n     */\n    function registerPool(\n        address _token,\n        address _offeredCurrency,\n        uint256 _offeredCurrencyDecimals,\n        uint256 _offeredRate,\n        address _wallet,\n        address _signer\n    ) external whenNotPaused returns (address pool) {\n        require(_token != address(0), \"ICOFactory::ZERO_ADDRESS\");\n        require(_wallet != address(0), \"ICOFactory::ZERO_ADDRESS\");\n        require(_offeredRate != 0, \"ICOFactory::ZERO_OFFERED_RATE\");\n        bytes memory bytecode = type(PreSalePool).creationCode;\n        uint256 tokenIndex = getCreatedPoolsLengthByToken(msg.sender, _token);\n        bytes32 salt =\n            keccak256(abi.encodePacked(msg.sender, _token, tokenIndex));\n        assembly {\n            pool := create2(0, add(bytecode, 32), mload(bytecode), salt)\n        }\n        IPool(pool).initialize(\n            _token,\n            _offeredCurrency,\n            _offeredRate,\n            _offeredCurrencyDecimals,\n            _wallet,\n            _signer\n        );\n        getPools[msg.sender][_token].push(pool);\n        allPools.push(pool);\n\n        emit PresalePoolCreated(msg.sender, _token, pool, allPools.length - 1);\n    }\n}\n"
    },
    "contracts/interfaces/IPool.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.1;\n\ninterface IPool {\n    // normal pool\n    function initialize(\n        address _token,\n        uint256 _duration,\n        uint256 _openTime,\n        address _offeredCurrency,\n        uint256 _offeredCurrencyDecimals,\n        uint256 _offeredRate,\n        address _walletAddress,\n        address _signer\n    ) external;\n\n    // pre-sale pool\n    function initialize(\n        address _token,\n        address _offeredCurrency,\n        uint256 _offeredRate,\n        uint256 _offeredCurrencyDecimals,\n        address _wallet,\n        address _signer\n    ) external;\n}"
    },
    "contracts/presale-pool/PreSalePool.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.7.1;\n\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\n//import \"../interfaces/IERC20.sol\";\nimport \"../interfaces/IPoolFactory.sol\";\nimport \"../libraries/TransferHelper.sol\";\nimport \"../libraries/Ownable.sol\";\nimport \"../libraries/ReentrancyGuard.sol\";\n//import \"../libraries/SafeMath.sol\";\nimport \"../libraries/Pausable.sol\";\nimport \"../extensions/VispxWhitelist.sol\";\n\ncontract PreSalePool is Ownable, ReentrancyGuard, Pausable, VispxWhitelist {\n    using SafeMath for uint256;\n    using SafeERC20 for IERC20;\n\n    struct OfferedCurrency {\n        uint256 decimals;\n        uint256 rate;\n    }\n\n    // The token being sold\n    IERC20 public token;\n\n    // The address of factory contract\n    address public factory;\n\n    // The address of signer account\n    address public signer;\n\n    // Address where funds are collected\n    address public fundingWallet;\n\n    // Max capacity of token for sale\n    uint256 public maxCap = 0;\n\n    // Amount of wei raised\n    uint256 public weiRaised = 0;\n\n    // Amount of token sold\n    uint256 public tokenSold = 0;\n\n    // Amount of token sold\n    uint256 public totalUnclaimed = 0;\n\n    // Number of token user purchased\n    mapping(address => uint256) public userPurchased;\n\n    // Number of token user claimed\n    mapping(address => uint256) public userClaimed;\n\n    // Number of token user purchased\n    mapping(address => mapping(address => uint256)) public investedAmountOf;\n\n    // Get offered currencies\n    mapping(address => OfferedCurrency) public offeredCurrencies;\n\n    // Pool extensions\n    bool public useWhitelist = true;\n\n    // -----------------------------------------\n    // Lauchpad Starter's event\n    // -----------------------------------------\n    event PresalePoolCreated(\n        address token,\n        address offeredCurrency,\n        uint256 offeredCurrencyDecimals,\n        uint256 offeredCurrencyRate,\n        address wallet,\n        address owner\n    );\n    event TokenPurchaseByEther(\n        address indexed purchaser,\n        uint256 value,\n        uint256 amount\n    );\n    event TokenPurchaseByToken(\n        address indexed purchaser,\n        address token,\n        uint256 value,\n        uint256 amount\n    );\n\n    event TokenClaimed(address user, uint256 amount);\n    event EmergencyWithdraw(address wallet, uint256 amount);\n    event PoolStatsChanged();\n    event CapacityChanged();\n    event TokenChanged(address token);\n\n    // -----------------------------------------\n    // Constructor\n    // -----------------------------------------\n    constructor() {\n        factory = msg.sender;\n    }\n\n    // -----------------------------------------\n    // Red Kite external interface\n    // -----------------------------------------\n\n    /**\n     * @dev fallback function\n     */\n    fallback() external {\n        revert();\n    }\n\n    /**\n     * @dev fallback function\n     */\n    receive() external payable {\n        revert();\n    }\n\n    /**\n     * @param _token Address of the token being sold\n     * @param _offeredCurrency Address of offered token\n     * @param _offeredCurrencyDecimals Decimals of offered token\n     * @param _offeredRate Number of currency token units a buyer gets\n     * @param _wallet Address where collected funds will be forwarded to\n     * @param _signer Address where collected funds will be forwarded to\n     */\n    function initialize(\n        address _token,\n        address _offeredCurrency,\n        uint256 _offeredRate,\n        uint256 _offeredCurrencyDecimals,\n        address _wallet,\n        address _signer\n    ) external {\n        require(msg.sender == factory, \"POOL::UNAUTHORIZED\");\n\n        token = IERC20(_token);\n        fundingWallet = _wallet;\n        owner = tx.origin;\n        paused = false;\n        signer = _signer;\n\n        offeredCurrencies[_offeredCurrency] = OfferedCurrency({\n            rate: _offeredRate,\n            decimals: _offeredCurrencyDecimals\n        });\n\n        emit PresalePoolCreated(\n            _token,\n            _offeredCurrency,\n            _offeredCurrencyDecimals,\n            _offeredRate,\n            _wallet,\n            owner\n        );\n    }\n\n    /**\n     * @notice Returns the conversion rate when user buy by offered token\n     * @return Returns only a fixed number of rate.\n     */\n    function getOfferedCurrencyRate(address _token)\n        public\n        view\n        returns (uint256)\n    {\n        return offeredCurrencies[_token].rate;\n    }\n\n    /**\n     * @notice Returns the conversion rate decimals when user buy by offered token\n     * @return Returns only a fixed number of decimals.\n     */\n    function getOfferedCurrencyDecimals(address _token)\n        public\n        view\n        returns (uint256)\n    {\n        return offeredCurrencies[_token].decimals;\n    }\n\n    /**\n     * @notice Return the available tokens for purchase\n     * @return availableTokens Number of total available\n     */\n    function getAvailableTokensForSale()\n        public\n        view\n        returns (uint256 availableTokens)\n    {\n        return maxCap.sub(tokenSold);\n    }\n\n    /**\n     * @notice Owner can set the offered token conversion rate. Receiver tokens = tradeTokens * tokenRate / 10 ** etherConversionRateDecimals\n     * @param _rate Fixed number of ether rate\n     * @param _decimals Fixed number of ether rate decimals\n     */\n    function setOfferedCurrencyRateAndDecimals(\n        address _token,\n        uint256 _rate,\n        uint256 _decimals\n    ) external onlyOwner {\n        offeredCurrencies[_token].rate = _rate;\n        offeredCurrencies[_token].decimals = _decimals;\n        emit PoolStatsChanged();\n    }\n\n    /**\n     * @notice Owner can set the offered token conversion rate. Receiver tokens = tradeTokens * tokenRate / 10 ** etherConversionRateDecimals\n     * @param _rate Fixed number of rate\n     */\n    function setOfferedCurrencyRate(address _token, uint256 _rate)\n        external\n        onlyOwner\n    {\n        require(offeredCurrencies[_token].rate != _rate, \"POOL::RATE_INVALID\");\n        offeredCurrencies[_token].rate = _rate;\n        emit PoolStatsChanged();\n    }\n\n    /**\n     * @notice Owner can set the offered token conversion rate. Receiver tokens = tradeTokens * tokenRate / 10 ** etherConversionRateDecimals\n     * @param _newSigner Address of new signer\n     */\n    function setNewSigner(address _newSigner) external onlyOwner {\n        require(signer != _newSigner, \"POOL::SIGNER_INVALID\");\n        signer = _newSigner;\n    }\n\n    /**\n     * @notice Owner can set the offered token conversion rate. Receiver tokens = tradeTokens * tokenRate / 10 ** etherConversionRateDecimals\n     * @param _decimals Fixed number of decimals\n     */\n    function setOfferedCurrencyDecimals(address _token, uint256 _decimals)\n        external\n        onlyOwner\n    {\n        require(\n            offeredCurrencies[_token].decimals != _decimals,\n            \"POOL::RATE_INVALID\"\n        );\n        offeredCurrencies[_token].decimals = _decimals;\n        emit PoolStatsChanged();\n    }\n\n    function setMaxCap(uint256 _maxCap) external onlyOwner {\n        require(_maxCap > tokenSold, \"POOL::INVALID_CAPACITY\");\n        maxCap = _maxCap;\n        emit CapacityChanged();\n    }\n\n    /**\n     * @notice Owner can set extentions.\n     * @param _whitelist Value in bool. True if using whitelist\n     */\n    function setPoolExtentions(bool _whitelist) external onlyOwner {\n        useWhitelist = _whitelist;\n        emit PoolStatsChanged();\n    }\n\n    function changeSaleToken(address _token) external onlyOwner {\n        require(_token != address(0));\n        token = IERC20(_token);\n        emit TokenChanged(_token);\n    }\n\n    function buyTokenByEtherWithPermission(\n        address _candidate,\n        bytes memory _signature\n    ) public payable whenNotPaused nonReentrant {\n        uint256 weiAmount = msg.value;\n\n        require(\n            offeredCurrencies[address(0)].rate != 0,\n            \"POOL::PURCHASE_METHOD_NOT_ALLOWED\"\n        );\n        require(\n            _verifyWhitelist(_candidate, weiAmount, _signature),\n            \"POOL:INVALID_SIGNATURE\"\n        );\n\n        // calculate token amount to be created\n        uint256 tokens = _getOfferedCurrencyToTokenAmount(\n            address(0),\n            weiAmount\n        );\n\n        _forwardFunds(weiAmount);\n\n        _updatePurchasingState(weiAmount, tokens);\n\n        investedAmountOf[address(0)][_candidate] = investedAmountOf[address(0)][\n            _candidate\n        ].add(weiAmount);\n\n        emit TokenPurchaseByEther(msg.sender, weiAmount, tokens);\n    }\n\n    function buyTokenByTokenWithPermission(\n        address _token,\n        uint256 _amount,\n        address _candidate,\n        bytes memory _signature\n    ) public whenNotPaused nonReentrant {\n        require(\n            offeredCurrencies[_token].rate != 0,\n            \"POOL::PURCHASE_METHOD_NOT_ALLOWED\"\n        );\n        require(\n            _verifyWhitelist(_candidate, _amount, _signature),\n            \"POOL:INVALID_SIGNATURE\"\n        );\n\n        uint256 tokens = _getOfferedCurrencyToTokenAmount(_token, _amount);\n\n        _forwardTokenFunds(_token, _amount);\n\n        _updatePurchasingState(_amount, tokens);\n\n        investedAmountOf[_token][_candidate] = investedAmountOf[address(0)][\n            _candidate\n        ].add(_amount);\n\n        emit TokenPurchaseByToken(msg.sender, _token, _amount, tokens);\n    }\n\n    /**\n     * @notice Emergency Mode: Owner can withdraw token\n     * @dev  Can withdraw token in emergency mode\n     * @param _wallet Address wallet who receive token\n     */\n    function emergencyWithdraw(address _wallet, uint256 _amount)\n        external\n        onlyOwner\n    {\n        require(\n            token.balanceOf(address(this)) >= _amount,\n            \"POOL::INSUFFICIENT_BALANCE\"\n        );\n\n        _deliverTokens(_wallet, _amount);\n        emit EmergencyWithdraw(_wallet, _amount);\n    }\n\n    /**\n     * @notice User can receive their tokens when pool finished\n     */\n    // user purchase: 2000\n    // turn 1: 600 400\n    /**\n     turn 1: 600\n     userPurchased = 1400\n\n      */\n\n    function claimTokens(\n        address _candidate,\n        uint256 _amount,\n        bytes memory _signature\n    ) public nonReentrant {\n        require(\n            _verifyClaimToken(_candidate, _amount, _signature),\n            \"POOL::NOT_ALLOW_TO_CLAIM\"\n        );\n        require(\n            _amount >= userClaimed[_candidate],\n            \"POOL::AMOUNT_MUST_GREATER_THAN_CLAIMED\"\n        ); // 400 600\n\n        uint256 maxClaimAmount = userPurchased[_candidate].sub(\n            userClaimed[_candidate]\n        ); // 2000 1400\n\n        uint256 claimAmount = _amount.sub(userClaimed[_candidate]); // 600 1000\n\n        if (claimAmount > maxClaimAmount) {\n            claimAmount = maxClaimAmount;\n        }\n\n        userClaimed[_candidate] = userClaimed[_candidate].add(claimAmount); // 600 1000\n\n        _deliverTokens(msg.sender, claimAmount);\n\n        totalUnclaimed = totalUnclaimed.sub(claimAmount);\n\n        emit TokenClaimed(msg.sender, claimAmount);\n    }\n\n    /**\n     * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.\n     * @param _beneficiary Address performing the token purchase\n     * @param _weiAmount Value in wei involved in the purchase\n     */\n    function _preValidatePurchase(address _beneficiary, uint256 _weiAmount)\n        internal\n        pure\n    {\n        require(_beneficiary != address(0), \"POOL::INVALID_BENEFICIARY\");\n        require(_weiAmount != 0, \"POOL::INVALID_WEI_AMOUNT\");\n    }\n\n    /**\n     * @dev Override to extend the way in which ether is converted to tokens.\n     * @param _amount Value in wei to be converted into tokens\n     * @return Number of tokens that can be purchased with the specified _weiAmount\n     */\n    function _getOfferedCurrencyToTokenAmount(address _token, uint256 _amount)\n        internal\n        view\n        returns (uint256)\n    {\n        uint256 rate = getOfferedCurrencyRate(_token);\n        uint256 decimals = getOfferedCurrencyDecimals(_token);\n        return _amount.mul(rate).div(10**decimals);\n    }\n\n    /**\n     * @dev Source of tokens. Transfer / mint\n     * @param _beneficiary Address performing the token purchase\n     * @param _tokenAmount Number of tokens to be emitted\n     */\n    function _deliverTokens(address _beneficiary, uint256 _tokenAmount)\n        internal\n    {\n        require(\n            token.balanceOf(address(this)) >= _tokenAmount,\n            \"POOL::INSUFFICIENT_FUND\"\n        );\n        token.safeTransfer(_beneficiary, _tokenAmount);\n    }\n\n    /**\n     * @dev Determines how ETH is stored/forwarded on purchases.\n     */\n    function _forwardFunds(uint256 _value) internal {\n        address payable wallet = address(uint160(fundingWallet));\n        (bool success, ) = wallet.call{value: _value}(\"\");\n        require(success, \"POOL::WALLET_TRANSFER_FAILED\");\n    }\n\n    /**\n     * @dev Determines how Token is stored/forwarded on purchases.\n     */\n    function _forwardTokenFunds(address _token, uint256 _amount) internal {\n        TransferHelper.safeTransferFrom(\n            _token,\n            msg.sender,\n            fundingWallet,\n            _amount\n        );\n    }\n\n    /**\n     * @param _tokens Value of sold tokens\n     * @param _weiAmount Value in wei involved in the purchase\n     */\n    function _updatePurchasingState(uint256 _weiAmount, uint256 _tokens)\n        internal\n    {\n        weiRaised = weiRaised.add(_weiAmount);\n        tokenSold = tokenSold.add(_tokens);\n        userPurchased[msg.sender] = userPurchased[msg.sender].add(_tokens);\n        totalUnclaimed = totalUnclaimed.add(_tokens);\n    }\n\n    /**vxcvxcvc\n     * @dev Transfer eth to an address\n     * @param _to Address receiving the eth\n     * @param _amount Amount of wei to transfer\n     */\n    function _transfer(address _to, uint256 _amount) private {\n        address payable payableAddress = address(uint160(_to));\n        (bool success, ) = payableAddress.call{value: _amount}(\"\");\n        require(success, \"POOL::TRANSFER_FEE_FAILED\");\n    }\n\n    /**\n     * @dev Verify permission of purchase\n     * @param _candidate Address of buyer\n     * @param _signature Signature of signers\n     */\n    function _verifyWhitelist(\n        address _candidate,\n        uint256 _amount,\n        bytes memory _signature\n    ) private view returns (bool) {\n        require(msg.sender == _candidate, \"POOL::WRONG_CANDIDATE\");\n\n        if (useWhitelist) {\n            return (verify(signer, _candidate, _amount, _signature));\n        }\n        return true;\n    }\n\n    /**\n     * @dev Verify permission of purchase\n     * @param _candidate Address of buyer\n     * @param _amount claimable amount\n     * @param _signature Signature of signers\n     */\n    function _verifyClaimToken(\n        address _candidate,\n        uint256 _amount,\n        bytes memory _signature\n    ) private view returns (bool) {\n        require(msg.sender == _candidate, \"POOL::WRONG_CANDIDATE\");\n\n        return (verifyClaimToken(signer, _candidate, _amount, _signature));\n    }\n}\n"
    },
    "contracts/libraries/Ownable.sol": {
      "content": "//SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.7.0;\n\n\n/**\n * @title Ownable\n * @dev The Ownable contract has an owner address, and provides basic authorization control\n * functions, this simplifies the implementation of \"user permissions\".\n */\ncontract Ownable {\n  address public owner;\n\n  event OwnershipTransferred(\n    address indexed previousOwner,\n    address indexed newOwner\n  );\n\n  /**\n   * @dev Throws if called by any account other than the owner.\n   */\n  modifier onlyOwner() {\n    require(msg.sender == owner);\n    _;\n  }\n\n  /**\n   * @dev Allows the current owner to transfer control of the contract to a newOwner.\n   * @param _newOwner The address to transfer ownership to.\n   */\n  function transferOwnership(address _newOwner) public onlyOwner {\n    _transferOwnership(_newOwner);\n  }\n\n  /**\n   * @dev Transfers control of the contract to a newOwner.\n   * @param _newOwner The address to transfer ownership to.\n   */\n  function _transferOwnership(address _newOwner) internal {\n    require(_newOwner != address(0));\n    emit OwnershipTransferred(owner, _newOwner);\n    owner = _newOwner;\n  }\n}\n"
    },
    "contracts/libraries/Pausable.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.7.1;\n\n\nimport \"./Ownable.sol\";\n\n\n/**\n * @title Pausable\n * @dev Base contract which allows children to implement an emergency stop mechanism.\n */\ncontract Pausable is Ownable {\n  event Pause();\n  event Unpause();\n\n  bool public paused;\n\n\n  /**\n   * @dev Modifier to make a function callable only when the contract is not paused.\n   */\n  modifier whenNotPaused() {\n    require(!paused, \"CONTRACT_PAUSED\");\n    _;\n  }\n\n  /**\n   * @dev Modifier to make a function callable only when the contract is paused.\n   */\n  modifier whenPaused() {\n    require(paused, \"CONTRACT_NOT_PAUSED\");\n    _;\n  }\n\n  /**\n   * @dev called by the owner to pause, triggers stopped state\n   */\n  function pause() onlyOwner whenNotPaused public {\n    paused = true;\n    emit Pause();\n  }\n\n  /**\n   * @dev called by the owner to unpause, returns to normal state\n   */\n  function unpause() onlyOwner whenPaused public {\n    paused = false;\n    emit Unpause();\n  }\n}"
    },
    "contracts/libraries/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity >=0.7.1 <0.8.0;\n\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        // extcodesize checks the size of the code stored in an address, and\n        // address returns the current address. Since the code is still not\n        // deployed when running a constructor, any checks on its code size will\n        // yield zero, making it an effective way to detect if a contract is\n        // under construction or not.\n        address self = address(this);\n        uint256 cs;\n        // solhint-disable-next-line no-inline-assembly\n        assembly { cs := extcodesize(self) }\n        return cs == 0;\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/SafeERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"../../math/SafeMath.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using SafeMath for uint256;\n    using Address for address;\n\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20 token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        // solhint-disable-next-line max-line-length\n        require((value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 newAllowance = token.allowance(address(this), spender).add(value);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 newAllowance = token.allowance(address(this), spender).sub(value, \"SafeERC20: decreased allowance below zero\");\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) { // Return data is optional\n            // solhint-disable-next-line max-line-length\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
    },
    "contracts/interfaces/IPoolFactory.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.1;\n\ninterface IPoolFactory {\n    function getTier() external view returns (address);\n}\n"
    },
    "contracts/libraries/TransferHelper.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity >=0.6.0;\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n    function safeApprove(\n        address token,\n        address to,\n        uint256 value\n    ) internal {\n        // bytes4(keccak256(bytes('approve(address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            'TransferHelper::safeApprove: approve failed'\n        );\n    }\n\n    function safeTransfer(\n        address token,\n        address to,\n        uint256 value\n    ) internal {\n        // bytes4(keccak256(bytes('transfer(address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            'TransferHelper::safeTransfer: transfer failed'\n        );\n    }\n\n    function safeTransferFrom(\n        address token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            'TransferHelper::transferFrom: transferFrom failed'\n        );\n    }\n}"
    },
    "contracts/libraries/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 () {\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"
    },
    "contracts/extensions/VispxWhitelist.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.7.0;\n\nimport \"openzeppelin-solidity/contracts/cryptography/ECDSA.sol\";\n\ncontract VispxWhitelist {\n    // Using Openzeppelin ECDSA cryptography library\n    function getMessageHash(address _candidate, uint256 _amount)\n        public\n        pure\n        returns (bytes32)\n    {\n        return keccak256(abi.encodePacked(_candidate, _amount));\n    }\n\n    function getClaimMessageHash(address _candidate, uint256 _amount)\n        public\n        pure\n        returns (bytes32)\n    {\n        return keccak256(abi.encodePacked(_candidate, _amount));\n    }\n\n    // Verify signature function\n    function verify(\n        address _signer,\n        address _candidate,\n        uint256 _amount,\n        bytes memory signature\n    ) public pure returns (bool) {\n        bytes32 messageHash = getMessageHash(_candidate, _amount);\n        bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash);\n\n        return getSignerAddress(ethSignedMessageHash, signature) == _signer;\n    }\n\n    // Verify signature function\n    function verifyClaimToken(\n        address _signer,\n        address _candidate,\n        uint256 _amount,\n        bytes memory signature\n    ) public pure returns (bool) {\n        bytes32 messageHash = getClaimMessageHash(_candidate, _amount);\n        bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash);\n\n        return getSignerAddress(ethSignedMessageHash, signature) == _signer;\n    }\n\n    function getSignerAddress(bytes32 _messageHash, bytes memory _signature)\n        public\n        pure\n        returns (address signer)\n    {\n        return ECDSA.recover(_messageHash, _signature);\n    }\n\n    // Split signature to r, s, v\n    function splitSignature(bytes memory _signature)\n        public\n        pure\n        returns (\n            bytes32 r,\n            bytes32 s,\n            uint8 v\n        )\n    {\n        require(_signature.length == 65, \"invalid signature length\");\n\n        assembly {\n            r := mload(add(_signature, 32))\n            s := mload(add(_signature, 64))\n            v := byte(0, mload(add(_signature, 96)))\n        }\n    }\n\n    function getEthSignedMessageHash(bytes32 _messageHash)\n        public\n        pure\n        returns (bytes32)\n    {\n        return ECDSA.toEthSignedMessageHash(_messageHash);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.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 IERC20 {\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"
    },
    "@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/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-solidity/contracts/cryptography/ECDSA.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 ECDSA {\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"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 1000
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "libraries": {}
  }
}