Mitigation Audit _ Folks Finance 34942 - [Smart Contract - Insight] In function function getTwapPric
Description
Vulnerability Details
if (latestRoundId == 0) {
break;
}
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 {
if (latestRoundId == 0) {
break;
}
}
}
return priceSum / priceCount;
}
Impact Details
Proof of concept
Proof of Concept
PreviousMitigation Audit _ Folks Finance 34929 - [Smart Contract - Critical] Accounting Discrepancy in Fee RNextMitigation Audit _ Folks Finance 35089 - [Smart Contract - Insight] Malicious actor can control inte
Last updated
Was this helpful?