-
Notifications
You must be signed in to change notification settings - Fork 2
/
schema.graphql
164 lines (156 loc) · 3.83 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
"""
A Swap entity represents an atomic swap of a base token for a quote token
made on either SdexSwap or Uniswap V3.
"""
type Swap @entity(immutable: true) {
id: Bytes!
transactionHash: Bytes!
callIndex: Int!
user: Bytes!
block: BigInt!
transactionIndex: BigInt!
time: BigInt!
pool: Pool!
isBuy: Boolean!
inBaseQty: Boolean!
qty: BigInt!
limitPrice: BigDecimal
minOut: BigInt
baseFlow: BigInt!
quoteFlow: BigInt!
price: BigDecimal
callSource: String!
dex: String!
}
"""
A LiquidityChange entity represents a single modification to a single
liquidity position made on SdexSwap. LiquidityChanges are categorized
according to their changeType, which can be equal to mint, burn, harvest,
claim, or recover.
"""
type LiquidityChange @entity(immutable: true) {
id: Bytes!
transactionHash: Bytes!
callIndex: Int!
pool: Pool!
user: Bytes!
block: BigInt!
time: BigInt!
positionType: String!
changeType: String!
bidTick: Int
askTick: Int
isBid: Boolean!
liq: BigInt
baseFlow: BigInt
quoteFlow: BigInt
callSource: String!
pivotTime: BigInt
}
"""
A Pool represents a single liquidity pool on SdexSwap, which is uniquely
specified by a base token, a quote token, and a poolIdx. The ID of the Pool
is the same as the poolHash used internally in SdexSwap contracts.
"""
type Pool @entity(immutable: true) {
id: Bytes!
blockCreate: BigInt!
timeCreate: BigInt!
base: Bytes!
quote: Bytes!
poolIdx: BigInt!
template: PoolTemplate
swaps: [Swap!]! @derivedFrom(field: "pool")
liquidityChanges: [LiquidityChange!]! @derivedFrom(field: "pool")
}
"""
PoolTemplate represents a pool type pattern to create new pools
"""
type PoolTemplate @entity(immutable: false) {
id: Bytes!
blockInit: BigInt!
timeInit: BigInt!
blockRevise: BigInt!
timeRevise: BigInt!
poolIdx: BigInt!
feeRate: Int!
enabled: Boolean!
pools: [Pool!]! @derivedFrom(field: "template")
}
"""
A KnockoutCross is an exact copy of the data emitted in a KnockoutCross event
emitted by the SdexSwap DEX. There is an exact 1:1 correspondence between
emitted events and KnockoutCross entities created by the subgraph.
"""
type KnockoutCross @entity(immutable: true) {
id: Bytes!
block: BigInt!
time: BigInt!
transactionHash: Bytes!
pool: Pool!
tick: Int!
isBid: Boolean!
pivotTime: BigInt!
feeMileage: BigInt!
}
"""
A UserBalance entity represents the first time that a user might have
conceivably "received" a given token from the SdexSwap DEX, such as via
the output of a swap or via the burning of a liquidity position. These
entities collectively represent the universe of tokens for which users
might have nonzero internal DEX balances.
"""
type UserBalance @entity(immutable: true) {
id: Bytes!
transactionHash: Bytes!
block: BigInt!
time: BigInt!
user: Bytes!
token: Bytes!
}
"""
LatestIndex entities are used to help perform bookkeeping related to the
generation of unique event IDs in the case where multiple identical entities
would otherwise be created within the same transaction.
"""
type LatestIndex @entity {
id: Bytes!
callIndex: Int!
}
"""
A FeeChange represents an update to the swap fee setting on a given SdexSwap
liquidity pool.
"""
type FeeChange @entity(immutable: true) {
id: Bytes!
transactionHash: Bytes!
callIndex: Int!
block: BigInt!
time: BigInt!
pool: Pool!
feeRate: Int!
}
"""
Reflects sequences of changes necessary to accurately calculate aggregate statistics
such as volume, TVL and fees collected
"""
type AggEvent @entity(immutable: true) {
id: Bytes!
transactionHash: Bytes!
eventIndex: Int!
pool: Pool!
block: BigInt!
time: BigInt!
baseFlow: BigInt
quoteFlow: BigInt
isSwap: Boolean!
isLiq: Boolean!
isFeeChange: Boolean!
swapPrice: BigDecimal
inBaseQty: Boolean!
isTickSkewed: Boolean!
flowsAtMarket: Boolean!
bidTick: Int
askTick: Int
feeRate: Int
}