From 41fe266e645210da56e9bf83595a9f35691c055e Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:32:24 -0400 Subject: [PATCH] Fix lint. --- indexer/services/comlink/src/config.ts | 2 +- .../controllers/api/v4/vault-controller.ts | 31 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/indexer/services/comlink/src/config.ts b/indexer/services/comlink/src/config.ts index f5f3879f8a..bfb702abcc 100644 --- a/indexer/services/comlink/src/config.ts +++ b/indexer/services/comlink/src/config.ts @@ -63,7 +63,7 @@ export const configSchema = { VAULT_PNL_HISTORY_DAYS: parseInteger({ default: 90 }), VAULT_PNL_HISTORY_HOURS: parseInteger({ default: 72 }), VAULT_LATEST_PNL_TICK_WINDOW_HOURS: parseInteger({ default: 1 }), - VAULT_FETCH_FUNDING_INDEX_BLOCK_WINDOWS: parseInteger({default: 250_000 }), + VAULT_FETCH_FUNDING_INDEX_BLOCK_WINDOWS: parseInteger({ default: 250_000 }), }; //////////////////////////////////////////////////////////////////////////////// diff --git a/indexer/services/comlink/src/controllers/api/v4/vault-controller.ts b/indexer/services/comlink/src/controllers/api/v4/vault-controller.ts index e84089da71..f5e8e6d708 100644 --- a/indexer/services/comlink/src/controllers/api/v4/vault-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/vault-controller.ts @@ -579,20 +579,22 @@ function getResolution(resolution: PnlTickInterval = PnlTickInterval.day): PnlTi /** * Gets funding index maps in a chunked fashion to reduce database load and aggregates into a * a map of funding index maps. - * @param updatedAtHeights - * @returns + * @param updatedAtHeights + * @returns */ async function getFundingIndexMapsChunked( - updatedAtHeights: string[] + updatedAtHeights: string[], ): Promise<{[blockHeight: string]: FundingIndexMap}> { const updatedAtHeightsNum: number[] = updatedAtHeights.map((height: string): number => { return parseInt(height, 10); }).sort(); const aggregateFundingIndexMaps: {[blockHeight: string]: FundingIndexMap} = {}; - for(const chunk of getHeightWindows(updatedAtHeightsNum)) { - const fundingIndexMaps: {[blockHeight: string]: FundingIndexMap} = await FundingIndexUpdatesTable.findFundingIndexMaps( - chunk.map((heightNum: number): string => { return heightNum.toString() }), - ); + for (const chunk of getHeightWindows(updatedAtHeightsNum)) { + const fundingIndexMaps: {[blockHeight: string]: FundingIndexMap} = await + FundingIndexUpdatesTable + .findFundingIndexMaps( + chunk.map((heightNum: number): string => { return heightNum.toString(); }), + ); for (const height of _.keys(fundingIndexMaps)) { aggregateFundingIndexMaps[height] = fundingIndexMaps[height]; } @@ -603,19 +605,19 @@ async function getFundingIndexMapsChunked( /** * Separates an array of heights into a chunks based on a window size. Each chunk should only * contain heights within a certain number of blocks of each other. - * @param heights - * @returns + * @param heights + * @returns */ function getHeightWindows( heights: number[], ): number[][] { - if (heights.length == 0) { + if (heights.length === 0) { return []; } const windows: number[][] = []; let windowStart: number = heights[0]; let currentWindow: number[] = []; - for(const height of heights) { + for (const height of heights) { if (height - windowStart < config.VAULT_FETCH_FUNDING_INDEX_BLOCK_WINDOWS) { currentWindow.push(height); } else { @@ -643,9 +645,10 @@ async function getVaultMapping(): Promise { }), ); for (const subaccountId of _.keys(vaultMapping)) { - const perpetual: PerpetualMarketFromDatabase | undefined = perpetualMarketRefresher.getPerpetualMarketFromClobPairId( - vaultMapping[subaccountId], - ); + const perpetual: PerpetualMarketFromDatabase | undefined = perpetualMarketRefresher + .getPerpetualMarketFromClobPairId( + vaultMapping[subaccountId], + ); if (perpetual === undefined) { logger.warning({ at: 'VaultController#getVaultPositions',