From 5f8f785557ee0b49d315122aab6cdc6a498af0a0 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Mon, 29 Jan 2024 12:44:56 -0300 Subject: [PATCH] fix: track total delegated tokens changes when rewards or fees are collected --- src/mappings/rewardsManager.ts | 1 + src/mappings/staking.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mappings/rewardsManager.ts b/src/mappings/rewardsManager.ts index 4c6f4677..bfcd1470 100644 --- a/src/mappings/rewardsManager.ts +++ b/src/mappings/rewardsManager.ts @@ -85,6 +85,7 @@ export function handleRewardsAssigned(event: RewardsAssigned): void { graphNetwork.totalIndexingDelegatorRewards = graphNetwork.totalIndexingDelegatorRewards.plus( delegatorIndexingRewards, ) + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(delegatorIndexingRewards) graphNetwork.save() } diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index fb9682d1..65389567 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -591,6 +591,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() }