diff --git a/schema.graphql b/schema.graphql index 2a4539db..3edc0e58 100644 --- a/schema.graphql +++ b/schema.graphql @@ -831,6 +831,8 @@ type Indexer @entity(immutable: false) { lastDelegationParameterUpdate: Int! "Count of how many times this indexer has been forced to close an allocation" forcedClosures: Int! + "[Horizon only] Latest value for thaw request thawingUntil" + thawingUntil: BigInt! # Provisioning provisions: [Provision!]! @derivedFrom(field: "indexer") @@ -996,6 +998,8 @@ type Provision @entity(immutable: false) { delegatedStakeRatio: BigDecimal! "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" indexerRewardsOwnGenerationRatio: BigDecimal! + "Latest value for thaw request thawingUntil" + thawingUntil: BigInt! "Service registry URL for the indexer" url: String diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 00f969e5..4715b95b 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -176,6 +176,7 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt ): indexer.forcedClosures = 0 indexer.allocationCount = 0 indexer.totalAllocationCount = BigInt.fromI32(0) + indexer.thawingUntil = BigInt.fromI32(0) indexer.totalReturn = BigDecimal.fromString('0') indexer.annualizedReturn = BigDecimal.fromString('0') @@ -241,6 +242,7 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By provision.delegatedTokens = BigInt.fromI32(0) provision.delegatorShares = BigInt.fromI32(0) provision.delegationExchangeRate = BigInt.fromI32(0).toBigDecimal() + provision.thawingUntil = BigInt.fromI32(0) provision.ownStakeRatio = BigInt.fromI32(0).toBigDecimal() provision.delegatedStakeRatio = BigInt.fromI32(0).toBigDecimal() provision.indexerRewardsOwnGenerationRatio = BigInt.fromI32(0).toBigDecimal() diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 1dee16e5..cca79653 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -270,6 +270,14 @@ export function handleThawRequestCreated(event: ThawRequestCreated): void { throw new Error("Invalid thaw request type") } request.save() + + // update latest thawingUntil for provision and indexer + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + provision.thawingUntil = event.params.thawingUntil > provision.thawingUntil ? event.params.thawingUntil : provision.thawingUntil + provision.save() + + indexer.thawingUntil = event.params.thawingUntil > indexer.thawingUntil ? event.params.thawingUntil : indexer.thawingUntil + indexer.save() } export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void {