Skip to content

Commit 09af3d0

Browse files
committed
feat: adding latest value for thawingUntil on Indexer and Provision
1 parent 932ed20 commit 09af3d0

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
@@ -831,6 +831,8 @@ type Indexer @entity(immutable: false) {
831831
lastDelegationParameterUpdate: Int!
832832
"Count of how many times this indexer has been forced to close an allocation"
833833
forcedClosures: Int!
834+
"[Horizon only] Latest value for thaw request thawingUntil"
835+
thawingUntil: BigInt!
834836

835837
# Provisioning
836838
provisions: [Provision!]! @derivedFrom(field: "indexer")
@@ -996,6 +998,8 @@ type Provision @entity(immutable: false) {
996998
delegatedStakeRatio: BigDecimal!
997999
"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"
9981000
indexerRewardsOwnGenerationRatio: BigDecimal!
1001+
"Latest value for thaw request thawingUntil"
1002+
thawingUntil: BigInt!
9991003

10001004
"Service registry URL for the indexer"
10011005
url: String

src/mappings/helpers/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt ):
176176
indexer.forcedClosures = 0
177177
indexer.allocationCount = 0
178178
indexer.totalAllocationCount = BigInt.fromI32(0)
179+
indexer.thawingUntil = BigInt.fromI32(0)
179180

180181
indexer.totalReturn = BigDecimal.fromString('0')
181182
indexer.annualizedReturn = BigDecimal.fromString('0')
@@ -241,6 +242,7 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By
241242
provision.delegatedTokens = BigInt.fromI32(0)
242243
provision.delegatorShares = BigInt.fromI32(0)
243244
provision.delegationExchangeRate = BigInt.fromI32(0).toBigDecimal()
245+
provision.thawingUntil = BigInt.fromI32(0)
244246
provision.ownStakeRatio = BigInt.fromI32(0).toBigDecimal()
245247
provision.delegatedStakeRatio = BigInt.fromI32(0).toBigDecimal()
246248
provision.indexerRewardsOwnGenerationRatio = BigInt.fromI32(0).toBigDecimal()

src/mappings/horizonStaking.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,14 @@ export function handleThawRequestCreated(event: ThawRequestCreated): void {
270270
throw new Error("Invalid thaw request type")
271271
}
272272
request.save()
273+
274+
// update latest thawingUntil for provision and indexer
275+
let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp)
276+
provision.thawingUntil = event.params.thawingUntil
277+
provision.save()
278+
279+
indexer.thawingUntil = event.params.thawingUntil
280+
indexer.save()
273281
}
274282

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

0 commit comments

Comments
 (0)