-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.graphql
169 lines (156 loc) · 6.35 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
type SwaapProtocol @entity {
id: ID!
poolCount: Int! # Number of pools
finalizedPoolCount: Int! # Number of finalized pools
crpCount: Int! # Number of CRP
pools: [Pool!] @derivedFrom(field: "factoryID")
txCount: BigInt! # Number of txs
totalLiquidity: BigDecimal! # All the pools liquidity value in USD
totalSwapVolume: BigDecimal! # All the swap volume in USD
totalSwapFee: BigDecimal! # All the swap fee in USD
}
type Pool @entity {
id: ID! # Pool address
controller: Bytes! # Controller address
publicSwap: Boolean! # isPublicSwap
finalized: Boolean! # isFinalized
crp: Boolean! # Is configurable rights pool
crpController: Bytes # CRP controller address
symbol: String # Pool token symbol
name: String # Pool token name
rights: [String!]! # List of rights (for CRP)
cap: BigInt # Maximum supply if any (for CRP)
active: Boolean! # isActive
swapFee: BigDecimal! # Swap Fees
totalWeight: BigDecimal!
totalShares: BigDecimal! # Total pool token shares
totalSwapVolume: BigDecimal! # Total swap volume in USD
totalSwapFee: BigDecimal! # Total swap fee in USD
liquidity: BigDecimal! # Pool liquidity value in USD
tokensList: [Bytes!]! # Temp workaround until graph supports filtering on derived field
tokens: [PoolToken!] @derivedFrom(field: "poolId")
shares: [PoolShare!] @derivedFrom(field: "poolId")
createTime: Int! # Block time pool was created
tokensCount: BigInt! # Number of tokens in the pool
holdersCount: BigInt! # Number of addresses holding a positive balance of SPT
joinsCount: BigInt! # liquidity has been added
exitsCount: BigInt! # liquidity has been removed
swapsCount: BigInt!
factoryID: SwaapProtocol!
tx: Bytes # Pool creation transaction id
swaps: [Swap!] @derivedFrom(field: "poolAddress")
dailyActivity: DailyActivity
priceStatisticsLookbackInRound: Int!
priceStatisticsLookbackStepInRound: Int!
dynamicCoverageFeesZ: BigDecimal!
dynamicCoverageFeesHorizon: BigDecimal!
priceStatisticsLookbackInSec: BigInt!
maxPriceUnpegRatio: BigDecimal!
initialShares: BigDecimal!
initialTokensBalance: [PoolTokenBalance!] @derivedFrom(field: "poolId")
lpTokenPrices: [LPTokenPrice!] @derivedFrom(field: "poolId")
}
type PoolToken @entity {
id: ID! # poolId + token address
poolId: Pool!
symbol: String
name: String
decimals: Int!
address: String!
balance: BigDecimal!
denormWeight: BigDecimal!
oracleInitialState: PoolOracleState!
}
type LPTokenPrice @entity {
id: ID! # poolId-$key ('initial' or 'current')
poolId: Pool! # poolId
price: BigDecimal!
}
type PoolShare @entity {
id: ID! # poolId + userAddress
userAddress: User!
poolId: Pool!
balance: BigDecimal!
}
type User @entity {
id: ID!
sharesOwned: [PoolShare!] @derivedFrom(field: "userAddress")
txs: [Transaction!] @derivedFrom(field: "userAddress")
swaps: [Swap!] @derivedFrom(field: "userAddress")
}
type Swap @entity {
id: ID! #
caller: Bytes! #
tokenIn: Bytes! #
tokenInSym: String! #
tokenOut: Bytes! #
tokenOutSym: String! #
tokenAmountIn: BigDecimal! #
tokenAmountOut: BigDecimal! #
poolAddress: Pool
userAddress: User # User address that initiates the swap
value: BigDecimal! # Swap value in USD
spread: BigDecimal! # Parameter modifying the final fees
taxBaseIn: BigDecimal! # TokenIn tax base
feeValue: BigDecimal! # Swap fee value in USD, from feeValue, spread, poolFees
poolTotalSwapVolume: BigDecimal! # Total pool swap volume in USD
poolTotalSwapFee: BigDecimal! # Total pool swap fee in USD
poolLiquidity: BigDecimal! # Pool liquidity value in USD
timestamp: Int!
}
type Transaction @entity {
id: ID! # Log ID
tx: Bytes!
event: String
block: Int!
timestamp: Int!
gasUsed: BigDecimal!
gasPrice: BigDecimal!
poolAddress: Pool
userAddress: User
action: SwapType
sender: Bytes
}
type TokenPrice @entity {
id: ID! # token address + oracle address
symbol: String
name: String
decimals: Int!
price: BigDecimal!
poolTokenId: String
}
enum SwapType {
swapExactAmountIn,
swapExactAmountOut,
joinswapExternAmountIn,
joinswapPoolAmountOut,
exitswapPoolAmountIn,
exitswapExternAmountOut
}
type DailyActivity @entity{
id: ID!
poolAddress: Pool!
dailyFees: BigDecimal!
dailyVolume: BigDecimal!
swapCount:Int!
todayTimestamps: [Int!]!
todayFees: [BigDecimal!]!
todayVolumes: [BigDecimal!]!
yesterdayTimestamps: [Int!]!
yesterdayFees: [BigDecimal!]!
yesterdayVolumes: [BigDecimal!]!
last: Int!
}
type PoolOracleState @entity {
id: ID! # poolId + token address
proxy: String!
description: String!
fixedPointPrice: BigInt!
decimals: Int!
poolToken: PoolToken! @derivedFrom(field: "oracleInitialState")
}
type PoolTokenBalance @entity {
id: ID! # poolId + token address
poolId: Pool!
balance: BigDecimal!
}