-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.graphql
More file actions
210 lines (190 loc) · 7.13 KB
/
schema.graphql
File metadata and controls
210 lines (190 loc) · 7.13 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
198
199
200
201
202
203
204
205
206
207
208
209
210
# GraphQL schema for all the data we collect from the Soccerverse
# smart contracts (excluding Democrit which has its own subgraph).
################################################################################
# Referral leaderboard
# A user that has referred others.
type Referrer @entity (immutable: false) {
# The ID is the Xaya account name as Bytes.
id: Bytes!
account: String!
referrals: [Referral!]! @derivedFrom (field: "referrer")
bonuses: [ReferrerBonus!]! @derivedFrom (field: "referrer")
totals: [ReferrerTotal!]! @derivedFrom (field: "referrer")
# The current (last) ReferrerTotal for this referrer.
currentTotal: ReferrerTotal!
}
# Each user that a referrer has referred is tracked here.
type Referral @entity (immutable: false) {
# The ID is the Xaya account name as Bytes.
id: Bytes!
account: String!
referrer: Referrer!
timestamp: BigInt!
}
# A referral bonus given.
type ReferrerBonus @entity (immutable: true) {
# The ID is constructed from txid and log index and just a unique ID.
id: Bytes!
referrer: Referrer!
referral: Referral!
timestamp: BigInt!
clubId: BigInt!
packsBought: BigInt!
usdSpent: BigInt!
bonusShares: BigInt!
}
# Running totals for referral stats. Whenever they change (such as new referral
# or referral overwritten, or bonus received), we add a new entry here with
# updated totals. From this, stats for some time range can be derived
# by subtracting the totals.
type ReferrerTotal @entity (immutable: true) {
# The ID is constructed from account name and a running counter for how many
# totals we already have for this account.
id: Bytes!
referrer: Referrer!
timestamp: BigInt!
# How many preceding totals there already are for this referrer.
index: BigInt!
referrals: BigInt!
bonusShares: BigInt!
# Total USD spent by referrals.
usdSpent: BigInt!
}
################################################################################
# Shop and pack-sale stuff
# A tier (individual sales contract) in the pack sale.
type SaleTier @entity (immutable: false) {
# The ID is the contract address (as Bytes).
id: Bytes!
name: String!
# True if the sale is active, i.e. not paused.
active: Boolean!
clubs: [SaleClub!]! @derivedFrom (field: "tier")
pausedClubs: [SaleClub!]! @derivedFrom (field: "pausedInTier")
pricingSteps: [PricingStep!]! @derivedFrom (field: "tier")
packsBought: [PacksBought!]! @derivedFrom (field: "tier")
}
# A pricing step for a sale tier.
type PricingStep @entity (immutable: false) {
# The ID is the tier ID / address and the step index added.
id: Bytes!
tier: SaleTier!
index: Int!
# Number of shares available at this price.
numShares: Int!
# Price of one share in this batch.
price: BigInt!
# Minimum number of shares minted before this is in effect.
fromTotal: Int!
# Maximum number of shares minted when this is still in effect.
toTotal: Int!
}
# A club in the sale.
type SaleClub @entity (immutable: false) {
# The ID is the club ID as integer converted to bytes.
id: Bytes!
clubId: Int!
# The SaleTier this is part of, if the club is actively sold.
tier: SaleTier
# The SaleTier this is part of as a paused club.
pausedInTier: SaleTier
# Total number of shares minted in the club so far.
minted: Int!
# The current tranche for the sale (or -1 if not for sale).
trancheIndex: Int!
# Number of influence remaining at the current tranche. Zero if
# there is none for sale.
remainingInTranche: Int!
primaryPack: Pack @derivedFrom (field: "primaryClub")
containedInPacks: [PackShareContent!]! @derivedFrom (field: "club")
packsBought: [PacksBought!]! @derivedFrom (field: "primaryClub")
}
# A pack that can be bought in the shop.
type Pack @entity (immutable: false) {
# The ID is the primary club ID as integer converted to bytes.
id: Bytes!
primaryClub: SaleClub!
# All club shares in the pack (including the primary one).
shares: [PackShareContent!]! @derivedFrom (field: "pack")
# Maximum number of packs that can be purchased.
maxPacks: Int!
# Cost of one pack in USDC/token base units.
cost: BigInt!
}
# Mapping table for all club shares included in packs.
type PackShareContent @entity (immutable: false) {
# The ID is the pack ID concat the club ID.
id: Bytes!
pack: Pack!
club: SaleClub!
num: Int!
}
# Each individual pack sale is recorded here.
type PacksBought @entity (immutable: true) {
# The ID is constructed from txid and log index and just a unique ID.
id: Bytes!
timestamp: BigInt!
# The buying address.
buyer: Bytes!
# The account name receiving the influence.
receiver: String!
primaryClub: SaleClub!
# The tier of this pack, at the time of buying (in case the club is
# changed later to be in another tier).
tier: SaleTier!
numPacks: Int!
usdSpent: BigInt!
}
################################################################################
# Price data for WCHI from Uniswap
# Data about a token that we track prices for.
type Token @entity (immutable: true) {
# The ID is the contract address.
id: Bytes!
# Number of decimals.
decimals: Int!
# The token symbol / tracker.
symbol: String!
}
# A pair of tokens that we track prices for.
type TokenPair @entity (immutable: true) {
# The ID is constructed by concat of tradedToken and baseToken.
id: Bytes!
# The token being traded (such as WCHI for the WCHI/WETH pair).
tradedToken: Token!
# The base token in which prices are denominated (such as WETH for WCHI/WETH).
baseToken: Token!
# The address of the Uniswap pair contract.
uniswapPair: Bytes!
# Price observations for this token pair.
prices: [PriceObservation!]! @derivedFrom (field: "pair")
}
# Average, periodic pricing data from Uniswap v2 for token pairs. These
# observations are recorded at fixed intervals, at virtual timestamps that
# represent these intervals exactly (such as UNIX timestamps for every whole
# hour or daily UTC midnights).
type PriceObservation @entity (immutable: true) {
# The ID is constructed by concat of the token pair ID and the virtual
# timestamp as 64-bit big-endian integer (so IDs sort chronologically).
id: Bytes!
# The token pair this is for.
pair: TokenPair!
# The virtual timestamp this observation is for.
virtualTimestamp: BigInt!
# The exact timestamp this observation is for. This might be slightly
# larger than the virtual timestamp, since the actual logic to take
# observations runs at certain block intervals, and uses the first block
# it runs on after a desired exact observation timestamp to get the values.
exactTimestamp: BigInt!
# The prices are encoded as fixed-point numbers with denominator 2**112,
# like Uniswap's UQ112x112 format. Unlike Uniswap, they take token decimals
# into account already, so the real number represented by the fixed-point
# value is the actual, human-readable token price in real token units
# (not the underlying integer base units).
# The cumulative price from the Uniswap pair as per the timestamp, encoded
# as fixed-point number.
cumulativePrice: BigInt!
# The moving average 24 hour price of the token as per the observation time.
# This will not be set for the initial 24 hours of observations.
average24h: BigInt
}