Skip to content

FluidUsdOracleSequencerL2 ​

Git Source

Inherits:Error

Title: FluidUsdOracleSequencerL2

L2 Chainlink sequencer uptime feed reads, grace-period math, and sequencerL2Data() view.

Core sequencer algorithm is copied 1:1 from contracts/oracle/fluidOracleL2.sol (FluidOracleL2). Intentional differences from v1 FluidOracleL2:

  • _ensureSequencerUpAndValid() uses FluidUsdOracleError with UsdOracle__SequencerDown and UsdOracle__SequencerGracePeriod instead of a single FluidOracleL2__SequencerOutage.
  • Constructor rejects sequencerUptimeFeed_ == address(0) (UsdOracle-specific).

Constants ​

_SEQUENCER_ORACLE ​

Chainlink L2 Sequencer Uptime feed to detect sequencer outages

solidity
IChainlinkAggregatorV3 internal immutable _SEQUENCER_ORACLE

_SEQUENCER_MAX_GRACE_PERIOD ​

max time period until oracle assumes normal behavior after a sequencer outage.

solidity
uint256 internal constant _SEQUENCER_MAX_GRACE_PERIOD = 45 minutes

Functions ​

constructor ​

Stores the Chainlink L2 sequencer uptime feed used for outage and grace-period checks.

solidity
constructor(address sequencerUptimeFeed_) ;

Parameters

NameTypeDescription
sequencerUptimeFeed_addressChainlink sequencer uptime aggregator; must be a contract, not address(0).

sequencerL2Data ​

Exposes Chainlink sequencer uptime feed state and grace-period diagnostics for off-chain monitoring and debugging.

When the sequencer is up, gracePeriod_ is the outage-duration-based grace window (capped at maxGracePeriod_). When the sequencer is down, gracePeriod_ is set to maxGracePeriod_ and lastOutageStartedAt_ is derived from feed rounds.

solidity
function sequencerL2Data()
    public
    view
    returns (
        address sequencerUptimeFeed_,
        uint256 maxGracePeriod_,
        bool isSequencerUp_,
        uint256 lastUptimeStartedAt_,
        uint256 gracePeriod_,
        bool gracePeriodPassed_,
        uint256 lastOutageStartedAt_,
        bool isSequencerUpAndValid_
    );

Returns

NameTypeDescription
sequencerUptimeFeed_addressChainlink IChainlinkAggregatorV3 sequencer uptime feed used by this contract.
maxGracePeriod_uint256Upper bound on the grace period after a sequencer outage (_SEQUENCER_MAX_GRACE_PERIOD).
isSequencerUp_boolTrue if the feed’s latest answer indicates the sequencer is currently up (Chainlink convention: answer 0 = up).
lastUptimeStartedAt_uint256Timestamp at the start of the current consecutive uptime window (0 if sequencer is down).
gracePeriod_uint256Required wait after uptime resumes before prices are considered valid (capped); see @dev.
gracePeriodPassed_boolTrue if block.timestamp - lastUptimeStartedAt_ exceeds gracePeriod_ while the sequencer is up.
lastOutageStartedAt_uint256Timestamp when the preceding downtime began (used for grace math; 0 when not applicable).
isSequencerUpAndValid_boolisSequencerUp_ && gracePeriodPassed_; matches _ensureSequencerUpAndValid() success conditions.

_ensureSequencerUpAndValid ​

Reverts with UsdOracle__SequencerDown if the feed reports the sequencer down, or UsdOracle__SequencerGracePeriod if the sequencer is up but the grace window after the last outage has not elapsed.

solidity
function _ensureSequencerUpAndValid() internal view;

_lastSequencerOutageStart ​

finds last round before uptimeStartRoundId_ where sequencer status was down, incl. handling cases of consecutive rounds where status was down.

solidity
function _lastSequencerOutageStart(uint80 uptimeStartRoundId_) private view returns (uint256 outageStartedAt_);

_sequencerUpStatus ​

finds last round where sequencer status was up, incl. handling cases of consecutive rounds where status was up.

solidity
function _sequencerUpStatus()
    private
    view
    returns (bool isSequencerUp_, uint80 uptimeStartRoundId_, uint256 uptimeStartedAt_);

_gracePeriod ​

returns the gracePeriod_ duration and if the grace period has passed_ based on current uptime round data vs the last sequencer outage duration.

solidity
function _gracePeriod(uint80 uptimeStartRoundId_, uint256 uptimeStartedAt_)
    private
    view
    returns (uint256 gracePeriod_, bool passed_, uint256 outageStartedAt_);