{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/types/LeftRight.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "library LeftRight {\n    using LeftRight for uint256;\n    using LeftRight for int256;\n    int256 internal constant RIGHT_HALF_BIT_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n    /*//////////////////////////////////////////////////////////////\n                              RIGHT SLOT\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice Get the \"right\" slot from a uint256 bit pattern.\n    /// @param self The uint256 (full 256 bits) to be cut in its right half\n    /// @return the right half of self (128 bits)\n    function rightSlot(uint256 self) internal pure returns (uint128) {\n        return uint128(self);\n    }\n\n    /// @notice Get the \"right\" slot from an int256 bit pattern.\n    /// @param self The int256 (full 256 bits) to be cut in its right half\n    /// @return the right half self (128 bits)\n    function rightSlot(int256 self) internal pure returns (int128) {\n        return int128(self);\n    }\n\n    /// @dev All toRightSlot functions add bits to the right slot without clearing it first\n    /// @dev Typically, the slot is already clear when writing to it, but if it is not, the bits will be added to the existing bits\n    /// @dev Therefore, the assumption must not be made that the bits will be cleared while using these helpers\n\n    /// @notice Write the \"right\" slot to a uint256.\n    /// @param self the original full uint256 bit pattern to be written to\n    /// @param right the bit pattern to write into the full pattern in the right half\n    /// @return self with incoming right added (not overwritten, but added) to its right 128 bits\n    function toRightSlot(uint256 self, uint128 right) internal pure returns (uint256) {\n        unchecked {\n            return self + uint256(right);\n        }\n    }\n\n    /// @notice Write the \"right\" slot to a uint256.\n    /// @param self the original full uint256 bit pattern to be written to\n    /// @param right the bit pattern to write into the full pattern in the right half\n    /// @return self with right added to its right 128 bits\n    function toRightSlot(uint256 self, int128 right) internal pure returns (uint256) {\n        if (right < 0) revert Errors.LeftRightInputError();\n        unchecked {\n            return self + uint256(int256(right));\n        }\n    }\n\n    /// @notice Write the \"right\" slot to an int256.\n    /// @param self the original full int256 bit pattern to be written to\n    /// @param right the bit pattern to write into the full pattern in the right half\n    /// @return self with right added to its right 128 bits\n    function toRightSlot(int256 self, uint128 right) internal pure returns (int256) {\n        unchecked {\n            return self + int256(uint256(right));\n        }\n    }\n\n    /// @notice Write the \"right\" slot to an int256.\n    /// @param self the original full int256 bit pattern to be written to\n    /// @param right the bit pattern to write into the full pattern in the right half\n    /// @return self with right added to its right 128 bits\n    function toRightSlot(int256 self, int128 right) internal pure returns (int256) {\n        // bit mask needed in case rightHalfBitPattern < 0 due to 2's complement\n        unchecked {\n            return self + (int256(right) & RIGHT_HALF_BIT_MASK);\n        }\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                              LEFT SLOT\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice Get the \"left\" half from a uint256 bit pattern.\n    /// @param self The uint256 (full 256 bits) to be cut in its left half\n    /// @return the left half (128 bits)\n    function leftSlot(uint256 self) internal pure returns (uint128) {\n        return uint128(self >> 128);\n    }\n\n    /// @notice Get the \"left\" half from an int256 bit pattern.\n    /// @param self The int256 (full 256 bits) to be cut in its left half\n    /// @return the left half (128 bits)\n    function leftSlot(int256 self) internal pure returns (int128) {\n        return int128(self >> 128);\n    }\n\n    /// @dev All toLeftSlot functions add bits to the left slot without clearing it first\n    /// @dev Typically, the slot is already clear when writing to it, but if it is not, the bits will be added to the existing bits\n    /// @dev Therefore, the assumption must not be made that the bits will be cleared while using these helpers\n\n    /// @notice Write the \"left\" slot to a uint256 bit pattern.\n    /// @param self the original full uint256 bit pattern to be written to\n    /// @param left the bit pattern to write into the full pattern in the right half\n    /// @return self with left added to its left 128 bits\n    function toLeftSlot(uint256 self, uint128 left) internal pure returns (uint256) {\n        unchecked {\n            return self + (uint256(left) << 128);\n        }\n    }\n\n    /// @notice Write the \"left\" slot to an int256 bit pattern.\n    /// @param self the original full int256 bit pattern to be written to\n    /// @param left the bit pattern to write into the full pattern in the right half\n    /// @return self with left added to its left 128 bits\n    function toLeftSlot(int256 self, uint128 left) internal pure returns (int256) {\n        unchecked {\n            return self + (int256(int128(left)) << 128);\n        }\n    }\n\n    /// @notice Write the \"left\" slot to an int256 bit pattern.\n    /// @param self the original full int256 bit pattern to be written to\n    /// @param left the bit pattern to write into the full pattern in the right half\n    /// @return self with left added to its left 128 bits\n    function toLeftSlot(int256 self, int128 left) internal pure returns (int256) {\n        unchecked {\n            return self + (int256(left) << 128);\n        }\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            MATH HELPERS\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice Add two uint256 bit LeftRight-encoded words; revert on overflow or underflow.\n    /// @param x the augend\n    /// @param y the addend\n    /// @return z the sum x + y\n    function add(uint256 x, uint256 y) internal pure returns (uint256 z) {\n        unchecked {\n            // adding leftRight packed uint128's is same as just adding the values explictily\n            // given that we check for overflows of the left and right values\n            z = x + y;\n\n            // on overflow z will be less than either x or y\n            // type cast z to uint128 to isolate the right slot and if it's lower than a value it's comprised of (x)\n            // then an overflow has occured\n            if (z < x || (uint128(z) < uint128(x))) revert Errors.UnderOverFlow();\n        }\n    }\n\n    /// @notice Add two int256 bit LeftRight-encoded words; revert on overflow.\n    /// @param x the augend\n    /// @param y the addend\n    /// @return z the sum x + y\n    function add(int256 x, int256 y) internal pure returns (int256 z) {\n        unchecked {\n            int256 left256 = int256(x.leftSlot()) + y.leftSlot();\n            int128 left128 = int128(left256);\n\n            int256 right256 = int256(x.rightSlot()) + y.rightSlot();\n            int128 right128 = int128(right256);\n\n            if (left128 != left256 || right128 != right256) revert Errors.UnderOverFlow();\n\n            return z.toRightSlot(right128).toLeftSlot(left128);\n        }\n    }\n\n    /// @notice Subtract two int256 bit LeftRight-encoded words; revert on overflow.\n    /// @param x the minuend\n    /// @param y the subtrahend\n    /// @return z the difference x - y\n    function sub(int256 x, int256 y) internal pure returns (int256 z) {\n        unchecked {\n            int256 left256 = int256(x.leftSlot()) - y.leftSlot();\n            int128 left128 = int128(left256);\n\n            int256 right256 = int256(x.rightSlot()) - y.rightSlot();\n            int128 right128 = int128(right256);\n\n            if (left128 != left256 || right128 != right256) revert Errors.UnderOverFlow();\n\n            return z.toRightSlot(right128).toLeftSlot(left128);\n        }\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            SAFE CASTING\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice Cast an int256 to an int128, revert on overflow or underflow.\n    /// @param self the int256 to be downcasted to int128\n    /// @return selfAsInt128 the downcasted integer, now of type int128\n    function toInt128(int256 self) internal pure returns (int128 selfAsInt128) {\n        if (!((selfAsInt128 = int128(self)) == self)) revert Errors.CastingError();\n    }\n\n    /// @notice Downcast uint256 to a uint128, revert on overflow\n    /// @param self the uint256 to be downcasted to uint128\n    /// @return selfAsUint128 the downcasted uint256 now as uint128\n    function toUint128(uint256 self) internal pure returns (uint128 selfAsUint128) {\n        if (!((selfAsUint128 = uint128(self)) == self)) revert Errors.CastingError();\n    }\n\n    /// @notice Cast a uint256 to an int256, revert on overflow\n    /// @param self the uint256 to be downcasted to uint128\n    /// @return the incoming uint256 but now of type int256\n    function toInt256(uint256 self) internal pure returns (int256) {\n        if (self > uint256(type(int256).max)) revert Errors.CastingError();\n        return int256(self);\n    }\n}"
}