Boost _ Folks Finance 33631 - [Smart Contract - Low] Wrong implementation of chainLink getTwapPrice
Description
Brief/Intro
Vulnerability Details
function getTwapPrice(
AggregatorV3Interface chainlink,
uint80 latestRoundId,
uint256 latestPrice,
uint256 twapTimeInterval
) internal view returns (uint256 price) {
uint256 priceSum = latestPrice;
uint256 priceCount = 1;
uint256 startTime = block.timestamp - twapTimeInterval;
/// @dev Iterate over the previous rounds until reaching a round that was updated before the start time
while (latestRoundId > 0) {
try chainlink.getRoundData(--latestRoundId) returns (
uint80,
int256 answer,
uint256,
uint256 updatedAt,
uint80
) {
if (updatedAt < startTime) {
break;
}
priceSum += answer.toUint256();
priceCount++;
} catch {
break;
}
}
return priceSum / priceCount;
}Impact Details
References
Proof of concept
Proof of Concept
PreviousBoost _ Folks Finance 33630 - [Smart Contract - High] Incorrect calculation of loanBorrowbalanceNextBoost _ Folks Finance 33643 - [Smart Contract - Low] PriceFeed from PythNode will always revert for
Last updated
Was this helpful?