{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/Twav/Twav.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract Twav {\n    struct TwavObservation {\n        uint32 timestamp;\n        uint256 cumulativeValuation;\n    }\n\n    /// @notice current index of twavObservations index\n    uint8 public twavObservationsIndex;\n    uint8 private constant TWAV_BLOCK_NUMBERS = 4; //TWAV of last 4 Blocks \n    uint32 public lastBlockTimeStamp;\n\n    /// @notice record of TWAV \n    TwavObservation[TWAV_BLOCK_NUMBERS] public twavObservations;\n\n    /// @notice updates twavObservations array\n    /// @param _blockTimestamp timestamp of the block\n    /// @param _valuation current valuation\n    function _updateTWAV(uint256 _valuation, uint32 _blockTimestamp) internal {\n        uint32 _timeElapsed; \n        unchecked {\n            _timeElapsed = _blockTimestamp - lastBlockTimeStamp;\n        }\n\n        uint256 _prevCumulativeValuation = twavObservations[((twavObservationsIndex + TWAV_BLOCK_NUMBERS) - 1) % TWAV_BLOCK_NUMBERS].cumulativeValuation;\n        twavObservations[twavObservationsIndex] = TwavObservation(_blockTimestamp, _prevCumulativeValuation + (_valuation * _timeElapsed)); //add the previous observation to make it cumulative\n        twavObservationsIndex = (twavObservationsIndex + 1) % TWAV_BLOCK_NUMBERS;\n        lastBlockTimeStamp = _blockTimestamp;\n    }\n\n    /// @notice returns the TWAV of the last 4 blocks\n    /// @return _twav TWAV of the last 4 blocks\n    function _getTwav() internal view returns(uint256 _twav){\n        if (twavObservations[TWAV_BLOCK_NUMBERS - 1].timestamp != 0) {\n            uint8 _index = ((twavObservationsIndex + TWAV_BLOCK_NUMBERS) - 1) % TWAV_BLOCK_NUMBERS;\n            TwavObservation memory _twavObservationCurrent = twavObservations[(_index)];\n            TwavObservation memory _twavObservationPrev = twavObservations[(_index + 1) % TWAV_BLOCK_NUMBERS];\n            _twav = (_twavObservationCurrent.cumulativeValuation - _twavObservationPrev.cumulativeValuation) / (_twavObservationCurrent.timestamp - _twavObservationPrev.timestamp);\n        }\n    }\n\n    function getTwavObservations() public view returns(TwavObservation[TWAV_BLOCK_NUMBERS] memory) {\n        return twavObservations;\n    }\n}"
}