FluidCenterPriceL2 ​
Inherits:IFluidCenterPrice, OracleError
Base contract that any Fluid Center Price L2 must implement
State Variables ​
_infoName ​
short helper string to easily identify the center price oracle. E.g. token symbols
bytes32 private immutable _infoName;_TARGET_DECIMALS ​
uint8 internal constant _TARGET_DECIMALS = 27;_SEQUENCER_ORACLE ​
Chainlink L2 Sequencer Uptime feed to detect sequencer outages
IChainlinkAggregatorV3 internal immutable _SEQUENCER_ORACLE;_SEQUENCER_MAX_GRACE_PERIOD ​
max time period until oracle assumes normal behavior after a sequencer outage.
uint256 internal constant _SEQUENCER_MAX_GRACE_PERIOD = 45 minutes;Functions ​
constructor ​
constructor(string memory infoName_, address sequencerUptimeFeed_);sequencerL2Data ​
returns all sequencer uptime feed related data
function sequencerL2Data()
public
view
returns (
address sequencerUptimeFeed_,
uint256 maxGracePeriod_,
bool isSequencerUp_,
uint256 lastUptimeStartedAt_,
uint256 gracePeriod_,
bool gracePeriodPassed_,
uint256 lastOutageStartedAt_,
bool isSequencerUpAndValid_
);_ensureSequencerUpAndValid ​
ensures that the sequencer is up and grace period has passed
function _ensureSequencerUpAndValid() internal view;targetDecimals ​
target decimals of the returned rate. for center price contracts it is always 27
function targetDecimals() public pure virtual returns (uint8);infoName ​
helper string to easily identify the oracle. E.g. token symbols
function infoName() public view virtual returns (string memory);centerPrice ​
Retrieves the center price for the pool
This function is marked as non-constant (potentially state-changing) to allow flexibility in price fetching mechanisms. While typically used as a read-only operation, this design permits write operations if needed for certain token pairs (e.g., fetching up-to-date exchange rates that may require state changes).
function centerPrice() external virtual returns (uint256 price_);Returns
| Name | Type | Description |
|---|---|---|
price_ | uint256 | The current price ratio of token1 to token0, expressed with 27 decimal places |
_lastSequencerOutageStart ​
finds last round before uptimeStartRoundId_ where sequencer status was down, incl. handling cases of consecutive rounds where status was down.
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.
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.
function _gracePeriod(uint80 uptimeStartRoundId_, uint256 uptimeStartedAt_)
private
view
returns (uint256 gracePeriod_, bool passed_, uint256 outageStartedAt_);
