Low precision is used when checking spot price deviation
Low precision is used when checking spot price deviation, which might lead to potential manipulation or create the potential for an MEV opportunity due to valuation discrepancy.\\nAssume the following:\\nThe max deviation is set to 1%\\n`nTokenOracleValue` is 1,000,000,000\\n`nTokenSpotValue` is 980,000,001\\n```\\nFile: Constants.sol\\n    // Basis for percentages\\n    int256 internal constant PERCENTAGE_DECIMALS = 100;\\n```\\n\\n```\\nFile: nTokenCalculations.sol\\n            int256 maxValueDeviationPercent = int256(\\n                uint256(uint8(nToken.parameters[Constants.MAX_MINT_DEVIATION_LIMIT]))\\n            );\\n            // Check deviation limit here\\n            int256 deviationInPercentage = nTokenOracleValue.sub(nTokenSpotValue).abs()\\n                .mul(Constants.PERCENTAGE_DECIMALS).div(nTokenOracleValue);\\n            require(deviationInPercentage <= maxValueDeviationPercent, "Over Deviation Limit");\\n```\\n\\nBased on the above formula:\\n```\\nnTokenOracleValue.sub(nTokenSpotValue).abs().mul(Constants.PERCENTAGE_DECIMALS).div(nTokenOracleValue);\\n((nTokenOracleValue - nTokenSpotValue) * Constants.PERCENTAGE_DECIMALS) / nTokenOracleValue\\n((1,000,000,000 - 980,000,001) * 100) / 1,000,000,000\\n(19,999,999 * 100) / 1,000,000,000\\n1,999,999,900 / 1,000,000,000 = 1.9999999 = 1\\n```\\n\\nThe above shows that the oracle and spot values have deviated by 1.99999%, which is close to 2%. However, due to a rounding error, it is rounded down to 1%, and the TX will not revert.
Consider increasing the precision.\\nFor instance, increasing the precision from `Constants.PERCENTAGE_DECIMALS` (100) to 1e8 would have caught the issue mentioned earlier in the report even after the rounding down.\\n```\\nnTokenOracleValue.sub(nTokenSpotValue).abs().mul(1e8).div(nTokenOracleValue);\\n((nTokenOracleValue - nTokenSpotValue) * 1e8) / nTokenOracleValue\\n((1,000,000,000 - 980,000,001) * 1e8) / 1,000,000,000\\n(19,999,999 * 1e8) / 1,000,000,000 = 1999999.9 = 1999999\\n```\\n\\n1% of 1e8 = 1000000\\n```\\nrequire(deviationInPercentage <= maxValueDeviationPercent, "Over Deviation Limit")\\nrequire(1999999 <= 1000000, "Over Deviation Limit") => Revert\\n```\\n
The purpose of the deviation check is to ensure that the spot market value is not manipulated. If the deviation check is not accurate, it might lead to potential manipulation or create the potential for an MEV opportunity due to valuation discrepancy.
```\\nFile: Constants.sol\\n    // Basis for percentages\\n    int256 internal constant PERCENTAGE_DECIMALS = 100;\\n```\\n