Skip to content

Commit

Permalink
respond to PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
livingrockrises committed Feb 12, 2024
1 parent 50da798 commit feb42a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contracts/token/oracles/IOracleAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ pragma solidity ^0.8.23;
interface IOracleAggregator {
struct TokenInfo {
uint8 tokenDecimals;
uint24 priceUpdateThreshold;
address tokenOracle;
address nativeOracle;
bool isDerivedFeed;
uint24 priceUpdateThreshold;
}

error MismatchInBaseAndQuoteDecimals();
Expand Down
4 changes: 3 additions & 1 deletion contracts/token/oracles/OracleAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ abstract contract OracleAggregator is Ownable, IOracleAggregator {
* @dev This function is used to get the latest price from the tokenOracle or nativeOracle.
* @notice Fetches the latest price from the given Oracle.
* @param _oracle The Oracle contract to fetch the price from.
* @param _priceUpdateThreshold The time after which the price is considered stale.
* @return price The latest price fetched from the Oracle.
*/
function fetchPrice(FeedInterface _oracle, uint24 _priceUpdateThreshold) internal view returns (uint256 price, bool isError) {
Expand All @@ -81,7 +82,8 @@ abstract contract OracleAggregator is Ownable, IOracleAggregator {
) {
// validateRound
if (answer <= 0) return (0, true);
// 2 days old price is considered stale since the price is updated every 24 hours
// price older than set _priceUpdateThreshold is considered stale
// _priceUpdateThreshold for oracle feed is usually heartbeat interval + block time + buffer
if (updatedAt < block.timestamp - _priceUpdateThreshold) return (0, true);
price = uint256(answer);
return (price, false);
Expand Down

0 comments on commit feb42a8

Please sign in to comment.