PythAdapter

Price oracle adapter that uses Pyth price feeds (https://pyth.network)

Events

PythContractAddressSet

event PythContractAddressSet(address sender, address pythContractAddress)

PriceFeedRegistered

event PriceFeedRegistered(address sender, address asset, bytes32 priceFeedId)

PriceFeedUnregistered

event PriceFeedUnregistered(address sender, address asset)

PriceMaxAgeSet

event PriceMaxAgeSet(address sender, uint256 newPriceMaxAge)

PriceMinConfidenceRatioSet

event PriceMinConfidenceRatioSet(address owner, address asset, uint256 oldPriceMinConfidenceRatio, uint256 newPriceMinConfidenceRatio)

PriceFeedsUpdated

event PriceFeedsUpdated(address sender, uint256 updateFee)

Functions

updatePriceFeeds

function updatePriceFeeds(bytes[] _priceUpdateData) external payable returns (bool success_)

Updates one or more Pyth price feeds

This function needs to be called right before calling getAssetPrice()

Parameters

Return Values

getAssetPrice

function getAssetPrice(address _asset) external view returns (uint256 assetPrice_)

Returns the asset price

This function reverts with a StalePrice error if the on-chain price has not been updated within the last getValidTimePeriod() seconds via updatePriceFeeds()

Parameters

Return Values

getPythContractAddress

function getPythContractAddress() external view returns (address pythContractAddress_)

Returns the Pyth contract address

Return Values

isPriceFeedRegistered

function isPriceFeedRegistered(address _asset) public view returns (bool isRegistered_)

Check if Pyth price feed is registered

Parameters

Return Values

getPriceFeedIdByAsset

function getPriceFeedIdByAsset(address _asset) public view returns (bytes32 priceFeedId_)

Returns the Pyth price feed id for an asset

Parameters

Return Values

getUpdateFee

function getUpdateFee(bytes[] _updateData) public view returns (uint256 updateFee_)

Returns the required fee to update an array of price updates

Parameters

Return Values

getValidTimePeriod

function getValidTimePeriod() external view returns (uint256 validTimePeriod_)

Returns the period (in seconds) that a price feed is considered valid since its publish time

Return Values

getPriceMaxAge

function getPriceMaxAge() external view returns (uint256)

Returns the maximum age of a price feed in seconds

Return Values

getPriceMinConfidenceRatio

function getPriceMinConfidenceRatio(address _asset) external view returns (uint256 priceMinConfidenceRatio_)

Returns the minimum confidence ratio for an asset

Parameters

Return Values

Last updated