From 04b742bada61d60dfad1c0d479ea44616bb978dc Mon Sep 17 00:00:00 2001 From: ssubik Date: Wed, 14 Dec 2022 13:38:10 +0545 Subject: [PATCH] one day rewards --- subgraph/src/staking.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subgraph/src/staking.ts b/subgraph/src/staking.ts index 9608ca2..1c76b88 100644 --- a/subgraph/src/staking.ts +++ b/subgraph/src/staking.ts @@ -273,11 +273,11 @@ function getOneDayReward(streamId: BigInt, now: BigInt):BigInt{ } const streamTime = stream.time let currentIndex = 0 - while(now.le(streamTime[currentIndex])){ + while(now.gt(streamTime[currentIndex])){ currentIndex++ } - const indexDuration = stream.time[currentIndex + 1].minus(stream.time[currentIndex]) - const indexRewards = stream.reward[currentIndex].minus(stream.reward[currentIndex + 1]) + const indexDuration = stream.time[currentIndex].minus(stream.time[currentIndex-1]) + const indexRewards = stream.reward[currentIndex-1].minus(stream.reward[currentIndex]) const oneDayReward = indexRewards.times(oneDay).div(indexDuration) return oneDayReward }