Skip to content

Commit 4cc46bb

Browse files
committed
feat: add pendingStake to transcoder and pool objects
Adds a `pendingStake` field to both the `Transcoder` and `Pool` entities to track pending bonded stake.
1 parent bb88ef2 commit 4cc46bb

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

schema.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ type Transcoder @entity {
8686
feeShareUpdateTimestamp: Int!
8787
"Total tokens delegated toward a transcoder (including their own)"
8888
totalStake: BigDecimal!
89+
"Pending bonded stake for the transcoder since last claiming rewards"
90+
pendingStake: BigDecimal!
8991
"Total fees generated by the transcoder in ETH (before distribution to delegators)"
9092
totalVolumeETH: BigDecimal!
9193
"Total fees generated by the transcoder in ETH (before distribution and in past 30 days)"
@@ -129,6 +131,8 @@ type Pool @entity {
129131
rewardTokens: BigDecimal
130132
"Transcoder's total stake during the earnings pool's round"
131133
totalStake: BigDecimal!
134+
"Pending bonded stake for the transcoder since last claiming rewards"
135+
pendingStake: BigDecimal!
132136
"Transcoder's reward cut during the earnings pool's round"
133137
rewardCut: BigInt!
134138
"Transcoder's fee share during the earnings pool's round"

src/mappings/bondingManager.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { store } from "@graphprotocol/graph-ts";
1+
import { Address, store } from "@graphprotocol/graph-ts";
22
import {
33
convertToDecimal,
44
createOrLoadDelegator,
@@ -8,6 +8,7 @@ import {
88
createOrLoadTranscoder,
99
EMPTY_ADDRESS,
1010
getBlockNum,
11+
integerFromString,
1112
makeEventId,
1213
makePoolId,
1314
makeUnbondingLockId,
@@ -500,6 +501,16 @@ export function reward(event: Reward): void {
500501
pool!.feeShare = transcoder.feeShare;
501502
pool!.rewardCut = transcoder.rewardCut;
502503

504+
let bondingManager = BondingManager.bind(event.address);
505+
let pendingStake = convertToDecimal(
506+
bondingManager.pendingStake(
507+
Address.fromString(transcoder.id),
508+
integerFromString(round.id)
509+
)
510+
);
511+
transcoder.pendingStake = pendingStake;
512+
pool.pendingStake = pendingStake;
513+
503514
transcoder.save();
504515
delegate.save();
505516
pool!.save();

0 commit comments

Comments
 (0)