Skip to content

Commit

Permalink
Added taxed and total amounts for Epoch qfees
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmardefago committed May 2, 2022
1 parent 6799d13 commit dc32ca7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1059,11 +1059,15 @@ type Epoch @entity {
signalledTokens: BigInt!
"Stake deposited during this epoch"
stakeDeposited: BigInt!
"Amount of query fees collected by all indexers during this epoch"
"Total amount of query fees generated during this epoch (Includes everything)"
totalQueryFees: BigInt!
"Amount of query fees generated that were burnt by the 1% protocol tax during this epoch"
taxedQueryFees: BigInt!
"Amount of query fees generated that are going to the rebate pool for indexers during this epoch"
queryFeesCollected: BigInt!
"Amount of query fees generated that are going to curators during this epoch"
curatorQueryFees: BigInt!
"Rebate amount claimed from the protocol through cobbs douglas"
"Rebate amount claimed from the protocol through cobbs douglas during this epoch (Doesn't correlate to the queryFeesCollected for this epoch since there's a 7 day period before claiming)"
queryFeeRebates: BigInt!
"Total indexing rewards earned in this epoch. Includes both delegator and indexer rewards"
totalRewards: BigInt!
Expand Down
9 changes: 6 additions & 3 deletions src/mappings/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,14 @@ export function handleAllocationCollected(event: AllocationCollected): void {
allocation.curatorRewards = allocation.curatorRewards.plus(event.params.curationFees)
allocation.save()

// since we don't get the protocol tax explicitly, we will use tokens - (curation + rebate) to calculate it
// This could also be calculated by doing: protocolPercentage * event.params.tokens
let taxedFees = event.params.tokens.minus(event.params.rebateFees.plus(event.params.curationFees))

// Update epoch
let epoch = createOrLoadEpoch(event.block.number)
epoch.totalQueryFees = epoch.totalQueryFees.plus(event.params.tokens)
epoch.taxedQueryFees = epoch.taxedQueryFees.plus(taxedFees)
epoch.queryFeesCollected = epoch.queryFeesCollected.plus(event.params.rebateFees)
epoch.curatorQueryFees = epoch.curatorQueryFees.plus(event.params.curationFees)
epoch.save()
Expand Down Expand Up @@ -421,9 +427,6 @@ export function handleAllocationCollected(event: AllocationCollected): void {

batchUpdateSubgraphSignalledTokens(deployment as SubgraphDeployment)

// since we don't get the protocol tax explicitly, we will use tokens - (curation + rebate) to calculate it
// This could also be calculated by doing: protocolPercentage * event.params.tokens
let taxedFees = event.params.tokens.minus(event.params.rebateFees.plus(event.params.curationFees))

// update graph network
let graphNetwork = GraphNetwork.load('1')!
Expand Down

0 comments on commit dc32ca7

Please sign in to comment.