From 4262452ba4f9691c3410526f605273f0529a9377 Mon Sep 17 00:00:00 2001 From: benesjan Date: Sun, 6 Dec 2020 16:23:28 -0600 Subject: [PATCH] Skipping snapshots when the user is null --- src/mappings/helpers.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mappings/helpers.ts b/src/mappings/helpers.ts index e412c867..d88e1c58 100644 --- a/src/mappings/helpers.ts +++ b/src/mappings/helpers.ts @@ -174,11 +174,26 @@ export function createLiquiditySnapshot(position: LiquidityPosition, event: Ethe let token0 = Token.load(pair.token0) let token1 = Token.load(pair.token1) + let user = User.load(position.user) + if (user === null) { + log.error( + 'Null user during snapshot creation. User id: ' + .concat(position.user) + .concat(' position id: ') + .concat(position.id) + .concat(' tx hash: ') + .concat(event.transaction.hash.toHexString()) + .concat(' --> SKIPPING SNAPSHOT CREATION'), + [] + ) + return + } + // create new snapshot let id = position.id - .concat("-") + .concat('-') .concat(event.transaction.hash.toHexString()) - .concat("-") + .concat('-') .concat(event.logIndex.toString()) let snapshot = new LiquidityPositionSnapshot(id) snapshot.liquidityPosition = position.id