creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/utils/math/SafeMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\n */\nlibrary SafeMath {\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a + b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a * b;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator.\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a % b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {trySub}.\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        unchecked {\n            require(b <= a, errorMessage);\n            return a - b;\n        }\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        unchecked {\n            require(b > 0, errorMessage);\n            return a / b;\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting with custom message when dividing by zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryMod}.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        unchecked {\n            require(b > 0, errorMessage);\n            return a % b;\n        }\n    }\n}\n"
      },
      "contracts/mainnet/common/basic.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\nimport { TokenInterface } from \"./interfaces.sol\";\nimport { Stores } from \"./stores.sol\";\nimport { DSMath } from \"./math.sol\";\n\nabstract contract Basic is DSMath, Stores {\n\n    function convert18ToDec(uint _dec, uint256 _amt) internal pure returns (uint256 amt) {\n        amt = (_amt / 10 ** (18 - _dec));\n    }\n\n    function convertTo18(uint _dec, uint256 _amt) internal pure returns (uint256 amt) {\n        amt = mul(_amt, 10 ** (18 - _dec));\n    }\n\n    function getTokenBal(TokenInterface token) internal view returns(uint _amt) {\n        _amt = address(token) == ethAddr ? address(this).balance : token.balanceOf(address(this));\n    }\n\n    function getTokensDec(TokenInterface buyAddr, TokenInterface sellAddr) internal view returns(uint buyDec, uint sellDec) {\n        buyDec = address(buyAddr) == ethAddr ?  18 : buyAddr.decimals();\n        sellDec = address(sellAddr) == ethAddr ?  18 : sellAddr.decimals();\n    }\n\n    function encodeEvent(string memory eventName, bytes memory eventParam) internal pure returns (bytes memory) {\n        return abi.encode(eventName, eventParam);\n    }\n\n    function approve(TokenInterface token, address spender, uint256 amount) internal {\n        try token.approve(spender, amount) {\n\n        } catch {\n            token.approve(spender, 0);\n            token.approve(spender, amount);\n        }\n    }\n\n    function changeEthAddress(address buy, address sell) internal pure returns(TokenInterface _buy, TokenInterface _sell){\n        _buy = buy == ethAddr ? TokenInterface(wethAddr) : TokenInterface(buy);\n        _sell = sell == ethAddr ? TokenInterface(wethAddr) : TokenInterface(sell);\n    }\n\n    function changeEthAddrToWethAddr(address token) internal pure returns(address tokenAddr){\n        tokenAddr = token == ethAddr ? wethAddr : token;\n    }\n\n    function convertEthToWeth(bool isEth, TokenInterface token, uint amount) internal {\n        if(isEth) token.deposit{value: amount}();\n    }\n\n    function convertWethToEth(bool isEth, TokenInterface token, uint amount) internal {\n       if(isEth) {\n            approve(token, address(token), amount);\n            token.withdraw(amount);\n        }\n    }\n}\n"
      },
      "contracts/mainnet/common/interfaces.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\ninterface TokenInterface {\n    function approve(address, uint256) external;\n    function transfer(address, uint) external;\n    function transferFrom(address, address, uint) external;\n    function deposit() external payable;\n    function withdraw(uint) external;\n    function balanceOf(address) external view returns (uint);\n    function decimals() external view returns (uint);\n    function totalSupply() external view returns (uint);\n    function allowance(address owner, address spender) external view returns (uint256);\n}\n\ninterface MemoryInterface {\n    function getUint(uint id) external returns (uint num);\n    function setUint(uint id, uint val) external;\n}\n\ninterface InstaMapping {\n    function cTokenMapping(address) external view returns (address);\n    function gemJoinMapping(bytes32) external view returns (address);\n}\n\ninterface AccountInterface {\n    function enable(address) external;\n    function disable(address) external;\n    function isAuth(address) external view returns (bool);\n    function cast(\n        string[] calldata _targetNames,\n        bytes[] calldata _datas,\n        address _origin\n    ) external payable returns (bytes32[] memory responses);\n}\n\ninterface ListInterface {\n    function accountID(address) external returns (uint64);\n}\n\ninterface InstaConnectors {\n    function isConnectors(string[] calldata) external returns (bool, address[] memory);\n}"
      },
      "contracts/mainnet/common/math.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\nimport { SafeMath } from \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\ncontract DSMath {\n  uint constant WAD = 10 ** 18;\n  uint constant RAY = 10 ** 27;\n\n  function add(uint x, uint y) internal pure returns (uint z) {\n    z = SafeMath.add(x, y);\n  }\n\n  function sub(uint x, uint y) internal virtual pure returns (uint z) {\n    z = SafeMath.sub(x, y);\n  }\n\n  function mul(uint x, uint y) internal pure returns (uint z) {\n    z = SafeMath.mul(x, y);\n  }\n\n  function div(uint x, uint y) internal pure returns (uint z) {\n    z = SafeMath.div(x, y);\n  }\n\n  function wmul(uint x, uint y) internal pure returns (uint z) {\n    z = SafeMath.add(SafeMath.mul(x, y), WAD / 2) / WAD;\n  }\n\n  function wdiv(uint x, uint y) internal pure returns (uint z) {\n    z = SafeMath.add(SafeMath.mul(x, WAD), y / 2) / y;\n  }\n\n  function rdiv(uint x, uint y) internal pure returns (uint z) {\n    z = SafeMath.add(SafeMath.mul(x, RAY), y / 2) / y;\n  }\n\n  function rmul(uint x, uint y) internal pure returns (uint z) {\n    z = SafeMath.add(SafeMath.mul(x, y), RAY / 2) / RAY;\n  }\n\n  function toInt(uint x) internal pure returns (int y) {\n    y = int(x);\n    require(y >= 0, \"int-overflow\");\n  }\n\n  function toUint(int256 x) internal pure returns (uint256) {\n      require(x >= 0, \"int-overflow\");\n      return uint256(x);\n  }\n\n  function toRad(uint wad) internal pure returns (uint rad) {\n    rad = mul(wad, 10 ** 27);\n  }\n\n}"
      },
      "contracts/mainnet/common/stores.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.2;\n\nimport { MemoryInterface, InstaMapping, ListInterface, InstaConnectors } from \"./interfaces.sol\";\n\n\nabstract contract Stores {\n\n  /**\n   * @dev Return ethereum address\n   */\n  address constant internal ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n  /**\n   * @dev Return Wrapped ETH address\n   */\n  address constant internal wethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n\n  /**\n   * @dev Return memory variable address\n   */\n  MemoryInterface constant internal instaMemory = MemoryInterface(0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F);\n\n  /**\n   * @dev Return InstaDApp Mapping Addresses\n   */\n  InstaMapping constant internal instaMapping = InstaMapping(0xe81F70Cc7C0D46e12d70efc60607F16bbD617E88);\n\n  /**\n   * @dev Return InstaList Address\n   */\n  ListInterface internal constant instaList = ListInterface(0x4c8a1BEb8a87765788946D6B19C6C6355194AbEb);\n\n  /**\n\t * @dev Return connectors registry address\n\t */\n\tInstaConnectors internal constant instaConnectors = InstaConnectors(0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11);\n\n  /**\n   * @dev Get Uint value from InstaMemory Contract.\n   */\n  function getUint(uint getId, uint val) internal returns (uint returnVal) {\n    returnVal = getId == 0 ? val : instaMemory.getUint(getId);\n  }\n\n  /**\n  * @dev Set Uint value in InstaMemory Contract.\n  */\n  function setUint(uint setId, uint val) virtual internal {\n    if (setId != 0) instaMemory.setUint(setId, val);\n  }\n\n}"
      },
      "contracts/mainnet/connectors/weeth/events.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ncontract Events {\n    event LogDeposit(\n        uint256 eETHAmount,\n        uint256 weETHAmount,\n        uint256 getId,\n        uint256 setId\n    );\n    event LogWithdraw(\n        uint256 weETHAmount,\n        uint256 eETHAmount,\n        uint256 getId,\n        uint256 setId\n    );\n}\n"
      },
      "contracts/mainnet/connectors/weeth/helpers.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport \"./interfaces.sol\";\nimport {TokenInterface} from \"../../common/interfaces.sol\";\n\ncontract Helpers {\n    IWEETH internal constant WEETH_CONTRACT =\n        IWEETH(0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee);\n\n    TokenInterface internal constant EETH_CONTRACT =\n        TokenInterface(0x35fA164735182de50811E8e2E824cFb9B6118ac2);\n}\n"
      },
      "contracts/mainnet/connectors/weeth/interfaces.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\ninterface IWEETH {\n    function balanceOf(address account) external view returns (uint256);\n    function wrap(uint256 _eETHAmount) external returns (uint256);\n    function unwrap(uint256 _weETHAmount) external returns (uint256);\n}\n"
      },
      "contracts/mainnet/connectors/weeth/main.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport \"./helpers.sol\";\nimport \"./events.sol\";\nimport {Basic} from \"../../common/basic.sol\";\n\ncontract WEETHContract is Helpers, Basic, Events {\n    /**\n     * @dev Deposit eETH into weETH.\n     * @notice Wrap eETH into weETH\n     * @param eETHAmount The amount of eETH to deposit. (For max: `uint256(-1)`)\n     * @param getId ID to retrieve eETH amount.\n     * @param setId ID stores the amount of weETH deposited.\n     */\n    function deposit(\n        uint256 eETHAmount,\n        uint256 getId,\n        uint256 setId\n    ) external returns (string memory _eventName, bytes memory _eventParam) {\n        uint256 _eETHAmount = getUint(getId, eETHAmount);\n        _eETHAmount = _eETHAmount == type(uint256).max\n            ? EETH_CONTRACT.balanceOf(address(this))\n            : _eETHAmount;\n\n        approve(EETH_CONTRACT, address(WEETH_CONTRACT), _eETHAmount);\n        uint256 _weETHAmount = WEETH_CONTRACT.wrap(_eETHAmount);\n\n        setUint(setId, _weETHAmount);\n\n        _eventName = \"LogDeposit(uint256,uint256,uint256,uint256)\";\n        _eventParam = abi.encode(_eETHAmount, _weETHAmount, getId, setId);\n    }\n\n    /**\n     * @dev Withdraw eETH from weETH from Smart Account\n     * @notice Unwrap eETH from weETH\n     * @param weETHAmount The amount of weETH to withdraw. (For max: `uint256(-1)`)\n     * @param getId ID to retrieve weETH amount.\n     * @param setId ID stores the amount of eETH.\n     */\n    function withdraw(\n        uint256 weETHAmount,\n        uint256 getId,\n        uint256 setId\n    ) external returns (string memory _eventName, bytes memory _eventParam) {\n        uint256 _weETHAmount = getUint(getId, weETHAmount);\n        _weETHAmount = _weETHAmount == type(uint256).max\n            ? WEETH_CONTRACT.balanceOf(address(this))\n            : _weETHAmount;\n\n        uint256 _eETHAmount = WEETH_CONTRACT.unwrap(_weETHAmount);\n        setUint(setId, _eETHAmount);\n\n        _eventName = \"LogWithdraw(uint256,uint256,uint256,uint256)\";\n        _eventParam = abi.encode(_weETHAmount, _eETHAmount, getId, setId);\n    }\n}\n\ncontract ConnectV2WEETH is WEETHContract {\n    string public constant name = \"WEETH-v1.0\";\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}