Skip to content

Commit

Permalink
feat: run pyth bot for optimism
Browse files Browse the repository at this point in the history
  • Loading branch information
rhlsthrm committed Jan 17, 2025
1 parent 202602e commit 8ea46ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/bots/pyth-updater/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -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,
};
21 changes: 21 additions & 0 deletions packages/bots/pyth-updater/src/config/optimism.ts
Original file line number Diff line number Diff line change
@@ -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%
},
];
4 changes: 3 additions & 1 deletion packages/bots/pyth-updater/src/run.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,6 +15,8 @@ export const run = async (): Promise<void> => {
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}`);
}
Expand Down

0 comments on commit 8ea46ef

Please sign in to comment.