Skip to content

Commit

Permalink
Merge pull request #117 from ionicprotocol/development
Browse files Browse the repository at this point in the history
Main deploy
  • Loading branch information
rhlsthrm authored Jan 25, 2024
2 parents 9894796 + 9aa6fcb commit ac5a7c3
Show file tree
Hide file tree
Showing 8,448 changed files with 71,540 additions and 68,336 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
}
2 changes: 1 addition & 1 deletion .github/workflows/package-ui-deploy-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '20'
cache: 'yarn'

- name: Install `foundry`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/package-ui-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '20'
cache: 'yarn'

- name: Install `foundry`
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/package-ui-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '20'
cache: 'yarn'

- name: Install `foundry`
Expand All @@ -36,5 +36,5 @@ jobs:
- name: Build `ui`
run: yarn build:deploy:ui

- name: Lint `ui`
run: yarn workspace @ionicprotocol/ui lint
# - name: Lint `ui`
# run: yarn workspace @ionicprotocol/ui lint
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
!.yarn/sdks
!.yarn/versions

# !.yarn/cache
#!.yarn/cache
.pnp.*
node_modules*
!/packages/bots/liquidator/.env
Expand Down
5 changes: 5 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ETHEREUM = "false"
ZKEVM = "true"
LINEA = "true"
NEON = "true"
# MODE_NETWORK = "true" # TODO
IS_SENTRY_ENABLED = "false"
IS_PRODUCTION = "false"

Expand All @@ -45,9 +46,11 @@ ARBITRUM = "true"
ETHEREUM = "false"
ZKEVM = "true"
LINEA = "true"
# MODE_NETWORK = "true" # TODO
NEON = "true"
IS_SENTRY_ENABLED = "false"
IS_PRODUCTION = "false"
NODE_ENV = "production"

[context.production.environment]
NEXT_PUBLIC_SHOW_TESTNETS = "false"
Expand All @@ -57,9 +60,11 @@ ARBITRUM = "true"
ETHEREUM = "false"
ZKEVM = "true"
LINEA = "true"
# MODE_NETWORK = "true" # TODO
NEON = "true"
IS_SENTRY_ENABLED = "true"
IS_PRODUCTION = "true"
NODE_ENV = "production"

[functions]
directory = "./packages/functions/dist/functions/src/functions"
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
},
"dependencies": {
"@resolver-engine/core": "^0.3.3",
"ts-node": "^10.9.1"
"@wagmi/core": "^2.2.1",
"ts-node": "^10.9.1",
"viem": "^2.1.1"
},
"resolutions": {
"@types/react": "^17.0.15"
Expand Down
6 changes: 4 additions & 2 deletions packages/bots/pyth-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "eslint . -c .eslintrc.json --ext ts,json",
"lint-fix": "eslint . -c .eslintrc.json --fix --ext ts,json",
"staging": "NODE_ENV=staging node build/server.js",
"dev": "HTTPS=true NODE_ENV=development ts-node-dev --inspect --respawn src/server.ts",
"dev": "HTTPS=true NODE_ENV=development ts-node-dev --inspect --respawn src/run.ts",
"test": "NODE_ENV=test nyc ./node_modules/.bin/mocha --require ts-node/register ./src/test/**/**/**/**/*.test.ts",
"build": "rimraf build && tsc -p tsconfig.json"
},
Expand Down Expand Up @@ -36,7 +36,8 @@
"ethers": "^5.6.5",
"pino": "^8.0.0",
"pino-pretty": "^9.1.1",
"prettier": "2.6.2"
"prettier": "2.6.2",
"ts-node-dev": "^2.0.0"
},
"devDependencies": {
"@types/eslint": "^8.4.3",
Expand All @@ -52,6 +53,7 @@
"prettier": "2.7.1",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.1.6"
}
}
4 changes: 3 additions & 1 deletion packages/bots/pyth-updater/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { linea, neon, zkevm } from '@ionicprotocol/chains';
import { linea, mode, neon, zkevm } from '@ionicprotocol/chains';

import { pythConfig as lineaPythConfig } from './linea';
import { pythConfig as modePythConfig } from './mode';
import { pythConfig as neonPythConfig } from './neon';
import { pythConfig as zkevmPythConfig } from './zkevm';

export const chainIdToConfig = {
[neon.chainId]: neonPythConfig,
[linea.chainId]: lineaPythConfig,
[zkevm.chainId]: zkevmPythConfig,
[mode.chainId]: modePythConfig,
};
70 changes: 70 additions & 0 deletions packages/bots/pyth-updater/src/config/mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { PythAssetConfig } from '../types';

import { pythConfig as commonPythConfig } from './common';

export const pythConfig: PythAssetConfig[] = [
...commonPythConfig,
{
// price feed for WETH
priceId: '0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
configRefreshRateInSeconds: 3600,
validTimePeriodSeconds: 86400, // 24 hrs
deviationThresholdBps: 100, // 1%
},
{
// price feed for USDC
priceId: '0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
configRefreshRateInSeconds: 3600,
validTimePeriodSeconds: 86400, // 24 hrs
deviationThresholdBps: 100, // 1%
},
{
// price feed for USDT
priceId: '0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b',
configRefreshRateInSeconds: 3600,
validTimePeriodSeconds: 86400, // 24 hrs
deviationThresholdBps: 100, // 1%
},
// {
// // price feed for WBTC
// priceId: '0xc9d8b075a5c69303365ae23633d4e085199bf5c520a3b90fed1322a0342ffc33',
// configRefreshRateInSeconds: 3600,
// validTimePeriodSeconds: 86400, // 24 hrs
// deviationThresholdBps: 100, // 1%
// },
// {
// // price feed for UNI
// priceId: '0x78d185a741d07edb3412b09008b7c5cfb9bbbd7d568bf00ba737b456ba171501',
// configRefreshRateInSeconds: 3600,
// validTimePeriodSeconds: 86400, // 24 hrs
// deviationThresholdBps: 100, // 1%
// },
// {
// // price feed for SNX
// priceId: '0x39d020f60982ed892abbcd4a06a276a9f9b7bfbce003204c110b6e488f502da3',
// configRefreshRateInSeconds: 3600,
// validTimePeriodSeconds: 86400, // 24 hrs
// deviationThresholdBps: 100, // 1%
// },
// {
// // price feed for LINK
// priceId: '0x8ac0c70fff57e9aefdf5edf44b51d62c2d433653cbb2cf5cc06bb115af04d221',
// configRefreshRateInSeconds: 3600,
// validTimePeriodSeconds: 86400, // 24 hrs
// deviationThresholdBps: 100, // 1%
// },
// {
// // price feed for DAI
// priceId: '0xb0948a5e5313200c632b51bb5ca32f6de0d36e9950a942d19751e833f70dabfd',
// configRefreshRateInSeconds: 3600,
// validTimePeriodSeconds: 86400, // 24 hrs
// deviationThresholdBps: 100, // 1%
// },
// {
// // price feed for BAL
// priceId: '0x07ad7b4a7662d19a6bc675f6b467172d2f3947fa653ca97555a9b20236406628',
// configRefreshRateInSeconds: 3600,
// validTimePeriodSeconds: 86400, // 24 hrs
// deviationThresholdBps: 100, // 1%
// },
];
4 changes: 2 additions & 2 deletions packages/bots/pyth-updater/src/config/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ doetenv.config();
const config = {
environment: process.env.NODE_ENV ?? 'development',
logLevel: process.env.LOG_LEVEL ?? 'info',
chainId: parseInt(process.env.TARGET_CHAIN_ID ?? '59144', 10),
rpcUrl: process.env.WEB3_HTTP_PROVIDER_URL ?? 'https://linea-mainnet.infura.io/v3/',
chainId: parseInt(process.env.TARGET_CHAIN_ID ?? '34443', 10),
rpcUrl: process.env.WEB3_HTTP_PROVIDER_URL ?? 'https://mainnet.mode.network',
adminPrivateKey: process.env.ETHEREUM_ADMIN_PRIVATE_KEY ?? '',
adminAccount: process.env.ETHEREUM_ADMIN_ACCOUNT ?? '',
discordWebhookUrl: process.env.DISCORD_WEBHOOK_URL ?? '',
Expand Down
1 change: 1 addition & 0 deletions packages/bots/pyth-updater/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const handler = async (
): Promise<APIGatewayProxyResult> => {
logger.info(`Event: ${JSON.stringify(event)}`);
logger.info(`Context: ${JSON.stringify(context)}`);
logger.info(`Started`);

const provider = new JsonRpcProvider(config.rpcUrl);
const signer = new Wallet(config.adminPrivateKey, provider);
Expand Down
22 changes: 22 additions & 0 deletions packages/bots/pyth-updater/src/run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { JsonRpcProvider } from '@ethersproject/providers';
import { Wallet } from 'ethers';

import { chainIdToConfig } from './config';
import config from './config/service';
import { Updater } from './services';
import { setUpSdk } from './utils';

export const run = async (): Promise<void> => {
const provider = new JsonRpcProvider(config.rpcUrl);
const signer = new Wallet(config.adminPrivateKey, provider);

const sdk = setUpSdk(config.chainId, signer);
const assetConfig = chainIdToConfig[config.chainId];
const updater = await new Updater(sdk).init(assetConfig);

sdk.logger.info(`Starting update loop bot on chain: ${config.chainId}`);
sdk.logger.info(`Config for bot: ${JSON.stringify({ ...config, adminPrivateKey: '*****' })}`);
await updater.updateFeeds();
};

run();
Loading

0 comments on commit ac5a7c3

Please sign in to comment.