{
    "Function": "slitherConstructorConstantVariables",
    "File": "src/libraries/Samples.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "library Samples {\n    using Encoder for uint256;\n    using Decoder for bytes32;\n\n    ///  [ cumulativeBinCrossed | cumulativeVolatilityAccumulated | cumulativeId | timestamp | initialized ]\n    ///  [        uint87        |              uint64             |    uint64    |   uint40  |    bool1    ]\n    /// MSB                                                                                               LSB\n\n    uint256 private constant _OFFSET_INITIALIZED = 0;\n    uint256 private constant _MASK_INITIALIZED = 1;\n\n    uint256 private constant _OFFSET_TIMESTAMP = 1;\n    uint256 private constant _MASK_TIMESTAMP = type(uint40).max;\n\n    uint256 private constant _OFFSET_CUMULATIVE_ID = 41;\n    uint256 private constant _MASK_CUMULATIVE_ID = type(uint64).max;\n\n    uint256 private constant _OFFSET_CUMULATIVE_VolatilityAccumulated = 105;\n    uint256 private constant _MASK_CUMULATIVE_VolatilityAccumulated = type(uint64).max;\n\n    uint256 private constant _OFFSET_CUMULATIVE_BIN_CROSSED = 169;\n    uint256 private constant _MASK_CUMULATIVE_BIN_CROSSED = 0x7fffffffffffffffffffff;\n\n    /// @notice Function to update a sample\n    /// @param _lastSample The latest sample of the oracle\n    /// @param _activeId The active index of the pair during the latest swap\n    /// @param _volatilityAccumulated The volatility accumulated of the pair during the latest swap\n    /// @param _binCrossed The bin crossed during the latest swap\n    /// @return packedSample The packed sample as bytes32\n    function update(\n        bytes32 _lastSample,\n        uint256 _activeId,\n        uint256 _volatilityAccumulated,\n        uint256 _binCrossed\n    ) internal view returns (bytes32 packedSample) {\n        uint256 _deltaTime = block.timestamp - timestamp(_lastSample);\n\n        // cumulative can overflow without any issue as what matter is the delta cumulative.\n        // It would be an issue if 2 overflows would happen but way too much time should elapsed for it to happen.\n        // The delta calculation needs to be unchecked math to allow for it to overflow again.\n        unchecked {\n            uint256 _cumulativeId = cumulativeId(_lastSample) + _activeId * _deltaTime;\n            uint256 _cumulativeVolatilityAccumulated = cumulativeVolatilityAccumulated(_lastSample) +\n                _volatilityAccumulated *\n                _deltaTime;\n            uint256 _cumulativeBinCrossed = cumulativeBinCrossed(_lastSample) + _binCrossed * _deltaTime;\n\n            return pack(_cumulativeBinCrossed, _cumulativeVolatilityAccumulated, _cumulativeId, block.timestamp, 1);\n        }\n    }\n\n    /// @notice Function to pack cumulative values\n    /// @param _cumulativeBinCrossed The cumulative bin crossed\n    /// @param _cumulativeVolatilityAccumulated The cumulative volatility accumulated\n    /// @param _cumulativeId The cumulative index\n    /// @param _timestamp The timestamp\n    /// @param _initialized The initialized value\n    /// @return packedSample The packed sample as bytes32\n    function pack(\n        uint256 _cumulativeBinCrossed,\n        uint256 _cumulativeVolatilityAccumulated,\n        uint256 _cumulativeId,\n        uint256 _timestamp,\n        uint256 _initialized\n    ) internal pure returns (bytes32 packedSample) {\n        return\n            _cumulativeBinCrossed.encode(_MASK_CUMULATIVE_BIN_CROSSED, _OFFSET_CUMULATIVE_BIN_CROSSED) |\n            _cumulativeVolatilityAccumulated.encode(\n                _MASK_CUMULATIVE_VolatilityAccumulated,\n                _OFFSET_CUMULATIVE_VolatilityAccumulated\n            ) |\n            _cumulativeId.encode(_MASK_CUMULATIVE_ID, _OFFSET_CUMULATIVE_ID) |\n            _timestamp.encode(_MASK_TIMESTAMP, _OFFSET_TIMESTAMP) |\n            _initialized.encode(_MASK_INITIALIZED, _OFFSET_INITIALIZED);\n    }\n\n    /// @notice View function to return the initialized value\n    /// @param _packedSample The packed sample\n    /// @return The initialized value\n    function initialized(bytes32 _packedSample) internal pure returns (uint256) {\n        return _packedSample.decode(_MASK_INITIALIZED, _OFFSET_INITIALIZED);\n    }\n\n    /// @notice View function to return the timestamp value\n    /// @param _packedSample The packed sample\n    /// @return The timestamp value\n    function timestamp(bytes32 _packedSample) internal pure returns (uint256) {\n        return _packedSample.decode(_MASK_TIMESTAMP, _OFFSET_TIMESTAMP);\n    }\n\n    /// @notice View function to return the cumulative id value\n    /// @param _packedSample The packed sample\n    /// @return The cumulative id value\n    function cumulativeId(bytes32 _packedSample) internal pure returns (uint256) {\n        return _packedSample.decode(_MASK_CUMULATIVE_ID, _OFFSET_CUMULATIVE_ID);\n    }\n\n    /// @notice View function to return the cumulative volatility accumulated value\n    /// @param _packedSample The packed sample\n    /// @return The cumulative volatility accumulated value\n    function cumulativeVolatilityAccumulated(bytes32 _packedSample) internal pure returns (uint256) {\n        return _packedSample.decode(_MASK_CUMULATIVE_VolatilityAccumulated, _OFFSET_CUMULATIVE_VolatilityAccumulated);\n    }\n\n    /// @notice View function to return the cumulative bin crossed value\n    /// @param _packedSample The packed sample\n    /// @return The cumulative bin crossed value\n    function cumulativeBinCrossed(bytes32 _packedSample) internal pure returns (uint256) {\n        return _packedSample.decode(_MASK_CUMULATIVE_BIN_CROSSED, _OFFSET_CUMULATIVE_BIN_CROSSED);\n    }\n}"
}