creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract 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() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@openzeppelin/contracts/interfaces/IERC1271.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n *\n * _Available since v4.1._\n */\ninterface IERC1271 {\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param hash      Hash of the data to be signed\n     * @param signature Signature byte array associated with _data\n     */\n    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"
      },
      "@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^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 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) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\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    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS,\n        InvalidSignatureV // Deprecated in v4.8\n    }\n\n    function _throwError(RecoverError error) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert(\"ECDSA: invalid signature\");\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert(\"ECDSA: invalid signature length\");\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert(\"ECDSA: invalid signature 's' value\");\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature` or error string. 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     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-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            return tryRecover(hash, v, r, s);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength);\n        }\n    }\n\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        (address recovered, RecoverError error) = tryRecover(hash, signature);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\n        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n        uint8 v = uint8((uint256(vs) >> 255) + 27);\n        return tryRecover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     *\n     * _Available since v4.2._\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\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 (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): 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        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature);\n        }\n\n        return (signer, RecoverError.NoError);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} 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        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\")\n            mstore(0x1c, hash)\n            message := keccak256(0x00, 0x3c)\n        }\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from `s`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Typed Data, created from a\n     * `domainSeparator` and a `structHash`. This produces hash corresponding\n     * to the one signed with the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n     * JSON-RPC method as part of EIP-712.\n     *\n     * See {recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(ptr, \"\\x19\\x01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            data := keccak256(ptr, 0x42)\n        }\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Data with intended validator, created from a\n     * `validator` and `data` according to the version 0 of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x00\", validator, data));\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/math/SafeCast.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     *\n     * _Available since v4.2._\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     *\n     * _Available since v4.2._\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     *\n     * _Available since v3.0._\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        require(value >= 0, \"SafeCast: value must be positive\");\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt248(int256 value) internal pure returns (int248 downcasted) {\n        downcasted = int248(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt240(int256 value) internal pure returns (int240 downcasted) {\n        downcasted = int240(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt232(int256 value) internal pure returns (int232 downcasted) {\n        downcasted = int232(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt224(int256 value) internal pure returns (int224 downcasted) {\n        downcasted = int224(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt216(int256 value) internal pure returns (int216 downcasted) {\n        downcasted = int216(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt208(int256 value) internal pure returns (int208 downcasted) {\n        downcasted = int208(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt200(int256 value) internal pure returns (int200 downcasted) {\n        downcasted = int200(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt192(int256 value) internal pure returns (int192 downcasted) {\n        downcasted = int192(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt184(int256 value) internal pure returns (int184 downcasted) {\n        downcasted = int184(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt176(int256 value) internal pure returns (int176 downcasted) {\n        downcasted = int176(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt168(int256 value) internal pure returns (int168 downcasted) {\n        downcasted = int168(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt160(int256 value) internal pure returns (int160 downcasted) {\n        downcasted = int160(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt152(int256 value) internal pure returns (int152 downcasted) {\n        downcasted = int152(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt144(int256 value) internal pure returns (int144 downcasted) {\n        downcasted = int144(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt136(int256 value) internal pure returns (int136 downcasted) {\n        downcasted = int136(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt128(int256 value) internal pure returns (int128 downcasted) {\n        downcasted = int128(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt120(int256 value) internal pure returns (int120 downcasted) {\n        downcasted = int120(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt112(int256 value) internal pure returns (int112 downcasted) {\n        downcasted = int112(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt104(int256 value) internal pure returns (int104 downcasted) {\n        downcasted = int104(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt96(int256 value) internal pure returns (int96 downcasted) {\n        downcasted = int96(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt88(int256 value) internal pure returns (int88 downcasted) {\n        downcasted = int88(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt80(int256 value) internal pure returns (int80 downcasted) {\n        downcasted = int80(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt72(int256 value) internal pure returns (int72 downcasted) {\n        downcasted = int72(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt64(int256 value) internal pure returns (int64 downcasted) {\n        downcasted = int64(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt56(int256 value) internal pure returns (int56 downcasted) {\n        downcasted = int56(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt48(int256 value) internal pure returns (int48 downcasted) {\n        downcasted = int48(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt40(int256 value) internal pure returns (int40 downcasted) {\n        downcasted = int40(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt32(int256 value) internal pure returns (int32 downcasted) {\n        downcasted = int32(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt24(int256 value) internal pure returns (int24 downcasted) {\n        downcasted = int24(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt16(int256 value) internal pure returns (int16 downcasted) {\n        downcasted = int16(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt8(int256 value) internal pure returns (int8 downcasted) {\n        downcasted = int8(value);\n        require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     *\n     * _Available since v3.0._\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n        return int256(value);\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/math/SignedMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Strings.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toString(int256 value) internal pure returns (string memory) {\n        return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "contracts/Access.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Implement access control of Hashkey.\nabstract contract Access is Ownable {\n    mapping(bytes32 => mapping(address => bool)) private _roleMembers;\n\n    event SetupRole(bytes32 role, bool enable, address indexed account);\n\n    modifier accessible(bytes32 role) {\n        require(\n            owner() == msg.sender || hasRole(role, msg.sender),\n            \"Access: caller has no access\"\n        );\n        _;\n    }\n\n    /// @dev Returns `true` if `account` has been granted `role`.\n    function hasRole(bytes32 role, address account) public view returns (bool) {\n        return _roleMembers[role][account];\n    }\n\n    /// @dev\n    function setupRole(bytes32 role, bool enable, address account) external onlyOwner {\n        require(account != address(0), \"Access: account is zero address\");\n        _roleMembers[role][account] = enable;\n        \n        emit SetupRole(role, enable, account);\n    }\n}"
      },
      "contracts/BlackList.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"./Access.sol\";\n\nabstract contract BlackList is Access {\n\n    bytes32 public constant BLACKLIST_ROLE = keccak256(\"Blacklist Role\");\n\n    mapping(address => bool) private _blacklist;\n\n    event SetupBlackList(address indexed account, bool blacklisted);\n\n    modifier notInBlackList(address account) {\n        require(!inBlackList(account), \"Blacklist: in blacklist\");\n        _;\n    }\n    \n    /// @dev Return if the account is in blacklist.\n    function inBlackList(address account) public view returns (bool) {\n        return _blacklist[account];\n    }\n    \n    /// @dev Add the account in the blacklist, or remove the account from the blacklist.\n    function setBlackList(address account, bool blacklisted) external accessible(BLACKLIST_ROLE) {\n        require(account != address(0), \"Blacklist: zero address\");\n        _blacklist[account] = blacklisted;\n        emit SetupBlackList(account, blacklisted);\n    }\n}\n"
      },
      "contracts/BurnPermit.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"./ERC20.sol\";\nimport \"./library/CheckSig.sol\";\n\nabstract contract BurnPermit is ERC20 {\n    using CheckSig for address;\n\n    mapping(address => uint256) private _burnNonces;\n\n    bytes32 private constant BURN_TYPEHASH = keccak256(\"HSK V1 Burn\");\n\n    bytes32 private constant BURN_FROM_TYPEHASH = keccak256(\"HSK V1 Burn From\");\n\n    bytes32 public constant BURN_ROLE = keccak256(\"Burn Role\");\n\n    /// @dev Return account's available nonce.\n    function burnNonce(address account) public view returns (uint256) {\n        return _burnNonces[account];\n    }\n\n    /// @dev Hash of the burn request message.\n    function burnMessageHash(\n        address applicant,\n        uint256 amount,\n        uint256 nonce,\n        uint256 deadline\n    ) public view returns (bytes32) {\n        return keccak256(\n            abi.encode(\n                BURN_TYPEHASH,\n                block.chainid,\n                address(this),\n                applicant,\n                amount,\n                nonce,\n                deadline\n            )\n        );\n    }\n\n    /// @dev Hash of the burn from request message.\n    function burnFromMessageHash(\n        address applicant,\n        address from,\n        uint256 amount,\n        uint256 nonce,\n        uint256 deadline\n    ) public view returns (bytes32) {\n        return keccak256(\n            abi.encode(\n                BURN_FROM_TYPEHASH,\n                block.chainid,\n                address(this),\n                applicant,\n                from,\n                amount,\n                nonce,\n                deadline\n            )\n        );\n    }\n\n    /// @dev Burn {amount} tokens of {applicant} by the owner, ensure {sig} is signed from {applicant}.\n    function burn(address applicant, uint256 amount, uint256 deadline, bytes memory sig)\n        external\n        accessible(BURN_ROLE)\n        notInBlackList(applicant)\n    {\n        // solhint-disable-next-line not-rely-on-time\n        require(block.timestamp <= deadline, \"BurnPermit: expired deadline\");\n\n        bytes32 message = burnMessageHash(applicant, amount, burnNonce(applicant), deadline);\n        bytes32 digest = ECDSA.toEthSignedMessageHash(message);\n        _burnNonces[applicant]++;\n\n        applicant.checkSignature(digest, sig);\n\n        _burn(applicant, amount);\n    }\n\n    /// @dev Burn {amount} tokens of {applicant} from {from} by the owner, ensure {sig} is signed from {applicant}.\n    function burnFrom(\n        address applicant,\n        address from,\n        uint256 amount,\n        uint256 deadline,\n        bytes memory sig\n    )\n        external\n        accessible(BURN_ROLE)\n        notInBlackList(applicant)\n        notInBlackList(from)\n    {\n        // solhint-disable-next-line not-rely-on-time\n        require(block.timestamp <= deadline, \"BurnPermit: expired deadline\");\n\n        bytes32 message = burnFromMessageHash(applicant, from, amount, burnNonce(applicant), deadline);\n        bytes32 digest = ECDSA.toEthSignedMessageHash(message);\n        _burnNonces[applicant]++;\n\n        applicant.checkSignature(digest, sig);\n\n        _burnFrom(applicant, from, amount);\n    }\n}"
      },
      "contracts/ERC20.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\npragma abicoder v2;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"./interface/IERC20.sol\";\nimport \"./library/Vesting.sol\";\nimport \"./library/Mint.sol\";\nimport \"./BlackList.sol\";\n\n/// @title Implement ERC20 token of HashKey Platform Token.\nabstract contract ERC20 is BlackList, IERC20 {\n    using SafeCast for uint256;\n    using Vesting for Vesting.Cliff;\n    using Vesting for Vesting.Linear;\n\n    /// @dev describe the account state of user, user's fund is consist of 3 parts\n    struct AccountState {\n        Vesting.Cliff[]         cliffVesting;\n        Vesting.Linear[]        linearVesting;\n        uint256                 available;\n    }\n\n    /// @dev describe the current cliff vesting schedule of user\n    struct CliffVesting {\n        Mint.Bucket             bucket;\n        uint64                  expiration;\n        uint256                 amount;\n    }\n\n    /// @dev describe the current linear vesting schedule of user\n    struct LinearVesting {\n        Mint.Bucket             bucket;\n        uint64                  interval;\n        uint64                  expiration;\n        uint256                 amount;\n    }\n\n    string  private constant NAME            = \"HashKey Platform Token\";\n    string  private constant SYMBOL          = \"HSK\";\n    uint8   private constant DECIMALS        = 18;\n\n    bytes32 public  constant ECO_GROWTH_ROLE = keccak256(\"Ecosystem Growth Role\");\n    bytes32 public  constant TEAM_ROLE       = keccak256(\"Team Role\");\n    bytes32 public  constant RESERVE_ROLE    = keccak256(\"Reserve Role\");\n\n    // It will cost less than 10,000 GAS to compute and refresh vesting state in\n    // each loop step of `_updateAccountState()`.\n    // Hereby we restrict a max schdules limit of 2000, which means it will\n    // never exceed 20,000,000 GAS, abount 2/3 of a block gas limit (30,000,000).\n    uint256 private constant MAX_SCHEDULES   = 2000;\n\n    // set to true to prevent calling `init()` in implementation contract.\n    bool    private _initialized             = true;\n    uint256 private _ecoGrowthShare          = 650000000  * 10 ** DECIMALS;\n    uint256 private _teamShare               = 300000000  * 10 ** DECIMALS;\n    uint256 private _reserveShare            = 50000000   * 10 ** DECIMALS;\n    uint256 private _totalSupply             = _ecoGrowthShare + _teamShare + _reserveShare;\n\n    mapping(address => AccountState) private accounts;\n    mapping(address => mapping(address => uint256)) private _allowances;\n\n    event MintType1(\n        Mint.Bucket indexed bucket,\n        address indexed recipient,\n        uint256 amount\n    );\n    event MintType2(\n        Mint.Bucket indexed bucket,\n        address indexed recipient,\n        uint256 expiration,\n        uint256 amount\n    );\n    event MintType3(\n        Mint.Bucket indexed bucket,\n        address indexed recipient,\n        uint256 start,\n        uint256 end,\n        uint256 interval,\n        uint256 amount\n    );\n\n    event ShrinkShare(Mint.Bucket indexed bucket, uint256 amount);\n    event RecallTeamVesting(address indexed account, uint256 amount);\n    event Burn(address indexed applicant, uint256 amount);\n    event BurnFrom(address indexed applicant, address indexed from, uint256 amount);\n\n    constructor() {\n        // set owner to zero address.\n        renounceOwnership();\n    }\n\n    /// @dev initialize token parameters.\n    /// @notice this function is designed to be called by proxy contract.\n    function init(address _owner) external {\n        // not initialized in proxy\n        require(!_initialized, \"ERC20: Already initialized\");\n\n        _initialized        = true;\n        _ecoGrowthShare     = 650000000  * 10 ** DECIMALS;\n        _teamShare          = 300000000  * 10 ** DECIMALS;\n        _reserveShare       = 50000000   * 10 ** DECIMALS;\n        _totalSupply        = _ecoGrowthShare + _teamShare + _reserveShare;\n\n        _transferOwnership(_owner);\n    }\n\n    ///////////////////////////// ERC20 methods /////////////////////////////\n\n    /// @dev see in IERC20\n    function name() public pure override returns (string memory) {\n        return NAME;\n    }\n\n    /// @dev see in IERC20.\n    function symbol() public pure override returns (string memory) {\n        return SYMBOL;\n    }\n\n    /// @dev see in IERC20.\n    function decimals() public pure override returns (uint8) {\n        return DECIMALS;\n    }\n\n    /// @dev see in IERC20.\n    function totalSupply() public view override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /// @dev see in IERC20.\n    /// @notice balance is consist of 4 parts: available part and 3 vesting parts.\n    function balanceOf(address _owner) public view override returns (uint256) {\n        AccountState storage state = accounts[_owner];\n        uint256 balance = state.available;\n\n        uint256 length = state.cliffVesting.length;\n        for (uint256 i = 0; i < length;) {\n            Vesting.Cliff storage vesting = state.cliffVesting[i];\n            if (vesting.active) {\n                // solhint-disable-next-line not-rely-on-time\n                (, uint256 released) = vesting.getCliff(block.timestamp);\n                unchecked { balance += released; }\n            }\n            unchecked { i++; }\n        }\n\n        length = state.linearVesting.length;\n        for (uint256 i = 0; i < length;) {\n            Vesting.Linear storage vesting = state.linearVesting[i];\n            if (vesting.active) {\n                // solhint-disable-next-line not-rely-on-time\n                (, uint256 released) = vesting.getLinear(block.timestamp);\n                unchecked { balance += released; }\n            }\n            unchecked { i++; }\n        }\n\n        return balance;\n    }\n\n    /// @dev see in IERC20.\n    function allowance(address _owner, address spender) public view override returns (uint256) {\n        return _allowances[_owner][spender];\n    }\n\n    /// @dev see in IERC20.\n    function transfer(address to, uint256 amount)\n        public\n        override\n        notInBlackList(msg.sender)\n        notInBlackList(to)\n        returns (bool)\n    {\n        _transfer(msg.sender, to, amount);\n        return true;\n    }\n\n    /// @dev see in IERC20.\n    function approve(address spender, uint256 amount)\n        public\n        override\n        notInBlackList(msg.sender)\n        notInBlackList(spender)\n        returns (bool)\n    {\n        _approve(msg.sender, spender, amount);\n        return true;\n    }\n\n    /// @dev see in IERC20.\n    /// @notice if _allowance is max of uint256, it means allowance is not limited.\n    function transferFrom(address from, address to, uint256 amount)\n        public\n        override\n        notInBlackList(msg.sender)\n        notInBlackList(from)\n        notInBlackList(to)\n        returns (bool)\n    {\n        uint256 _allowance = allowance(from, msg.sender);\n        if (_allowance != type(uint256).max) {\n            require(amount <= _allowance, \"ERC20: Insufficient allowance\");\n            _allowances[from][msg.sender] = _allowance - amount;\n        }\n        _transfer(from, to, amount);\n        return true;\n    }\n\n    ///////////////////////////// HSK methods ///////////////////////////// \n\n    /// @dev batch execute transfer tokens.\n    function batchTransfer(address[] memory tos, uint256[] memory amounts) external {\n        require(tos.length == amounts.length, \"ERC20: Unmatched array length\");\n\n        for (uint256 i = 0; i < tos.length; i++) {\n            transfer(tos[i], amounts[i]);\n        }\n    }\n\n    /// @dev batch execute transferFrom tokens.\n    function batchTransferFrom(\n        address from,\n        address[] memory tos,\n        uint256[] memory amounts\n    ) external {\n        require(tos.length == amounts.length, \"ERC20: Unmatched array length\");\n\n        for (uint256 i = 0; i < tos.length; i++) {\n            transferFrom(from, tos[i], amounts[i]);\n        }\n    }\n\n    /// @dev return _ecoGrowthShare.\n    function ecoGrowthShare() external view returns (uint256) {\n        return _ecoGrowthShare;\n    }\n\n    /// @dev return _teamShare.\n    function teamShare() external view returns (uint256) {\n        return _teamShare;\n    }\n\n    /// @dev return _reserveShare.\n    function reserveShare() external view returns (uint256) {\n        return _reserveShare;\n    }\n\n    /// @dev total unlocked token amount of all vesting schedules.\n    function vestingAmountOf(address _owner) external view returns (uint256) {\n        AccountState storage state = accounts[_owner];\n        uint256 amount = 0;\n\n        uint256 length = state.cliffVesting.length;\n        for (uint256 i = 0; i < length;) {\n            Vesting.Cliff storage vesting = state.cliffVesting[i];\n            if (vesting.active) {\n                // solhint-disable-next-line not-rely-on-time\n                (uint256 locking, ) = vesting.getCliff(block.timestamp);\n                unchecked { amount += locking; }\n            }\n            unchecked { i++; }\n        }\n\n        length = state.linearVesting.length;\n        for (uint256 i = 0; i < length;) {\n            Vesting.Linear storage vesting = state.linearVesting[i];\n            if (vesting.active) {\n                // solhint-disable-next-line not-rely-on-time\n                (uint256 locking, ) = vesting.getLinear(block.timestamp);\n                unchecked { amount += locking; }\n            }\n            unchecked { i++; }\n        }\n\n        return amount;\n    }\n\n    /// @dev compute all cliff vesting schedules of `_owner`.\n    function cliffVestingOf(address _owner) external view returns (CliffVesting[] memory) {\n        AccountState storage state = accounts[_owner];\n        \n        uint256 num = 0;\n        uint256 length = state.cliffVesting.length;\n        uint256[] memory lockings = new uint256[](length);\n        for (uint256 i = 0; i < length;) {\n            Vesting.Cliff storage vesting = state.cliffVesting[i];\n            if (vesting.active) {\n                // solhint-disable-next-line not-rely-on-time\n                (uint256 locking, ) = vesting.getCliff(block.timestamp);\n                if (locking > 0) {\n                    lockings[i] = locking;\n                    unchecked { num++; }\n                }\n            }\n            unchecked { i++; }\n        }\n\n        CliffVesting[] memory schedules = new CliffVesting[](num);\n        num = 0;\n        for (uint256 i = 0; i < length;) {\n            uint256 locking = lockings[i];\n            if (locking > 0) {\n                Vesting.Cliff storage vesting = state.cliffVesting[i];\n                schedules[num] = CliffVesting({\n                    bucket: vesting.bucket,\n                    expiration: vesting.expiration,\n                    amount: locking\n                });\n                unchecked { num++; }\n            }\n            unchecked { i++; }\n        }\n\n        return schedules;\n    }\n\n    /// @dev compute all linear vesting schedules of `_owner`.\n    function linearVestingOf(address _owner) external view returns (LinearVesting[] memory) {\n        AccountState storage state = accounts[_owner];\n        \n        uint256 num = 0;\n        uint256 length = state.linearVesting.length;\n        uint256[] memory lockings = new uint256[](length);\n        for (uint256 i = 0; i < length;) {\n            Vesting.Linear storage vesting = state.linearVesting[i];\n            if (vesting.active) {\n                // solhint-disable-next-line not-rely-on-time\n                (uint256 locking, ) = vesting.getLinear(block.timestamp);\n                if (locking > 0) {\n                    lockings[i] = locking;\n                    unchecked { num++; }\n                }\n            }\n            unchecked { i++; }\n        }\n\n        LinearVesting[] memory schedules = new LinearVesting[](num);\n        num = 0;\n        for (uint256 i = 0; i < length;) {\n            uint256 locking = lockings[i];\n            if (locking > 0) {\n                Vesting.Linear storage vesting = state.linearVesting[i];\n                schedules[num] = LinearVesting({\n                    bucket: vesting.bucket,\n                    interval: vesting.interval,\n                    expiration: vesting.end,\n                    amount: locking\n                });\n                unchecked { num++; }\n            }\n            unchecked { i++; }\n        }\n\n        return schedules;\n    }\n\n    /// @dev mint type 1: directly mint to account, without any vesting schedule.\n    function mint1(Mint.Bucket bucket, address recipient, uint256 amount)\n        public\n        accessible(_selectRole(bucket))\n        notInBlackList(recipient)\n    {\n        require(amount > 0, \"ERC20: Amount is zero\");\n        _decreaseShare(bucket, amount);\n\n        AccountState storage state = accounts[recipient];\n        state.available += amount;\n\n        emit MintType1(bucket, recipient, amount);\n    }\n\n    /// @dev batch execution of mint type 1.\n    function batchMint1(\n        Mint.Bucket[] memory buckets,\n        address[] memory recipients,\n        uint256[] memory amounts\n    ) external {\n        require(buckets.length == recipients.length, \"ERC20: Unmatched array length\");\n        require(recipients.length == amounts.length, \"ERC20: Unmatched array length\");\n\n        for (uint256 i = 0; i < recipients.length; i++) {\n            mint1(buckets[i], recipients[i], amounts[i]);\n        }\n    }\n\n    /// @dev mint type 2: mint to account with cliff vesting schedule.\n    function mint2(Mint.Bucket bucket, address recipient, uint256 expiration, uint256 amount)\n        public\n        accessible(_selectRole(bucket))\n        notInBlackList(recipient)\n    {\n        // solhint-disable-next-line not-rely-on-time\n        require(expiration > block.timestamp, \"ERC20: Expiration less than block time\");\n        require(amount > 0, \"ERC20: Amount is zero\");\n        _decreaseShare(bucket, amount);\n\n        AccountState storage state = accounts[recipient];\n        require(\n            state.cliffVesting.length + state.linearVesting.length < MAX_SCHEDULES,\n            \"ERC20: Too many vesting schedules\"\n        );\n        state.cliffVesting.push(Vesting.Cliff({\n            active: true,\n            bucket: bucket,\n            expiration: expiration.toUint64(),\n            amount: amount\n        }));\n\n        emit MintType2(bucket, recipient, expiration, amount);\n    }\n\n    /// @dev batch execution of mint type 2.\n    function batchMint2(\n        Mint.Bucket[] memory buckets,\n        address[] memory recipients,\n        uint256[] memory expirations,\n        uint256[] memory amounts\n    ) external {\n        require(buckets.length == recipients.length, \"ERC20: Unmatched array length\");\n        require(recipients.length == expirations.length, \"ERC20: Unmatched array length\");\n        require(expirations.length == amounts.length, \"ERC20: Unmatched array length\");\n\n        for (uint256 i = 0; i < recipients.length; i++) {\n            mint2(buckets[i], recipients[i], expirations[i], amounts[i]);\n        }\n    }\n\n    /// @dev Mint type 3: mint to account with linear vesting schedule.\n    function mint3(\n        Mint.Bucket bucket,\n        address recipient,\n        uint256 start,\n        uint256 end,\n        uint256 interval,\n        uint256 amount\n    )\n        public\n        accessible(_selectRole(bucket))\n        notInBlackList(recipient)\n    {\n        require(interval > 0, \"ERC20: Interval is zero\");\n        // solhint-disable-next-line not-rely-on-time\n        require(start > block.timestamp, \"ERC20: Start less than block time\");\n        require(start < end, \"ERC20: Start greater than end\");\n        require((end - start) % interval == 0, \"ERC20: Interval is indivisible\");\n        require(amount > 0, \"ERC20: Amount is zero\");\n        _decreaseShare(bucket, amount);\n\n        AccountState storage state = accounts[recipient];\n        require(\n            state.cliffVesting.length + state.linearVesting.length < MAX_SCHEDULES,\n            \"ERC20: Too many vesting schedules\"\n        );\n        state.linearVesting.push(Vesting.Linear({\n            active: true,\n            bucket: bucket,\n            start: start.toUint64(),\n            end: end.toUint64(),\n            interval: interval.toUint64(),\n            amount: amount\n        }));\n\n        emit MintType3(bucket, recipient, start, end, interval, amount);\n    }\n\n    /// @dev batch execution of mint type 3.\n    function batchMint3(\n        Mint.Bucket[] memory buckets,\n        address[] memory recipients,\n        uint256[] memory starts,\n        uint256[] memory ends,\n        uint256[] memory intervals,\n        uint256[] memory amounts\n    ) external {\n        require(buckets.length == recipients.length, \"ERC20: Unmatched array length\");\n        require(recipients.length == starts.length, \"ERC20: Unmatched array length\");\n        require(starts.length == ends.length, \"ERC20: Unmatched array length\");\n        require(ends.length == intervals.length, \"ERC20: Unmatched array length\");\n        require(intervals.length == amounts.length, \"ERC20: Unmatched array length\");\n\n        for (uint256 i = 0; i < recipients.length; i++) {\n            mint3(buckets[i], recipients[i], starts[i], ends[i], intervals[i], amounts[i]);\n        }\n    }\n\n    /// @dev recall vesting amount of a team member.\n    function recallTeamVesting(address account) external accessible(TEAM_ROLE) {\n        AccountState storage state = accounts[account];\n        _updateAccountState(state);\n\n        uint256 recycling = 0;\n        uint256 length = state.cliffVesting.length;\n        for (uint256 i = 0; i < length;) {\n            Vesting.Cliff storage vesting = state.cliffVesting[i];\n            if (vesting.active && vesting.bucket == Mint.Bucket.Team) {\n                vesting.active = false;\n                unchecked { recycling += vesting.amount; }\n            }\n            unchecked { i++; }\n        }\n\n        length = state.linearVesting.length;\n        for (uint256 i = 0; i < length;) {\n            Vesting.Linear storage vesting = state.linearVesting[i];\n            if (vesting.active && vesting.bucket == Mint.Bucket.Team) {\n                vesting.active = false;\n                unchecked { recycling += vesting.amount; }\n            }\n            unchecked { i++; }\n        }\n        // recycle to teamShare\n        _teamShare += recycling;\n\n        emit RecallTeamVesting(account, recycling);\n    }\n\n    /// @dev reduce share of specified `bucket`, add reduce `_totalSupply`.\n    function shrinkShare(Mint.Bucket bucket, uint256 amount) external onlyOwner {\n        require(amount > 0, \"ERC20: Amount is zero\");\n        _decreaseShare(bucket, amount);\n        _totalSupply -= amount;\n\n        emit ShrinkShare(bucket, amount);\n    }\n\n    ///////////////////////////// Internal Methods /////////////////////////////\n\n    function _selectRole(Mint.Bucket bucket) internal pure returns (bytes32) {\n        if (bucket == Mint.Bucket.EcoGrowth) {\n            return ECO_GROWTH_ROLE;\n        } else if (bucket == Mint.Bucket.Team) {\n            return TEAM_ROLE;\n        } else if (bucket == Mint.Bucket.Reserve) {\n            return RESERVE_ROLE;\n        } else {\n            revert(\"ERC20: Invalid mint bucket\");\n        }\n    }\n\n    function _decreaseShare(Mint.Bucket bucket, uint256 amount) internal {\n        if (bucket == Mint.Bucket.EcoGrowth) {\n            require(amount <= _ecoGrowthShare, \"ERC20: Insufficient share\");\n            _ecoGrowthShare -= amount;\n        } else if (bucket == Mint.Bucket.Team) {\n            require(amount <= _teamShare, \"ERC20: Insufficient share\");\n            _teamShare -= amount;\n        } else if (bucket == Mint.Bucket.Reserve) {\n            require(amount <= _reserveShare, \"ERC20: Insufficient share\");\n            _reserveShare -= amount;\n        } else {\n            revert(\"ERC20: Invalid mint bucket\");\n        }\n    }\n\n    /// @dev compute the releasing amount of vest part and even vest part.\n    function _updateAccountState(AccountState storage state) internal {\n        uint256 increased = 0;\n        uint256 released;\n        uint256 length = state.cliffVesting.length;\n        for (uint256 i = 0; i < length;) {\n            Vesting.Cliff storage vesting = state.cliffVesting[i];\n            // solhint-disable-next-line not-rely-on-time\n            released = vesting.updateCliff(block.timestamp);\n            unchecked {\n                increased += released;\n                i++;\n            }\n        }\n\n        length = state.linearVesting.length;\n        for (uint256 i = 0; i < length;) {\n            Vesting.Linear storage vesting = state.linearVesting[i];\n            // solhint-disable-next-line not-rely-on-time\n            released = vesting.updateLinear(block.timestamp);\n            unchecked {\n                increased += released;\n                i++;\n            }\n        }\n\n        state.available += increased;\n    }\n\n    /// @dev transfer {amount} from {_from} to {_to}.\n    /// @notice update account state firstly.\n    function _transfer(address from, address to, uint256 amount) internal {\n        require(to != address(0), \"ERC20: To address is zero\");\n\n        AccountState storage fromState = accounts[from];\n        _updateAccountState(fromState);\n        require(fromState.available >= amount, \"ERC20: Insufficient balance\");\n        fromState.available -= amount;\n\n        AccountState storage toState = accounts[to];\n        toState.available += amount;\n\n        emit Transfer(from, to, amount);\n    }\n\n    /// @dev approve {amount} of {spender} from {owner}\n    function _approve(address _owner, address spender, uint256 amount) internal {\n        require(spender != address(0), \"ERC20: Spender address is zero\");\n\n        _allowances[_owner][spender] = amount;\n        \n        emit Approval(_owner, spender, amount);\n    }\n\n    /// @dev burn {amount} of {applicant}, and reduce _totalSupply.\n    function _burn(address applicant, uint256 amount) internal {\n        AccountState storage state = accounts[applicant];\n        _updateAccountState(state);\n\n        require(state.available >= amount, \"ERC20: Insufficient balance\");\n        state.available -= amount;\n        _totalSupply -= amount;\n\n        emit Burn(applicant, amount);\n    }\n\n    /// @dev burn {amount} of {from} allowance for {applicant}, and reduce _totalSupply.\n    function _burnFrom(address applicant, address from, uint256 amount) internal {\n        uint256 _allowance = allowance(from, applicant);\n        require(amount <= _allowance, \"ERC20: Insufficient allowance\");\n        _allowances[from][applicant] = _allowance - amount;\n        \n        AccountState storage state = accounts[from];\n        _updateAccountState(state);\n\n        require(state.available >= amount, \"ERC20: Insufficient balance\");\n        state.available -= amount;\n        _totalSupply -= amount;\n\n        emit BurnFrom(applicant, from, amount);\n    }\n}"
      },
      "contracts/ERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"./interface/IERC20Permit.sol\";\nimport \"./ERC20.sol\";\nimport \"./library/CheckSig.sol\";\n\n/// @title ERC20 with permit, as defined in https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]\n/// @notice ERC20 tokens which supports approvement via signature\nabstract contract ERC20Permit is IERC20Permit, ERC20 {\n    using CheckSig for address;\n\n    bytes32 private constant NAME_HASH = keccak256(\"HSK\");\n\n    bytes32 private constant VERSION_HASH = keccak256(\"version 1\");\n\n    bytes32 private constant TYPE_HASH =\n        keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n    // solhint-disable-next-line var-name-mixedcase\n    bytes32 private constant PERMIT_TYPEHASH =\n        keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n    mapping(address => uint256) private _nonces;\n\n    /// @dev return user's current nonce and increase it.\n    function increaseNonce(address account) internal returns (uint256) {\n        uint256 n = _nonces[account];\n        _nonces[account]++;\n        return n;\n    }\n\n    /// @dev See in IERC20Permit\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() public view override returns (bytes32) {\n        return keccak256(abi.encode(TYPE_HASH, NAME_HASH, VERSION_HASH, block.chainid, address(this)));\n    }\n\n    /// @dev See in IERC20Permit.\n    function nonces(address account) public view override returns (uint256) {\n        return _nonces[account];\n    }\n\n    /// @dev See in IERC20Permit.\n    function permit(\n        address _owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    )\n        public\n        override\n        notInBlackList(_owner)\n        notInBlackList(spender)\n    {\n        // solhint-disable-next-line not-rely-on-time\n        require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n        bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, _owner, spender, value, increaseNonce(_owner), deadline));\n        bytes32 digest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR(), structHash);\n\n        _owner.checkSignature(digest, v, r, s);\n\n        _approve(_owner, spender, value);\n    }\n}"
      },
      "contracts/HSK.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"./ERC20Permit.sol\";\nimport \"./BurnPermit.sol\";\n\n/// @title HashKey Platform Token Contract\ncontract HSKImplementationV1 is BurnPermit, ERC20Permit {\n    receive() external payable {\n        revert(\"Contract is not payable\");\n    }\n}"
      },
      "contracts/interface/IERC20.sol": {
        "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n    \n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\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 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 Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}"
      },
      "contracts/interface/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}"
      },
      "contracts/library/CheckSig.sol": {
        "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/interfaces/IERC1271.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\nlibrary CheckSig {\n    /// @dev Check {from} has signed a hashed message {digest} with signature {v, r, s}.\n    function checkSignature(address from, bytes32 digest, uint8 v, bytes32 r, bytes32 s) internal view {\n        if (from.code.length > 0) {\n            // from is a contract\n            (bool success, bytes memory result) = from.staticcall(\n                abi.encodeWithSelector(IERC1271.isValidSignature.selector, digest, abi.encodePacked(r, s, v))\n            );\n            require(\n                success && result.length == 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector),\n                \"ERC1271: Unauthorized\"\n            );\n        } else {\n            require(ECDSA.recover(digest, v, r, s) == from, \"CheckSig: Unauthorized\");\n        }\n    }\n\n    /// @dev Check {from} has signed a hashed message {digest} with signature {sig}.\n    function checkSignature(address from, bytes32 digest, bytes memory sig) internal view {\n        if (from.code.length > 0) {\n            // from is a contract\n            (bool success, bytes memory result) = from.staticcall(\n                abi.encodeWithSelector(IERC1271.isValidSignature.selector, digest, sig)\n            );\n            require(\n                success && result.length == 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector),\n                \"ERC1271: Unauthorized\"\n            );\n        } else {\n            require(ECDSA.recover(digest, sig) == from, \"CheckSig: Unauthorized\");\n        }\n    }\n}"
      },
      "contracts/library/Mint.sol": {
        "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nlibrary Mint {\n    \n    enum Bucket {\n        // 0\n        EcoGrowth,\n        // 1\n        Team,\n        // 2\n        Reserve\n    }\n}"
      },
      "contracts/library/Vesting.sol": {
        "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"./Mint.sol\";\n\nlibrary Vesting {\n\n    /// Cliff Vesting defines `amount` tokens will be fully unlocked after `expiration`.\n    struct Cliff {\n        bool            active;\n        Mint.Bucket     bucket;\n        uint64          expiration;\n        uint256         amount;\n    }\n\n    /// Linear Vesting defines `amount` tokens will start unlocking linearly from `start` to `end`.\n    /// Tokens will unlock every `interval` seconds.\n    struct Linear {\n        bool            active;\n        Mint.Bucket     bucket;\n        uint64          start;\n        uint64          end;\n        uint64          interval;\n        uint256         amount;\n    }\n\n    /// @dev compute current (locking, released) amount of a Cliff Vesting.\n    function getCliff(Cliff storage vesting, uint256 timestamp) internal view returns (uint256, uint256) {\n        require(vesting.active, \"Cliff Vesting is not active\");\n\n        if (timestamp >= vesting.expiration) {\n            return (0, vesting.amount);\n        } else {\n            return (vesting.amount, 0);\n        }\n    }\n\n    /// @dev compute current (locking, released) amount of a Linear Vesting.\n    function getLinear(Linear storage vesting, uint256 timestamp) internal view returns (uint256, uint256) {\n        require(vesting.active, \"Linear Vesting is not active\");\n\n        if (timestamp <= vesting.start) {\n            return (vesting.amount, 0);\n        } else if (timestamp > vesting.start && timestamp < vesting.end) {\n            // the following computation will never overflow\n            unchecked {\n                // interval is always greater than 0 less than 1 year\n                uint256 iTimes = (timestamp - vesting.start) / vesting.interval;\n                uint256 nTimes = (vesting.end - vesting.start) / vesting.interval;\n                // nTimes interval is always greater\n                uint256 released = vesting.amount * iTimes / nTimes;\n                return (vesting.amount - released, released);\n            }\n        } else {\n            return (0, vesting.amount);\n        }\n    }\n\n    /// @dev update a Cliff Vesting, return the released amount.\n    function updateCliff(Cliff storage vesting, uint256 timestamp) internal returns (uint256) {\n        if (!vesting.active || timestamp < vesting.expiration) {\n            return 0;\n        }\n\n        vesting.active = false;\n        return vesting.amount;\n    }\n\n    /// @dev update a Linear Vesting, return the released amount.\n    function updateLinear(Linear storage vesting, uint256 timestamp) internal returns (uint256) {\n        if (!vesting.active || timestamp < vesting.start + vesting.interval) {\n            return 0;\n        }\n\n        if (timestamp < vesting.end) {\n            // the following computation will never overflow\n            unchecked {\n                uint256 iTimes = (timestamp - vesting.start) / vesting.interval;\n                uint256 nTimes = (vesting.end - vesting.start) / vesting.interval;\n                uint256 released = vesting.amount * iTimes / nTimes;\n                vesting.start = uint64(iTimes * vesting.interval + vesting.start);\n                vesting.amount = vesting.amount - released;\n                return released;\n            }\n        } else {\n            vesting.active = false;\n            return vesting.amount;\n        }\n    }\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 10000
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    }
  }}