Skip to content

Commit

Permalink
style: make code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlinEgalite committed Oct 4, 2023
1 parent 69b6ebd commit 31ec914
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libraries/ChainlinkDataFeedLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ library ChainlinkDataFeedLib {
/// @dev When `feed` is the address zero, returns 1.
function getPrice(AggregatorV3Interface feed) internal view returns (uint256) {
if (address(feed) == address(0)) return 1;

(, int256 answer,,,) = feed.latestRoundData();
require(answer >= 0, ErrorsLib.NEGATIVE_ANSWER);

return uint256(answer);
}

/// @dev Returns the number of decimals of a feed.
/// @dev When `feed` is the address zero, returns 0.
function getDecimals(AggregatorV3Interface feed) internal view returns (uint256) {
if (address(feed) == address(0)) return 0;

return feed.decimals();
}
}

0 comments on commit 31ec914

Please sign in to comment.