diff --git a/contracts/interfaces/ISequencerOracle.sol b/contracts/interfaces/ISequencerOracle.sol index af6122160..afb4896e9 100644 --- a/contracts/interfaces/ISequencerOracle.sol +++ b/contracts/interfaces/ISequencerOracle.sol @@ -9,8 +9,21 @@ pragma solidity 0.8.10; interface ISequencerOracle { /** * @notice Returns the health status of the sequencer. - * @return True if the sequencer is down, false otherwise - * @return The timestamp of last time the sequencer got up + * @return roundId The round ID from the aggregator for which the data was retrieved combined with a phase to ensure + * that round IDs get larger as time moves forward. + * @return answer The answer for the latest round: 0 if the sequencer is up, 1 if it is down. + * @return startedAt The timestamp when the round was started. + * @return updatedAt The timestamp of the block in which the answer was updated on L1. + * @return answeredInRound The round ID of the round in which the answer was computed. */ - function latestAnswer() external view returns (bool, uint256); + function latestRoundData() + external + view + returns ( + uint80 roundId, + int256 answer, + uint256 startedAt, + uint256 updatedAt, + uint80 answeredInRound + ); } diff --git a/contracts/mocks/oracle/SequencerOracle.sol b/contracts/mocks/oracle/SequencerOracle.sol index c608124a2..64608f085 100644 --- a/contracts/mocks/oracle/SequencerOracle.sol +++ b/contracts/mocks/oracle/SequencerOracle.sol @@ -27,7 +27,22 @@ contract SequencerOracle is ISequencerOracle, Ownable { } /// @inheritdoc ISequencerOracle - function latestAnswer() external view override returns (bool, uint256) { - return (_isDown, _timestampGotUp); + function latestRoundData() + external + view + override + returns ( + uint80 roundId, + int256 answer, + uint256 startedAt, + uint256 updatedAt, + uint80 answeredInRound + ) + { + int256 isDown; + if (_isDown) { + isDown = 1; + } + return (0, isDown, 0, _timestampGotUp, 0); } } diff --git a/contracts/protocol/configuration/PriceOracleSentinel.sol b/contracts/protocol/configuration/PriceOracleSentinel.sol index 493ff379a..81b22d8db 100644 --- a/contracts/protocol/configuration/PriceOracleSentinel.sol +++ b/contracts/protocol/configuration/PriceOracleSentinel.sol @@ -73,8 +73,8 @@ contract PriceOracleSentinel is IPriceOracleSentinel { * @return True if the SequencerOracle is up and the grace period passed, false otherwise */ function _isUpAndGracePeriodPassed() internal view returns (bool) { - (bool isDown, uint256 timestampGotUp) = _sequencerOracle.latestAnswer(); - return !isDown && block.timestamp - timestampGotUp > _gracePeriod; + (, int256 answer, , uint256 lastUpdateTimestamp, ) = _sequencerOracle.latestRoundData(); + return answer == 0 && block.timestamp - lastUpdateTimestamp > _gracePeriod; } /// @inheritdoc IPriceOracleSentinel diff --git a/test-suites/price-oracle-sentinel.spec.ts b/test-suites/price-oracle-sentinel.spec.ts index 6579878b9..93c3bf6e1 100644 --- a/test-suites/price-oracle-sentinel.spec.ts +++ b/test-suites/price-oracle-sentinel.spec.ts @@ -70,9 +70,9 @@ makeSuite('PriceOracleSentinel', (testEnv: TestEnv) => { expect(await addressesProvider.getPriceOracleSentinel()).to.be.eq(priceOracleSentinel.address); - const answer = await sequencerOracle.latestAnswer(); - expect(answer[0]).to.be.eq(false); + const answer = await sequencerOracle.latestRoundData(); expect(answer[1]).to.be.eq(0); + expect(answer[3]).to.be.eq(0); }); it('Pooladmin updates grace period for sentinel', async () => { @@ -212,8 +212,8 @@ makeSuite('PriceOracleSentinel', (testEnv: TestEnv) => { const userGlobalData = await pool.getUserAccountData(borrower.address); expect(userGlobalData.healthFactor).to.be.lt(utils.parseUnits('1', 18), INVALID_HF); - const currAnswer = await sequencerOracle.latestAnswer(); - waitForTx(await sequencerOracle.setAnswer(true, currAnswer[1])); + const currAnswer = await sequencerOracle.latestRoundData(); + waitForTx(await sequencerOracle.setAnswer(true, currAnswer[3])); }); it('Tries to liquidate borrower when sequencer is down (HF > 0.95) (revert expected)', async () => { @@ -431,8 +431,8 @@ makeSuite('PriceOracleSentinel', (testEnv: TestEnv) => { }); it('Turn off sequencer + increase time more than grace period', async () => { - const currAnswer = await sequencerOracle.latestAnswer(); - await waitForTx(await sequencerOracle.setAnswer(true, currAnswer[1])); + const currAnswer = await sequencerOracle.latestRoundData(); + await waitForTx(await sequencerOracle.setAnswer(true, currAnswer[3])); await increaseTime(GRACE_PERIOD.mul(2).toNumber()); });