The LibWstethEthOracle:getWstethEthPrice
function computes the current price of wstETH
(Wrapped stETH) relative to ETH (Ethereum) by utilizing multiple data sources, including the Chainlink Oracle and Uniswap V3. It calculates the price in three ways: by multiplying the wstETH:stETH redemption rate with the stETH:ETH price obtained from Chainlink, by fetching the price directly from the wstETH:ETH Uniswap Pool, and by considering the stETH redemption rate alone. The function then computes a final price by taking the minimum of the last method and either the average or the Chainlink-based price if their difference falls within a predefined threshold.
In the getWstethEthPrice
function, there is no else condition at the end of the if statement block. This means that if the condition within the if statement (LibOracleHelpers.getPercentDifference(chainlinkPrice, uniswapPrice) < MAX_DIFFERENCE)
evaluates to false, the function will exit without returning a value.
See the following code:
Without an else condition, the function may terminate abruptly without providing any meaningful output if the condition in the if statement is not met. This can lead to unpredictable behavior, making it difficult to determine why the function failed to produce a result. Incomplete or unexpected function execution paths can introduce bugs into the codebase, making it harder to maintain and debug the application. Developers may have difficulty understanding the intended behavior of the function without clear error handling or fallback mechanisms.
Manual Review
To address this issue, we need to ensure that the function always returns a value, even if the condition within the if statement evaluates to false. By adding an else condition, we ensure that the function always returns a value, even if the condition in the if statement is not met. This enhances the reliability and predictability of the codebase, making it easier to understand and maintain.
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.