The LibWstethEthOracle::getWstethEthPrice
function is designed in the system to compute the wstETH/ETH
price . On the top of the LibWstethEthOracle
contract a detailed NatSpec describes the price computation logic. Reported here for clarity: "It then computes a wstETH:ETH price by taking the minimum of (3) and either the average of (1) and (2) if (1) and (2) are within MAX_DIFFERENCE
from each other or (1)."
According to the NatSpec, the contract should compute the wstETH:ETH
price by taking the minimum of the the redemption value or the average of the Chainlink and Uniswap oracle prices if their percent difference is within a specified threshold (MAX_DIFFERENCE
) or the Chainlink oracle price if the percent difference exceeds this threshold. However, the actual implementation does not handle the scenario where the percent difference exceeds MAX_DIFFERENCE
. Consequently, users interacts with the system, such as minting fertilizer tokens, using inaccurate price data.
The LibWstethEthOracle::getWstethEthPrice
lacks explicit handling for scenarios where the percent difference between the Chainlink and Uniswap oracle prices is greater then MAX_DIFFERENCE
. This omission leads to situations where the contract does not default to the Chainlink price as intended, affecting the accuracy and reliability of the wstETH:ETH
price computation.
The absence of the missing return of the Chainlink oracle price in scenarios of significant price discrepancy between the Chainlink and Uniswap oracles (LibOracleHelpers.getPercentDifference(chainlinkPrice, uniswapPrice) > MAX_DIFFERENCE
) can lead to a scenario where the contract uses an average price that does not accurately reflect market conditions. The smart contract will operate with an inaccurate wstETH:ETH
price, impacting operations dependent on this price. This could result in financial losses for users and undermine the integrity of the system.
For example, in the beanstalk system, the FertilizerFacet::mintFertilizer
function relies on the LibWstethEthOracle::getWstethEthPrice
to fetch the wstETH:ETH
price from. This price is crucial for calculating the amount of Fertilizer tokens that can be acquired with the provided tokenAmountIn
. However, if this function returns an inaccurate price, it would not reflect the actual price of the asset. Consequently, users could continue to mint fertilizer tokens using this inaccurate price data, leading to transactions occurring at incorrect prices.
Manual review
Modify the LibWstethEthOracle::getWstethEthPrice
function to include explicit logic for handling the case where the percent difference between the Chainlink and Uniswap prices is greater then MAX_DIFFERENCE
.
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.