-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.graphql
288 lines (242 loc) · 7.98 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
type OptionType @entity {
# OptionId
id: ID!
# Position
underlyingAsset: Token!
underlyingAmount: BigInt!
exerciseAsset: Token!
exerciseAmount: BigInt!
# Exercisable Window
exerciseTimestamp: BigInt!
expiryTimestamp: BigInt!
# The address that created the newOptionType
creator: Account!
# The transaction for the creation of the newOptionType
createTx: Transaction!
# The amount of ERC-1155 options written for this OptionType
amountWritten: BigInt!
# The amount of ERC-1155 options exercised for this OptionType
amountExercised: BigInt!
# Claims which collateralize this type of option
claims: [Claim!]! @derivedFrom(field: "optionType")
# The exercise assignment buckets for this OptionType
buckets: [OptionTypeBucket!]! @derivedFrom(field: "optionType")
}
type Claim @entity {
# ClaimId
id: ID!
# The OptionType the Claim belongs to
optionType: OptionType!
# The address that wrote the claim
writer: Account!
# The write transaction
writeTx: Transaction!
# Whether or not claim has been redeemed
redeemed: Boolean!
# Optional: The address that redeemed the claim
redeemer: Account
# Optional: The redeem transaction
redeemTx: Transaction
# The total number of fungible ERC-1155 Options that this claim corresponds to
amountWritten: BigInt!
# The amount of ERC-1155 options assigned exercise for this claim
amountExercised: BigInt!
# The bucket(s) that this claim is assigned to
claimBuckets: [ClaimBucket!]!
}
type OptionTypeBucket @entity {
# The optionId + index of bucket
# `{optionId}-{bucketIndex}`
id: ID!
# The OptionType the bucket belongs to
optionType: OptionType!
# The corresponding claimBucket(s) for this optionTypeBucket
claimBuckets: [ClaimBucket!]!
# The total amount of ERC-1155 options written for this optionTypeBucket
amountWritten: BigInt!
# The total amount of ERC-1155 options assigned exercise for this optionTypeBucket
amountExercised: BigInt!
}
type ClaimBucket @entity {
# The claimId + OptionTypeBucketId
# `{claimId}-{optionTypeBucketId}`
id: ID!
# The Claim the bucket belongs to
claim: Claim!
# The corresponding optionTypeBucket
optionTypeBucket: OptionTypeBucket!
# The total amount of ERC-1155 options written for this claimBucket
amountWritten: BigInt!
# The total amount of ERC-1155 options assigned exercise for this claimBucket
amountExercised: BigInt!
}
type DecimalValue @entity {
id: ID!
value: BigDecimal!
exact: BigInt!
decimals: Int!
}
type DayData @entity {
# Timestamp of day at 00:00AM UTC
id: ID!
# Timestamp of day at 00:00AM UTC
date: Int!
# TVL in USD
totalValueLockedUSD: BigDecimal!
# Notional Volumes in USD
notionalVolWrittenUSD: BigDecimal! # Underlying Asset written
notionalVolExercisedUSD: BigDecimal! # Exercise Asset exercised for Options
notionalVolRedeemedUSD: BigDecimal! # Underlying and/or Exercise Asset redeemed from Claims
notionalVolTransferredUSD: BigDecimal! # Claim Transferred: Current Underlying and/or Exercise Asset; Option Transferred: Underlying Asset
notionalVolSettledUSD: BigDecimal! # Fee Earning Volume; Written + Exercised
notionalVolCoreSumUSD: BigDecimal! # Written + Exercised + Redeemed + Transferred
volFeesAccruedUSD: BigDecimal!
volFeesSweptUSD: BigDecimal!
# ValoremOptionsClearinghouse pointer
och: ValoremOptionsClearinghouse!
# Metrics for each Token on same day
tokenDayData: [TokenDayData!]! @derivedFrom(field: "dayData")
}
type Token @entity {
# Token Address
id: ID!
# Token Info
symbol: String!
name: String!
decimals: Int!
# Total number of tokens in the OCH
totalValueLocked: BigInt!
# Amount of tokens that are ready to be swept as fees
feeBalance: BigInt!
# Lifetime sum of tokens paid to Valorem as fees
feesAccrued: BigInt!
# Daily metrics (tvl, volume, etc) for the token
tokenDayData: [TokenDayData!]! @derivedFrom(field: "token")
}
type TokenDayData @entity {
# Token Address + Timestamp of day at 00:00AM UTC
id: ID!
# Timestamp of day at 00:00AM UTC
date: Int!
# The Token that these metrics belong to
token: Token!
# TVL in OCH in token units
totalValueLocked: BigInt!
# TVL in OCH in USD
totalValueLockedUSD: BigDecimal!
## Notional Volumes in token units
notionalVolWritten: BigInt! # Underlying Asset written
notionalVolExercised: BigInt! # Exercise Asset exercised for Options
notionalVolRedeemed: BigInt! # Underlying and/or Exercise Asset redeemed from Claims
notionalVolTransferred: BigInt! # Claim Transferred: Current Underlying and/or Exercise Asset; Option Transferred: Underlying Asset
notionalVolSettled: BigInt! # Fee Earning Volume; Written + Exercised
notionalVolCoreSum: BigInt! # Written + Exercised + Redeemed + Transferred
volFeesAccrued: BigInt!
volFeesSwept: BigInt!
## Notional Volumes in USD
notionalVolWrittenUSD: BigDecimal!
notionalVolExercisedUSD: BigDecimal!
notionalVolRedeemedUSD: BigDecimal!
notionalVolTransferredUSD: BigDecimal!
notionalVolSettledUSD: BigDecimal!
notionalVolCoreSumUSD: BigDecimal!
volFeesAccruedUSD: BigDecimal!
volFeesSweptUSD: BigDecimal!
# Pointer to DayData for same day
dayData: DayData!
}
type ValoremOptionsClearinghouse @entity {
# ValoremOptionsClearinghouse contract address
id: ID!
# Whether or not fees for protocol are enabled
feesEnabled: Boolean!
# The address of the recipient of protocol fees
feeToAddress: Account!
# Daily metrics
historicalDayData: [DayData!]! @derivedFrom(field: "och")
}
#######
# The following types/entities are credited to https://github.com/OpenZeppelin/openzeppelin-subgraphs
# Included under MIT License
# Extended to support Valorem
#######
type Account @entity {
id: ID!
asERC1155: ERC1155Contract
ERC1155balances: [ERC1155Balance!]! @derivedFrom(field: "account")
ERC1155operatorOwner: [ERC1155Operator!]! @derivedFrom(field: "owner")
ERC1155operatorOperator: [ERC1155Operator!]! @derivedFrom(field: "operator")
ERC1155transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "from")
ERC1155transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "to")
ERC1155transferOperatorEvent: [ERC1155Transfer!]!
@derivedFrom(field: "operator")
events: [Event!]! @derivedFrom(field: "emitter")
}
type ERC1155Contract @entity(immutable: true) {
id: ID!
asAccount: Account!
tokens: [ERC1155Token!]! @derivedFrom(field: "contract")
balances: [ERC1155Balance!]! @derivedFrom(field: "contract")
operators: [ERC1155Operator!]! @derivedFrom(field: "contract")
transfers: [ERC1155Transfer!]! @derivedFrom(field: "contract")
}
type ERC1155Token @entity {
id: ID!
contract: ERC1155Contract!
identifier: BigInt!
uri: String
totalSupply: ERC1155Balance!
balances: [ERC1155Balance!]! @derivedFrom(field: "token")
transfers: [ERC1155Transfer!]! @derivedFrom(field: "token")
## Valorem extended ERC-1155Token attributes
# 1 = Option; 2 = Claim
type: Int
# The OptionId if (type == 1)
optionType: OptionType
# The ClaimId if (type == 2)
claim: Claim
}
type ERC1155Balance @entity {
id: ID!
contract: ERC1155Contract!
token: ERC1155Token!
account: Account
value: BigDecimal!
valueExact: BigInt!
transferFromEvent: [ERC1155Transfer!]! @derivedFrom(field: "fromBalance")
transferToEvent: [ERC1155Transfer!]! @derivedFrom(field: "toBalance")
}
type ERC1155Operator @entity {
id: ID!
contract: ERC1155Contract!
owner: Account!
operator: Account!
approved: Boolean!
}
type ERC1155Transfer implements Event @entity(immutable: true) {
id: ID!
emitter: Account!
transaction: Transaction!
timestamp: BigInt!
contract: ERC1155Contract!
token: ERC1155Token!
operator: Account!
from: Account
fromBalance: ERC1155Balance
to: Account
toBalance: ERC1155Balance
value: BigDecimal!
valueExact: BigInt!
}
interface Event {
id: ID!
transaction: Transaction!
emitter: Account!
timestamp: BigInt!
}
type Transaction @entity(immutable: true) {
id: ID!
timestamp: BigInt!
blockNumber: BigInt!
events: [Event!]! @derivedFrom(field: "transaction")
}