@@ -163,7 +163,7 @@ export function handleStakeSlashed(event: StakeSlashed): void {
163163
164164 // When tokens are slashed, locked tokens might need to be unlocked if indexer overallocated
165165 if ( slashedTokens . gt ( BigInt . fromI32 ( 0 ) ) ) {
166- let tokensUsed = indexer . allocatedTokens . plus ( indexer . legacyLockedTokens )
166+ let tokensUsed = indexer . legacyAllocatedTokens . plus ( indexer . legacyLockedTokens )
167167 let tokensAvailable = tokensUsed . gt ( indexer . stakedTokens )
168168 ? BigInt . fromI32 ( 0 )
169169 : indexer . stakedTokens . minus ( tokensUsed )
@@ -349,6 +349,7 @@ export function handleAllocationCreated(event: AllocationCreated): void {
349349
350350 // update indexer
351351 let indexer = Indexer . load ( indexerID ) !
352+ indexer . legacyAllocatedTokens = indexer . legacyAllocatedTokens . plus ( event . params . tokens )
352353 indexer . allocatedTokens = indexer . allocatedTokens . plus ( event . params . tokens )
353354 indexer . totalAllocationCount = indexer . totalAllocationCount . plus ( BigInt . fromI32 ( 1 ) )
354355 indexer . allocationCount = indexer . allocationCount + 1
@@ -529,6 +530,7 @@ export function handleAllocationClosed(event: AllocationClosed): void {
529530 allocation . forceClosed = false
530531 }
531532 indexer . allocatedTokens = indexer . allocatedTokens . minus ( event . params . tokens )
533+ indexer . legacyAllocatedTokens = indexer . legacyAllocatedTokens . minus ( event . params . tokens )
532534 indexer . allocationCount = indexer . allocationCount - 1
533535 indexer = updateLegacyAdvancedIndexerMetrics ( indexer as Indexer )
534536 indexer = calculateCapacities ( indexer as Indexer )
@@ -591,6 +593,7 @@ export function handleAllocationClosedCobbDouglas(event: AllocationClosed1): voi
591593 } else {
592594 allocation . forceClosed = false
593595 }
596+ indexer . legacyAllocatedTokens = indexer . legacyAllocatedTokens . minus ( event . params . tokens )
594597 indexer . allocatedTokens = indexer . allocatedTokens . minus ( event . params . tokens )
595598 indexer . allocationCount = indexer . allocationCount - 1
596599 indexer = updateLegacyAdvancedIndexerMetrics ( indexer as Indexer )
0 commit comments