From 8ea46efebd40dc319a22fe90faa7aa5496d3dab7 Mon Sep 17 00:00:00 2001 From: Rahul Sethuram Date: Fri, 17 Jan 2025 17:41:42 +0400 Subject: [PATCH] feat: run pyth bot for optimism --- .../bots/pyth-updater/src/config/index.ts | 5 +++-- .../bots/pyth-updater/src/config/optimism.ts | 21 +++++++++++++++++++ packages/bots/pyth-updater/src/run.ts | 4 +++- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 packages/bots/pyth-updater/src/config/optimism.ts diff --git a/packages/bots/pyth-updater/src/config/index.ts b/packages/bots/pyth-updater/src/config/index.ts index 3faf4915ed..71ae65e687 100644 --- a/packages/bots/pyth-updater/src/config/index.ts +++ b/packages/bots/pyth-updater/src/config/index.ts @@ -1,9 +1,10 @@ -import { base, mode } from '@ionicprotocol/chains'; +import { base, mode, optimism } from '@ionicprotocol/chains'; import { pythConfig as basePythConfig } from './base'; import { pythConfig as modePythConfig } from './mode'; - +import { pythConfig as optimismPythConfig } from './optimism'; export const chainIdToConfig = { [mode.chainId]: modePythConfig, [base.chainId]: basePythConfig, + [optimism.chainId]: optimismPythConfig, }; diff --git a/packages/bots/pyth-updater/src/config/optimism.ts b/packages/bots/pyth-updater/src/config/optimism.ts new file mode 100644 index 0000000000..57b0d2ef58 --- /dev/null +++ b/packages/bots/pyth-updater/src/config/optimism.ts @@ -0,0 +1,21 @@ +import { PythAssetConfig } from '../types'; + +import { pythConfig as commonPythConfig } from './common'; + +export const pythConfig: PythAssetConfig[] = [ + ...commonPythConfig, + { + // price feed for WBTC + priceId: '0xc9d8b075a5c69303365ae23633d4e085199bf5c520a3b90fed1322a0342ffc33', + configRefreshRateInSeconds: 3600, + validTimePeriodSeconds: 86400, // 24 hrs + deviationThresholdBps: 100, // 1% + }, + { + // price feed for SNX + priceId: '0x39d020f60982ed892abbcd4a06a276a9f9b7bfbce003204c110b6e488f502da3', + configRefreshRateInSeconds: 3600, + validTimePeriodSeconds: 86400, // 24 hrs + deviationThresholdBps: 100, // 1% + }, +]; diff --git a/packages/bots/pyth-updater/src/run.ts b/packages/bots/pyth-updater/src/run.ts index 5145bbdf14..5c14650232 100644 --- a/packages/bots/pyth-updater/src/run.ts +++ b/packages/bots/pyth-updater/src/run.ts @@ -1,6 +1,6 @@ import { createPublicClient, createWalletClient, fallback, Hex, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; -import { base, mode } from 'viem/chains'; +import { base, mode, optimism } from 'viem/chains'; import { chainIdToConfig } from './config'; import config from './config/service'; @@ -15,6 +15,8 @@ export const run = async (): Promise => { chain = mode; } else if (config.chainId === base.id) { chain = base; + } else if (config.chainId === optimism.id) { + chain = optimism; } else { throw new Error(`Unsupported chain ID: ${config.chainId}`); }