@dhedge/backend-flatcoin-core 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contracts/abi/FlatcoinErrors.json +436 -0
- package/dist/contracts/helpers.d.ts +2 -0
- package/dist/contracts/helpers.js +6 -0
- package/dist/contracts/index.d.ts +3 -0
- package/dist/contracts/index.js +7 -1
- package/dist/entity/apy.d.ts +12 -0
- package/dist/entity/apy.js +48 -0
- package/dist/entity/competitionBoardAccount.d.ts +14 -0
- package/dist/entity/competitionBoardAccount.js +80 -0
- package/dist/entity/flatcoin.price.parent.js +4 -3
- package/dist/entity/index.d.ts +2 -0
- package/dist/entity/index.js +2 -0
- package/dist/repository/apy-history.repository.d.ts +4 -1
- package/dist/repository/apy-history.repository.js +7 -2
- package/dist/repository/apy.repository.d.ts +4 -1
- package/dist/repository/apy.repository.js +7 -2
- package/dist/repository/flatcoin-pnl.repository.d.ts +12 -0
- package/dist/repository/flatcoin-pnl.repository.js +49 -0
- package/dist/repository/index.d.ts +1 -0
- package/dist/repository/index.js +1 -0
- package/dist/repository/price.repository.d.ts +6 -2
- package/dist/repository/price.repository.js +20 -6
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/shared-types.d.ts +24 -0
- package/dist/utils/shared-types.js +6 -0
- package/package.json +4 -2
- /package/dist/utils/{price.util.d.ts → util.d.ts} +0 -0
- /package/dist/utils/{price.util.js → util.js} +0 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [
|
|
4
|
+
{
|
|
5
|
+
"internalType": "uint256",
|
|
6
|
+
"name": "amount",
|
|
7
|
+
"type": "uint256"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"internalType": "uint256",
|
|
11
|
+
"name": "minAmount",
|
|
12
|
+
"type": "uint256"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"name": "AmountTooSmall",
|
|
16
|
+
"type": "error"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"inputs": [
|
|
20
|
+
{
|
|
21
|
+
"internalType": "uint256",
|
|
22
|
+
"name": "executableTime",
|
|
23
|
+
"type": "uint256"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"name": "ExecutableTimeNotReached",
|
|
27
|
+
"type": "error"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"inputs": [
|
|
31
|
+
{
|
|
32
|
+
"internalType": "uint256",
|
|
33
|
+
"name": "supplied",
|
|
34
|
+
"type": "uint256"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"internalType": "uint256",
|
|
38
|
+
"name": "accepted",
|
|
39
|
+
"type": "uint256"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"name": "HighSlippage",
|
|
43
|
+
"type": "error"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"inputs": [
|
|
47
|
+
{
|
|
48
|
+
"internalType": "uint256",
|
|
49
|
+
"name": "fee",
|
|
50
|
+
"type": "uint256"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"name": "InvalidFee",
|
|
54
|
+
"type": "error"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"inputs": [
|
|
58
|
+
{
|
|
59
|
+
"internalType": "string",
|
|
60
|
+
"name": "variableName",
|
|
61
|
+
"type": "string"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"name": "InvariantViolation",
|
|
65
|
+
"type": "error"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"inputs": [
|
|
69
|
+
{
|
|
70
|
+
"internalType": "uint256",
|
|
71
|
+
"name": "maxFillPrice",
|
|
72
|
+
"type": "uint256"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"internalType": "uint256",
|
|
76
|
+
"name": "leverageModifyFillPrice",
|
|
77
|
+
"type": "uint256"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"name": "MaxFillPriceTooLow",
|
|
81
|
+
"type": "error"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"inputs": [
|
|
85
|
+
{
|
|
86
|
+
"internalType": "uint256",
|
|
87
|
+
"name": "minFillPrice",
|
|
88
|
+
"type": "uint256"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"internalType": "uint256",
|
|
92
|
+
"name": "leverageModifyFillPrice",
|
|
93
|
+
"type": "uint256"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"name": "MinFillPriceTooHigh",
|
|
97
|
+
"type": "error"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"inputs": [
|
|
101
|
+
{
|
|
102
|
+
"internalType": "enum IDelayedOrder.OrderType",
|
|
103
|
+
"name": "orderType",
|
|
104
|
+
"type": "uint8"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"name": "NoPendingOrderAllowed",
|
|
108
|
+
"type": "error"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"inputs": [
|
|
112
|
+
{
|
|
113
|
+
"internalType": "address",
|
|
114
|
+
"name": "account",
|
|
115
|
+
"type": "address"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"internalType": "uint256",
|
|
119
|
+
"name": "totalBalance",
|
|
120
|
+
"type": "uint256"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"internalType": "uint256",
|
|
124
|
+
"name": "withdrawAmount",
|
|
125
|
+
"type": "uint256"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"name": "NotEnoughBalanceForWithdraw",
|
|
129
|
+
"type": "error"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"inputs": [
|
|
133
|
+
{
|
|
134
|
+
"internalType": "int256",
|
|
135
|
+
"name": "marginAmount",
|
|
136
|
+
"type": "int256"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"internalType": "uint256",
|
|
140
|
+
"name": "feeAmount",
|
|
141
|
+
"type": "uint256"
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"name": "NotEnoughMarginForFees",
|
|
145
|
+
"type": "error"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"inputs": [
|
|
149
|
+
{
|
|
150
|
+
"internalType": "uint256",
|
|
151
|
+
"name": "tokenId",
|
|
152
|
+
"type": "uint256"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"internalType": "address",
|
|
156
|
+
"name": "msgSender",
|
|
157
|
+
"type": "address"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"name": "NotTokenOwner",
|
|
161
|
+
"type": "error"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"inputs": [
|
|
165
|
+
{
|
|
166
|
+
"internalType": "address",
|
|
167
|
+
"name": "msgSender",
|
|
168
|
+
"type": "address"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"name": "OnlyOwner",
|
|
172
|
+
"type": "error"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"inputs": [],
|
|
176
|
+
"name": "OrderHasExpired",
|
|
177
|
+
"type": "error"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"inputs": [],
|
|
181
|
+
"name": "OrderHasNotExpired",
|
|
182
|
+
"type": "error"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"inputs": [
|
|
186
|
+
{
|
|
187
|
+
"internalType": "bytes32",
|
|
188
|
+
"name": "moduleKey",
|
|
189
|
+
"type": "bytes32"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"name": "Paused",
|
|
193
|
+
"type": "error"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"inputs": [
|
|
197
|
+
{
|
|
198
|
+
"internalType": "string",
|
|
199
|
+
"name": "variableName",
|
|
200
|
+
"type": "string"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
"name": "ZeroAddress",
|
|
204
|
+
"type": "error"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"inputs": [
|
|
208
|
+
{
|
|
209
|
+
"internalType": "string",
|
|
210
|
+
"name": "variableName",
|
|
211
|
+
"type": "string"
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"name": "ZeroValue",
|
|
215
|
+
"type": "error"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"inputs": [
|
|
219
|
+
{
|
|
220
|
+
"internalType": "uint256",
|
|
221
|
+
"name": "collateralCap",
|
|
222
|
+
"type": "uint256"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"name": "DepositCapReached",
|
|
226
|
+
"type": "error"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"inputs": [
|
|
230
|
+
{
|
|
231
|
+
"internalType": "uint256",
|
|
232
|
+
"name": "skewFractionMax",
|
|
233
|
+
"type": "uint256"
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
"name": "InvalidSkewFractionMax",
|
|
237
|
+
"type": "error"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"inputs": [],
|
|
241
|
+
"name": "MarginMismatchOnClose",
|
|
242
|
+
"type": "error"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"inputs": [
|
|
246
|
+
{
|
|
247
|
+
"internalType": "uint256",
|
|
248
|
+
"name": "skewFraction",
|
|
249
|
+
"type": "uint256"
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
"name": "MaxSkewReached",
|
|
253
|
+
"type": "error"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"inputs": [
|
|
257
|
+
{
|
|
258
|
+
"internalType": "address",
|
|
259
|
+
"name": "msgSender",
|
|
260
|
+
"type": "address"
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
"name": "OnlyAuthorizedModule",
|
|
264
|
+
"type": "error"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"inputs": [
|
|
268
|
+
{
|
|
269
|
+
"internalType": "uint256",
|
|
270
|
+
"name": "tokenId",
|
|
271
|
+
"type": "uint256"
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
"name": "TaskNotFound",
|
|
275
|
+
"type": "error"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"inputs": [],
|
|
279
|
+
"name": "AdjustNotAllowed",
|
|
280
|
+
"type": "error"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"inputs": [],
|
|
284
|
+
"name": "InvalidLeverageCriteria",
|
|
285
|
+
"type": "error"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"inputs": [
|
|
289
|
+
{
|
|
290
|
+
"internalType": "uint256",
|
|
291
|
+
"name": "leverageMax",
|
|
292
|
+
"type": "uint256"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"internalType": "uint256",
|
|
296
|
+
"name": "leverage",
|
|
297
|
+
"type": "uint256"
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
"name": "LeverageTooHigh",
|
|
301
|
+
"type": "error"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"inputs": [
|
|
305
|
+
{
|
|
306
|
+
"internalType": "uint256",
|
|
307
|
+
"name": "leverageMin",
|
|
308
|
+
"type": "uint256"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"internalType": "uint256",
|
|
312
|
+
"name": "leverage",
|
|
313
|
+
"type": "uint256"
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
"name": "LeverageTooLow",
|
|
317
|
+
"type": "error"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"inputs": [
|
|
321
|
+
{
|
|
322
|
+
"internalType": "uint256",
|
|
323
|
+
"name": "marginMin",
|
|
324
|
+
"type": "uint256"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"internalType": "uint256",
|
|
328
|
+
"name": "margin",
|
|
329
|
+
"type": "uint256"
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
"name": "MarginTooSmall",
|
|
333
|
+
"type": "error"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"inputs": [
|
|
337
|
+
{
|
|
338
|
+
"internalType": "int256",
|
|
339
|
+
"name": "settledMargin",
|
|
340
|
+
"type": "int256"
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
"name": "SettledMarginNotPositive",
|
|
344
|
+
"type": "error"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"inputs": [
|
|
348
|
+
{
|
|
349
|
+
"internalType": "uint256",
|
|
350
|
+
"name": "tokenId",
|
|
351
|
+
"type": "uint256"
|
|
352
|
+
}
|
|
353
|
+
],
|
|
354
|
+
"name": "CannotLiquidate",
|
|
355
|
+
"type": "error"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"inputs": [
|
|
359
|
+
{
|
|
360
|
+
"internalType": "uint256",
|
|
361
|
+
"name": "lower",
|
|
362
|
+
"type": "uint256"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"internalType": "uint256",
|
|
366
|
+
"name": "upper",
|
|
367
|
+
"type": "uint256"
|
|
368
|
+
}
|
|
369
|
+
],
|
|
370
|
+
"name": "InvalidBounds",
|
|
371
|
+
"type": "error"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"inputs": [],
|
|
375
|
+
"name": "ETHPriceExpired",
|
|
376
|
+
"type": "error"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"inputs": [],
|
|
380
|
+
"name": "ETHPriceInvalid",
|
|
381
|
+
"type": "error"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"inputs": [
|
|
385
|
+
{
|
|
386
|
+
"internalType": "enum FlatcoinErrors.PriceSource",
|
|
387
|
+
"name": "priceSource",
|
|
388
|
+
"type": "uint8"
|
|
389
|
+
}
|
|
390
|
+
],
|
|
391
|
+
"name": "PriceExpired",
|
|
392
|
+
"type": "error"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"inputs": [
|
|
396
|
+
{
|
|
397
|
+
"internalType": "enum FlatcoinErrors.PriceSource",
|
|
398
|
+
"name": "priceSource",
|
|
399
|
+
"type": "uint8"
|
|
400
|
+
}
|
|
401
|
+
],
|
|
402
|
+
"name": "PriceInvalid",
|
|
403
|
+
"type": "error"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"inputs": [],
|
|
407
|
+
"name": "OracleConfigInvalid",
|
|
408
|
+
"type": "error"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"inputs": [
|
|
412
|
+
{
|
|
413
|
+
"internalType": "uint256",
|
|
414
|
+
"name": "diffPercent",
|
|
415
|
+
"type": "uint256"
|
|
416
|
+
}
|
|
417
|
+
],
|
|
418
|
+
"name": "PriceMismatch",
|
|
419
|
+
"type": "error"
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"inputs": [],
|
|
423
|
+
"name": "RefundFailed",
|
|
424
|
+
"type": "error"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"inputs": [],
|
|
428
|
+
"name": "PriceImpactDuringFullWithdraw",
|
|
429
|
+
"type": "error"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"inputs": [],
|
|
433
|
+
"name": "PriceImpactDuringWithdraw",
|
|
434
|
+
"type": "error"
|
|
435
|
+
}
|
|
436
|
+
]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInterfaceInstance = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const createInterfaceInstance = (abi) => new ethers_1.utils.Interface(abi);
|
|
6
|
+
exports.createInterfaceInstance = createInterfaceInstance;
|
|
@@ -2,3 +2,6 @@ import * as FlatcoinV1 from '../contracts/abi/FlatcoinV1.json';
|
|
|
2
2
|
export { FlatcoinV1 };
|
|
3
3
|
import * as Viewer from '../contracts/abi/Viewer.json';
|
|
4
4
|
export { Viewer };
|
|
5
|
+
import * as FlatcoinErrors from '../contracts/abi/FlatcoinErrors.json';
|
|
6
|
+
export { FlatcoinErrors };
|
|
7
|
+
export * from './helpers';
|
package/dist/contracts/index.js
CHANGED
|
@@ -22,9 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Viewer = exports.FlatcoinV1 = void 0;
|
|
29
|
+
exports.FlatcoinErrors = exports.Viewer = exports.FlatcoinV1 = void 0;
|
|
27
30
|
const FlatcoinV1 = __importStar(require("../contracts/abi/FlatcoinV1.json"));
|
|
28
31
|
exports.FlatcoinV1 = FlatcoinV1;
|
|
29
32
|
const Viewer = __importStar(require("../contracts/abi/Viewer.json"));
|
|
30
33
|
exports.Viewer = Viewer;
|
|
34
|
+
const FlatcoinErrors = __importStar(require("../contracts/abi/FlatcoinErrors.json"));
|
|
35
|
+
exports.FlatcoinErrors = FlatcoinErrors;
|
|
36
|
+
__exportStar(require("./helpers"), exports);
|
package/dist/entity/apy.d.ts
CHANGED
|
@@ -3,4 +3,16 @@ export declare class Apy {
|
|
|
3
3
|
monthly: number;
|
|
4
4
|
weekly: number;
|
|
5
5
|
daily: number;
|
|
6
|
+
monthly1: number;
|
|
7
|
+
weekly1: number;
|
|
8
|
+
daily1: number;
|
|
9
|
+
monthly2: number;
|
|
10
|
+
weekly2: number;
|
|
11
|
+
daily2: number;
|
|
12
|
+
monthly3: number;
|
|
13
|
+
weekly3: number;
|
|
14
|
+
daily3: number;
|
|
15
|
+
monthly4: number;
|
|
16
|
+
weekly4: number;
|
|
17
|
+
daily4: number;
|
|
6
18
|
}
|
package/dist/entity/apy.js
CHANGED
|
@@ -35,6 +35,54 @@ __decorate([
|
|
|
35
35
|
(0, typeorm_1.Column)({ name: 'daily', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
36
36
|
__metadata("design:type", Number)
|
|
37
37
|
], Apy.prototype, "daily", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'monthly_1', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
40
|
+
__metadata("design:type", Number)
|
|
41
|
+
], Apy.prototype, "monthly1", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ name: 'weekly_1', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
44
|
+
__metadata("design:type", Number)
|
|
45
|
+
], Apy.prototype, "weekly1", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ name: 'daily_1', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
48
|
+
__metadata("design:type", Number)
|
|
49
|
+
], Apy.prototype, "daily1", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ name: 'monthly_2', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], Apy.prototype, "monthly2", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ name: 'weekly_2', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], Apy.prototype, "weekly2", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({ name: 'daily_2', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
60
|
+
__metadata("design:type", Number)
|
|
61
|
+
], Apy.prototype, "daily2", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typeorm_1.Column)({ name: 'monthly_3', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], Apy.prototype, "monthly3", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.Column)({ name: 'weekly_3', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
68
|
+
__metadata("design:type", Number)
|
|
69
|
+
], Apy.prototype, "weekly3", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typeorm_1.Column)({ name: 'daily_3', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
72
|
+
__metadata("design:type", Number)
|
|
73
|
+
], Apy.prototype, "daily3", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typeorm_1.Column)({ name: 'monthly_4', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
76
|
+
__metadata("design:type", Number)
|
|
77
|
+
], Apy.prototype, "monthly4", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({ name: 'weekly_4', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
80
|
+
__metadata("design:type", Number)
|
|
81
|
+
], Apy.prototype, "weekly4", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typeorm_1.Column)({ name: 'daily_4', type: 'decimal', precision: 30, scale: 2, transformer: utils_1.numericTransformer }),
|
|
84
|
+
__metadata("design:type", Number)
|
|
85
|
+
], Apy.prototype, "daily4", void 0);
|
|
38
86
|
exports.Apy = Apy = __decorate([
|
|
39
87
|
(0, graphql_1.ObjectType)(),
|
|
40
88
|
(0, typeorm_1.Entity)({ name: 'apy' })
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class CompetitionBoardAccount {
|
|
2
|
+
id: number;
|
|
3
|
+
account: string;
|
|
4
|
+
twitterAccount: string;
|
|
5
|
+
twitterProfileImage: string;
|
|
6
|
+
emailAddress: string;
|
|
7
|
+
wethBalanceFormatted: number;
|
|
8
|
+
flatcoinBalanceFormatted: number;
|
|
9
|
+
marginBalanceWethFormatted: number;
|
|
10
|
+
totalWethValueFormatted: number;
|
|
11
|
+
totalUsdValueFormatted: number;
|
|
12
|
+
performanceFormatted: number;
|
|
13
|
+
statusOfCalculation: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CompetitionBoardAccount = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
15
|
+
let CompetitionBoardAccount = class CompetitionBoardAccount {
|
|
16
|
+
};
|
|
17
|
+
exports.CompetitionBoardAccount = CompetitionBoardAccount;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id' }),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], CompetitionBoardAccount.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, graphql_1.Field)(() => String, { nullable: false }),
|
|
24
|
+
(0, typeorm_1.Column)({ name: 'account', unique: true, nullable: false }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], CompetitionBoardAccount.prototype, "account", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, graphql_1.Field)(() => String, { nullable: true }),
|
|
29
|
+
(0, typeorm_1.Column)({ name: 'twitter_account' }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], CompetitionBoardAccount.prototype, "twitterAccount", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, graphql_1.Field)(() => String, { nullable: true }),
|
|
34
|
+
(0, typeorm_1.Column)({ name: 'twitter_profile_image' }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], CompetitionBoardAccount.prototype, "twitterProfileImage", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, graphql_1.Field)(() => String, { nullable: true }),
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'email_address' }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], CompetitionBoardAccount.prototype, "emailAddress", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
44
|
+
(0, typeorm_1.Column)({ name: 'weth_balance_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], CompetitionBoardAccount.prototype, "wethBalanceFormatted", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
49
|
+
(0, typeorm_1.Column)({ name: 'flatcoin_balance_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
50
|
+
__metadata("design:type", Number)
|
|
51
|
+
], CompetitionBoardAccount.prototype, "flatcoinBalanceFormatted", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
54
|
+
(0, typeorm_1.Column)({ name: 'margin_balance_weth_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
55
|
+
__metadata("design:type", Number)
|
|
56
|
+
], CompetitionBoardAccount.prototype, "marginBalanceWethFormatted", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
59
|
+
(0, typeorm_1.Column)({ name: 'total_weth_value_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
60
|
+
__metadata("design:type", Number)
|
|
61
|
+
], CompetitionBoardAccount.prototype, "totalWethValueFormatted", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
64
|
+
(0, typeorm_1.Column)({ name: 'total_usd_value_formatted', type: 'decimal', precision: 20, scale: 6 }),
|
|
65
|
+
__metadata("design:type", Number)
|
|
66
|
+
], CompetitionBoardAccount.prototype, "totalUsdValueFormatted", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, graphql_1.Field)(() => graphql_1.Float, { nullable: true }),
|
|
69
|
+
(0, typeorm_1.Column)({ name: 'performance_formatted', type: 'decimal', precision: 20, scale: 2 }),
|
|
70
|
+
__metadata("design:type", Number)
|
|
71
|
+
], CompetitionBoardAccount.prototype, "performanceFormatted", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, graphql_1.Field)(() => String, { nullable: true }),
|
|
74
|
+
(0, typeorm_1.Column)({ name: 'status_of_calculation' }),
|
|
75
|
+
__metadata("design:type", String)
|
|
76
|
+
], CompetitionBoardAccount.prototype, "statusOfCalculation", void 0);
|
|
77
|
+
exports.CompetitionBoardAccount = CompetitionBoardAccount = __decorate([
|
|
78
|
+
(0, graphql_1.ObjectType)(),
|
|
79
|
+
(0, typeorm_1.Entity)({ name: 'account_competition_board' })
|
|
80
|
+
], CompetitionBoardAccount);
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.FlatcoinPriceParent = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const graphql_1 = require("@nestjs/graphql");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
15
16
|
let FlatcoinPriceParent = class FlatcoinPriceParent {
|
|
16
17
|
};
|
|
17
18
|
exports.FlatcoinPriceParent = FlatcoinPriceParent;
|
|
@@ -26,16 +27,16 @@ __decorate([
|
|
|
26
27
|
], FlatcoinPriceParent.prototype, "priceUsd", void 0);
|
|
27
28
|
__decorate([
|
|
28
29
|
(0, graphql_1.Field)(),
|
|
29
|
-
(0, typeorm_1.Column)({ name: 'price_usd_formatted', type: 'decimal', precision: 10, scale: 2 }),
|
|
30
|
+
(0, typeorm_1.Column)({ name: 'price_usd_formatted', type: 'decimal', precision: 10, scale: 2, transformer: utils_1.numericTransformer }),
|
|
30
31
|
__metadata("design:type", Number)
|
|
31
32
|
], FlatcoinPriceParent.prototype, "priceUsdFormatted", void 0);
|
|
32
33
|
__decorate([
|
|
33
34
|
(0, graphql_1.Field)(),
|
|
34
|
-
(0, typeorm_1.Column)({ name: 'timestamp', type: 'numeric', precision: 25 }),
|
|
35
|
+
(0, typeorm_1.Column)({ name: 'timestamp', type: 'numeric', precision: 25, transformer: utils_1.numericTransformer }),
|
|
35
36
|
__metadata("design:type", Number)
|
|
36
37
|
], FlatcoinPriceParent.prototype, "timestamp", void 0);
|
|
37
38
|
__decorate([
|
|
38
|
-
(0, typeorm_1.Column)({ name: 'block_number', type: 'numeric', precision: 25 }),
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'block_number', type: 'numeric', precision: 25, transformer: utils_1.numericTransformer }),
|
|
39
40
|
__metadata("design:type", Number)
|
|
40
41
|
], FlatcoinPriceParent.prototype, "blockNumber", void 0);
|
|
41
42
|
exports.FlatcoinPriceParent = FlatcoinPriceParent = __decorate([
|
package/dist/entity/index.d.ts
CHANGED
package/dist/entity/index.js
CHANGED
|
@@ -24,3 +24,5 @@ __exportStar(require("./flatcoin.price"), exports);
|
|
|
24
24
|
__exportStar(require("./apy-history"), exports);
|
|
25
25
|
__exportStar(require("./flatcoin-pnl"), exports);
|
|
26
26
|
__exportStar(require("./period-performance"), exports);
|
|
27
|
+
__exportStar(require("./flatcoin-pnl"), exports);
|
|
28
|
+
__exportStar(require("./competitionBoardAccount"), exports);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
1
2
|
import { Repository } from 'typeorm';
|
|
2
3
|
import { ApyHistory } from '../entity';
|
|
3
4
|
export declare class ApyHistoryRepository {
|
|
4
5
|
private readonly repository;
|
|
5
|
-
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(repository: Repository<ApyHistory>, logger: Logger);
|
|
6
8
|
getAllFromTimestamp(fromTimestamp: number): Promise<ApyHistory[]>;
|
|
9
|
+
save(apyHistory: ApyHistory): void;
|
|
7
10
|
}
|
|
@@ -18,8 +18,9 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
18
18
|
const typeorm_2 = require("typeorm");
|
|
19
19
|
const entity_1 = require("../entity");
|
|
20
20
|
let ApyHistoryRepository = class ApyHistoryRepository {
|
|
21
|
-
constructor(repository) {
|
|
21
|
+
constructor(repository, logger) {
|
|
22
22
|
this.repository = repository;
|
|
23
|
+
this.logger = logger;
|
|
23
24
|
}
|
|
24
25
|
async getAllFromTimestamp(fromTimestamp) {
|
|
25
26
|
return await this.repository
|
|
@@ -29,10 +30,14 @@ let ApyHistoryRepository = class ApyHistoryRepository {
|
|
|
29
30
|
.setParameter('fromTimestamp', fromTimestamp)
|
|
30
31
|
.getMany();
|
|
31
32
|
}
|
|
33
|
+
save(apyHistory) {
|
|
34
|
+
this.repository.save(apyHistory).catch((error) => this.logger.error('Error while saving apy history', error));
|
|
35
|
+
}
|
|
32
36
|
};
|
|
33
37
|
exports.ApyHistoryRepository = ApyHistoryRepository;
|
|
34
38
|
exports.ApyHistoryRepository = ApyHistoryRepository = __decorate([
|
|
35
39
|
(0, common_1.Injectable)(),
|
|
36
40
|
__param(0, (0, typeorm_1.InjectRepository)(entity_1.ApyHistory)),
|
|
37
|
-
__metadata("design:paramtypes", [typeorm_2.Repository
|
|
41
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
42
|
+
common_1.Logger])
|
|
38
43
|
], ApyHistoryRepository);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
1
2
|
import { Repository } from 'typeorm';
|
|
2
3
|
import { Apy } from '../entity';
|
|
3
4
|
export declare class ApyRepository {
|
|
4
5
|
private repository;
|
|
5
|
-
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(repository: Repository<Apy>, logger: Logger);
|
|
6
8
|
getApy(): Promise<Apy | null>;
|
|
9
|
+
save(apy: Apy): void;
|
|
7
10
|
}
|
|
@@ -18,16 +18,21 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
18
18
|
const typeorm_2 = require("typeorm");
|
|
19
19
|
const entity_1 = require("../entity");
|
|
20
20
|
let ApyRepository = class ApyRepository {
|
|
21
|
-
constructor(repository) {
|
|
21
|
+
constructor(repository, logger) {
|
|
22
22
|
this.repository = repository;
|
|
23
|
+
this.logger = logger;
|
|
23
24
|
}
|
|
24
25
|
async getApy() {
|
|
25
26
|
return this.repository.createQueryBuilder().getOne();
|
|
26
27
|
}
|
|
28
|
+
save(apy) {
|
|
29
|
+
this.repository.save(apy).catch((error) => this.logger.error('Error while saving apy', error));
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
exports.ApyRepository = ApyRepository;
|
|
29
33
|
exports.ApyRepository = ApyRepository = __decorate([
|
|
30
34
|
(0, common_1.Injectable)(),
|
|
31
35
|
__param(0, (0, typeorm_1.InjectRepository)(entity_1.Apy)),
|
|
32
|
-
__metadata("design:paramtypes", [typeorm_2.Repository
|
|
36
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
37
|
+
common_1.Logger])
|
|
33
38
|
], ApyRepository);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { FlatcoinPnl } from '../entity/flatcoin-pnl';
|
|
3
|
+
import { Repository } from 'typeorm';
|
|
4
|
+
export declare class FlatcoinPnlRepository {
|
|
5
|
+
private readonly repository;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(repository: Repository<FlatcoinPnl>, logger: Logger);
|
|
8
|
+
getAll(): Promise<FlatcoinPnl[]>;
|
|
9
|
+
save(flatcoinPnls: FlatcoinPnl[]): void;
|
|
10
|
+
getLastUpdatedAt(): Promise<FlatcoinPnl | null>;
|
|
11
|
+
findByAccount(account: string): Promise<FlatcoinPnl | null>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FlatcoinPnlRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const flatcoin_pnl_1 = require("../entity/flatcoin-pnl");
|
|
19
|
+
const typeorm_2 = require("typeorm");
|
|
20
|
+
let FlatcoinPnlRepository = class FlatcoinPnlRepository {
|
|
21
|
+
constructor(repository, logger) {
|
|
22
|
+
this.repository = repository;
|
|
23
|
+
this.logger = logger;
|
|
24
|
+
}
|
|
25
|
+
async getAll() {
|
|
26
|
+
return this.repository.createQueryBuilder().getMany();
|
|
27
|
+
}
|
|
28
|
+
save(flatcoinPnls) {
|
|
29
|
+
this.repository.save(flatcoinPnls).catch((error) => this.logger.error('Error while saving flatcoin pnl', error));
|
|
30
|
+
}
|
|
31
|
+
async getLastUpdatedAt() {
|
|
32
|
+
return await this.repository.createQueryBuilder('pnl').orderBy('pnl.block_updated_at', 'DESC').take(1).getOne();
|
|
33
|
+
}
|
|
34
|
+
async findByAccount(account) {
|
|
35
|
+
return await this.repository
|
|
36
|
+
.createQueryBuilder('pnl')
|
|
37
|
+
.where('pnl.account = :account')
|
|
38
|
+
.setParameter('account', account)
|
|
39
|
+
.take(1)
|
|
40
|
+
.getOne();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.FlatcoinPnlRepository = FlatcoinPnlRepository;
|
|
44
|
+
exports.FlatcoinPnlRepository = FlatcoinPnlRepository = __decorate([
|
|
45
|
+
(0, common_1.Injectable)(),
|
|
46
|
+
__param(0, (0, typeorm_1.InjectRepository)(flatcoin_pnl_1.FlatcoinPnl)),
|
|
47
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
48
|
+
common_1.Logger])
|
|
49
|
+
], FlatcoinPnlRepository);
|
package/dist/repository/index.js
CHANGED
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./apy-history.repository"), exports);
|
|
18
18
|
__exportStar(require("./apy.repository"), exports);
|
|
19
19
|
__exportStar(require("./price.repository"), exports);
|
|
20
|
+
__exportStar(require("./flatcoin-pnl.repository"), exports);
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Repository } from 'typeorm';
|
|
2
|
-
import { FlatcoinPriceOneDay, FlatcoinPriceOneMonth, FlatcoinPriceOneWeek, FlatcoinPriceOneYear, FlatcoinPriceParent } from '../entity';
|
|
2
|
+
import { FlatcoinPrice, FlatcoinPriceOneDay, FlatcoinPriceOneMonth, FlatcoinPriceOneWeek, FlatcoinPriceOneYear, FlatcoinPriceParent } from '../entity';
|
|
3
3
|
export declare class PriceRepository {
|
|
4
4
|
private flatcoinPriceOneDayRepository;
|
|
5
5
|
private flatcoinPriceOneWeekRepository;
|
|
6
6
|
private flatcoinPriceOneMonthRepository;
|
|
7
7
|
private flatcoinPriceOneYearRepository;
|
|
8
|
-
|
|
8
|
+
private readonly repository;
|
|
9
|
+
constructor(flatcoinPriceOneDayRepository: Repository<FlatcoinPriceOneDay>, flatcoinPriceOneWeekRepository: Repository<FlatcoinPriceOneWeek>, flatcoinPriceOneMonthRepository: Repository<FlatcoinPriceOneMonth>, flatcoinPriceOneYearRepository: Repository<FlatcoinPriceOneYear>, repository: Repository<FlatcoinPrice>);
|
|
9
10
|
findAllByPeriod(period: string): Promise<FlatcoinPriceParent[]>;
|
|
11
|
+
findLast(): Promise<FlatcoinPrice | null>;
|
|
12
|
+
findFirstByTimestamp(fromTimestamp: number): Promise<FlatcoinPrice | null>;
|
|
13
|
+
findFirst(): Promise<FlatcoinPrice | null>;
|
|
10
14
|
private getRepository;
|
|
11
15
|
}
|
|
@@ -19,18 +19,30 @@ const typeorm_2 = require("typeorm");
|
|
|
19
19
|
const entity_1 = require("../entity");
|
|
20
20
|
const constants_1 = require("../constants");
|
|
21
21
|
let PriceRepository = class PriceRepository {
|
|
22
|
-
constructor(flatcoinPriceOneDayRepository, flatcoinPriceOneWeekRepository, flatcoinPriceOneMonthRepository, flatcoinPriceOneYearRepository) {
|
|
22
|
+
constructor(flatcoinPriceOneDayRepository, flatcoinPriceOneWeekRepository, flatcoinPriceOneMonthRepository, flatcoinPriceOneYearRepository, repository) {
|
|
23
23
|
this.flatcoinPriceOneDayRepository = flatcoinPriceOneDayRepository;
|
|
24
24
|
this.flatcoinPriceOneWeekRepository = flatcoinPriceOneWeekRepository;
|
|
25
25
|
this.flatcoinPriceOneMonthRepository = flatcoinPriceOneMonthRepository;
|
|
26
26
|
this.flatcoinPriceOneYearRepository = flatcoinPriceOneYearRepository;
|
|
27
|
+
this.repository = repository;
|
|
27
28
|
}
|
|
28
29
|
async findAllByPeriod(period) {
|
|
29
|
-
return this.getRepository(period).
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
return this.getRepository(period).createQueryBuilder('price').orderBy('price.timestamp', 'ASC').getMany();
|
|
31
|
+
}
|
|
32
|
+
async findLast() {
|
|
33
|
+
return this.repository.createQueryBuilder('price').orderBy('price.timestamp', 'DESC').take(1).getOne();
|
|
34
|
+
}
|
|
35
|
+
async findFirstByTimestamp(fromTimestamp) {
|
|
36
|
+
return await this.repository
|
|
37
|
+
.createQueryBuilder('price')
|
|
38
|
+
.where('timestamp > :fromTimestamp')
|
|
39
|
+
.orderBy('price.timestamp', 'ASC')
|
|
40
|
+
.setParameter('fromTimestamp', fromTimestamp)
|
|
41
|
+
.take(1)
|
|
42
|
+
.getOne();
|
|
43
|
+
}
|
|
44
|
+
async findFirst() {
|
|
45
|
+
return await this.repository.createQueryBuilder('price').orderBy('price.timestamp', 'ASC').take(1).getOne();
|
|
34
46
|
}
|
|
35
47
|
getRepository(period) {
|
|
36
48
|
switch (period) {
|
|
@@ -54,7 +66,9 @@ exports.PriceRepository = PriceRepository = __decorate([
|
|
|
54
66
|
__param(1, (0, typeorm_1.InjectRepository)(entity_1.FlatcoinPriceOneWeek)),
|
|
55
67
|
__param(2, (0, typeorm_1.InjectRepository)(entity_1.FlatcoinPriceOneMonth)),
|
|
56
68
|
__param(3, (0, typeorm_1.InjectRepository)(entity_1.FlatcoinPriceOneYear)),
|
|
69
|
+
__param(4, (0, typeorm_1.InjectRepository)(entity_1.FlatcoinPrice)),
|
|
57
70
|
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
71
|
+
typeorm_2.Repository,
|
|
58
72
|
typeorm_2.Repository,
|
|
59
73
|
typeorm_2.Repository,
|
|
60
74
|
typeorm_2.Repository])
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./column.numeric.transformer"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./util"), exports);
|
|
19
|
+
__exportStar(require("./shared-types"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
export interface DepositEvent {
|
|
3
|
+
blockNumber: string;
|
|
4
|
+
depositor: string;
|
|
5
|
+
depositAmount: string;
|
|
6
|
+
mintedAmount: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Deposits {
|
|
9
|
+
deposits: DepositEvent[];
|
|
10
|
+
}
|
|
11
|
+
export interface WithdrawEvent {
|
|
12
|
+
blockNumber: string;
|
|
13
|
+
withdrawer: string;
|
|
14
|
+
withdrawAmount: string;
|
|
15
|
+
burnedAmount: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Withdraws {
|
|
18
|
+
withdraws: WithdrawEvent[];
|
|
19
|
+
}
|
|
20
|
+
export declare class DepositWithdrawAction {
|
|
21
|
+
isDeposit: boolean;
|
|
22
|
+
blockNumber: number;
|
|
23
|
+
unitAmount: BigNumber;
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhedge/backend-flatcoin-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Backend Flatcoin Core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"@nestjs/graphql": "^12.0.9",
|
|
21
21
|
"@nestjs/typeorm": "^9.0.0",
|
|
22
22
|
"typeorm": "^0.3.17",
|
|
23
|
-
"ethers": "5.7.2"
|
|
23
|
+
"ethers": "5.7.2",
|
|
24
|
+
"nest-winston": "1.9.3",
|
|
25
|
+
"winston": "3.10.0"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@swc/core": "^1.3.90",
|
|
File without changes
|
|
File without changes
|