Skip to content

Commit

Permalink
Add importPythFeeds (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit authored Oct 8, 2024
1 parent 9bceb15 commit 8dcadd1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/importPythFeeds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export async function importPythFeeds(chainId: number, preset: string): Promise<string[]> {
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`);
}
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 8dcadd1

Please sign in to comment.