diff --git a/schema.graphql b/schema.graphql index aa25ed2..0bf0a5d 100755 --- a/schema.graphql +++ b/schema.graphql @@ -86,6 +86,8 @@ type Transcoder @entity { feeShareUpdateTimestamp: Int! "Total tokens delegated toward a transcoder (including their own)" totalStake: BigDecimal! + "Pending bonded stake for the transcoder since last claiming rewards" + pendingStake: BigDecimal! "Total fees generated by the transcoder in ETH (before distribution to delegators)" totalVolumeETH: BigDecimal! "Total fees generated by the transcoder in ETH (before distribution and in past 30 days)" @@ -129,6 +131,8 @@ type Pool @entity { rewardTokens: BigDecimal "Transcoder's total stake during the earnings pool's round" totalStake: BigDecimal! + "Pending bonded stake for the transcoder since last claiming rewards" + pendingStake: BigDecimal! "Transcoder's reward cut during the earnings pool's round" rewardCut: BigInt! "Transcoder's fee share during the earnings pool's round" diff --git a/src/mappings/bondingManager.ts b/src/mappings/bondingManager.ts index fa94260..02827e2 100755 --- a/src/mappings/bondingManager.ts +++ b/src/mappings/bondingManager.ts @@ -1,4 +1,4 @@ -import { store } from "@graphprotocol/graph-ts"; +import { Address, store } from "@graphprotocol/graph-ts"; import { convertToDecimal, createOrLoadDelegator, @@ -8,6 +8,7 @@ import { createOrLoadTranscoder, EMPTY_ADDRESS, getBlockNum, + integerFromString, makeEventId, makePoolId, makeUnbondingLockId, @@ -500,6 +501,16 @@ export function reward(event: Reward): void { pool!.feeShare = transcoder.feeShare; pool!.rewardCut = transcoder.rewardCut; + let bondingManager = BondingManager.bind(event.address); + let pendingStake = convertToDecimal( + bondingManager.pendingStake( + Address.fromString(transcoder.id), + integerFromString(round.id) + ) + ); + transcoder.pendingStake = pendingStake; + pool.pendingStake = pendingStake; + transcoder.save(); delegate.save(); pool!.save();