Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: PriceOracleSentinel incorrectly reading L2 sequencer Chainlink feed state #926

Open
fredwes opened this issue Nov 14, 2023 · 0 comments

Comments

@fredwes
Copy link

fredwes commented Nov 14, 2023

PriceOracleSentinel disables Borrowing and Liquidations because it believes the L2 sequencer has failed the Chainlink health check. The lastUpdateTimestamp is updated roughly every 24 hours by Chainlink even if the answer is unchanged, this causes borrowing and liquidations to be disabled for an hour roughly once per day even though the sequencer is healthy. I believe the startedAt timestamp would reflect the timestamp of a new round (when the status has changed).

Existing code:

/**
   * @notice Checks the sequencer oracle is healthy: is up and grace period passed.
   * @return True if the SequencerOracle is up and the grace period passed, false otherwise
   */
  function _isUpAndGracePeriodPassed() internal view returns (bool) {
    (, int256 answer, , uint256 lastUpdateTimestamp, ) = _sequencerOracle.latestRoundData();
    return answer == 0 && block.timestamp - lastUpdateTimestamp > _gracePeriod;
  }

Proposed fix:

/**
   * @notice Checks the sequencer oracle is healthy: is up and grace period passed.
   * @return True if the SequencerOracle is up and the grace period passed, false otherwise
   */
  function _isUpAndGracePeriodPassed() internal view returns (bool) {
    (, int256 answer, uint256 startedAt, , ) = _sequencerOracle.latestRoundData();
    return answer == 0 && block.timestamp - startedAt > _gracePeriod;
  }

Chainlink docs sample code: https://docs.chain.link/data-feeds/l2-sequencer-feeds#example-code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant