gas

More documentation is preferred

Reward

Total

24.49 USDC

Selected
24.49 USDC
Selected Submission

More documentation is preferred

Severity

Gas Optimization / Informational

Relevant GitHub Links

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/libraries/OracleLib.sol#L19-L37

Summary

Code base needs more Natspec comments. Documentation should be consistent and clear for the auditors and devs.

Vulnerability Details

Code base lacks documentation.

Impact

Documentation should be consistent and clear for the auditors and devs.

Tools Used

Manual review

Recommendations

+    /**
+     * @notice This function checks if the latest round data is stale or not.
+     * @dev If the latest round data is stale, the function will revert.
+     * @param priceFeed The Chainlink Oracle price feed.
+     */
    function staleCheckLatestRoundData(AggregatorV3Interface priceFeed) // @audit here if the oracle price is stale, the function will revert, then the system will be unusable. This is not right and we need a plan B in this case.
        public
        view
        returns (uint80, int256, uint256, uint256, uint80)
    {
        (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
            priceFeed.latestRoundData();
        // @audit also check 1. if the answer is more than 0, and check 2. the current roundId is more than the previous roundId.
        uint256 secondsSince = block.timestamp - updatedAt;
        if (secondsSince > TIMEOUT) revert OracleLib__StalePrice();

        return (roundId, answer, startedAt, updatedAt, answeredInRound);
    }

+    /**
+     * @notice This function returns the timeout value for the OracleLib
+     */
    function getTimeout(AggregatorV3Interface /* chainlinkFeed */ ) public pure returns (uint256) {
        return TIMEOUT;
    }
}