Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/misc/UnitPriceFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {AggregatorV3Interface} from 'src/dependencies/chainlink/AggregatorV3Inte
/// @notice Price feed that returns the unit price (1), with decimals precision.
/// @dev This price feed can be set for reserves that use the base currency as collateral.
contract UnitPriceFeed is AggregatorV3Interface {
error InvalidRound(uint80 roundId);

/// @inheritdoc AggregatorV3Interface
uint8 public immutable decimals;

Expand Down Expand Up @@ -45,13 +47,14 @@ contract UnitPriceFeed is AggregatorV3Interface {
uint80 answeredInRound
)
{
if (_roundId <= uint80(block.timestamp)) {
roundId = _roundId;
answer = _units;
startedAt = _roundId;
updatedAt = _roundId;
answeredInRound = _roundId;
if (_roundId > uint80(block.timestamp)) {
revert InvalidRound(_roundId);
}
roundId = _roundId;
answer = _units;
startedAt = _roundId;
updatedAt = _roundId;
answeredInRound = _roundId;
}

/// @inheritdoc AggregatorV3Interface
Expand Down