From 31ec9141da7029a5948fe2fe8ba961b114353b3e Mon Sep 17 00:00:00 2001 From: MerlinEgalite Date: Wed, 4 Oct 2023 18:53:40 +0200 Subject: [PATCH] style: make code more readable --- src/libraries/ChainlinkDataFeedLib.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/ChainlinkDataFeedLib.sol b/src/libraries/ChainlinkDataFeedLib.sol index 24d2124..8c08a9d 100644 --- a/src/libraries/ChainlinkDataFeedLib.sol +++ b/src/libraries/ChainlinkDataFeedLib.sol @@ -14,8 +14,10 @@ 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); } @@ -23,6 +25,7 @@ library ChainlinkDataFeedLib { /// @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(); } }