@@ -47,6 +47,9 @@ type Token @entity {
47
47
"dispensers using this token"
48
48
dispensers : [Dispenser ! ] @derivedFrom (field :"token" )
49
49
50
+ "pools, only available for datatokens"
51
+ pools : [Pool ! ] @derivedFrom (field :"datatoken" )
52
+
50
53
"block time datatoken was created"
51
54
createdTimestamp : Int !
52
55
@@ -112,6 +115,133 @@ type Nft @entity{
112
115
orderCount : BigInt !
113
116
}
114
117
118
+ type Pool @entity {
119
+ "pool address"
120
+ id : ID !
121
+
122
+ "owner address, pool controller"
123
+ controller : String !
124
+
125
+ "only finalized pools are relevant to us"
126
+ isFinalized : Boolean !
127
+
128
+ "pool token symbol"
129
+ symbol : String
130
+
131
+ "pool token name"
132
+ name : String
133
+
134
+ "maximum supply if any, converted from wei"
135
+ cap : BigDecimal
136
+
137
+ baseToken : Token !
138
+ baseTokenLiquidity : BigDecimal !
139
+ baseTokenWeight : BigDecimal !
140
+
141
+ datatoken : Token !
142
+ datatokenLiquidity : BigDecimal !
143
+ datatokenWeight : BigDecimal !
144
+
145
+ "publisher market fee value"
146
+ publishMarketSwapFee : BigDecimal !
147
+ "publisher market fee total amount"
148
+ publishMarketSwapFeeAmount : BigDecimal
149
+
150
+ "Liquidty provider fee value"
151
+ liquidityProviderSwapFee : BigDecimal
152
+ "liquidity provider fee total amount"
153
+ liquidityProviderSwapFeeAmount : BigDecimal !
154
+
155
+ "total pool token shares"
156
+ totalShares : BigDecimal !
157
+
158
+ "total tokens that were swaped"
159
+ totalSwapVolume : [TokenValuePair ! ]!
160
+
161
+ spotPrice : BigDecimal !
162
+
163
+ "count for when liquidity has been added"
164
+ joinCount : BigInt !
165
+
166
+ "count for when liquidity has been removed"
167
+ exitCount : BigInt !
168
+
169
+ "count for when tokens were swapped"
170
+ swapCount : BigInt !
171
+
172
+ "number of transactions in this pool involving liquidity changes"
173
+ transactionCount : BigInt !
174
+
175
+ "block time when pool was created"
176
+ createdTimestamp : Int !
177
+ "pool creation transaction id"
178
+ tx : String !
179
+ "block number when it was created"
180
+ block : Int
181
+
182
+ shares : [PoolShare ! ] @derivedFrom (field : " pool" )
183
+ transactions : [PoolTransaction ! ] @derivedFrom (field : " pool" )
184
+
185
+ "address of the market where the datatoken was created. This address collects market fees."
186
+ publishMarketFeeAddress : String
187
+
188
+
189
+
190
+
191
+ }
192
+
193
+ # we will need to track pool share tx between users - bpool transfer tx event
194
+ type PoolShare @entity {
195
+ "poolAddress + userAddress"
196
+ id : ID !
197
+ user : User !
198
+ pool : Pool !
199
+ shares : BigDecimal !
200
+ }
201
+
202
+ enum PoolTransactionType {
203
+ JOIN ,
204
+ EXIT ,
205
+ SWAP ,
206
+ SETUP
207
+ }
208
+
209
+ type PoolTransaction @entity {
210
+ "tx address + caller address"
211
+ id : ID !
212
+ "pool related to this tx"
213
+ pool : Pool !
214
+ "user that initiates the tx"
215
+ user : User !
216
+ type : PoolTransactionType !
217
+
218
+ "number of shares transfered"
219
+ sharesTransferAmount : BigDecimal !
220
+
221
+ "block time when pool was created"
222
+ timestamp : Int !
223
+ "pool creation transaction id"
224
+ tx : String !
225
+ "block number when it was created"
226
+ block : Int
227
+
228
+ gasLimit : BigDecimal !
229
+ "price expressed in eth"
230
+ gasPrice : BigDecimal !
231
+
232
+ "base tokens transfered"
233
+ baseToken : Token
234
+
235
+ "number of base tokens transfered, for type SWAP if value is negative it means it was removed"
236
+ baseTokenValue : BigDecimal
237
+
238
+ "datatokens transfered"
239
+ datatoken : Token
240
+
241
+ "number of datatokens transfered, for type SWAP if value is negative it means it was removed"
242
+ datatokenValue : BigDecimal
243
+ }
244
+
115
245
type OrderReuse @entity {
116
246
id : ID !
117
247
order : Order !
@@ -120,6 +250,7 @@ type OrderReuse @entity {
120
250
tx : String !
121
251
block : BigInt !
122
252
providerFee : String
253
+ providerFeeValidUntil : BigInt
123
254
}
124
255
type Order @entity {
125
256
"transaction hash - token address - from address"
@@ -137,6 +268,7 @@ type Order @entity {
137
268
publishingMarketToken : Token #
138
269
publishingMarketAmmount : BigDecimal #call contract to get fee amount
139
270
providerFee : String
271
+ providerFeeValidUntil : BigInt
140
272
141
273
consumerMarket : User
142
274
consumerMarketToken : Token #
@@ -169,7 +301,9 @@ type TokenTransaction @entity {
169
301
170
302
type User @entity {
171
303
id : ID !
304
+ sharesOwned : [PoolShare ! ] @derivedFrom (field : " user" )
172
305
tokenBalancesOwned : [TokenValuePair ! ]
306
+ poolTransactions : [PoolTransaction ! ] @derivedFrom (field : " user" )
173
307
orders : [Order ! ] @derivedFrom (field : " payer" )
174
308
freSwaps : [FixedRateExchangeSwap ! ] @derivedFrom (field : " by" )
175
309
@@ -287,6 +421,28 @@ type DispenserTransaction @entity {
287
421
tx : String !
288
422
}
289
423
424
+ type PoolSnapshot @entity {
425
+ id : ID !
426
+ pool : Pool !
427
+ "total pool shares at the end of the 24h interval"
428
+ totalShares : BigDecimal !
429
+ "swap value 24h"
430
+ swapVolume : BigDecimal !
431
+ "swap fee value 24h"
432
+ swapFees : BigDecimal !
433
+ "date without time"
434
+ date : Int !
435
+ "last spot price in the 24h interval"
436
+ spotPrice : BigDecimal !
437
+
438
+ baseToken : Token !
439
+ baseTokenLiquidity : BigDecimal !
440
+
441
+ datatoken : Token !
442
+ datatokenLiquidity : BigDecimal !
443
+
444
+ }
445
+
290
446
"utility type"
291
447
type GlobalTotalLiquidityPair @entity {
292
448
"address of the token"
@@ -296,6 +452,15 @@ type GlobalTotalLiquidityPair @entity {
296
452
value : BigDecimal!
297
453
}
298
454
455
+ "utility type"
456
+ type GlobalTotalPoolSwapPair @entity {
457
+ "address of the token"
458
+ id : ID!
459
+ globalStatistic : GlobalStatistic !
460
+ token : Token!
461
+ value : BigDecimal!
462
+ count : BigInt !
463
+ }
299
464
"utility type"
300
465
type GlobalTotalFixedSwapPair @entity {
301
466
"address of the token"
@@ -306,18 +471,25 @@ type GlobalTotalFixedSwapPair @entity {
306
471
count : BigInt !
307
472
}
308
473
type GlobalStatistic @entity {
309
- id : ID !
474
+ id : ID !
475
+
476
+ "total liquidity for each base token in pools"
477
+ totalLiquidity : [GlobalTotalLiquidityPair ! ]! @derivedFrom (field : " globalStatistic" )
478
+ "total swap volume for each base token in pools"
479
+ totalPoolSwapVolume : [GlobalTotalPoolSwapPair ! ]! @derivedFrom (field : " globalStatistic" )
310
480
311
481
"total swap volume for each base token in fixed rate exchanges"
312
482
totalFixedSwapVolume : [GlobalTotalFixedSwapPair ! ] @derivedFrom (field : " globalStatistic" )
313
483
314
- "number of total orders. fixed rate exchange orders + dispenser orders"
484
+ "number of total orders. pool orders + fixed rate exchange orders + dispenser orders"
315
485
orderCount : Int !
316
486
317
487
"total nfts(erc721) created"
318
488
nftCount : Int !
319
489
"total datatokens (tokens with isDatatoken = true) created"
320
- datatokenCount :Int !
490
+ datatokenCount :Int !
491
+ "number of pools"
492
+ poolCount : Int !
321
493
322
494
"number of fixed rate exchanges"
323
495
fixedCount : Int !
0 commit comments