Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/mappings/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions src/mappings/horizonStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.save()

indexer.thawingUntil = event.params.thawingUntil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessarily true, that the latest thaw request has the latest thawingUntil, because we could change the thawingPeriod but I think we should not worry about it. Maybe just note it with a comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I didn't think about it, but that's correct, maybe simply doing a max out of the current value and the next?

indexer.save()
}

export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void {
Expand Down