Skip to content

Commit

Permalink
fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCactus committed Aug 7, 2023
1 parent 0e41b4e commit d1ea0cf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions liquidator/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-loop-func */
import got from 'got';
import { MarketConfig } from 'global';
import dotenv from 'dotenv';
Expand Down Expand Up @@ -35,10 +34,13 @@ export async function getMarkets(): Promise<MarketConfig[]> {
const maxAttempt = 10;
const marketUrl = getMarketsUrl();

do {
// Function to wait for a certain amount of time
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

while (attemptCount < maxAttempt) {
try {
if (attemptCount > 0) {
await new Promise((resolve) => setTimeout(resolve, backoffFactor * 10));
await wait(backoffFactor * 10);
backoffFactor *= 2;
}
attemptCount += 1;
Expand All @@ -48,7 +50,7 @@ export async function getMarkets(): Promise<MarketConfig[]> {
} catch (error) {
console.error('error fetching /v1/markets/configs ', error);
}
} while (attemptCount < maxAttempt);
}

throw new Error('failed to fetch /v1/markets/configs');
}
Expand Down

0 comments on commit d1ea0cf

Please sign in to comment.