-
Notifications
You must be signed in to change notification settings - Fork 4
/
schema.graphql
290 lines (249 loc) · 7.61 KB
/
schema.graphql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
enum DepositStatus {
UNKNOWN
REVEALED #-> bridge.revealDeposit() / DepositRevealed event
MINTING_REQUESTED
SWEPT # -> bridge.submitDepositSweepProof() / DepositSwept event && bank.increaseBalances() / BalanceIncreased event
MINTING_FINALIZED
CANCELED # -> Guardian cancel , The optimistic minting request for the given deposit exis or The optimistic minting request for the given deposit has not been finalized yet.
REFUNDED
}
enum RedemptionStatus {
UNKNOWN
REQUESTED #-> bridge.requestRedemption() / RedemptionRequested event && bank.transferBalanceFrom() / BalanceTransferred event
COMPLETED #-> bridge.submitRedemptionProof() / RedemptionCompleted event && bank.DecreaseBalance() / BalanceDecreased event && bank.trasferBalance() / BalanceTransferred event
TIMEDOUT #-> bridge.notifyRedemptionTimeout() / RedemptionTimedOut
}
type _Schema_
@fulltext(
name: "searchRedemption"
language: en
algorithm: rank
include: [{ entity: "Redemption", fields: [{ name: "id" }] }]
)
type Transaction @entity {
id: ID!
txHash: Bytes!
timestamp: BigInt!
from: Bytes!
to: Bytes
amount: BigInt
description: String
deposits: [Deposit!] @derivedFrom(field: "transactions")
redemptions: [Redemption!] @derivedFrom(field: "transactions")
}
type User @entity {
id: Bytes!
mintingDebt: BigInt!
tokenBalance: BigInt!
totalTokensHeld: BigInt!
tbtcToken : TBTCToken!
deposits: [Deposit!]!
redemptions: [Redemption!]! @derivedFrom(field: "user")
}
type Deposit @entity {
#keccak256(fundingTxHash|fundingOutputIndex)
id: Bytes!
status: DepositStatus
user: User!
amount: BigInt!
newDebt: BigInt!
actualAmountReceived: BigInt!
treasuryFee: BigInt!
walletPubKeyHash: Bytes
fundingTxHash: Bytes
fundingOutputIndex: BigInt
blindingFactor: Bytes
refundPubKeyHash: Bytes
refundLocktime: Bytes
vault: Bytes
transactions: [Transaction!]!
sweptAt: BigInt
depositTimestamp: BigInt
updateTimestamp: BigInt
}
type Redemption @entity {
#keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash) + "-" + count
id: ID!
status: RedemptionStatus
user: User!
amount: BigInt!
walletPubKeyHash: Bytes
redeemerOutputScript: Bytes
redemptionTxHash: Bytes
treasuryFee: BigInt
txMaxFee: BigInt
completedTxHash: Bytes
transactions: [Transaction!]!
redemptionTimestamp: BigInt
updateTimestamp: BigInt!
}
type TBTCToken @entity{
"TBTCToken"
id: ID!
name: String!
symbol: String!
decimals: Int!
address: Bytes!
totalSupply: BigInt!
totalMint: BigInt!
totalBurn: BigInt!
currentTokenHolders: BigInt!
holders: [User!] @derivedFrom(field: "tbtcToken")
}
enum TransactionEvent {
STAKED,
TOPUP,
UNSTAKE,
AUTHORIZED_RANDOM_BEACON,
AUTHORIZED_TBTC,
AUTHORIZED_UNKNOW,
DECREASE_AUTHORIZED_RANDOM_BEACON,
DECREASE_AUTHORIZED_TBTC,
REGISTERED_OPERATOR,
BOND_OPERATOR,
JOINED_SORTITION_POOL,
SLASHED,
WITHDRAW_REWARD
}
type Event @entity {
#Hash of transaction
id: ID!
txHash: Bytes!
timestamp: BigInt!
from: Bytes!
to: Bytes
amount: BigInt!
isRandomBeaconEvent: Boolean!
event: TransactionEvent!
operator: [Operator!] @derivedFrom(field: "events")
}
type GroupPublicKey @entity {
# Group id
id: ID!
# Group public key
pubKey: Bytes!
group : RandomBeaconGroup!
}
type RandomBeaconGroup @entity {
id: ID!
createdAt: BigInt!
createdAtBlock: BigInt!
groupPublicKey: GroupPublicKey! @derivedFrom(field: "group")
memberships: [RandomBeaconGroupMembership!]! @derivedFrom(field: "group")
"The total number of slots."
size: Int!
uniqueMemberCount: Int!
"Total fault."
misbehavedCount: Int!
totalSlashedAmount: BigInt!
terminated: Boolean!
nonce: BigInt!
notifier : Bytes
"Create from WalletRegistry"
isWalletRegistry: Boolean!
relayEntries: [RelayEntry!]! @derivedFrom(field: "group")
}
"""
Represents the membership of an operator in a beacon group.
"""
type RandomBeaconGroupMembership @entity {
#keccak256(group id , operator address)
id: ID!
group: RandomBeaconGroup!
operator: Operator!
seats: [Int!]!
"The same operator can fill multiple membership slots within a group."
count: Int!
# These are denormalized fields from the group & operator, to allow sorting memberships by these fields.
groupCreatedAt: BigInt!
}
type RelayEntry @entity {
"Request Id"
id: ID!
requestedAt: BigInt!
requestedBy: Bytes!
group: RandomBeaconGroup!
value: Bytes
submitter: Bytes!
submittedAt: BigInt
isInProgress: Boolean!
}
type Operator @entity {
#Staking Provider address
id: ID!
#Operator address
address: Bytes!
registeredOperatorAddress: Int!
"registered operator address use PreApplication"
isBondRegisteredOperatorAddress: Boolean!
"When this operator had a stake delegated to them. This is like a createdAt, and the operation also assigns the beneficiary/authorizer roles."
stakedAt: BigInt!
stakeType: Int!
randomBeaconGroupMemberships: [RandomBeaconGroupMembership!]! @derivedFrom(field: "operator")
# The other "staker" roles.
owner: Bytes
beneficiary: Bytes
authorizer: Bytes
# Authorizations
randomBeaconAuthorized: Boolean!
tBTCAuthorized: Boolean!
# Statistics
tBTCAuthorizedAmount: BigInt!
randomBeaconAuthorizedAmount: BigInt!
stakedAmount: BigInt!
"Total reward withdrew"
rewardDispensed : BigInt!
"The reward available to withdraw."
availableReward: BigInt!
"How often this operator was involved in a fault."
misbehavedCount: Int!
totalSlashedAmount: BigInt!
"Duration of the sortition pool rewards ban imposed on operators who misbehaved"
poolRewardBanDuration: BigInt!
beaconGroupCount: Int!
events: [Event!]!
}
enum State {
"Group creation is not in progress. It is a state set after group creation completion either by timeout or by a result approval."
IDLE,
"Group creation is awaiting the seed and sortition pool is locked."
AWAITING_SEED,
"Off-chain DKG protocol execution is in progress. A result is being calculated by the clients in this state. It's not yet possible to submit the result."
KEY_GENERATION,
""" After off-chain DKG protocol execution the contract awaits result submission.
This is a state to which group creation returns in case of a result
challenge notification."""
AWAITING_RESULT,
"""DKG result was submitted and awaits an approval or a challenge. If a result
gets challenge the state returns to `AWAITING_RESULT`. If a result gets
approval the state changes to `IDLE`."""
CHALLENGE
}
"""
Exposes some global system statistics. Only a single record with the id "current" is available.
"""
type StatsRecord @entity {
id: ID!
"The total number of stakers with a stake larger than 0."
numOperators: Int!
numOperatorsRegisteredNode: Int!
totalTBTCAuthorizedAmount: BigInt!
totalRandomBeaconAuthorizedAmount: BigInt!
totalStaked: BigInt!
"True is not pause"
mintingStatus: Boolean!
}
"""
Exposes some global system status data. Only a single record with the id "status" is available.
"""
type StatusRecord @entity {
id: ID!
"The currently requested RandomBeacon relay entry, if any. Only a single request can exist at a time."
groupState: State!
ecdsaState: State!
challenger: Bytes
reason: String
pendingRedemptions: [Bytes!]!
lastMintedInfo: [String!]!
lastMintedHash: Bytes!
}