Skip to main content
OracleModule manages all price data for the protocol: Pyth spot prices for settlement, publisher-submitted forward prices for position opening and PnL calculation, and fixing prices recorded at maturity. Forward price publishing includes M2 safeguard checks that reject updates that are too frequent, too large, or deviate too far from prior prices.

Contract Relationships

Read Functions

getForward

function getForward(bytes32 pairId, uint64 fixingTimestamp)
    external view returns (ForwardPrice memory)
Returns the forward price struct for a pair and fixing timestamp. Does not check staleness.

getForwardByTenor

function getForwardByTenor(bytes32 pairId, Tenor tenor)
    external view returns (uint64 fixingTimestamp, ForwardPrice memory forward)
Returns the forward price by tenor, auto-computing the fixing timestamp from Config.

getForwardPrice

function getForwardPrice(bytes32 pairId, uint64 fixingTimestamp)
    external view returns (int256 price, uint64 publishTime)
Returns the forward price with staleness check. Reverts with OracleStale if the price exceeds maxForwardAge.

getFixingPrice

function getFixingPrice(bytes32 pairId, uint64 fixingTimestamp) external view returns (int256)
Returns the recorded fixing price for a pair and timestamp. Returns 0 if not yet recorded.

isOracleValid

function isOracleValid(bytes32 pairId) external view returns (bool)
Returns whether the oracle is valid for a pair. Checks both forward price staleness and overall oracle health.

latestForwardRoundId

function latestForwardRoundId(bytes32 pairId, uint64 fixingTimestamp) external view returns (uint64)
Returns the latest forward round ID for a given pair and fixing timestamp.

getActiveFixingTimestamps

function getActiveFixingTimestamps(bytes32 pairId) external view returns (uint64[] memory)
Returns all active (non-cleared) fixing timestamps for a pair. Used by the publisher to know which maturities need price updates.

Pair Registry

FunctionReturns
getPairPriceId(pairId)Pyth price feed ID
getPairPriceExpo(pairId)Pyth price exponent (e.g., -5)
isPairEnabled(pairId)Whether pair is enabled
getAllPairs()All registered pair IDs
getPairCount()Number of registered pairs
getPairAt(index)Pair ID by index

Safeguard Views

FunctionReturns
getLastForwardPublishTime(pairId)Timestamp of last forward publish
getLastAcceptedForwardPrice(pairId, fixingTimestamp)Last accepted forward price

Write Functions

publishForwardRound

function publishForwardRound(bytes32 pairId, uint64 fixingTimestamp, int256 price, uint64 roundId) external
Publishes a new forward price round. Restricted to PUBLISHER_ROLE. Subject to M2 safeguard checks.
NameTypeDescription
pairIdbytes32Currency pair identifier
fixingTimestampuint64Maturity timestamp
priceint256Forward price (18 decimal precision)
roundIduint64Sequential round identifier
M2 safeguard checks reject updates that violate spacing (minForwardUpdateSpacing), exceed move limits (maxOracleMovePerUpdateBps), or deviate too far from the prior forward (maxDeviationVsPriorBps) or last close price (maxDeviationVsLastCloseBps). See Oracle Safeguards.

publishForwardRounds

function publishForwardRounds(
    bytes32[] calldata pairIds,
    uint64[] calldata fixingTimestamps,
    int256[] calldata prices,
    uint64[] calldata roundIds
) external
Batch publishes multiple forward rounds in a single transaction for gas efficiency.

recordFixingPriceFromPyth

function recordFixingPriceFromPyth(
    bytes32 pairId,
    uint64 fixingTimestamp,
    bytes[] calldata pythUpdateData
) external payable
Records a fixing price from Pyth for a matured position. Permissionless — anyone can call. Requires ETH for the Pyth update fee.
NameTypeDescription
pairIdbytes32Currency pair identifier
fixingTimestampuint64Matured fixing timestamp
pythUpdateDatabytes[]Signed Pyth price data from Hermes API

clearForwardRound

function clearForwardRound(bytes32 pairId, uint64 fixingTimestamp) external
Clears forward round storage for a matured timestamp. Permissionless — earns a gas refund from storage slot cleanup. Reverts if open positions still reference this timestamp.

clearMaturedForwards

function clearMaturedForwards(bytes32 pairId) external
Clears all matured forward rounds with no remaining open positions. Permissionless.

Admin Functions

registerPair

function registerPair(bytes32 pairId, bytes32 priceId, int8 priceExpo) external
Registers a currency pair with its Pyth price feed ID and exponent. Owner only.

disablePair

function disablePair(bytes32 pairId) external
Disables a currency pair. Owner only.

adminSetFixingPrice

function adminSetFixingPrice(bytes32 pairId, uint64 fixingTimestamp, int256 price) external
Admin override to set a fixing price directly without Pyth data. Owner only — for emergency use.

clearAllForwards

function clearAllForwards(bytes32 pairId) external
Clears all forward rounds for a pair and resets safeguard baselines. Owner only.

Events

EventWhen Emitted
PairRegisteredNew currency pair registered
PairDisabledCurrency pair disabled
ForwardRoundPublishedForward price published by publisher
ForwardRoundClearedForward round storage cleared
FixingPriceRecordedFixing price recorded from Pyth
OracleInvalidatedOracle marked invalid
OracleSafeguardConfigUpdatedSafeguard configuration changed

Oracle Pricing

Forward price formula and interest rate parity.

Oracle Safeguards

M2 safeguard checks and thresholds.

Publisher Operations

Running the forward price publisher service.