-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.graphql
466 lines (447 loc) · 11.1 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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
"""
Transaction data, including hash and timestamp
"""
type Transaction @entity {
"""
ID is transaction hash
"""
id: ID!
blockNumber: Int!
"""
The timestamp the transaction was confirmed
"""
timestamp: Int!
gasPrice: BigInt!
"""
The index of this transaction within the block
"""
index: Int!
"""
The account that initiated this transaction. This must be an Account and not a Contract.
"""
from: User!
"""
The contract the user interacted with
"""
to: Bytes
value: BigInt!
gasLimit: BigInt!
functionSignature: String!
}
type User @entity {
id: ID!
createdAt: Int!
}
"""
This is an event emitted from the staking contract when tokens are staked, either by a user or by a vesting contract
If tokens are staked by a vesting contract, there may be multiple tokens staked event per transaction (eg if tokensa are vested over 10 months, there would be 10 TokensStaked events each with a different lockedUntil date)
We have improvements planned to better represent staking on our subgraph.
"""
type TokensStaked @entity {
"""
ID is transaction hash + log index
"""
id: ID!
"""
If tokens were staked by a vesting contract, user property will be null
"""
user: User
"""
The staker is either a user address or a vesting contract address
"""
staker: Bytes! # address
"""
The amount of SOV staked in this event (as mentioned above, there can be multiple TokensStaked events per transaction)
"""
amount: BigDecimal! # uint256
"""
The date when these tokens will unlock
A user/vesting contract can have multiple stakes with different lockedUntil dates
"""
lockedUntil: Int! # uint256
"""
The total amount staked for this specific user until this specific lockedUntil date
"""
totalStaked: BigDecimal! # uint256
timestamp: Int!
emittedBy: Bytes! #address
transaction: Transaction!
"""
If this is false, the tokens were staked by a vesting contract, and not voluntarily by a user
"""
isUserStaked: Boolean!
}
"""
This entity holds the voluntary staking history (ie not staking by a vesting contract) of one user
"""
type UserStakeHistory @entity {
"""
ID is the user address
"""
id: ID! # id is user
user: User!
"""
Granular history of the user's voluntary staking activity
"""
stakeHistory: [StakeHistoryItem!] @derivedFrom(field: "user")
"""
totalStaked is the total amount the user has EVER staked (over all time).
Eg if they stake 10 SOV and then withdraw it and stake it again, totalStaked is 20 SOV
"""
totalStaked: BigDecimal!
"""
totalWithdrawn is the total amount the user has ever withdrawn from voluntary staking (over all time)
"""
totalWithdrawn: BigDecimal!
"""
totalRemaining is the amount the user currently has staked.
It should be the same as the result of calling the balanceOf(USER_ADDRESS) method on the staking contract.
"""
totalRemaining: BigDecimal!
}
type Stake @entity {
id: ID! # ID is the user address + lockedUntil date. ID can change
user: User
amount: BigDecimal
vestingAmount: BigDecimal!
delegatedAmount: BigDecimal!
lockedUntil: Int
}
enum StakeHistoryAction {
"""
Voluntarily staking SOV (ie not staked through a vesting contract)
"""
Stake
"""
Increasing the amount of an existing stake. The lockedUntil date of this stake remains the same, but amount increases.
"""
IncreaseStake
"""
Extending an existing stake. The amount of the stake remains the same, but the lockedUntil date increases.
"""
ExtendStake
"""
When a user delegates voting power to another user. This can also be for voting power that the user has through a vesting contract.
"""
Delegate
DelegateVested
"""
Unstake is early unstaking, when a user withdraws staked SOV before the lockedUntil date and incurs a slashing penalty.
"""
Unstake
"""
WithdrawStaked is when a user withdraws SOV from the staking contract after the unlock date, when the funds are no longer staked or locked
"""
WithdrawStaked
"""
When a user withdraws their share of the Protocol fees that is shared amongst stakers
"""
FeeWithdrawn
}
"""
This entity is the granular history of user actions related to voluntary staking
"""
type StakeHistoryItem @entity {
id: ID! # transaction hash
user: UserStakeHistory!
action: StakeHistoryAction!
timestamp: Int!
transaction: Transaction!
amount: BigDecimal
token: String
lockedUntil: Int
delegatee: User
emittedBy: Bytes!
}
# This event is emitted when tokens are transferred to the Protocol contract as fees
# It is needed because this is a flag for if staked tokens were unstaked early
type FeeSharingTokensTransferred @entity {
id: ID! # ID is tx hash - it can't be tx hash + log index because we need to load on tx hash
sender: Bytes!
token: Bytes!
amount: BigDecimal!
}
"""
Voluntary staked tokens grouped by lockedUntil date
"""
type V2Stake @entity {
"""
ID is the user address + lockedUntil date.
"""
id: ID!
"""
The user who staked the tokens
"""
user: User!
"""
The total amount staked for this specific user until this specific lockedUntil date
"""
amount: BigDecimal!
"""
The date when these tokens will unlock
"""
lockedUntil: Int!
"""
If tokens delegated to another user, this is the address of the delegatee
"""
delegate: User
"""
Timestamp of a date when the stake was created
"""
timestamp: Int!
}
"""
This event is emitted when tokens are staked, either by a user or by a vesting contract.
"""
type V2TokensStaked @entity {
id: ID!
"""
The user who staked the tokens (if tokens were staked by a vesting contract, user will be staking contract)
"""
user: User!
"""
Amount of SOV staked in this event
"""
amount: BigDecimal!
"""
The date when these tokens will unlock
"""
lockedUntil: Int!
"""
The total amount staked for this specific user until this specific lockedUntil date. As of the time of this event.
"""
totalStaked: BigDecimal!
"""
Timestamp of the transaction
"""
timestamp: Int!
}
"""
Event is emitted when voluntary staked token lockedUntil date is extended
"""
type V2ExtendedStakingDuration @entity {
id: ID!
"""
The user who staked the tokens
"""
user: User!
"""
LockedUntil date of original stake
"""
previousDate: Int!
"""
New lockedUntil date
"""
newDate: Int!
"""
Amount that was moved to the new lockedUntil date
"""
amountStaked: BigDecimal!
"""
Timestamp of the transaction
"""
timestamp: Int!
}
"""
Event is emitted when voluntary or vested staked tokens are withdrawn
"""
type V2StakingWithdrawn @entity {
id: ID!
"""
The user who staked the tokens (owner of tokens)
"""
user: User!
"""
Address who received the tokens
"""
receiver: User
"""
Amount of tokens withdrawn (does not include slashed amount)
"""
amount: BigDecimal!
"""
lockedUntil date of the stake from which tokens were withdrawn
"""
until: Int!
"""
Timestamp of the transaction
"""
timestamp: Int!
"""
If this is true, tokens were withdrawn by governance (eg revoked vesting contract)
"""
isGovernance: Boolean!
}
"""
Event is emitted when stake owner delegates voting power to another user
"""
type V2DelegateChanged @entity {
id: ID!
"""
The user who staked the tokens
"""
user: User!
"""
lockedUntil date of the stake
"""
lockedUntil: Int!
"""
Address of the new delegatee
"""
delegate: User
"""
Address of the previous delegatee
"""
previousDelegate: User
"""
Timestamp of the transaction
"""
timestamp: Int!
}
# Vesting Registry
enum VestingContractType {
"""
Vesting contracts for investors who participated in the Sovryn Origin sale
"""
Origins
"""
Vesting contracts for investors who participated in the Sovryn Genesis sale
"""
Genesis
"""
FISH (Babelfish governance token) vesting contracts
"""
Fish
"""
Babelfish team vesting contracts
"""
FishTeam
"""
Sovryn team vesting contracts
"""
Team
"""
Vesting contracts for vested rewards
"""
Rewards
"""
Vesting contracts for strategic investors with a four-year lockup
"""
FourYearVesting
"""
Vesting contracts for early strategic investors
"""
Strategic
}
"""
This entity represents one vesting contract
A User can have multiple vesting contracts
"""
type VestingContract @entity {
"""
ID is the vesting contract address
"""
id: ID! # vesting contract id
"""
The owner of the vesting contract
"""
user: User!
"""
Date that the vesting contract was created
"""
createdAtTimestamp: Int!
"""
The cliff is the period (in seconds) until the first tokens become liquid on this contract
"""
cliff: Int # uint256
"""
The total duration of the vesting contract, including the cliff, in seconds.
For example, a 9 month vesting contract with a 1 month cliff would have a duration of 26280000 (10 months in seconds)
"""
duration: Int # uint256
"""
The initial balance when this contract was created. This is often 0, as tokens can be added to the contract after contract creation
"""
startingBalance: BigDecimal! # uint256
"""
Current balance of tokens on the contract, including locked and liquid tokens that have not been withdrawn.
Incremented on TokensStaked actions, decremented on TokensWithdrawn actions
"""
currentBalance: BigDecimal!
"""
Type of contract (see VestingContractType docs for more details)
"""
type: VestingContractType!
emittedBy: Bytes!
createdAtTransaction: Transaction!
"""
A granular history of every action involving this vesting contract
"""
stakeHistory: [VestingHistoryItem!] @derivedFrom(field: "staker")
"""
Delegated too
"""
delegate: User
"""
Staking contract address
"""
staking: Bytes! #address
"""
Token staked in this vesting contract
"""
token: Bytes! #address
}
enum VestingHistoryItemAction {
"""
Tokens are staked by the Vesting contract. This happens when the Vesting contract receives funds.
"""
TokensStaked
"""
This is only relevant to Team tokens. For Team contracts, a vesting contract can be revoked by governance if a team member leaves the project.
If this happens, all tokens still locked are returned to the exchequer.
This is ONLY possible with Team or FishTeam vesting contracts.
"""
TeamTokensRevoked
"""
When a user withdraws unlocked tokens from the vesting contract
"""
TokensWithdrawn
"""
When a user delegates their vesting contract to another user
"""
DelegateChanged
}
"""
Granular data for each vesting contract, and any actions involving that contract
"""
type VestingHistoryItem @entity {
"""
ID is transaction hash + "-" + log index
For TokensStaked actions, there can be multiple actions per transactions, and each will create a new entity
"""
id: ID!
action: VestingHistoryItemAction!
"""
The staker here will always be the vesting contract
"""
staker: VestingContract!
"""
Delegated too
"""
delegatee: User
"""
Amount being staked
"""
amount: BigDecimal! # uint256
"""
The date when the tokens become unlocked
"""
lockedUntil: Int # uint256
"""
Total number of tokens staked until this lockedUntil date
"""
totalStaked: BigDecimal! # uint256
timestamp: Int!
emittedBy: Bytes! #address
transaction: Transaction!
}