Skip to content

Commit 6ce272c

Browse files
committed
feat: basic implementation for ThawRequests
1 parent d020532 commit 6ce272c

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

schema.graphql

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -847,28 +847,45 @@ type Provision @entity {
847847

848848
tokensProvisioned: BigInt!
849849

850+
"Timestamp when the provision was created"
851+
createdAt: BigInt!
852+
850853
"Service provider tokens that are being thawed (and will stop being slashable soon)"
851854
tokensThawing: BigInt!
852855

853-
"Shares representing the thawing tokens"
854-
sharesThawing: BigInt!
855-
856856
"Max amount that can be taken by the verifier when slashing, expressed in parts-per-million of the amount slashed"
857857
maxVerifierCut: Int!
858858

859-
"Time, in seconds, tokens must thaw before being withdrawn"
860-
thawingPeriod: BigInt!
861-
862-
"Timestamp when the provision was created"
863-
createdAt: BigInt!
864-
865859
"Pending value for maxVerifierCut. Verifier needs to accept it before it becomes active"
866860
maxVerifierCutPending: Int!
867861

862+
"Time, in seconds, tokens must thaw before being withdrawn"
863+
thawingPeriod: BigInt!
864+
868865
"Pending value for thawingPeriod. Verifier needs to accept it before it becomes active"
869866
thawingPeriodPending: BigInt!
870867
}
871868

869+
type ThawRequest @entity {
870+
id: ID!
871+
872+
indexer: Indexer!
873+
874+
service: DataService!
875+
876+
owner: GraphAccount!
877+
878+
"Shares representing the thawing tokens"
879+
shares: BigInt!
880+
881+
"Tokens thawed"
882+
tokens: BigInt!
883+
884+
thawingUntil: BigInt!
885+
886+
valid: Boolean
887+
}
888+
872889
"""
873890
A state channel Allocation representing a single Indexer-SubgraphDeployment stake
874891
"""

src/mappings/horizonStaking.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { BigInt, log } from '@graphprotocol/graph-ts'
22
import { addresses } from '../../config/addresses'
33
import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, TokensDeprovisioned } from '../types/HorizonStaking/HorizonStaking'
4-
import { Indexer, GraphNetwork } from '../types/schema'
5-
import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers'
4+
import { Indexer, GraphNetwork, ThawRequest } from '../types/schema'
5+
import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers'
66
import {
77
ProvisionCreated,
88
ProvisionIncreased,
@@ -177,17 +177,23 @@ export function handleProvisionSlashed(event: ProvisionSlashed): void {
177177
}
178178

179179
export function handleThawRequestCreated(event: ThawRequestCreated): void {
180-
// To Do
180+
let dataService = createOrLoadDataService(event.params.verifier)
181+
let indexer = Indexer.load(event.params.serviceProvider.toHexString())!
182+
let owner = createOrLoadGraphAccount(event.params.owner, event.block.timestamp)
183+
184+
let request = new ThawRequest(event.params.thawRequestId.toHexString())
185+
request.indexer = indexer.id
186+
request.service = dataService.id
187+
request.owner = owner.id
188+
request.shares = event.params.shares
189+
request.tokens = BigInt.fromI32(0)
190+
request.thawingUntil = event.params.thawingUntil
191+
request.save()
181192
}
182193

183194
export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void {
184-
// To Do
185-
}
186-
187-
export function handleThawRequestsFulfilled(event: ThawRequestsFulfilled): void {
188-
// To Do
189-
}
190-
191-
export function handleThawingPeriodCleared(event: ThawingPeriodCleared): void {
192-
// To Do
193-
}
195+
let request = ThawRequest.load(event.params.thawRequestId.toHexString())
196+
request.tokens = event.params.tokens
197+
request.valid = event.params.valid
198+
request.save()
199+
}

subgraph.template.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,6 @@ dataSources:
423423
handler: handleThawRequestCreated
424424
- event: ThawRequestFulfilled(indexed bytes32,uint256,uint256,uint64,bool)
425425
handler: handleThawRequestFulfilled
426-
- event: ThawRequestsFulfilled(indexed address,indexed address,indexed address,uint256,uint256,uint8)
427-
handler: handleThawRequestsFulfilled
428-
- event: ThawingPeriodCleared()
429-
handler: handleThawingPeriodCleared
430426
- kind: ethereum/contract
431427
name: Curation
432428
network: {{network}}

0 commit comments

Comments
 (0)