diff --git a/src/libraries/OracleLib.sol b/src/libraries/OracleLib.sol index 4326c3a..44b8f97 100644 --- a/src/libraries/OracleLib.sol +++ b/src/libraries/OracleLib.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.18; import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; - /* * @title OracleLib * @author Ghadi Mhawej @@ -15,20 +14,20 @@ library OracleLib { error OracleLib__StalePrice(); uint256 private constant TIMEOUT = 3 hours; - function staleCheckLatestRoundData(AggregatorV3Interface priceFeed) public view returns(uint80, int256, uint256, uint256, uint80) { - ( - uint80 roundId, - int256 answer, - uint256 startedAt, - uint256 updatedAt, - uint80 answeredInRound - ) = priceFeed.latestRoundData(); - uint256 secondsSinceLastUpdate = block.timestamp - updatedAt; - if (secondsSinceLastUpdate > TIMEOUT) { - revert OracleLib__StalePrice(); - } + function staleCheckLatestRoundData(AggregatorV3Interface priceFeed) + public + view + returns (uint80, int256, uint256, uint256, uint80) + { + (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) = + priceFeed.latestRoundData(); - return (roundId, answer, startedAt, updatedAt, answeredInRound); + uint256 secondsSinceLastUpdate = block.timestamp - updatedAt; + if (secondsSinceLastUpdate > TIMEOUT) { + revert OracleLib__StalePrice(); + } + + return (roundId, answer, startedAt, updatedAt, answeredInRound); + } } -} \ No newline at end of file diff --git a/test/fuzz/Handler.t.sol b/test/fuzz/Handler.t.sol index db7b0b9..1e79770 100644 --- a/test/fuzz/Handler.t.sol +++ b/test/fuzz/Handler.t.sol @@ -35,7 +35,7 @@ contract Handler is Test { weth = ERC20Mock(collateralTokens[0]); wbtc = ERC20Mock(collateralTokens[1]); - ethUsdPriceFeed = MockV3Aggregator(engine.getPriceFeed(address(weth))); + ethUsdPriceFeed = MockV3Aggregator(engine.getPriceFeed(address(weth))); } function depositCollateral(uint256 collateralSeed, uint256 amountCollateral) public { diff --git a/test/fuzz/InvariantsTest.t.sol b/test/fuzz/InvariantsTest.t.sol index d1bfc4a..d4505d8 100644 --- a/test/fuzz/InvariantsTest.t.sol +++ b/test/fuzz/InvariantsTest.t.sol @@ -55,6 +55,5 @@ contract InvariantsTest is StdInvariant, Test { // Getter functions should never revert function invariant_getterFunctionsShouldNeverRevert() public view { engine.getCollateralTokens(); - } }