Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit 0457e71

Browse files
committed
feat: updated price oracle sentinel interface
1 parent 0e9927e commit 0457e71

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

contracts/interfaces/ISequencerOracle.sol

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,21 @@ pragma solidity 0.8.10;
99
interface ISequencerOracle {
1010
/**
1111
* @notice Returns the health status of the sequencer.
12-
* @return True if the sequencer is down, false otherwise
13-
* @return The timestamp of last time the sequencer got up
12+
* @return roundId The round ID from the aggregator for which the data was retrieved combined with a phase to ensure
13+
* that round IDs get larger as time moves forward.
14+
* @return answer The answer for the latest round: 0 if the sequencer is up, 1 if it is down.
15+
* @return startedAt The timestamp when the round was started.
16+
* @return updatedAt The timestamp of the block in which the answer was updated on L1.
17+
* @return answeredInRound The round ID of the round in which the answer was computed.
1418
*/
15-
function latestAnswer() external view returns (bool, uint256);
19+
function latestRoundData()
20+
external
21+
view
22+
returns (
23+
uint80 roundId,
24+
int256 answer,
25+
uint256 startedAt,
26+
uint256 updatedAt,
27+
uint80 answeredInRound
28+
);
1629
}

contracts/mocks/oracle/SequencerOracle.sol

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,22 @@ contract SequencerOracle is ISequencerOracle, Ownable {
2727
}
2828

2929
/// @inheritdoc ISequencerOracle
30-
function latestAnswer() external view override returns (bool, uint256) {
31-
return (_isDown, _timestampGotUp);
30+
function latestRoundData()
31+
external
32+
view
33+
override
34+
returns (
35+
uint80 roundId,
36+
int256 answer,
37+
uint256 startedAt,
38+
uint256 updatedAt,
39+
uint80 answeredInRound
40+
)
41+
{
42+
int256 isDown;
43+
if (_isDown) {
44+
isDown = 1;
45+
}
46+
return (0, isDown, 0, _timestampGotUp, 0);
3247
}
3348
}

contracts/protocol/configuration/PriceOracleSentinel.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ contract PriceOracleSentinel is IPriceOracleSentinel {
7373
* @return True if the SequencerOracle is up and the grace period passed, false otherwise
7474
*/
7575
function _isUpAndGracePeriodPassed() internal view returns (bool) {
76-
(bool isDown, uint256 timestampGotUp) = _sequencerOracle.latestAnswer();
77-
return !isDown && block.timestamp - timestampGotUp > _gracePeriod;
76+
(, int256 answer, , uint256 lastUpdateTimestamp, ) = _sequencerOracle.latestRoundData();
77+
return answer == 0 && block.timestamp - lastUpdateTimestamp > _gracePeriod;
7878
}
7979

8080
/// @inheritdoc IPriceOracleSentinel

test-suites/price-oracle-sentinel.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ makeSuite('PriceOracleSentinel', (testEnv: TestEnv) => {
7070

7171
expect(await addressesProvider.getPriceOracleSentinel()).to.be.eq(priceOracleSentinel.address);
7272

73-
const answer = await sequencerOracle.latestAnswer();
74-
expect(answer[0]).to.be.eq(false);
73+
const answer = await sequencerOracle.latestRoundData();
7574
expect(answer[1]).to.be.eq(0);
75+
expect(answer[3]).to.be.eq(0);
7676
});
7777

7878
it('Pooladmin updates grace period for sentinel', async () => {
@@ -212,8 +212,8 @@ makeSuite('PriceOracleSentinel', (testEnv: TestEnv) => {
212212
const userGlobalData = await pool.getUserAccountData(borrower.address);
213213

214214
expect(userGlobalData.healthFactor).to.be.lt(utils.parseUnits('1', 18), INVALID_HF);
215-
const currAnswer = await sequencerOracle.latestAnswer();
216-
waitForTx(await sequencerOracle.setAnswer(true, currAnswer[1]));
215+
const currAnswer = await sequencerOracle.latestRoundData();
216+
waitForTx(await sequencerOracle.setAnswer(true, currAnswer[3]));
217217
});
218218

219219
it('Tries to liquidate borrower when sequencer is down (HF > 0.95) (revert expected)', async () => {
@@ -431,8 +431,8 @@ makeSuite('PriceOracleSentinel', (testEnv: TestEnv) => {
431431
});
432432

433433
it('Turn off sequencer + increase time more than grace period', async () => {
434-
const currAnswer = await sequencerOracle.latestAnswer();
435-
await waitForTx(await sequencerOracle.setAnswer(true, currAnswer[1]));
434+
const currAnswer = await sequencerOracle.latestRoundData();
435+
await waitForTx(await sequencerOracle.setAnswer(true, currAnswer[3]));
436436
await increaseTime(GRACE_PERIOD.mul(2).toNumber());
437437
});
438438

0 commit comments

Comments
 (0)