IPythAdapter

IPythAdapter

registerPriceFeed

function registerPriceFeed(address _asset, bytes32 _priceFeedId) external returns (bool success)

Registers a new Pyth price feed

Parameters

NameTypeDescription

_asset

address

ERC-20 token address

_priceFeedId

bytes32

Pyth price feed id

Return Values

NameTypeDescription

success

bool

Confirmation of success

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

NameTypeDescription

_priceUpdateData

bytes[]

Pyth price update data

Return Values

NameTypeDescription

success

bool

Confirmation of success

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 updateAssetPrice()

Parameters

NameTypeDescription

_asset

address

ERC-20 token address

Return Values

NameTypeDescription

assetPrice

uint256

Asset price in USD with 18 decimal places

isPriceFeedRegistered

function isPriceFeedRegistered(address _asset) external view returns (bool isRegistered)

Check if Pyth price feed is registered

Parameters

NameTypeDescription

_asset

address

ERC-20 token address

Return Values

NameTypeDescription

isRegistered

bool

Confirmation of registration

getUpdateFee

function getUpdateFee(bytes[] _updateData) external view returns (uint256 updateFee)

Returns the required fee to update an array of price updates

Parameters

NameTypeDescription

_updateData

bytes[]

Array of price update data

Return Values

NameTypeDescription

updateFee

uint256

Update fee in Wei

Last updated