diff --git a/schema.graphql b/schema.graphql index 9059fba..3f59a52 100644 --- a/schema.graphql +++ b/schema.graphql @@ -195,6 +195,10 @@ type GraphNetwork @entity { subgraphDeploymentCount: Int! "Total epochs" epochCount: Int! + "Total amount of allocations opened" + allocationCount: Int! + "Total amount of allocations currently active" + activeAllocationCount: Int! # Dispute Manager global variables "Dispute arbitrator" diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 454e2c4..f40b875 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -576,6 +576,8 @@ export function createOrLoadGraphNetwork( graphNetwork.subgraphCount = 0 graphNetwork.subgraphDeploymentCount = 0 graphNetwork.activeSubgraphCount = 0 + graphNetwork.allocationCount = 0 + graphNetwork.activeAllocationCount = 0 graphNetwork.arbitrator = Address.fromString('0x0000000000000000000000000000000000000000') graphNetwork.querySlashingPercentage = 0 diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index 7fff1bd..d72faaf 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -336,6 +336,8 @@ export function handleAllocationCreated(event: AllocationCreated): void { // update graph network graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.plus(event.params.tokens) + graphNetwork.allocationCount = graphNetwork.allocationCount + 1 + graphNetwork.activeAllocationCount = graphNetwork.activeAllocationCount + 1 graphNetwork.save() // update subgraph deployment @@ -519,6 +521,7 @@ export function handleAllocationClosed(event: AllocationClosed): void { deployment.save() // update graph network + graphNetwork.activeAllocationCount = graphNetwork.activeAllocationCount - 1 graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.minus(event.params.tokens) graphNetwork.save() }