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 30, 2024
1 parent 888f6b6 commit 7f2b7e9
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 7f2b7e9

Please sign in to comment.