Skip to main content

ChainlinkFeedOracle.sol

ChainlinkFeedOracle

Chainlink implementation of the IOracle interface.

One instance per Chainlink price feed should be deployed. Multiple products may use the same ChainlinkOracle instance if their payoff functions are based on the same underlying oracle. This implementation only support non-negative prices.

UnableToSyncError

error UnableToSyncError()

aggregator

ChainlinkAggregator aggregator

Chainlink feed aggregator address

Phase

struct Phase {
uint128 startingVersion;
uint128 startingRoundId;
}

constructor

constructor(ChainlinkAggregator aggregator_) public

Initializes the contract state

  • Parameters:

    NameTypeDescription
    aggregator_ChainlinkAggregatorChainlink price feed aggregator

sync

function sync() external returns (struct IOracleProvider.OracleVersion)

Checks for a new price and updates the internal phase annotation state accordingly

sync is expected to be called soon after a phase update occurs in the underlying proxy. Phase updates should be detected using off-chain mechanism and should trigger a sync call This is feasible in the short term due to how infrequent phase updates are, but phase update and roundCount detection should eventually be implemented at the contract level. Reverts if there is more than 1 phase to update in a single sync because we currently cannot determine the startingRoundId for the intermediary phase.

  • Return Values:

    NameTypeDescription
    [0]struct IOracleProvider.OracleVersionThe current oracle version after sync

currentVersion

function currentVersion() public view returns (struct IOracleProvider.OracleVersion oracleVersion)

Returns the current oracle version

  • Return Values:

    NameTypeDescription
    oracleVersionstruct IOracleProvider.OracleVersionoracleVersion Current oracle version

atVersion

function atVersion(uint256 version) public view returns (struct IOracleProvider.OracleVersion oracleVersion)

Returns the current oracle version

  • Parameters:

    NameTypeDescription
    versionuint256The version of which to lookup
  • Return Values:

    NameTypeDescription
    oracleVersionstruct IOracleProvider.OracleVersionoracleVersion Oracle version at version version

description

function description() external view returns (string)

Retrieves the description of the Oracle Provider.

  • Return Values:

    NameTypeDescription
    [0]stringA string representing the description of the Oracle Provider.

oracleProviderName

function oracleProviderName() external pure returns (string)

Retrieves the name of the Oracle Provider.

  • Return Values:

    NameTypeDescription
    [0]stringA string representing the name of the Oracle Provider.