Skip to content

Commit

Permalink
fix: delegation params
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmardefago committed Nov 30, 2023
1 parent 4637c57 commit 4f94579
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/mappings/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@ import {
import { addresses } from '../../config/addresses'

export function handleDelegationParametersUpdated(event: DelegationParametersUpdated): void {
let id = event.params.indexer.toHexString()
// Quick fix to avoid creating new Indexer entities if they don't exist yet.
let account = GraphAccount.load(id)
if (account != null) {
let indexer = createOrLoadIndexer(Bytes.fromHexString(id), event.block.timestamp)
indexer.indexingRewardCut = event.params.indexingRewardCut.toI32()
indexer.queryFeeCut = event.params.queryFeeCut.toI32()
indexer.delegatorParameterCooldown = event.params.cooldownBlocks.toI32()
indexer.lastDelegationParameterUpdate = event.block.number.toI32()
indexer = updateAdvancedIndexerMetrics(indexer as Indexer)
indexer.save()
}
let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address)
let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp)
indexer.indexingRewardCut = event.params.indexingRewardCut.toI32()
indexer.queryFeeCut = event.params.queryFeeCut.toI32()
indexer.delegatorParameterCooldown = event.params.cooldownBlocks.toI32()
indexer.lastDelegationParameterUpdate = (
addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!
).toI32()
indexer = updateAdvancedIndexerMetrics(indexer as Indexer)
indexer.save()
}

/**
Expand Down

0 comments on commit 4f94579

Please sign in to comment.