`Errors.InvalidTwapPrice()` is never invoked when `if (twapPriceInEther == 0)` is true
The protocol expects to `revert` with `Errors.InvalidTwapPrice()` when twapPriceInEther == 0:\\n```\\nFile: contracts/libraries/LibOracle.sol\\n\\n85            uint256 twapPriceInEther = (twapPrice / Constants.DECIMAL_USDC) * 1 ether;\\n86            uint256 twapPriceInv = twapPriceInEther.inv();\\n87            if (twapPriceInEther == 0) {\\n88                revert Errors.InvalidTwapPrice(); // @audit : unreachable code\\n89            }\\n```\\n\\nHowever, the control never reaches Line 88 when `twapPriceInEther` is zero. It rather reverts before that with error `Division or modulo by 0`.\\nNOTE: Due to this bug, `Errors.InvalidTwapPrice()` is never invoked/thrown by the protocol even under satisfactory conditions, even though it has been defined.\\nSince I could not find any helper function inside `contracts/` or `test/` which lets one set the `twapPrice` returned by uint256 `twapPrice` = IDiamond(payable(address(this))).estimateWETHInUSDC(Constants.UNISWAP_WETH_BASE_AMT, 30 minutes); to zero for testing purposes, I have created a simplified PoC which targets the problem area:\\nSave the following as a file named `test/InvalidTwapPriceErrorCheck.t.sol` and run the test via `forge test --mt testInvalidTwapPriceErrNeverInvoked -vv`. You will find that the test reverts with error `Division or modulo by 0`, but not with `Errors.InvalidTwapPrice()`. The PoC uses the same underlying math libraries and logic path as the protocol does in `contracts/libraries/LibOracle.sol::baseOracleCircuitBreaker()`.\\n```\\n// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity 0.8.21;\\n\\nimport {Constants} from "contracts/libraries/Constants.sol";\\nimport {Errors} from "contracts/libraries/Errors.sol";\\nimport {U256} from "contracts/libraries/PRBMathHelper.sol";\\nimport {OBFixture} from "test/utils/OBFixture.sol";\\n\\ncontract InvalidTwapPriceErrorCheck is OBFixture {\\n    using U256 for uint256;\\n\\n    function getZeroTwapPriceInEther_IncorrectStyle_As_In_Existing_DittoProtocol()\\n        internal\\n        pure\\n        returns (uint256 twapPriceInEther, uint256 twapPriceInv)\\n    {\\n        // fake the twapPrice to 0\\n        uint256 twapPrice = 0; // IDiamond(payable(address(this))).estimateWETHInUSDC(Constants.UNISWAP_WETH_BASE_AMT, 30 minutes);\\n        // Following code is copied as-is from\\n        // `contracts/libraries/LibOracle.sol::baseOracleCircuitBreaker()#L85-L89`\\n        twapPriceInEther = (twapPrice / Constants.DECIMAL_USDC) * 1 ether;\\n        twapPriceInv = twapPriceInEther.inv();\\n        if (twapPriceInEther == 0) {\\n            revert Errors.InvalidTwapPrice(); // @audit : unreachable code\\n        }\\n    }\\n\\n    function getZeroTwapPriceInEther_CorrectStyle()\\n        internal\\n        pure\\n        returns (uint256 twapPriceInEther, uint256 twapPriceInv)\\n    {\\n        // fake the twapPrice to 0\\n        uint256 twapPrice = 0; // IDiamond(payable(address(this))).estimateWETHInUSDC(Constants.UNISWAP_WETH_BASE_AMT, 30 minutes);\\n        twapPriceInEther = (twapPrice / Constants.DECIMAL_USDC) * 1 ether;\\n        if (twapPriceInEther == 0) { \\n            revert Errors.InvalidTwapPrice();\\n        }\\n        twapPriceInv = twapPriceInEther.inv();\\n    }\\n\\n    function testInvalidTwapPriceErrNeverInvoked() public pure {\\n        getZeroTwapPriceInEther_IncorrectStyle_As_In_Existing_DittoProtocol();\\n    }\\n\\n    function testInvalidTwapPriceErrInvokedCorrectly() public {\\n        vm.expectRevert(Errors.InvalidTwapPrice.selector);\\n        getZeroTwapPriceInEther_CorrectStyle();\\n    }\\n}\\n```\\n\\n\\nIn the above test file, you can also run the test which invokes the "fixed" or "correct" code style via `forge test --mt testInvalidTwapPriceErrInvokedCorrectly -vv`. This will invoke the `Errors.InvalidTwapPrice` error, as expected.
The check on Line 87 (if condition) needs to be performed immediately after Line 85.\\n```\\n    85            uint256 twapPriceInEther = (twapPrice / Constants.DECIMAL_USDC) * 1 ether;\\n// Add the line below\\n   86            if (twapPriceInEther == 0) {\\n// Add the line below\\n   87                revert Errors.InvalidTwapPrice();\\n// Add the line below\\n   88            }\\n// Add the line below\\n   89            uint256 twapPriceInv = twapPriceInEther.inv();\\n// Remove the line below\\n   86            uint256 twapPriceInv = twapPriceInEther.inv();\\n// Remove the line below\\n   87            if (twapPriceInEther == 0) {\\n// Remove the line below\\n   88                revert Errors.InvalidTwapPrice();\\n// Remove the line below\\n   89            }\\n```\\n\\nThe above fix needed to be done because the `inv()` call caused a revert even before control used to reach the `if` condition.
Protocol owner or developer monitoring for a revert due to `Errors.InvalidTwapPrice()` in the logs will never see it and will make debugging & issue resolution harder.
```\\nFile: contracts/libraries/LibOracle.sol\\n\\n85            uint256 twapPriceInEther = (twapPrice / Constants.DECIMAL_USDC) * 1 ether;\\n86            uint256 twapPriceInv = twapPriceInEther.inv();\\n87            if (twapPriceInEther == 0) {\\n88                revert Errors.InvalidTwapPrice(); // @audit : unreachable code\\n89            }\\n```\\n