From 8dcadd143d56e9aea940819d740a12bb74073124 Mon Sep 17 00:00:00 2001 From: Noisekit <28145325+noisekit@users.noreply.github.com> Date: Tue, 8 Oct 2024 22:01:29 +0800 Subject: [PATCH] Add importPythFeeds (#10) --- src/importPythFeeds.ts | 36 ++++++++++++++++++++++++++++++++++++ src/index.ts | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/importPythFeeds.ts diff --git a/src/importPythFeeds.ts b/src/importPythFeeds.ts new file mode 100644 index 0000000..7b67b7f --- /dev/null +++ b/src/importPythFeeds.ts @@ -0,0 +1,36 @@ +export async function importPythFeeds(chainId: number, preset: string): Promise { + const deployment = `${Number(chainId).toFixed(0)}-${preset}`; + switch (deployment) { + case '1-main': { + const [{ default: pythFeeds }] = await Promise.all([import('@synthetixio/v3-contracts/1-main/pythFeeds.json')]); + return pythFeeds; + } + case '11155111-main': { + const [{ default: pythFeeds }] = await Promise.all([import('@synthetixio/v3-contracts/11155111-main/pythFeeds.json')]); + return pythFeeds; + } + case '10-main': { + const [{ default: pythFeeds }] = await Promise.all([import('@synthetixio/v3-contracts/10-main/pythFeeds.json')]); + return pythFeeds; + } + case '8453-andromeda': { + const [{ default: pythFeeds }] = await Promise.all([import('@synthetixio/v3-contracts/8453-andromeda/pythFeeds.json')]); + return pythFeeds; + } + case '84532-andromeda': { + const [{ default: pythFeeds }] = await Promise.all([import('@synthetixio/v3-contracts/84532-andromeda/pythFeeds.json')]); + return pythFeeds; + } + case '42161-main': { + const [{ default: pythFeeds }] = await Promise.all([import('@synthetixio/v3-contracts/42161-main/pythFeeds.json')]); + return pythFeeds; + } + case '421614-main': { + const [{ default: pythFeeds }] = await Promise.all([import('@synthetixio/v3-contracts/421614-main/pythFeeds.json')]); + return pythFeeds; + } + default: { + throw new Error(`Unsupported deployment ${deployment} for pythFeeds`); + } + } +} diff --git a/src/index.ts b/src/index.ts index 8acecf0..a712a38 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,6 +47,7 @@ export * from './importMulticall'; export * from './importPerpsAccountProxy'; export * from './importPerpsMarketProxy'; export * from './importPythERC7412Wrapper'; +export * from './importPythFeeds'; export * from './importRewardsDistributors'; export * from './importSpotMarketProxy'; export * from './importSynthTokens'; @@ -75,8 +76,8 @@ export * from './usePerpsCommitOrder'; export * from './usePerpsCreateAccount'; export * from './usePerpsGetAvailableMargin'; export * from './usePerpsGetCollateralAmount'; -export * from './usePerpsGetMarkets'; export * from './usePerpsGetMarketSummary'; +export * from './usePerpsGetMarkets'; export * from './usePerpsGetOpenPosition'; export * from './usePerpsGetOrder'; export * from './usePerpsGetRequiredMargins';