@@ -22,6 +22,7 @@ contract NFTOracle is INFTOracle, Initializable, OwnableUpgradeable, BlockContex
22
22
event FeedAdminUpdated (address indexed admin );
23
23
event SetAssetData (address indexed asset , uint256 price , uint256 timestamp , uint256 roundId );
24
24
event SetAssetTwapPrice (address indexed asset , uint256 price , uint256 timestamp );
25
+ event SetPriceStale (address indexed asset , bool val );
25
26
26
27
struct NFTPriceData {
27
28
uint256 roundId;
@@ -64,6 +65,7 @@ contract NFTOracle is INFTOracle, Initializable, OwnableUpgradeable, BlockContex
64
65
mapping (address => address ) private _mappedAssetToOriginalAsset;
65
66
uint8 public decimals;
66
67
uint256 public decimalPrecision;
68
+ mapping (address => bool ) public nftPriceStale;
67
69
68
70
// !!! For upgradable, MUST append one new variable above !!!
69
71
//////////////////////////////////////////////////////////////////////////////
@@ -394,10 +396,38 @@ contract NFTOracle is INFTOracle, Initializable, OwnableUpgradeable, BlockContex
394
396
}
395
397
396
398
function setPause (address _nftContract , bool val ) external override onlyOwner {
399
+ requireKeyExisted (_nftContract, true );
400
+
397
401
nftPaused[_nftContract] = val;
398
402
}
399
403
400
404
function setTwapInterval (uint256 _twapInterval ) external override onlyOwner {
401
405
twapInterval = _twapInterval;
402
406
}
407
+
408
+ function setPriceStale (address [] calldata _nftContracts , bool val ) public override {
409
+ address sender = _msgSender ();
410
+ if (val) {
411
+ require ((sender == priceFeedAdmin) || (sender == owner ()), "NFTOracle: invalid caller " );
412
+ } else {
413
+ require (sender == owner (), "NFTOracle: invalid caller " );
414
+ }
415
+
416
+ for (uint256 i = 0 ; i < _nftContracts.length ; i++ ) {
417
+ requireKeyExisted (_nftContracts[i], true );
418
+ nftPriceStale[_nftContracts[i]] = val;
419
+ emit SetPriceStale (_nftContracts[i], val);
420
+
421
+ // Set flag for mapped assets
422
+ address [] memory mappedAddresses = _originalAssetToMappedAsset[_nftContracts[i]].values ();
423
+ for (uint256 j = 0 ; j < mappedAddresses.length ; j++ ) {
424
+ nftPriceStale[mappedAddresses[j]] = val;
425
+ emit SetPriceStale (mappedAddresses[j], val);
426
+ }
427
+ }
428
+ }
429
+
430
+ function isPriceStale (address _nftContract ) public view override returns (bool ) {
431
+ return nftPriceStale[_nftContract];
432
+ }
403
433
}
0 commit comments