Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ type Pool @entity {
rewardCut: BigInt!
"Transcoder's fee share during the earnings pool's round"
feeShare: BigInt!
"Cumulative reward factor for delegator rewards calculation"
cumulativeRewardFactor: BigDecimal
}

"""
Expand Down
10 changes: 9 additions & 1 deletion src/mappings/bondingManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { store } from "@graphprotocol/graph-ts";
import { store, Address } from "@graphprotocol/graph-ts";
import {
convertToDecimal,
createOrLoadDelegator,
Expand All @@ -8,6 +8,7 @@ import {
createOrLoadTranscoder,
EMPTY_ADDRESS,
getBlockNum,
integerFromString,
makeEventId,
makePoolId,
makeUnbondingLockId,
Expand Down Expand Up @@ -500,6 +501,13 @@ export function reward(event: Reward): void {
pool!.feeShare = transcoder.feeShare;
pool!.rewardCut = transcoder.rewardCut;

let bondingManager = BondingManager.bind(event.address);
let earningsPool = bondingManager.getTranscoderEarningsPoolForRound(
Address.fromString(transcoder.id),
integerFromString(round.id)
);
pool!.cumulativeRewardFactor = convertToDecimal(earningsPool.cumulativeRewardFactor);

transcoder.save();
delegate.save();
pool!.save();
Expand Down
Loading