Skip to content

Commit

Permalink
fix: subtract previously locked tokens when computing total unstaked …
Browse files Browse the repository at this point in the history
…locked
  • Loading branch information
pcarranzav authored and juanmardefago committed Jan 31, 2024
1 parent b020292 commit b9001b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mappings/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,19 @@ 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)
indexer = calculateCapacities(indexer as Indexer)
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
}
Expand Down

0 comments on commit b9001b3

Please sign in to comment.