From 01fa6e218417230cc0cfa1cb898f9054c3b23efe Mon Sep 17 00:00:00 2001 From: prathamesh0 <42446521+prathamesh0@users.noreply.github.com> Date: Fri, 17 Dec 2021 11:57:32 +0530 Subject: [PATCH] Fix asserts for nullable values in uni-info-watcher mapping code (#320) --- packages/uni-info-watcher/src/indexer.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/uni-info-watcher/src/indexer.ts b/packages/uni-info-watcher/src/indexer.ts index 2119d44e..68183990 100644 --- a/packages/uni-info-watcher/src/indexer.ts +++ b/packages/uni-info-watcher/src/indexer.ts @@ -904,7 +904,8 @@ export class Indexer implements IndexerInterface { assert(token0 && token1, 'Pool tokens not found.'); const oldTick = pool.tick; - assert(oldTick); + // Check that the tick value is not null (can be zero). + assert(oldTick !== null); // Amounts - 0/1 are token deltas. Can be positive or negative. const amount0 = convertTokenToDecimal(BigInt(swapEvent.amount0), BigInt(token0.decimals)); @@ -1098,7 +1099,9 @@ export class Indexer implements IndexerInterface { // Update inner vars of current or crossed ticks. const newTick = pool.tick; - assert(newTick); + // Check that the tick value is not null (can be zero). + assert(newTick !== null); + const tickSpacing = feeTierToTickSpacing(pool.feeTier); const modulo = newTick % tickSpacing;