contract PriceFeed {
    address private immutable _quotePriceFeed;
    address private immutable _pyth;
    uint256 private immutable _decimalsDiff; // <==== Audit
    bytes32 private immutable _priceId;

    uint256 private constant VALID_TIME_PERIOD = 5 * 60;

    constructor(address quotePrice, address pyth, bytes32 priceId, uint256 decimalsDiff) { // <==== Audit
        _quotePriceFeed = quotePrice;
        _pyth = pyth;
        _priceId = priceId;
        _decimalsDiff = decimalsDiff; // <==== Audit
    }

    /// @notice This function returns the square root of the baseToken price quoted in quoteToken.
    function getSqrtPrice() external view returns (uint256 sqrtPrice) {
        (, int256 quoteAnswer,,,) = AggregatorV3Interface(_quotePriceFeed).latestRoundData();

        IPyth.Price memory basePrice = IPyth(_pyth).getPriceNoOlderThan(_priceId, VALID_TIME_PERIOD);

        require(basePrice.expo == -8, "INVALID_EXP");

        require(quoteAnswer > 0 && basePrice.price > 0);

        uint256 price = uint256(int256(basePrice.price)) * Constants.Q96 / uint256(quoteAnswer);
        price = price * Constants.Q96 / _decimalsDiff; // <==== Audit

        sqrtPrice = FixedPointMathLib.sqrt(price);
    }
}
 forge test --match-contract PriceFeedDiscrepancyTest -vv
[] Compiling...
No files changed, compilation skipped

Ran 1 test for test/fork/PriceFeedDiscrepancy.t.sol:PriceFeedDiscrepancyTest
[FAIL. Reason: assertion failed] testSqrtIndexPrice() (gas: 4948278)
Logs:
  Error: a ~= b not satisfied [uint]
          Left: 1333136901050186247877690170972068
         Right: 1331884368549106242288122906
   Max % Delta: 1.000000000000000000
       % Delta: 100093942.135387808257073200

Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 17.83ms (4.19ms CPU time)

Ran 1 test suite in 342.31ms (17.83ms CPU time): 0 tests passed, 1 failed, 0 skipped (1 total tests)

Failing tests:
Encountered 1 failing test in test/fork/PriceFeedDiscrepancy.t.sol:PriceFeedDiscrepancyTest
[FAIL. Reason: assertion failed] testSqrtIndexPrice() (gas: 4948278)

Encountered a total of 1 failing tests, 0 tests succeeded
diff --git a/src/PriceFeed.sol b/src/PriceFeed.sol
index a8cd985..bd0152d 100644
--- a/src/PriceFeed.sol
+++ b/src/PriceFeed.sol
@@ -9,13 +9,13 @@ import {Constants} from "./libraries/Constants.sol";
 contract PriceFeedFactory {
     address private immutable _pyth;
 
-    event PriceFeedCreated(address quotePrice, bytes32 priceId, uint256 decimalsDiff, address priceFeed);
+    event PriceFeedCreated(address quotePrice, bytes32 priceId, int256 decimalsDiff, address priceFeed);
 
     constructor(address pyth) {
         _pyth = pyth;
     }
 
-    function createPriceFeed(address quotePrice, bytes32 priceId, uint256 decimalsDiff) external returns (address) {
+    function createPriceFeed(address quotePrice, bytes32 priceId, int256 decimalsDiff) external returns (address) {
         PriceFeed priceFeed = new PriceFeed(quotePrice, _pyth, priceId, decimalsDiff);
 
         emit PriceFeedCreated(quotePrice, priceId, decimalsDiff, address(priceFeed));
@@ -29,12 +29,12 @@ contract PriceFeedFactory {
 contract PriceFeed {
     address private immutable _quotePriceFeed;
     address private immutable _pyth;
-    uint256 private immutable _decimalsDiff;
+    int256 private immutable _decimalsDiff;
     bytes32 private immutable _priceId;
 
     uint256 private constant VALID_TIME_PERIOD = 5 * 60;
 
-    constructor(address quotePrice, address pyth, bytes32 priceId, uint256 decimalsDiff) {
+    constructor(address quotePrice, address pyth, bytes32 priceId, int256 decimalsDiff) {
         _quotePriceFeed = quotePrice;
         _pyth = pyth;
         _priceId = priceId;
@@ -52,7 +52,12 @@ contract PriceFeed {
         require(quoteAnswer > 0 && basePrice.price > 0);
 
         uint256 price = uint256(int256(basePrice.price)) * Constants.Q96 / uint256(quoteAnswer);
-        price = price * Constants.Q96 / _decimalsDiff;
+
+        if (_decimalsDiff > 0) {
+            price = price * Constants.Q96 / 10 ** uint256(_decimalsDiff);
+        } else {
+            price = price * Constants.Q96 * 10 ** uint256(-_decimalsDiff);
+        }
 
         sqrtPrice = FixedPointMathLib.sqrt(price);
     }
