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
Updates one or more Pyth price feeds
This function needs to be called right before calling getAssetPrice()
Parameters
_priceUpdateData
bytes[]
Pyth price update data
Return Values
success_
bool
Confirmation of success
getAssetPrice
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
_asset
address
ERC-20 token address
Return Values
assetPrice_
uint256
Asset price in USD with 18 decimal places
getPythContractAddress
Returns the Pyth contract address
Return Values
pythContractAddress_
address
Pyth contract address
isPriceFeedRegistered
Check if Pyth price feed is registered
Parameters
_asset
address
ERC-20 token address
Return Values
isRegistered_
bool
Confirmation of registration
getPriceFeedIdByAsset
Returns the Pyth price feed id for an asset
Parameters
_asset
address
ERC-20 token address
Return Values
priceFeedId_
bytes32
Pyth price feed id
getUpdateFee
Returns the required fee to update an array of price updates
Parameters
_updateData
bytes[]
Array of price update data
Return Values
updateFee_
uint256
Update fee in Wei
getValidTimePeriod
Returns the period (in seconds) that a price feed is considered valid since its publish time
Return Values
validTimePeriod_
uint256
Valid time period in seconds
getPriceMaxAge
Returns the maximum age of a price feed in seconds
Return Values
[0]
uint256
priceMaxAge Maximum age of a price feed in seconds
getPriceMinConfidenceRatio
Returns the minimum confidence ratio for an asset
Parameters
_asset
address
ERC-20 token address
Return Values
priceMinConfidenceRatio_
uint256
Minimum confidence ratio for the asset
Last updated