Skip to content

Commit ba8bb75

Browse files
Merge pull request #299 from graphprotocol/juanmardefago/horizon-thawing-until
feat: adding latest value for thawingUntil on Indexer and Provision
2 parents 47bf789 + 7c3c215 commit ba8bb75

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

schema.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,8 @@ type Indexer @entity(immutable: false) {
847847
lastDelegationParameterUpdate: Int!
848848
"Count of how many times this indexer has been forced to close an allocation"
849849
forcedClosures: Int!
850+
"[Horizon only] Latest value for thaw request thawingUntil"
851+
thawingUntil: BigInt!
850852

851853
# Provisioning
852854
provisions: [Provision!]! @derivedFrom(field: "indexer")
@@ -1004,6 +1006,8 @@ type Provision @entity(immutable: false) {
10041006
delegatedStakeRatio: BigDecimal!
10051007
"Percentage of indexers' own rewards received in relation to its own stake. 1 (100%) means that the indexer is receiving the exact amount that is generated by his own stake, the value can be over 100% or below depending on the amount of delegation and cuts set"
10061008
indexerRewardsOwnGenerationRatio: BigDecimal!
1009+
"Latest value for thaw request thawingUntil"
1010+
thawingUntil: BigInt!
10071011

10081012
"Service registry URL for the indexer"
10091013
url: String

src/mappings/helpers/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt ):
183183
indexer.forcedClosures = 0
184184
indexer.allocationCount = 0
185185
indexer.totalAllocationCount = BigInt.fromI32(0)
186+
indexer.thawingUntil = BigInt.fromI32(0)
186187

187188
indexer.url = ''
188189
indexer.geoHash = ''
@@ -244,6 +245,7 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By
244245
provision.delegatedTokens = BigInt.fromI32(0)
245246
provision.delegatorShares = BigInt.fromI32(0)
246247
provision.delegationExchangeRate = BigInt.fromI32(0).toBigDecimal()
248+
provision.thawingUntil = BigInt.fromI32(0)
247249
provision.ownStakeRatio = BigInt.fromI32(0).toBigDecimal()
248250
provision.delegatedStakeRatio = BigInt.fromI32(0).toBigDecimal()
249251
provision.indexerRewardsOwnGenerationRatio = BigInt.fromI32(0).toBigDecimal()

src/mappings/horizonStaking.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ export function handleThawRequestCreated(event: ThawRequestCreated): void {
281281
throw new Error("Invalid thaw request type")
282282
}
283283
request.save()
284+
285+
// update latest thawingUntil for provision and indexer
286+
let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp)
287+
provision.thawingUntil = event.params.thawingUntil > provision.thawingUntil ? event.params.thawingUntil : provision.thawingUntil
288+
provision.save()
289+
290+
indexer.thawingUntil = event.params.thawingUntil > indexer.thawingUntil ? event.params.thawingUntil : indexer.thawingUntil
291+
indexer.save()
284292
}
285293

286294
export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void {

0 commit comments

Comments
 (0)