Skip to main content

PythFeedOracle.sol

PythFeedOracle

PriceFeedNotExist

error PriceFeedNotExist()

WrongData

error WrongData()

pyth

contract AbstractPyth pyth

Pyth address (https://docs.pyth.network/documentation/pythnet-price-feeds/evm)

priceFeedId

bytes32 priceFeedId

The id of pyth price feed (https://pyth.network/developers/price-feed-ids#pyth-evm-mainnet)

constructor

constructor(contract AbstractPyth pyth_, bytes32 priceFeedId_, string description_) public

Initializes the contract state

sync

function sync() public 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

lastSyncedVersion

function lastSyncedVersion() external view returns (struct IOracleProvider.OracleVersion)

Retrieves the last synchronized oracle version

  • Return Values:

    NameTypeDescription
    [0]struct IOracleProvider.OracleVersionLast synchronized 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.

extraModule

function extraModule() external pure returns (enum ExtraModule)

Returns the type of automation module that the Keeper will execute, either "None" or "Pyth".

  • Return Values:

    NameTypeDescription
    [0]enum ExtraModuleAutomation module type, which can be "None" or "Pyth".

extraParam

function extraParam() external view returns (bytes)

Retrieves the parameter needed to request data from the Keeper, e.g., the price feed ID in the case of Pyth integration.

  • Return Values:

    NameTypeDescription
    [0]bytesRequired parameter for Keeper requests as bytes

updatePrice

function updatePrice(bytes offchainData) external payable

Updates the Oracle Provider with the provided off-chain data

  • Parameters:

    NameTypeDescription
    offchainDatabytesOff-chain data used for the update

getUpdateFee

function getUpdateFee(bytes offchainData) external view returns (uint256)

Returns the fee required to update the Oracle Provider with the given off-chain data

  • Parameters:

    NameTypeDescription
    offchainDatabytesOff-chain data required for the update
  • Return Values:

    NameTypeDescription
    [0]uint256fee amount

decodeOffchainData

function decodeOffchainData(bytes offchainData) internal pure returns (struct PythOffchainPrice)

baseDecimalPrice

function baseDecimalPrice(int256 pythPrice, int32 expo) internal pure returns (int256)

pythPriceToOracleVersion

function pythPriceToOracleVersion(struct PythStructs.Price price, uint256 version) internal pure returns (struct IOracleProvider.OracleVersion)

parseExtraData

function parseExtraData(bytes extraData) external view returns (struct IOracleProvider.OracleVersion)

Parses the provided off-chain data received from the Keeper and returns an OracleVersion structure representing the parsed data

  • Parameters:

    NameTypeDescription
    extraDatabytesOff-chain data received from the Keeper
  • Return Values:

    NameTypeDescription
    [0]struct IOracleProvider.OracleVersionParsed OracleVersion structure