On our end, we are updating the Pyth price every 30 seconds by calling the following function:
0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::pyth::update_price_feeds_with_funder
However, we occasionally encounter an error when generating the payload:
Failed to generate a Pyth price payload: TypeError: fetch failed
at node:internal/deps/undici/undici:13502:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async HermesClient.httpRequest (C:\kanalabs\perpetual repos\liquidation-bot\node_modules\@pythnetwork\hermes-client\lib\HermesClient.js:29:30) {
[cause]: Error: getaddrinfo ENOTFOUND hermes-beta.pyth.network
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'hermes-beta.pyth.network'
}
}
Here is the code we are using:
export const updatePythPricePayload = async (marketId: string) => {
try {
const priceIds = [MARKET_PRICE_FEEDS[marketId]];
const connection = new HermesClient(process.env.PYTH_HERMES_ENDPOINT!, {});
const priceFeedUpdateData = await connection.getLatestPriceUpdates(priceIds, {
encoding: "base64",
});
const binaryDataAsNumbers: number[][] = priceFeedUpdateData.binary.data.map((base64String: string) =>
Array.from(Buffer.from(base64String, "base64"))
);
const payloadResponse = {
function: "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::pyth::update_price_feeds_with_funder",
functionArguments: [binaryDataAsNumbers],
typeArguments: [],
} as InputEntryFunctionData;
return payloadResponse;
} catch (error: any) {
console.log("Failed to update Pyth price payload: ", error);
rollbar.error("Failed to update Pyth price payload.", error);
}
};
We’ve set PYTH_HERMES_ENDPOINT=https://hermes-beta.pyth.network and APT_PRICE_FEED_ID=0x44a93dddd8effa54ea51076c4e851b6cbbfd938e82eb90197de38fe8876bb66e.
Could anyone please help us understand and resolve this issue?