-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathschema.graphql
More file actions
197 lines (186 loc) · 6.36 KB
/
Copy pathschema.graphql
File metadata and controls
197 lines (186 loc) · 6.36 KB
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
type Swap
@storage(postgres: true, clickhouse: true)
@index(fields: ["pool", ["timestamp", "DESC"]]) {
id: ID!
transaction: String! # Instead of Transaction reference
timestamp: BigInt! @index
pool: String! # Instead of Pool reference
token0: Token! # Changed from String to Token reference
token1: Token! # Changed from String to Token reference
sender: String! # Instead of Bytes
origin: String! # Instead of Bytes
amount0: BigDecimal!
amount1: BigDecimal!
amountUSD: BigDecimal!
sqrtPriceX96: BigInt!
tick: BigInt!
logIndex: BigInt!
# Fee paid for this swap in hundredths of a bip (i.e. raw PoolManager Swap.fee).
# For dynamic-fee pools this captures the per-swap effective fee, which would
# otherwise be lost when pool.feeTier is overwritten by the next swap.
fee: BigInt!
}
type PoolManager @storage(postgres: true, clickhouse: true) {
id: ID!
poolCount: BigInt!
txCount: BigInt!
totalVolumeUSD: BigDecimal!
totalVolumeETH: BigDecimal!
totalFeesUSD: BigDecimal!
totalFeesETH: BigDecimal!
untrackedVolumeUSD: BigDecimal!
totalValueLockedUSD: BigDecimal!
totalValueLockedETH: BigDecimal!
totalValueLockedUSDUntracked: BigDecimal!
totalValueLockedETHUntracked: BigDecimal!
owner: String!
numberOfSwaps: BigInt! # total swaps on network
hookedPools: BigInt! # number of pools with hooks
hookedSwaps: BigInt! # number of swaps through hooked pools
}
type Pool
@storage(postgres: true, clickhouse: true)
@index(fields: ["hooks", ["totalValueLockedUSD", "DESC"]]) {
id: ID!
name: String!
createdAtTimestamp: BigInt! @index
createdAtBlockNumber: BigInt!
token0: String! # Instead of Token reference
token1: String! # Instead of Token reference
feeTier: BigInt!
liquidity: BigInt!
sqrtPrice: BigInt!
token0Price: BigDecimal!
token1Price: BigDecimal!
tick: BigInt
tickSpacing: BigInt!
observationIndex: BigInt!
volumeToken0: BigDecimal!
volumeToken1: BigDecimal!
volumeUSD: BigDecimal! @index
untrackedVolumeUSD: BigDecimal!
feesUSD: BigDecimal!
feesUSDUntracked: BigDecimal!
txCount: BigInt! @index
collectedFeesToken0: BigDecimal!
collectedFeesToken1: BigDecimal!
collectedFeesUSD: BigDecimal!
totalValueLockedToken0: BigDecimal!
totalValueLockedToken1: BigDecimal!
totalValueLockedETH: BigDecimal!
totalValueLockedUSD: BigDecimal! @index
totalValueLockedUSDUntracked: BigDecimal!
liquidityProviderCount: BigInt!
hooks: String!
# derived fields
ticks: [Tick!]! @derivedFrom(field: "pool")
}
type Tick
@storage(postgres: true, clickhouse: true)
@index(fields: ["pool", "tickIdx"]) {
id: ID! # <pool address>#<tickIdx>
pool: Pool! # Pointer back to Pool
tickIdx: BigInt!
liquidityGross: BigInt! # abs liquidity at this boundary
liquidityNet: BigInt! # delta when price crosses boundary
price0: BigDecimal! # Optional – 1.0001^tickIdx
price1: BigDecimal! # Optional inverse price
createdAtTimestamp: BigInt!
createdAtBlockNumber: BigInt!
}
type Token @storage(postgres: true, clickhouse: true) {
id: ID!
symbol: String!
name: String!
decimals: BigInt!
totalSupply: BigInt!
volume: BigDecimal!
volumeUSD: BigDecimal!
untrackedVolumeUSD: BigDecimal!
feesUSD: BigDecimal!
txCount: BigInt!
poolCount: BigInt!
totalValueLocked: BigDecimal!
totalValueLockedUSD: BigDecimal!
totalValueLockedUSDUntracked: BigDecimal!
derivedETH: BigDecimal!
whitelistPools: [String!]! # Changed from Pool reference to String for simplicity
}
# stores for USD calculations
type Bundle @storage(postgres: true, clickhouse: true) {
id: ID!
# price of ETH in usd
ethPriceUSD: BigDecimal!
}
type HookStats @storage(postgres: true, clickhouse: true) {
id: ID! # hook address
numberOfPools: BigInt!
numberOfSwaps: BigInt!
firstPoolCreatedAt: BigInt!
totalValueLockedUSD: BigDecimal! @index # Total TVL across all pools using this hook
totalVolumeUSD: BigDecimal! # Total volume across all pools using this hook
untrackedVolumeUSD: BigDecimal! # Untracked volume for non-whitelisted tokens
totalFeesUSD: BigDecimal! # Total fees across all pools using this hook
}
type Position @storage(postgres: true, clickhouse: true) {
id: ID! # <chainId>_<tokenId>
tokenId: BigInt! @index
owner: String! @index # address of current owner
origin: String! # the EOA that minted the position
createdAtTimestamp: BigInt!
# derived fields
subscriptions: [Subscribe!]! @derivedFrom(field: "position")
unsubscriptions: [Unsubscribe!]! @derivedFrom(field: "position")
transfers: [Transfer!]! @derivedFrom(field: "position")
}
type Transfer @storage(postgres: true, clickhouse: true) {
id: ID!
tokenId: BigInt! @index
from: String! # address of previous owner
to: String! # address of new owner
transaction: String! # Instead of Transaction reference
logIndex: BigInt!
timestamp: BigInt! @index
origin: String! # the EOA that initiated the tx
position: Position!
}
type Subscribe @storage(postgres: true, clickhouse: true) {
id: ID!
tokenId: BigInt! @index
address: String! # address of subscriber
transaction: String! # Instead of Transaction reference
logIndex: BigInt!
timestamp: BigInt! @index
origin: String! # the EOA that initiated the tx
position: Position!
}
type Unsubscribe @storage(postgres: true, clickhouse: true) {
id: ID!
tokenId: BigInt! @index
address: String! # address of unsubscriber
transaction: String! # Instead of Transaction reference
logIndex: BigInt!
timestamp: BigInt! @index
origin: String! # the EOA that initiated the tx
position: Position!
}
type ModifyLiquidity
@storage(postgres: true, clickhouse: true)
@index(fields: ["pool", ["timestamp", "DESC"]])
@index(fields: ["pool", "transaction"]) {
id: ID!
transaction: String! # Instead of Transaction reference
timestamp: BigInt! @index
pool: Pool! # Instead of Pool reference
token0: Token! # Token reference like in Swap entity
token1: Token! # Token reference like in Swap entity
sender: String! # Instead of Bytes
origin: String! # Instead of Bytes - the EOA that initiated the txn
amount: BigInt! # amount of liquidity modified
amount0: BigDecimal! # amount of token 0 modified
amount1: BigDecimal! # amount of token 1 modified
amountUSD: BigDecimal! @index # derived amount based on available prices of tokens
tickLower: BigInt! # lower tick of the position
tickUpper: BigInt! # upper tick of the position
logIndex: BigInt! # index within the txn
}