-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueries.py
246 lines (244 loc) · 4.53 KB
/
queries.py
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
"""
Dict of queries used to import data from the subgraph.
Tinlake subgraph schema can be found here:
https://github.com/centrifuge/tinlake-subgraph/blob/main/schema.graphql
Can likely automate this, but hardcoded queries avoid unexpected breaks if subgraph updated
"""
all_queries = {
"lastSyncedBlock": """
{
_meta {
block {
number
}
}
}
""",
"pools": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
pools(first: $first, skip: $skip, block:{number: $block})
{
id
totalDebt
totalBorrowsCount
totalBorrowsAggregatedAmount
totalRepaysCount
totalRepaysAggregatedAmount
weightedInterestRate
seniorDebt
seniorInterestRate
minJuniorRatio
maxJuniorRatio
currentJuniorRatio
maxReserve
seniorTokenPrice
juniorTokenPrice
juniorYield30Days
seniorYield30Days
juniorYield90Days
seniorYield90Days
assetValue
reserve
shortName
version
}
}
""",
"dailyPoolDatas": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
dailyPoolDatas(first: $first, skip: $skip)
{
id
day {
id
}
pool {
id
}
reserve
totalDebt
assetValue
seniorDebt
seniorTokenPrice
juniorTokenPrice
currentJuniorRatio
juniorYield30Days
seniorYield30Days
juniorYield90Days
seniorYield90Days
}
}
""",
"loans": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
pools
{
loans(first: $first, skip: $skip, block:{number: $block})
{
id
pool {
id
}
index
nftId
nftRegistry
owner
opened
closed
debt
interestRatePerSecond
ceiling
threshold
borrowsCount
borrowsAggregatedAmount
repaysCount
repaysAggregatedAmount
maturityDate
financingDate
riskGroup
}
}
}
""",
"erc20Transfers": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
erc20Transfers(first: $first, skip: $skip, block:{number: $block})
{
id
transaction
token {
id
}
from
to
amount
pool {
id
}
}
}
""",
"tokens": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
tokens(first: $first, skip: $skip, block:{number: $block})
{
id
symbol
price
}
}
""",
# TODO probably fix this as some stuff was changed here
"rewardDayTotals": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
rewardDayTotals(first: $first, skip: $skip, block:{number: $block})
{
id
aoRewardRate
dropRewardRate
tinRewardRate
toDateAORewardAggregateValue
toDateAggregateValue
toDateRewardAggregateValue
todayAOReward
todayReward
todayValue
}
}
""",
"aorewardBalances": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
aorewardBalances(first: $first, skip: $skip, block:{number: $block})
{
id
linkableRewards
totalRewards
}
}
""",
"rewardLinks": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
rewardLinks(first: $first, skip: $skip, block:{number: $block})
{
id
ethAddress
centAddress
rewardsAccumulated
}
}
""",
"poolInvestors": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
poolInvestors(first: $first, skip: $skip, block:{number: $block})
{
id
accounts
}
}
""",
# TODO: Add in logic to paginate through tokenBalance
# Buggy data causes query of 1000 to fail. Start with 100.
"tokenBalances": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
tokenBalances(first: $first, skip: $skip, block:{number: $block})
{
id
owner {
id
}
balanceAmount
balanceValue
totalAmount
totalValue
token {
id
}
pendingSupplyCurrency
supplyAmount
supplyValue
pendingRedeemToken
redeemAmount
}
}
""",
}
# Unused queries:
# dailyInvestorTokenBalances — dataset returned is huge, so not using for now
'''
"dailyInvestorTokenBalances": """
query ($block: Int!, $first: Int!, $skip: Int!)
{
dailyInvestorTokenBalances(first: $first, skip: $skip)
{
id
account {
id
}
day {
id
}
pool {
id
}
seniorTokenAmount
seniorTokenValue
seniorSupplyAmount
seniorPendingSupplyCurrency
juniorTokenAmount
juniorTokenValue
juniorSupplyAmount
juniorPendingSupplyCurrency
}
}
""",
'''