creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@uniswap/lib/contracts/libraries/TransferHelper.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity >=0.6.0;\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n    function safeApprove(\n        address token,\n        address to,\n        uint256 value\n    ) internal {\n        // bytes4(keccak256(bytes('approve(address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            'TransferHelper::safeApprove: approve failed'\n        );\n    }\n\n    function safeTransfer(\n        address token,\n        address to,\n        uint256 value\n    ) internal {\n        // bytes4(keccak256(bytes('transfer(address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            'TransferHelper::safeTransfer: transfer failed'\n        );\n    }\n\n    function safeTransferFrom(\n        address token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));\n        require(\n            success && (data.length == 0 || abi.decode(data, (bool))),\n            'TransferHelper::transferFrom: transferFrom failed'\n        );\n    }\n\n    function safeTransferETH(address to, uint256 value) internal {\n        (bool success, ) = to.call{value: value}(new bytes(0));\n        require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');\n    }\n}\n"
      },
      "contracts/core/ICore.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\ninterface ICore {\n    // ----------- Getters -----------\n\n    function isBurner(address _address) external view returns (bool);\n\n    function isMinter(address _address) external view returns (bool);\n\n    function isGovernor(address _address) external view returns (bool);\n\n    function isGuardian(address _address) external view returns (bool);\n}\n"
      },
      "contracts/FewWrappedToken.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity =0.6.6;\n\nimport '@uniswap/lib/contracts/libraries/TransferHelper.sol';\n\nimport './interfaces/IFewWrappedToken.sol';\nimport './libraries/SafeMath.sol';\nimport './refs/ICoreRef.sol';\nimport './interfaces/IFewFactory.sol';\n\n/// @title Few Wrapped Token\ncontract FewWrappedToken is IFewWrappedToken {\n    using SafeMath for uint;\n\n    string public override name;\n    string public override symbol;\n    uint8 public override decimals;\n    uint  public override totalSupply;\n    mapping(address => uint) public override balanceOf;\n    mapping(address => mapping(address => uint)) public override allowance;\n\n    bytes32 public override DOMAIN_SEPARATOR;\n    // keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n    bytes32 public override constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;\n    mapping(address => uint) public override nonces;\n\n    address public override factory;\n    address public override token;\n\n    modifier onlyMinter() {\n        require(ICoreRef(factory).core().isMinter(msg.sender), \"CoreRef: Caller is not a minter\");\n        _;\n    }\n\n    modifier onlyBurner() {\n        require(ICoreRef(factory).core().isBurner(msg.sender), \"CoreRef: Caller is not a burner\");\n        _;\n    }\n\n    modifier whenNotPaused() {\n        require(!IFewFactory(factory).paused(), \"CoreRef: Caller is paused\");\n        _;\n    }\n\n    event Mint(address indexed minter, uint256 amount, address indexed to);\n    event Burn(address indexed burner, uint256 amount, address indexed to);\n    event Wrap(address indexed sender, uint256 amount, address indexed to);\n    event Unwrap(address indexed sender, uint256 amount, address indexed to);\n\n    /// @notice Few wrapped token constructor\n    constructor() public {\n        uint chainId;\n        assembly {\n            chainId := chainid()\n        }\n\n        factory = msg.sender;\n        token = IFewFactory(msg.sender).parameter();\n        name = string(abi.encodePacked(\"Few Wrapped \", IERC20(token).name()));\n        symbol = string(abi.encodePacked(\"fw\", IERC20(token).symbol()));\n        decimals = IERC20(token).decimals();\n\n        DOMAIN_SEPARATOR = keccak256(\n            abi.encode(\n                keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),\n                keccak256(bytes(name)),\n                keccak256(bytes('1')),\n                chainId,\n                address(this)\n            )\n        );\n    }\n\n    function _mint(address to, uint value) internal {\n        totalSupply = totalSupply.add(value);\n        balanceOf[to] = balanceOf[to].add(value);\n        emit Transfer(address(0), to, value);\n    }\n\n    function _burn(address from, uint value) internal {\n        balanceOf[from] = balanceOf[from].sub(value);\n        totalSupply = totalSupply.sub(value);\n        emit Transfer(from, address(0), value);\n    }\n\n    function _approve(address owner, address spender, uint value) internal {\n        allowance[owner][spender] = value;\n        emit Approval(owner, spender, value);\n    }\n\n    function _transfer(address from, address to, uint value) private {\n        balanceOf[from] = balanceOf[from].sub(value);\n        balanceOf[to] = balanceOf[to].add(value);\n        emit Transfer(from, to, value);\n    }\n\n    function approve(address spender, uint value) external override returns (bool) {\n        _approve(msg.sender, spender, value);\n        return true;\n    }\n\n    function transfer(address to, uint value) external override returns (bool) {\n        _transfer(msg.sender, to, value);\n        return true;\n    }\n\n    function transferFrom(address from, address to, uint value) external override returns (bool) {\n        if (allowance[from][msg.sender] != uint(-1)) {\n            allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);\n        }\n        _transfer(from, to, value);\n        return true;\n    }\n\n    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external override {\n        require(deadline >= block.timestamp, 'Few: EXPIRED');\n        bytes32 digest = keccak256(\n            abi.encodePacked(\n                '\\x19\\x01',\n                DOMAIN_SEPARATOR,\n                keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))\n            )\n        );\n        address recoveredAddress = ecrecover(digest, v, r, s);\n        require(recoveredAddress != address(0) && recoveredAddress == owner, 'Few: INVALID_SIGNATURE');\n        _approve(owner, spender, value);\n    }\n\n    /// @notice mint Few wrapped tokens\n    /// @param account the account to mint to\n    /// @param amount the amount to mint\n    function mint(address account, uint256 amount)\n        external\n        override\n        onlyMinter\n        whenNotPaused\n    {\n        _mint(account, amount);\n        emit Mint(msg.sender, amount, account);\n    }\n\n    /// @notice burn Few wrapped tokens from caller\n    /// @param amount the amount to burn\n    function burn(uint256 amount) public override {\n        _burn(msg.sender, amount);\n        emit Burn(msg.sender, amount, msg.sender);\n    }\n\n    /// @notice burn Few wrapped tokens from specified account\n    /// @param account the account to burn from\n    /// @param amount the amount to burn\n    function burnFrom(address account, uint256 amount)\n        public\n        override\n        onlyBurner\n        whenNotPaused\n    {\n        _burn(account, amount);\n        emit Burn(msg.sender, amount, account);\n    }\n\n    /// @notice exchanges token to Few wrapped token\n    /// @param amount the amount to wrap\n    /// @param to wrapped token reciver address\n    function wrapTo(uint256 amount, address to) public override returns (uint256) {\n        require(amount > 0, \"Few: can't wrap zero token\");\n        TransferHelper.safeTransferFrom(token, msg.sender, address(this), amount);\n        _mint(to, amount);\n        emit Wrap(msg.sender, amount, to);\n        return amount;\n    }\n\n    function wrap(uint256 amount) external override returns (uint256) {\n        return wrapTo(amount, msg.sender);\n    }\n\n    /// @notice exchange Few wrapped token to token\n    /// @param amount the amount to unwrap\n    /// @param to token receiver address\n    function unwrapTo(uint256 amount, address to) public override returns (uint256) {\n        require(amount > 0, \"Few: zero amount unwrap not allowed\");\n        _burn(msg.sender, amount);\n        TransferHelper.safeTransfer(address(token), to, amount);\n        emit Unwrap(msg.sender, amount, to);\n        return amount;\n    }\n\n    function unwrap(uint256 amount) external override returns (uint256) {\n        return unwrapTo(amount, msg.sender);\n    }\n}\n"
      },
      "contracts/interfaces/IERC20.sol": {
        "content": "pragma solidity >=0.5.0;\n\ninterface IERC20 {\n    event Approval(address indexed owner, address indexed spender, uint value);\n    event Transfer(address indexed from, address indexed to, uint value);\n\n    function name() external view returns (string memory);\n    function symbol() external view returns (string memory);\n    function decimals() external view returns (uint8);\n    function totalSupply() external view returns (uint);\n    function balanceOf(address owner) external view returns (uint);\n    function allowance(address owner, address spender) external view returns (uint);\n\n    function approve(address spender, uint value) external returns (bool);\n    function transfer(address to, uint value) external returns (bool);\n    function transferFrom(address from, address to, uint value) external returns (bool);\n}\n"
      },
      "contracts/interfaces/IFewERC20.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport './IERC20.sol';\n\ninterface IFewERC20 is IERC20 {\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n    function PERMIT_TYPEHASH() external pure returns (bytes32);\n    function nonces(address owner) external view returns (uint);\n\n    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n}\n"
      },
      "contracts/interfaces/IFewFactory.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\ninterface IFewFactory {\n    event WrappedTokenCreated(address indexed originalToken, address wrappedToken, uint);\n\n    function getWrappedToken(address originalToken) external view returns (address wrappedToken);\n    function allWrappedTokens(uint) external view returns (address wrappedToken);\n    function parameter() external view returns (address);\n    function allWrappedTokensLength() external view returns (uint);\n    function paused() external view returns (bool);\n    function createToken(address originalToken) external returns (address wrappedToken);\n}\n"
      },
      "contracts/interfaces/IFewWrappedToken.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport '../interfaces/IFewERC20.sol';\n\ninterface IFewWrappedToken is IFewERC20 {\n    event Mint(address indexed minter, uint256 amount, address indexed to);\n    event Burn(address indexed burner, uint256 amount, address indexed to);\n    event Wrap(address indexed sender, uint256 amount, address indexed to);\n    event Unwrap(address indexed sender, uint256 amount, address indexed to);\n\n    function factory() external view returns (address);\n    function token() external view returns (address);\n\n    function mint(address account, uint256 amount) external;\n    function burn(uint256 amount) external;\n    function burnFrom(address account, uint256 amount) external;\n    function wrapTo(uint256 amount, address to) external returns (uint256);\n    function wrap(uint256 amount) external returns (uint256);\n    function unwrapTo(uint256 amount, address to) external returns (uint256);\n    function unwrap(uint256 amount) external returns (uint256);\n}\n"
      },
      "contracts/libraries/SafeMath.sol": {
        "content": "pragma solidity =0.6.6;\n\n// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)\n\nlibrary SafeMath {\n    function add(uint x, uint y) internal pure returns (uint z) {\n        require((z = x + y) >= x, 'ds-math-add-overflow');\n    }\n\n    function sub(uint x, uint y) internal pure returns (uint z) {\n        require((z = x - y) <= x, 'ds-math-sub-underflow');\n    }\n\n    function mul(uint x, uint y) internal pure returns (uint z) {\n        require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');\n    }\n}\n"
      },
      "contracts/refs/ICoreRef.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport '../core/ICore.sol';\n\n/// @title CoreRef interface\ninterface ICoreRef {\n    event CoreUpdate(address indexed _core);\n\n    function setCore(address coreAddress) external;\n    function pause() external;\n    function unpause() external;\n    function core() external view returns (ICore);\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 999999
      },
      "evmVersion": "istanbul",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}