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 fee factor for delegator fees calculation"
cumulativeFeeFactor: BigDecimal
}

"""
Expand Down
14 changes: 13 additions & 1 deletion src/mappings/ticketBroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
createOrLoadTranscoderDay,
getBlockNum,
getEthPriceUsd,
integerFromString,
makeEventId,
makePoolId,
ZERO_BD,
Expand All @@ -29,6 +30,9 @@ import {
WinningTicketRedeemed,
Withdrawal,
} from "../types/TicketBroker/TicketBroker";
import {
BondingManager,
} from "../types/BondingManager/BondingManager";

export function winningTicketRedeemed(event: WinningTicketRedeemed): void {
let round = createOrLoadRound(getBlockNum());
Expand Down Expand Up @@ -97,9 +101,17 @@ export function winningTicketRedeemed(event: WinningTicketRedeemed): void {
protocol.winningTicketCount = protocol.winningTicketCount + 1;
protocol.save();

// update the transcoder pool fees
// update the transcoder pool fees and cummulative factors
if (pool) {
pool.fees = pool.fees.plus(faceValue);

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

pool.save();
}

Expand Down
Loading