From 9c719cc5a06d7d07d2baf33c214c30e88c3b0fdb Mon Sep 17 00:00:00 2001 From: Data-Nexus Date: Tue, 4 Oct 2022 20:11:13 -0400 Subject: [PATCH 1/2] staking.ts update for delayed collection --- src/mappings/staking.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index 3e808e0c..9380d8ee 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -397,7 +397,7 @@ export function handleAllocationCollected(event: AllocationCollected): void { let taxedFees = event.params.tokens.minus(event.params.rebateFees.plus(event.params.curationFees)) // Update epoch - let epoch = createOrLoadEpoch(event.block.number) + let epoch = createOrLoadEpoch(allocation.closedAtBlockNumber? allocation.closedAtBlockNumber : event.block.number) epoch.totalQueryFees = epoch.totalQueryFees.plus(event.params.tokens) epoch.taxedQueryFees = epoch.taxedQueryFees.plus(taxedFees) epoch.queryFeesCollected = epoch.queryFeesCollected.plus(event.params.rebateFees) @@ -405,7 +405,7 @@ export function handleAllocationCollected(event: AllocationCollected): void { epoch.save() // update pool - let pool = createOrLoadPool(event.params.epoch) + let pool = createOrLoadPool(epoch.id? epoch.id : event.params.epoch) // ONLY if allocation is closed. Otherwise it gets collected into an allocation, and it will // get added to the pool where the allocation gets closed if (allocation.status == 'Closed') { From b7380721c35d0b9c9a2af3b86b481422335d58c5 Mon Sep 17 00:00:00 2001 From: Data-Nexus Date: Tue, 4 Oct 2022 21:33:32 -0400 Subject: [PATCH 2/2] Updated staking.ts --- src/mappings/staking.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index 9380d8ee..6a0555c6 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -398,18 +398,20 @@ export function handleAllocationCollected(event: AllocationCollected): void { // Update epoch let epoch = createOrLoadEpoch(allocation.closedAtBlockNumber? allocation.closedAtBlockNumber : event.block.number) + if (allocation.status == 'Closed'){ + epoch.queryFeesCollected = epoch.queryFeesCollected.plus(allocation.queryFeesCollected) + } epoch.totalQueryFees = epoch.totalQueryFees.plus(event.params.tokens) epoch.taxedQueryFees = epoch.taxedQueryFees.plus(taxedFees) - epoch.queryFeesCollected = epoch.queryFeesCollected.plus(event.params.rebateFees) epoch.curatorQueryFees = epoch.curatorQueryFees.plus(event.params.curationFees) epoch.save() // update pool - let pool = createOrLoadPool(epoch.id? epoch.id : event.params.epoch) + let pool = createOrLoadPool(epoch.id) // ONLY if allocation is closed. Otherwise it gets collected into an allocation, and it will // get added to the pool where the allocation gets closed if (allocation.status == 'Closed') { - pool.totalQueryFees = pool.totalQueryFees.plus(event.params.rebateFees) + pool.totalQueryFees = pool.totalQueryFees.plus(allocation.queryFeesCollected) } // Curator rewards in pool is not stored in the contract, so we take the actual value of it // happening. Every time an allocation is collected, curator rewards get transferred into