##Summary:
The getSavedOrSpotOraclePrice() function in the LibOracle library may return outdated prices when the offset time is greater than 15 minutes and the price has changed significantly during that time.
File: LibOracle.sol
Function: getSavedOrSpotOraclePrice
The getSavedOrSpotOraclePrice() function in the LibOracle library is designed to return either the saved oracle price or the current oracle price depending on the time difference between the saved price and the current time.
function getSavedOrSpotOraclePrice(address asset) internal view returns (uint256) {
if (LibOrders.getOffsetTime() - getTime(asset) < 15 minutes) {
return getPrice(asset);
} else {
return getOraclePrice(asset);
}
}
The issue arises when the time difference (LibOrders.getOffsetTime() - getTime(asset)) is greater than 15 minutes. In this case, the function will return the saved price (getPrice(asset)) even if the market price has changed significantly.
Steps to Reproduce:
Set up a scenario where the offset time is greater than 15 minutes.
Ensure that the market price of the asset has changed significantly during this time.
The getSavedOrSpotOraclePrice() function should return the most up-to-date price, regardless of the time difference, to accurately reflect the current market conditions.
If the time difference exceeds 15 minutes, the function will return the saved price, potentially leading to outdated and inaccurate pricing information.
To address this issue, consider updating the logic in getSavedOrSpotOraclePrice() to always fetch the most current oracle price, regardless of the time difference.
function getSavedOrSpotOraclePrice(address asset) internal view returns (uint256) {
return getOraclePrice(asset);
}
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.