From d6d983ccc9d4a9705c5763915171db547b8378a6 Mon Sep 17 00:00:00 2001 From: Alfredo Gutierrez Date: Wed, 6 Mar 2024 13:06:21 -0600 Subject: [PATCH] improve performance by initializing only once the excluded blocks and improving on the check condition. Signed-off-by: Alfredo Gutierrez --- .../v2/src/mappings/position-manager.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/subgraphs/saucerswap/v2/src/mappings/position-manager.ts b/subgraphs/saucerswap/v2/src/mappings/position-manager.ts index c202aeb..4e4990b 100644 --- a/subgraphs/saucerswap/v2/src/mappings/position-manager.ts +++ b/subgraphs/saucerswap/v2/src/mappings/position-manager.ts @@ -10,15 +10,14 @@ import { ADDRESS_ZERO, factoryContract, ZERO_BD, ZERO_BI } from '../utils/consta import { Address, BigInt, ethereum, log } from '@graphprotocol/graph-ts' import { convertTokenToDecimal, loadTransaction } from '../utils' +const excludedBlocks: BigInt[] = [ + BigInt.fromI32(56517027), + BigInt.fromI32(56520786) + // Add more block numbers as needed here +]; + export function isBlockNumberExcluded(blockNumber: BigInt): boolean { - // Initialize the list of excluded blocks each time the function is called - let excludedBlocks: BigInt[] = [ - BigInt.fromI32(56517027), - BigInt.fromI32(56520786) - // Add more block numbers as needed here - ]; - - return excludedBlocks.some(excludedBlock => excludedBlock.equals(blockNumber)); + return excludedBlocks.includes(blockNumber); } function getPosition(event: ethereum.Event, tokenId: BigInt): Position | null {