Skip to content

Commit

Permalink
fix: track total delegated tokens changes when rewards or fees are co…
Browse files Browse the repository at this point in the history
…llected
  • Loading branch information
pcarranzav authored and juanmardefago committed Jan 29, 2024
1 parent a34c33e commit 888f6b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mappings/rewardsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export function handleRewardsAssigned(event: RewardsAssigned): void {
graphNetwork.totalIndexingDelegatorRewards = graphNetwork.totalIndexingDelegatorRewards.plus(
delegatorIndexingRewards,
)
graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(delegatorIndexingRewards)
graphNetwork.save()
}

Expand Down
2 changes: 2 additions & 0 deletions src/mappings/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ export function handleRebateClaimed(event: RebateClaimed): void {
graphNetwork.totalUnclaimedQueryFeeRebates = graphNetwork.totalUnclaimedQueryFeeRebates.minus(
event.params.delegationFees.plus(event.params.tokens),
)
graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.delegationFees)
graphNetwork.save()
}

Expand Down Expand Up @@ -742,6 +743,7 @@ export function handleRebateCollected(event: RebateCollected): void {
graphNetwork.totalUnclaimedQueryFeeRebates = graphNetwork.totalUnclaimedQueryFeeRebates.minus(
event.params.delegationRewards.plus(event.params.queryRebates),
)
graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.delegationRewards)
graphNetwork.save()
}

Expand Down

0 comments on commit 888f6b6

Please sign in to comment.