-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.graphql
264 lines (215 loc) · 6.5 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
type Token @entity {
id: ID!
address: Bytes! #address
name: String!
symbol: String!
decimals: String!
protocol: Protocol
}
type Vault @entity {
id: ID!
vaultId: BigInt
owner: Bytes! #address
collateral: BigInt!
debt: BigInt!
currentRatio: BigInt
address: Bytes #address
tokenSymbol: String!
hardVault: Boolean!
underlyingProtocol: Protocol!
blockTS: BigInt!
}
type State @entity {
id: ID!
owner: Bytes #address
isPaused: Boolean
tcapContract: Bytes #address
collateralContract: Bytes #address
collateralOracle: Bytes #address
ethContract: Bytes #address
tcapOracle: Bytes #address
burnFee: BigInt
liquidationPenalty: BigInt
ratio: BigInt
divisor: BigInt
amountStaked: BigInt!
rewardContract: Bytes #3
treasuryContract: Bytes #address
}
type Oracle @entity {
id: ID!
address: Bytes #address
answer: BigInt
updatedAt: BigInt
roundId: BigInt
}
type Protocol @entity {
id: ID!
address: Bytes #address
totalCollateral: BigInt!
totalDebt: BigInt!
totalBurnFee: BigInt!
createdVaults: BigInt!
totalTransactions: BigInt!
underlyingToken: Token
}
enum ProposalStatus {
PENDING
ACTIVE
CANCELLED
QUEUED
EXECUTED
}
# Ctx Governance Graph
type TokenHolder @entity {
"A TokenHolder is any address that holds any amount of Ctx Tokens, the id used is the blockchain address."
id: ID!
"Delegate address of the token holder which will participate in votings. Delegates don't need to hold any tokens and can even be the token holder itself."
delegate: Delegate
delegator: Delegator
"Ctx Token balance of this address expressed in the smallest unit of the CtxToken"
tokenBalanceRaw: BigInt!
"Ctx Token balance of this address expressed as a BigDecimal normalized value for the Ctx Token"
tokenBalance: BigDecimal!
"Total amount of Ctx Token ever held by this address expressed in the smallest unit of the CtxToken"
totalTokensHeldRaw: BigInt!
"Total amount of Ctx Token ever held by this address expressed as a BigDecimal normalized value for the Ctx Token"
totalTokensHeld: BigDecimal!
}
type Delegate @entity {
"A Delegate is any address that has been delegated with voting tokens by a token holder, id is the blockchain address of said delegate"
id: ID!
"Amount of votes delegated to this delegate to be used on proposal votings expressed in the smallest unit of the CtxToken"
delegatedVotesRaw: BigInt!
"Amount of votes delegated to this delegate to be used on proposal votings expressed as a BigDecimal normalized value for the Ctx Token"
delegatedVotes: BigDecimal!
tokenHoldersRepresentedAmount: Int!
"Token holders that this delegate represents"
tokenHoldersRepresented: [TokenHolder!]! @derivedFrom(field: "delegate")
"Votes that a delegate has made in different proposals"
votes: [Vote!]! @derivedFrom(field: "voter")
"Proposals that the delegate has created"
proposals: [Proposal!]! @derivedFrom(field: "proposer")
}
type Proposal @entity {
"Internal proposal ID, in this implementation it seems to be a autoincremental id"
id: ID!
"Delegate that proposed the change"
proposer: Delegate!
"Targets data for the change"
targets: [Bytes!]
"Values data for the change"
values: [BigInt!]
"Signature data for the change"
signatures: [String!]
"Call data for the change"
calldatas: [Bytes!]
"Block number from where the voting starts"
startBlock: BigInt!
"Block number from where the voting ends"
endBlock: BigInt!
"String description of the change"
description: String!
"Status of the proposal"
status: ProposalStatus!
"Once the proposal is queued for execution it will have an ETA of the execution"
executionETA: BigInt
"Votes associated to this proposal"
votes: [Vote!]! @derivedFrom(field: "proposal")
}
type Vote @entity {
"Delegate ID + Proposal ID"
id: ID!
"Whether the vote is in favour or against the proposal"
support: Boolean!
"Amount of votes in favour or against expressed in the smallest unit of the CtxToken"
votesRaw: BigInt!
"Amount of votes in favour or against expressed as a BigDecimal normalized value for the Ctx Token"
votes: BigDecimal!
"Delegate that emitted the vote"
voter: Delegate!
"Proposal that is being voted on"
proposal: Proposal!
}
type Governance @entity {
"Unique entity used to keep track of common aggregated data"
id: ID!
"Number of proposals created"
proposals: BigInt!
"Total number of token holders currently"
currentTokenHolders: BigInt!
"Total number of delegates participating on the governance currently"
currentDelegates: BigInt!
"Total number of token holders"
totalTokenHolders: BigInt!
"Total number of delegates that held delegated votes"
totalDelegates: BigInt!
"Total number of votes delegated expressed in the smallest unit of the Ctx Token"
delegatedVotesRaw: BigInt!
"Total number of votes delegated expressed as a BigDecimal normalized value for the Ctx Token"
delegatedVotes: BigDecimal!
"Number of proposals currently queued for execution"
proposalsQueued: BigInt!
}
type Delegator @entity {
"A Delegator is any contract address created by the DelegatorFactory."
id: ID!
delegatee: Bytes!
"Amount of votes delegated to this delegatee to be used on proposal votings expressed in the smallest unit of the CtxToken"
delegatedVotesRaw: BigInt!
"Amount of votes delegated to this delegatee to be used on proposal votings expressed as a BigDecimal normalized value for the Ctx Token"
delegatedVotes: BigDecimal!
totalHoldersRepresented: Int!
tokenOwners: [DelegatorTokenOwner!]! @derivedFrom(field: "delegator")
}
type DelegatorTokenOwner @entity {
id: ID!
tokenOwner: Bytes!
delegator: Delegator!
stake: BigDecimal!
stakeRaw: BigInt!
}
# UniswapV3
type Tick @entity {
# format: <pool address>#<tick index>
id: ID!
# pool address
poolAddress: String!
# tick index
tickIdx: BigInt!
# calculated price of token0 of tick within this pool - constant
price0: BigDecimal!
# calculated price of token1 of tick within this pool - constant
price1: BigDecimal!
createdAtTimestamp: BigInt!
# created block
createdAtBlockNumber: BigInt!
}
type Position @entity {
id: ID!
owner: String!
poolAddress: String!
staked: Boolean!
token0: Bytes!
token1: Bytes!
# lower tick of the position
tickLower: Tick!
# upper tick of the position
tickUpper: Tick!
liquidity: BigInt!
depositedToken0: BigInt!
depositedToken1: BigInt!
withdrawnToken0: BigInt!
withdrawnToken1: BigInt!
secondsPerLiquidityInsideX128: BigInt
stakedBlockNumber: BigInt!
}
type APR @entity {
id: ID!
tvl: BigDecimal
totalAmount0: BigDecimal
totalAmount1: BigDecimal
tcapPrice: BigDecimal
wethPrice: BigDecimal
stakedPositions: [String!]!
}