Skip to content

Commit df993ea

Browse files
committed
Skipping snapshots when the user is null
1 parent 96bb7ed commit df993ea

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/mappings/helpers.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,30 @@ export function createUser(address: Address): void {
169169
}
170170

171171
export function createLiquiditySnapshot(position: LiquidityPosition, event: EthereumEvent): void {
172+
if (User.load(position.user) === null) {
173+
log.error(
174+
'Null user during snapshot creation. User id: '
175+
.concat(position.user)
176+
.concat(' position id: ')
177+
.concat(position.id)
178+
.concat(' tx hash: ')
179+
.concat(event.transaction.hash.toHexString())
180+
.concat(' --> SKIPPING SNAPSHOT CREATION'),
181+
[]
182+
)
183+
return
184+
}
185+
172186
let bundle = Bundle.load('1')
173187
let pair = Pair.load(position.pair)
174188
let token0 = Token.load(pair.token0)
175189
let token1 = Token.load(pair.token1)
176190

177191
// create new snapshot
178192
let id = position.id
179-
.concat("-")
193+
.concat('-')
180194
.concat(event.transaction.hash.toHexString())
181-
.concat("-")
195+
.concat('-')
182196
.concat(event.logIndex.toString())
183197
let snapshot = new LiquidityPositionSnapshot(id)
184198
snapshot.liquidityPosition = position.id

0 commit comments

Comments
 (0)