Helpers ​
Inherits:Variables, Events, OracleError
Functions ​
constructor ​
constructor(CLXStockOracleConstructorParams memory p_) Constants(p_);_requireNotPaused ​
function _requireNotPaused() internal view;_getPrice ​
Current-session price. Debt inverts extended-hours clamp vs collateral. isRaw_: skip pause / band / staleness; return 0 if CL/multiplier invalid.
function _getPrice(bool isOperate_, bool isDebt_, bool isRaw_)
internal
view
returns (uint256 price_, uint256 liveMultiplier_);_getPriceWrite ​
Write path: MH cursor, in-band multiplier sync, optional RTH store / fallback event.
function _getPriceWrite(bool isOperate_, bool isDebt_) internal returns (uint256 price_);_regularHoursSyncTime ​
Seal only once regularEnd + REGULAR_HOURS_ANCHOR_BUFFER has passed: a close print can land in the window until then, and sealing first would lock in an earlier round. Before that, store a hint.
function _regularHoursSyncTime(uint256 sessionType_, uint32 regularEnd_) internal view returns (uint32);_getPriceForSession ​
Session price. persistRoundId_ = 0 & regularHoursNotFoundFallback_ = true when RTH clamp skipped.
function _getPriceForSession(
bool isOperate_,
bool isDebt_,
uint256 sessionType_,
uint32 regularStart_,
uint32 regularEnd_,
bool isRaw_
)
internal
view
returns (uint256 price_, uint256 liveMultiplier_, uint80 persistRoundId_, bool regularHoursNotFoundFallback_);_revertIfStalePrice ​
Op Regular/Extended: heartbeat-fresh. Else (liq / Holiday/Unknown / MH window failure): 5d extended.
function _revertIfStalePrice(uint256 updatedAt_, bool isOperate_, uint256 sessionType_, bool mhWindowFailure_)
internal
view;_isRegularWindowTrusted ​
MH window metadata ok to use for clamp (non-empty, well-formed, regularEnd < 5d old). Does not look up Chainlink — that is _findLatestRegularHoursRound.
function _isRegularWindowTrusted(uint32 regularStart_, uint32 regularEnd_) internal view returns (bool);_clampExtendedHoursPrice ​
Resolve RTH CL answer + clamp. found_=false if no CL round in the RTH time window.
function _clampExtendedHoursPrice(
uint256 price_,
uint256 liveMultiplier_,
bool isOperate_,
bool isDebt_,
uint32 regularStart_,
uint32 regularEnd_
) internal view returns (bool found_, uint80 resolvedRoundId_, uint256 clamped_);_storeRegularHoursReference ​
syncTime_ from _regularHoursSyncTime: regularEnd seals the round, anything else is a hint.
function _storeRegularHoursReference(uint80 roundId_, uint32 syncTime_) internal;_mayRollRegularHoursReference ​
Rate limit on gap-reference rolls: without it, a split that CL prints as several quick rounds can be walked past the gap guard by re-anchoring onto an intermediate print (one in-band hop covers a 2:1). Same-round stores only refresh the marker; gov / class ≥ 3 rolls skip this gate. A blocked roll is skipped silently — pricing itself is never affected.
function _mayRollRegularHoursReference(uint80 newRoundId_, uint256 sessionType_, uint32 regularStart_)
internal
view
returns (bool);_resolveRegularHoursReference ​
RTH answer for regularEnd_: the stored round if sealed for it, else search.
function _resolveRegularHoursReference(uint32 regularStart_, uint32 regularEnd_)
internal
view
returns (bool found_, uint80 roundId_, uint256 answer_);_findLatestRegularHoursRound ​
Walk CL history for the latest round in [regularStart_, regularEnd_ + buffer]. Once the window is past, the start widens by MIN_CHAINLINK_HEARTBEAT so quiet sessions still anchor. See EDGE_CASES.md.
function _findLatestRegularHoursRound(
uint32 regularStart_,
uint32 regularEnd_,
uint80 hintRoundId_,
uint32 hintSyncedAt_
) internal view returns (bool found_, uint80 roundId_, uint256 answer_);Parameters
| Name | Type | Description |
|---|---|---|
regularStart_ | uint32 | |
regularEnd_ | uint32 | |
hintRoundId_ | uint80 | 0 = start from latest. |
hintSyncedAt_ | uint32 | Sync age, or 0 → age by round updatedAt. Stale hints start from latest. |
_isPreWindowAnchorTrusted ​
Rejects a pre-window anchor only if the feed provably missed a print it owed (print + heartbeat) during trading hours. A missed deadline in HOLIDAY or UNKNOWN proves nothing. See EDGE_CASES.md.
function _isPreWindowAnchorTrusted(uint80 roundId_, uint256 updatedAt_) internal view returns (bool);_getRegularHoursRoundCursor ​
Fresh hint if age-ok; else latest. hintSyncedAt_ != 0 ages by sync, else by CL updatedAt.
function _getRegularHoursRoundCursor(uint80 hintRoundId_, uint32 hintSyncedAt_)
internal
view
returns (bool found_, uint80 roundIdCursor_, uint256 answerAtCursor_, uint256 updatedAt_);_walkBackToLatestInWindow ​
From after windowEnd_, walk back to first updatedAt <= windowEnd_ (latest in-window candidate). Stops on read failure or updatedAt == 0 (post-tip phantom rounds some CL feeds return as success).
function _walkBackToLatestInWindow(
uint80 roundIdCursor_,
uint256 answerAtCursor_,
uint256 updatedAt_,
uint256 windowStart_,
uint256 windowEnd_
) internal view returns (bool found_, uint80 roundId_, uint256 answer_, uint256 foundUpdatedAt_);_walkForwardToLatestInWindow ​
From at/before windowEnd_, walk forward; keep last in [windowStart_, windowEnd_]. Stops on read failure or updatedAt == 0 (post-tip phantom rounds some CL feeds return as success).
function _walkForwardToLatestInWindow(
uint80 roundIdCursor_,
uint256 answerAtCursor_,
uint256 updatedAt_,
uint256 windowStart_,
uint256 windowEnd_
) internal view returns (bool found_, uint80 roundId_, uint256 answer_, uint256 foundUpdatedAt_);_syncAcceptedMultiplier ​
function _syncAcceptedMultiplier(uint256 live_) internal;_tryReadChainlinkRound ​
roundId_ == 0 → latest. Revert → success false. Answer ≤ 0 → answer_ == 0. updatedAt == 0 is returned as-is: callers decide (walkers treat it as tip/gap, live price path surfaces it as StalePrice).
function _tryReadChainlinkRound(uint80 roundId_) internal view returns (bool, uint80, uint256, uint256);_readLatestPrice ​
CL × live multiplier × RATE_MULTIPLIER. Raw soft-fails to zeros; else InvalidPrice.
function _readLatestPrice(bool isRaw_)
internal
view
returns (uint256 price_, uint256 multiplier_, uint256 updatedAt_, uint80 roundId_);_revertIfScheduledMultiplierOutsideBand ​
Pending schedule within SCHEDULED_MULTIPLIER_FREEZE_BUFFER and outside absolute MAX% vs live.
function _revertIfScheduledMultiplierOutsideBand(uint256 live_) internal view;_freshAnchorReferenceAnswer ​
Anchor-round answer as gap reference; 0 = unset / unreadable / too old.
function _freshAnchorReferenceAnswer() internal view returns (uint256 answer_);_isPriceGapOutside ​
Strictly outside −down% / +up% of reference_.
function _isPriceGapOutside(uint256 reference_, uint256 value_) internal view returns (bool);_isLiveMultiplierOutsideBand ​
Outside time-accrued band of _acceptedMultiplier. MAX% == 0 → freeze (live != accepted). Accrues absolute maxDiff = accepted * MAX% * elapsed / (PERIOD * 1e4) (not floored percent).
function _isLiveMultiplierOutsideBand(uint256 live_) internal view returns (bool);