From fb717ba76be100d734699a9bd983a4d19c8398db Mon Sep 17 00:00:00 2001 From: Ahmed Ihsan Tawfeeq Date: Tue, 16 Aug 2022 13:34:20 -0600 Subject: [PATCH] feat: add support for a fallback Ethereum provider build: upgrade package version --- deployment.yaml | 2 +- package.json | 2 +- src/helpers.ts | 2 +- src/index.ts | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/deployment.yaml b/deployment.yaml index 26790e1..686ada9 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -49,7 +49,7 @@ spec: secretKeyRef: name: hifi-liquidator-js-secret key: wallet-seed - image: hififinance/hifi-liquidator-js:1.0.1 + image: hififinance/hifi-liquidator-js:1.0.2 name: hifi-liquidator-js resources: limits: diff --git a/package.json b/package.json index b6d4099..90e9fca 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@hifi/liquidator-js", "description": "Utility for automatically liquidating underwater accounts in Hifi", - "version": "1.0.1", + "version": "1.0.2", "author": { "name": "Hifi", "email": "contact@hifi.finance", diff --git a/src/helpers.ts b/src/helpers.ts index 4d4d707..26c0c17 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -14,7 +14,7 @@ export async function batchQueryFilter( eventFilter: EventFilter, fromBlock: number = 0, toBlock: number, - span: number = 10000, + span: number = 3500, ) { let events: Event[] = []; for (let currBlock = fromBlock; currBlock < toBlock + 1; currBlock += span) { diff --git a/src/index.ts b/src/index.ts index f28e251..ef74430 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import { Wallet, providers, utils } from "ethers"; require("dotenv").config(); -const { ALCHEMY_KEY, PERSISTENCE, SELECTED_ACCOUNT, WALLET_SEED } = process.env as { +const { ALCHEMY_KEY, INFURA_KEY, PERSISTENCE, SELECTED_ACCOUNT, WALLET_SEED } = process.env as { [key: string]: string; }; @@ -14,7 +14,10 @@ const { NETWORK_NAME } = process.env as { NETWORK_NAME: NetworkName }; const account = utils.HDNode.fromMnemonic(WALLET_SEED as string).derivePath(`m/44'/60'/0'/0/${SELECTED_ACCOUNT}`); -const provider = new providers.AlchemyProvider(NETWORK_NAME, ALCHEMY_KEY); +const provider = new providers.FallbackProvider([ + new providers.AlchemyProvider(NETWORK_NAME, ALCHEMY_KEY), + new providers.InfuraProvider(NETWORK_NAME, INFURA_KEY), +]); const signer = new Wallet(account, provider);