Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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.thawingUntil ? event.params.thawingUntil : provision.thawingUntil
provision.save()

indexer.thawingUntil = event.params.thawingUntil > indexer.thawingUntil ? event.params.thawingUntil : indexer.thawingUntil
Copy link
Contributor

Choose a reason for hiding this comment

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

Sry I was just reviewing this more closely for the Engineering Plan: don't we have to set indexer.thawingUntil back to 0 in handleThawRequestFulfilled or handleTokensDeprovisioned?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, I think so. At least on fulfilled it makes sense.
Worst case scenario, the value is easy to identify as invalid though, since if thawingUntil is essentially in the past, it's essentially done thawing

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah actually you're right! shouldn't be a big deal! It's overwritten by a later timestamp anyway and if it's in the past it's withdrawable as you say. nvm then! thx!!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm gonna merge it, but worst case scenario we can modify it later down the road if necessary

indexer.save()
}

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