Function: calculateDeviation(uint256 price1, uint256 price2)
This function calculates the percentage deviation between two prices.
Inputs
price1Control: Fully controlled by the caller.
Constraints: None.
Impact: A price to calculate the deviation of.
price2Control: Fully controlled by the caller.
Constraints: None.
Impact: A price to calculate the deviation of.
Branches and code coverage
Intended branches
Check if
price1is zero.Check if
price2is zero.Calculate the absolute difference between the two prices.
Use the larger price as a denominator for a more conservative estimate.
Return the deviation as a percentage in 18 decimals.