Assessment reports>Benqi Oracle>Threat Model>calculateDeviation

Function: calculateDeviation(uint256 price1, uint256 price2)

This function calculates the percentage deviation between two prices.

Inputs

  • price1

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: A price to calculate the deviation of.

  • price2

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: A price to calculate the deviation of.

Branches and code coverage

Intended branches

  • Check if price1 is zero.

  • Check if price2 is 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.

Zellic © 2025Back to top ↑