@@ -26,7 +26,7 @@ contract PriceFeed is PriceFeedStorage, IPriceFeed {
26
26
27
27
/// @notice Returns the latest price obtained from the Oracle. Called by Zero functions that require a current price.
28
28
/// It uses the main price feed and fallback to the backup one in case of an error. If both fail return the last
29
- /// good price seen.
29
+ /// good price seen. Function will rever if got false success flag from the medianizer contract.
30
30
/// @dev It's also callable by anyone externally
31
31
/// @return The price
32
32
function fetchPrice () external override returns (uint256 ) {
@@ -39,7 +39,8 @@ contract PriceFeed is PriceFeedStorage, IPriceFeed {
39
39
emit PriceFeedBroken (index, address (priceFeeds[index]));
40
40
}
41
41
}
42
- return lastGoodPrice;
42
+
43
+ revert ("PriceFeed: Price feed price is stale " );
43
44
}
44
45
45
46
/// @notice Allows users to setup the main and the backup price feeds
@@ -50,8 +51,7 @@ contract PriceFeed is PriceFeedStorage, IPriceFeed {
50
51
require (_index < priceFeeds.length , "Out of bounds when setting the price feed " );
51
52
checkContract (_newPriceFeed);
52
53
priceFeeds[_index] = IExternalPriceFeed (_newPriceFeed);
53
- (uint256 price , bool success ) = priceFeeds[_index].latestAnswer ();
54
- require (success, "PriceFeed: Price feed must be working " );
54
+ (uint256 price , bool _ ) = priceFeeds[_index].latestAnswer ();
55
55
emit PriceFeedUpdated (_index, _newPriceFeed);
56
56
return price;
57
57
}
@@ -61,4 +61,8 @@ contract PriceFeed is PriceFeedStorage, IPriceFeed {
61
61
lastGoodPrice = _currentPrice;
62
62
emit LastGoodPriceUpdated (_currentPrice);
63
63
}
64
+
65
+ function getPriceFeedAtIndex (uint8 _index ) external view returns (address ) {
66
+ return address (priceFeeds[_index]);
67
+ }
64
68
}
0 commit comments