Skip to content

Commit

Permalink
Skipping snapshots when the user is null
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Dec 6, 2020
1 parent 96bb7ed commit 4262452
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/mappings/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4262452

Please sign in to comment.