{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/contracts/nomad-core/libs/ExcessivelySafeCall.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "library ExcessivelySafeCall {\n  uint256 constant LOW_28_MASK = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\n\n  /// @notice Use when you _really_ really _really_ don't trust the called\n  /// contract. This prevents the called contract from causing reversion of\n  /// the caller in as many ways as we can.\n  /// @dev The main difference between this and a solidity low-level call is\n  /// that we limit the number of bytes that the callee can cause to be\n  /// copied to caller memory. This prevents stupid things like malicious\n  /// contracts returning 10,000,000 bytes causing a local OOG when copying\n  /// to memory.\n  /// @param _target The address to call\n  /// @param _gas The amount of gas to forward to the remote contract\n  /// @param _value The value in wei to send to the remote contract\n  /// @param _maxCopy The maximum number of bytes of returndata to copy\n  /// to memory.\n  /// @param _calldata The data to send to the remote contract\n  /// @return success and returndata, as `.call()`. Returndata is capped to\n  /// `_maxCopy` bytes.\n  function excessivelySafeCall(\n    address _target,\n    uint256 _gas,\n    uint256 _value,\n    uint16 _maxCopy,\n    bytes memory _calldata\n  ) internal returns (bool, bytes memory) {\n    // set up for assembly call\n    uint256 _toCopy;\n    bool _success;\n    bytes memory _returnData = new bytes(_maxCopy);\n    // dispatch message to recipient\n    // by assembly calling \"handle\" function\n    // we call via assembly to avoid memcopying a very large returndata\n    // returned by a malicious contract\n    assembly {\n      _success := call(\n        _gas, // gas\n        _target, // recipient\n        _value, // ether value\n        add(_calldata, 0x20), // inloc\n        mload(_calldata), // inlen\n        0, // outloc\n        0 // outlen\n      )\n      // limit our copy to 256 bytes\n      _toCopy := returndatasize()\n      if gt(_toCopy, _maxCopy) {\n        _toCopy := _maxCopy\n      }\n      // Store the length of the copied bytes\n      mstore(_returnData, _toCopy)\n      // copy the bytes from returndata[0:_toCopy]\n      returndatacopy(add(_returnData, 0x20), 0, _toCopy)\n    }\n    return (_success, _returnData);\n  }\n\n  /// @notice Use when you _really_ really _really_ don't trust the called\n  /// contract. This prevents the called contract from causing reversion of\n  /// the caller in as many ways as we can.\n  /// @dev The main difference between this and a solidity low-level call is\n  /// that we limit the number of bytes that the callee can cause to be\n  /// copied to caller memory. This prevents stupid things like malicious\n  /// contracts returning 10,000,000 bytes causing a local OOG when copying\n  /// to memory.\n  /// @param _target The address to call\n  /// @param _gas The amount of gas to forward to the remote contract\n  /// @param _maxCopy The maximum number of bytes of returndata to copy\n  /// to memory.\n  /// @param _calldata The data to send to the remote contract\n  /// @return success and returndata, as `.call()`. Returndata is capped to\n  /// `_maxCopy` bytes.\n  function excessivelySafeStaticCall(\n    address _target,\n    uint256 _gas,\n    uint16 _maxCopy,\n    bytes memory _calldata\n  ) internal view returns (bool, bytes memory) {\n    // set up for assembly call\n    uint256 _toCopy;\n    bool _success;\n    bytes memory _returnData = new bytes(_maxCopy);\n    // dispatch message to recipient\n    // by assembly calling \"handle\" function\n    // we call via assembly to avoid memcopying a very large returndata\n    // returned by a malicious contract\n    assembly {\n      _success := staticcall(\n        _gas, // gas\n        _target, // recipient\n        add(_calldata, 0x20), // inloc\n        mload(_calldata), // inlen\n        0, // outloc\n        0 // outlen\n      )\n      // limit our copy to 256 bytes\n      _toCopy := returndatasize()\n      if gt(_toCopy, _maxCopy) {\n        _toCopy := _maxCopy\n      }\n      // Store the length of the copied bytes\n      mstore(_returnData, _toCopy)\n      // copy the bytes from returndata[0:_toCopy]\n      returndatacopy(add(_returnData, 0x20), 0, _toCopy)\n    }\n    return (_success, _returnData);\n  }\n\n  /**\n   * @notice Swaps function selectors in encoded contract calls\n   * @dev Allows reuse of encoded calldata for functions with identical\n   * argument types but different names. It simply swaps out the first 4 bytes\n   * for the new selector. This function modifies memory in place, and should\n   * only be used with caution.\n   * @param _newSelector The new 4-byte selector\n   * @param _buf The encoded contract args\n   */\n  function swapSelector(bytes4 _newSelector, bytes memory _buf) internal pure {\n    require(_buf.length >= 4);\n    uint256 _mask = LOW_28_MASK;\n    assembly {\n      // load the first word of\n      let _word := mload(add(_buf, 0x20))\n      // mask out the top 4 bytes\n      // /x\n      _word := and(_word, _mask)\n      _word := or(_newSelector, _word)\n      mstore(add(_buf, 0x20), _word)\n    }\n  }\n}"
}