Skip to content

Commit 904aa79

Browse files
committed
update
Signed-off-by: chrismaree <christopher.maree@gmail.com>
1 parent 63cdd04 commit 904aa79

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/OevOracle.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ contract OevOracle is AggregatorV3Interface, Ownable {
3737
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) =
3838
baseAggregator.latestRoundData();
3939

40-
require(latestRound != roundId);
40+
require(latestRound != roundId, "No update needed");
4141
if (msg.sender != updater && msg.sender != owner()) {
4242
require(block.timestamp - updatedAt >= permissionWindow, "In permissioned window");
4343
}
@@ -48,6 +48,11 @@ contract OevOracle is AggregatorV3Interface, Ownable {
4848
roundData[roundId] = RoundData(roundId, answer, startedAt, updatedAt, answeredInRound);
4949
}
5050

51+
function canUpdateAnswer() public view returns (bool) {
52+
(uint256 roundId,,,,) = baseAggregator.latestRoundData();
53+
return latestRound != roundId;
54+
}
55+
5156
function setUpdater(address _updater) public onlyOwner {
5257
updater = _updater;
5358
}

test/OevOracle.updateAnswer.sol

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ pragma solidity 0.8.17;
44
import "./OevOracle.Common.sol";
55

66
contract OevOracleUpdateAnswer is OevOracleCommon {
7+
int256 newPrice = 1900 * 1e8;
8+
9+
function testUpdateWithNoDiffIsNoOp() public {
10+
verifyOevOracleMatchesBaseAggregator();
11+
assertFalse(oevOracle.canUpdateAnswer());
12+
vm.expectRevert("No update needed");
13+
oevOracle.updateAnswer();
14+
verifyOevOracleMatchesBaseAggregator();
15+
}
16+
717
function testUpdaterCanUpdateAnswer() public {
818
verifyOevOracleMatchesBaseAggregator();
919

10-
int256 newPrice = 1900 * 1e8;
1120
baseAggregator.updateAnswer(newPrice);
1221

1322
vm.prank(permissionedUpdater);
@@ -17,7 +26,6 @@ contract OevOracleUpdateAnswer is OevOracleCommon {
1726
}
1827

1928
function testAnyAccountCanUpdateAnswerAfterDelay() public {
20-
int256 newPrice = 1900 * 1e8;
2129
baseAggregator.updateAnswer(newPrice);
2230

2331
vm.expectRevert("In permissioned window");

0 commit comments

Comments
 (0)