Skip to content

Commit 493a6d2

Browse files
committed
Revert "Removing pools from schema"
This reverts commit 0b8f6e1.
1 parent 07ce939 commit 493a6d2

File tree

1 file changed

+175
-3
lines changed

1 file changed

+175
-3
lines changed

schema.graphql

+175-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ type Token @entity {
4747
"dispensers using this token"
4848
dispensers: [Dispenser!] @derivedFrom(field:"token")
4949

50+
"pools, only available for datatokens"
51+
pools: [Pool!] @derivedFrom(field:"datatoken")
52+
5053
"block time datatoken was created"
5154
createdTimestamp: Int!
5255

@@ -112,6 +115,133 @@ type Nft @entity{
112115
orderCount: BigInt!
113116
}
114117

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+
115245
type OrderReuse @entity {
116246
id: ID!
117247
order: Order!
@@ -120,6 +250,7 @@ type OrderReuse @entity {
120250
tx: String!
121251
block: BigInt!
122252
providerFee: String
253+
providerFeeValidUntil: BigInt
123254
}
124255
type Order @entity {
125256
"transaction hash - token address - from address"
@@ -137,6 +268,7 @@ type Order @entity {
137268
publishingMarketToken: Token #
138269
publishingMarketAmmount: BigDecimal #call contract to get fee amount
139270
providerFee: String
271+
providerFeeValidUntil: BigInt
140272

141273
consumerMarket: User
142274
consumerMarketToken: Token #
@@ -169,7 +301,9 @@ type TokenTransaction @entity {
169301

170302
type User @entity {
171303
id: ID!
304+
sharesOwned: [PoolShare!] @derivedFrom(field: "user")
172305
tokenBalancesOwned: [TokenValuePair!]
306+
poolTransactions: [PoolTransaction!] @derivedFrom(field: "user")
173307
orders: [Order!] @derivedFrom(field: "payer")
174308
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
175309

@@ -287,6 +421,28 @@ type DispenserTransaction @entity {
287421
tx: String!
288422
}
289423

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+
290446
"utility type"
291447
type GlobalTotalLiquidityPair @entity {
292448
"address of the token"
@@ -296,6 +452,15 @@ type GlobalTotalLiquidityPair @entity {
296452
value : BigDecimal!
297453
}
298454

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+
}
299464
"utility type"
300465
type GlobalTotalFixedSwapPair @entity {
301466
"address of the token"
@@ -306,18 +471,25 @@ type GlobalTotalFixedSwapPair @entity {
306471
count: BigInt!
307472
}
308473
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")
310480

311481
"total swap volume for each base token in fixed rate exchanges"
312482
totalFixedSwapVolume: [GlobalTotalFixedSwapPair!] @derivedFrom(field: "globalStatistic")
313483

314-
"number of total orders. fixed rate exchange orders + dispenser orders"
484+
"number of total orders. pool orders + fixed rate exchange orders + dispenser orders"
315485
orderCount: Int!
316486

317487
"total nfts(erc721) created"
318488
nftCount: Int!
319489
"total datatokens (tokens with isDatatoken = true) created"
320-
datatokenCount:Int!
490+
datatokenCount:Int!
491+
"number of pools"
492+
poolCount: Int!
321493

322494
"number of fixed rate exchanges"
323495
fixedCount: Int!

0 commit comments

Comments
 (0)