Skip to content

Commit 9c5e883

Browse files
author
cwsnt
committed
merge with latest development branch & fix conflict
2 parents bd697a6 + 0e0d58d commit 9c5e883

File tree

7 files changed

+994
-184
lines changed

7 files changed

+994
-184
lines changed

contracts/PriceFeed.sol

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ contract PriceFeed is PriceFeedStorage, IPriceFeed {
2626

2727
/// @notice Returns the latest price obtained from the Oracle. Called by Zero functions that require a current price.
2828
/// 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.
3030
/// @dev It's also callable by anyone externally
3131
/// @return The price
3232
function fetchPrice() external override returns (uint256) {
@@ -39,7 +39,8 @@ contract PriceFeed is PriceFeedStorage, IPriceFeed {
3939
emit PriceFeedBroken(index, address(priceFeeds[index]));
4040
}
4141
}
42-
return lastGoodPrice;
42+
43+
revert("PriceFeed: Price feed price is stale");
4344
}
4445

4546
/// @notice Allows users to setup the main and the backup price feeds
@@ -50,8 +51,7 @@ contract PriceFeed is PriceFeedStorage, IPriceFeed {
5051
require(_index < priceFeeds.length, "Out of bounds when setting the price feed");
5152
checkContract(_newPriceFeed);
5253
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();
5555
emit PriceFeedUpdated(_index, _newPriceFeed);
5656
return price;
5757
}
@@ -61,4 +61,8 @@ contract PriceFeed is PriceFeedStorage, IPriceFeed {
6161
lastGoodPrice = _currentPrice;
6262
emit LastGoodPriceUpdated(_currentPrice);
6363
}
64+
65+
function getPriceFeedAtIndex(uint8 _index) external view returns(address) {
66+
return address(priceFeeds[_index]);
67+
}
6468
}

deployment/deploy/7-PriceFeed.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { DeployFunction } from "hardhat-deploy/types";
2+
import { deployWithCustomProxy } from "../../scripts/helpers/helpers";
3+
import { getContractNameFromScriptFileName } from "../../scripts/helpers/utils";
4+
const path = require("path");
5+
6+
const deploymentName = getContractNameFromScriptFileName(path.basename(__filename));
7+
8+
const func: DeployFunction = async (hre) => {
9+
const { getNamedAccounts } = hre;
10+
const { deployer } = await getNamedAccounts();
11+
await deployWithCustomProxy(hre, deployer, deploymentName, "UpgradableProxy");
12+
};
13+
14+
func.tags = [deploymentName];
15+
export default func;

0 commit comments

Comments
 (0)