diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index 1cd7d5e..7fff1bd 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -103,6 +103,7 @@ export function handleStakeLocked(event: StakeLocked): void { // update indexer let id = event.params.indexer.toHexString() let indexer = Indexer.load(id)! + let oldLockedTokens = indexer.lockedTokens indexer.lockedTokens = event.params.tokens indexer.tokensLockedUntil = event.params.until.toI32() indexer = updateAdvancedIndexerMetrics(indexer as Indexer) @@ -110,9 +111,11 @@ export function handleStakeLocked(event: StakeLocked): void { indexer.save() // update graph network + // the tokens from the event replace the previously locked tokens + // from this indexer graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.plus( event.params.tokens, - ) + ).minus(oldLockedTokens) if (indexer.stakedTokens == indexer.lockedTokens) { graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount - 1 }