According to comments , the LibUniswapOracle.consult()
is:
However, the function itself does not live up to this as it does not return 0
on failure.
https://github.com/Cyfrin/2024-04-beanstalk-2/blob/27ff8c87c9164c1fbff054be5f22e56f86cdf127/protocol/contracts/libraries/Oracle/LibUniswapOracle.sol#L41-L62
If the observation is successful (i.e., the try block executes without error
), the function calculates the arithmetic mean tick using the tick cumulatives obtained from the observation.
If the observation fails (i.e., the try block encounters an error
), the function catches the error without reverting. This is indicated by the empty catch block {}
.
In case of failure, the function does not provide any specific handling or return value
, leaving success as false and arithmeticMeanTick
uninitialized.
0
is only returned when the consult()
function is used within another function with a success boolean set to it such as in getTwap()
:
https://github.com/Cyfrin/2024-04-beanstalk-2/blob/27ff8c87c9164c1fbff054be5f22e56f86cdf127/protocol/contracts/libraries/Oracle/LibUniswapOracle.sol#L30-L34
Therefore, the consult()
as it is does not return 0
as the comments suggest on its own.
Without specific handling or return values for failure cases, the behavior of the function becomes ambiguous. It's unclear what to expect when an error occurs.
Manual Review
To ensure clarity and consistency in the consult function's behavior, modify it to return 0
when the observation fails.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.