forked from paco0x/bodhi-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 2
/
schema.graphql
163 lines (150 loc) · 3.61 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
# Bodhi
type Create @entity(immutable: true) {
id: Bytes!
assetId: BigInt! # uint256
sender: Bytes! # address
arTxId: String! # string
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type Remove @entity(immutable: true) {
id: Bytes!
assetId: BigInt! # uint256
sender: Bytes! # address
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type Trade @entity(immutable: true) {
id: Bytes!
tradeType: Int! # uint8
assetId: BigInt! # uint256
asset: Asset!
user: User! # address
tokenAmount: BigDecimal!
ethAmount: BigDecimal!
creatorFee: BigDecimal!
price: BigDecimal!
realSender: Bytes # address
proxy: Int! # uint8 (0: none, 1: space.create, 2: helper.safeBuy)
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type Transfer @entity(immutable: true) {
id: Bytes!
operator: Bytes! # address
from: Bytes! # address
to: Bytes! # address
assetId: BigInt! # uint256
amount: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type User @entity {
id: ID!
address: Bytes! # address
creatorProfit: BigDecimal!
tradingPnl: BigDecimal!
totalTrades: BigInt!
assets: [UserAsset!]! @derivedFrom(field: "user")
trades: [Trade!]! @derivedFrom(field: "user")
}
type UserAsset @entity {
id: ID! # `user.id.concat(asset.id)`
assetId: BigInt!
user: User!
asset: Asset!
amount: BigDecimal!
avgPrice: BigDecimal!
}
type Asset @entity {
id: ID!
assetId: BigInt!
arTxId: String
creator: User # who created the asset (in Bodhi)
createdAt: BigInt!
totalSupply: BigDecimal!
totalTrades: BigInt!
totalFees: BigDecimal!
totalVolume: BigDecimal!
totalHolders: BigInt!
removed: Boolean!
spacePost: SpacePost
realCreator: Bytes # who is real author of content (in apps)
holders: [UserAsset!]! @derivedFrom(field: "asset")
}
# Bodhi Trade Helper
type SafeBuy @entity(immutable: true) {
id: Bytes!
assetId: BigInt! # uint256
sender: Bytes!
tokenAmount: BigDecimal!
ethAmount: BigDecimal!
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type ProxyTrade @entity {
id: Bytes! # tx hash
realSender: Bytes! # address
proxy: Int! # uint8 (0 none, 1 space.create, 2 helper.safeBuy)
}
# Space
type SpaceCreateEvent @entity(immutable: true) {
id: Bytes!
spaceId: BigInt! # uint256
spaceAddress: Bytes! # address
assetId: BigInt! # uint256
creator: Bytes! # address
spaceName: String!
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type SpacePostCreateEvent @entity(immutable: true) {
id: Bytes!
space: Space!
spaceId: BigInt! # uint256, for query
parentId: BigInt! # uint256
assetId: BigInt! # uint256
creator: User!
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type SpacePostRemoveEvent @entity(immutable: true) {
id: Bytes!
space: Space!
spaceId: BigInt! # uint256, for query
assetId: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
}
type Space @entity {
id: ID! # space contract address
spaceId: BigInt! # can be used for sorting
spaceName: String!
spaceAddress: Bytes! # address
creator: User!
asset: Asset!
user: User! # space as user (for revenue)
totalPosts: BigInt!
}
type SpacePost @entity {
id: ID! # asset id
assetId: BigInt! # for sorting (latest)
spaceId: BigInt!
asset: Asset!
creator: User!
isRoot: Boolean!
parentId: BigInt!
parent: SpacePost
rootId: BigInt!
totalReplies: BigInt!
removedFromSpace: Boolean!
children: [SpacePost!]! @derivedFrom(field: "parent")
}