@dhedge/backend-flatcoin-core 0.2.10 → 0.2.13

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.
@@ -18,6 +18,38 @@ exports.FlatcoinErrors = [
18
18
  name: 'AmountTooSmall',
19
19
  type: 'error',
20
20
  },
21
+ {
22
+ inputs: [
23
+ {
24
+ internalType: 'uint256',
25
+ name: 'tokenId',
26
+ type: 'uint256',
27
+ },
28
+ ],
29
+ name: 'CannotLiquidate',
30
+ type: 'error',
31
+ },
32
+ {
33
+ inputs: [
34
+ {
35
+ internalType: 'uint256',
36
+ name: 'collateralCap',
37
+ type: 'uint256',
38
+ },
39
+ ],
40
+ name: 'DepositCapReached',
41
+ type: 'error',
42
+ },
43
+ {
44
+ inputs: [],
45
+ name: 'ETHPriceInvalid',
46
+ type: 'error',
47
+ },
48
+ {
49
+ inputs: [],
50
+ name: 'ETHPriceStale',
51
+ type: 'error',
52
+ },
21
53
  {
22
54
  inputs: [
23
55
  {
@@ -45,224 +77,191 @@ exports.FlatcoinErrors = [
45
77
  name: 'HighSlippage',
46
78
  type: 'error',
47
79
  },
80
+ {
81
+ inputs: [],
82
+ name: 'InsufficientGlobalMargin',
83
+ type: 'error',
84
+ },
48
85
  {
49
86
  inputs: [
50
87
  {
51
88
  internalType: 'uint256',
52
- name: 'fee',
89
+ name: 'lower',
90
+ type: 'uint256',
91
+ },
92
+ {
93
+ internalType: 'uint256',
94
+ name: 'upper',
53
95
  type: 'uint256',
54
96
  },
55
97
  ],
56
- name: 'InvalidFee',
98
+ name: 'InvalidBounds',
57
99
  type: 'error',
58
100
  },
59
101
  {
60
102
  inputs: [
61
103
  {
62
- internalType: 'string',
63
- name: 'variableName',
64
- type: 'string',
104
+ internalType: 'uint256',
105
+ name: 'fee',
106
+ type: 'uint256',
65
107
  },
66
108
  ],
67
- name: 'InvariantViolation',
109
+ name: 'InvalidFee',
110
+ type: 'error',
111
+ },
112
+ {
113
+ inputs: [],
114
+ name: 'InvalidLeverageCriteria',
68
115
  type: 'error',
69
116
  },
70
117
  {
71
118
  inputs: [
72
119
  {
73
120
  internalType: 'uint256',
74
- name: 'maxFillPrice',
121
+ name: 'maxVelocitySkew',
75
122
  type: 'uint256',
76
123
  },
124
+ ],
125
+ name: 'InvalidMaxVelocitySkew',
126
+ type: 'error',
127
+ },
128
+ {
129
+ inputs: [
77
130
  {
78
131
  internalType: 'uint256',
79
- name: 'leverageModifyFillPrice',
132
+ name: 'skewFractionMax',
80
133
  type: 'uint256',
81
134
  },
82
135
  ],
83
- name: 'MaxFillPriceTooLow',
136
+ name: 'InvalidSkewFractionMax',
84
137
  type: 'error',
85
138
  },
86
139
  {
87
140
  inputs: [
88
141
  {
89
142
  internalType: 'uint256',
90
- name: 'minFillPrice',
143
+ name: 'priceLowerThreshold',
91
144
  type: 'uint256',
92
145
  },
93
146
  {
94
147
  internalType: 'uint256',
95
- name: 'leverageModifyFillPrice',
148
+ name: 'priceUpperThreshold',
96
149
  type: 'uint256',
97
150
  },
98
151
  ],
99
- name: 'MinFillPriceTooHigh',
152
+ name: 'InvalidThresholds',
100
153
  type: 'error',
101
154
  },
102
155
  {
103
156
  inputs: [
104
157
  {
105
- internalType: 'enum IDelayedOrder.OrderType',
106
- name: 'orderType',
107
- type: 'uint8',
158
+ internalType: 'string',
159
+ name: 'variableName',
160
+ type: 'string',
108
161
  },
109
162
  ],
110
- name: 'NoPendingOrderAllowed',
163
+ name: 'InvariantViolation',
111
164
  type: 'error',
112
165
  },
113
166
  {
114
167
  inputs: [
115
- {
116
- internalType: 'address',
117
- name: 'account',
118
- type: 'address',
119
- },
120
168
  {
121
169
  internalType: 'uint256',
122
- name: 'totalBalance',
170
+ name: 'leverageMax',
123
171
  type: 'uint256',
124
172
  },
125
173
  {
126
174
  internalType: 'uint256',
127
- name: 'withdrawAmount',
175
+ name: 'leverage',
128
176
  type: 'uint256',
129
177
  },
130
178
  ],
131
- name: 'NotEnoughBalanceForWithdraw',
179
+ name: 'LeverageTooHigh',
132
180
  type: 'error',
133
181
  },
134
182
  {
135
183
  inputs: [
136
184
  {
137
185
  internalType: 'uint256',
138
- name: 'withdrawAmount',
186
+ name: 'leverageMin',
139
187
  type: 'uint256',
140
188
  },
141
189
  {
142
190
  internalType: 'uint256',
143
- name: 'keeperFee',
191
+ name: 'leverage',
144
192
  type: 'uint256',
145
193
  },
146
194
  ],
147
- name: 'WithdrawalTooSmall',
195
+ name: 'LeverageTooLow',
148
196
  type: 'error',
149
197
  },
150
198
  {
151
199
  inputs: [
152
- {
153
- internalType: 'int256',
154
- name: 'marginAmount',
155
- type: 'int256',
156
- },
157
200
  {
158
201
  internalType: 'uint256',
159
- name: 'feeAmount',
202
+ name: 'tokenId',
160
203
  type: 'uint256',
161
204
  },
162
205
  ],
163
- name: 'NotEnoughMarginForFees',
206
+ name: 'LimitOrderInvalid',
164
207
  type: 'error',
165
208
  },
166
209
  {
167
210
  inputs: [
168
211
  {
169
212
  internalType: 'uint256',
170
- name: 'tokenId',
213
+ name: 'price',
171
214
  type: 'uint256',
172
215
  },
173
216
  {
174
- internalType: 'address',
175
- name: 'msgSender',
176
- type: 'address',
217
+ internalType: 'uint256',
218
+ name: 'priceLowerThreshold',
219
+ type: 'uint256',
177
220
  },
178
- ],
179
- name: 'NotTokenOwner',
180
- type: 'error',
181
- },
182
- {
183
- inputs: [
184
221
  {
185
- internalType: 'address',
186
- name: 'msgSender',
187
- type: 'address',
222
+ internalType: 'uint256',
223
+ name: 'priceUpperThreshold',
224
+ type: 'uint256',
188
225
  },
189
226
  ],
190
- name: 'OnlyOwner',
191
- type: 'error',
192
- },
193
- {
194
- inputs: [],
195
- name: 'OrderHasExpired',
196
- type: 'error',
197
- },
198
- {
199
- inputs: [],
200
- name: 'InsufficientGlobalMargin',
227
+ name: 'LimitOrderPriceNotInRange',
201
228
  type: 'error',
202
229
  },
203
230
  {
204
231
  inputs: [],
205
- name: 'OrderHasNotExpired',
206
- type: 'error',
207
- },
208
- {
209
- inputs: [
210
- {
211
- internalType: 'bytes32',
212
- name: 'moduleKey',
213
- type: 'bytes32',
214
- },
215
- ],
216
- name: 'Paused',
232
+ name: 'MarginMismatchOnClose',
217
233
  type: 'error',
218
234
  },
219
235
  {
220
236
  inputs: [
221
237
  {
222
- internalType: 'string',
223
- name: 'variableName',
224
- type: 'string',
238
+ internalType: 'uint256',
239
+ name: 'marginMin',
240
+ type: 'uint256',
225
241
  },
226
- ],
227
- name: 'ZeroAddress',
228
- type: 'error',
229
- },
230
- {
231
- inputs: [
232
242
  {
233
- internalType: 'string',
234
- name: 'variableName',
235
- type: 'string',
243
+ internalType: 'uint256',
244
+ name: 'margin',
245
+ type: 'uint256',
236
246
  },
237
247
  ],
238
- name: 'ZeroValue',
248
+ name: 'MarginTooSmall',
239
249
  type: 'error',
240
250
  },
241
251
  {
242
252
  inputs: [
243
253
  {
244
254
  internalType: 'uint256',
245
- name: 'collateralCap',
255
+ name: 'maxFillPrice',
246
256
  type: 'uint256',
247
257
  },
248
- ],
249
- name: 'DepositCapReached',
250
- type: 'error',
251
- },
252
- {
253
- inputs: [
254
258
  {
255
259
  internalType: 'uint256',
256
- name: 'skewFractionMax',
260
+ name: 'currentPrice',
257
261
  type: 'uint256',
258
262
  },
259
263
  ],
260
- name: 'InvalidSkewFractionMax',
261
- type: 'error',
262
- },
263
- {
264
- inputs: [],
265
- name: 'MarginMismatchOnClose',
264
+ name: 'MaxFillPriceTooLow',
266
265
  type: 'error',
267
266
  },
268
267
  {
@@ -279,135 +278,134 @@ exports.FlatcoinErrors = [
279
278
  {
280
279
  inputs: [
281
280
  {
282
- internalType: 'uint256',
283
- name: 'maxVelocitySkew',
284
- type: 'uint256',
281
+ internalType: 'string',
282
+ name: 'variableName',
283
+ type: 'string',
285
284
  },
286
285
  ],
287
- name: 'InvalidMaxVelocitySkew',
286
+ name: 'MaxVarianceExceeded',
288
287
  type: 'error',
289
288
  },
290
289
  {
291
290
  inputs: [
292
291
  {
293
- internalType: 'address',
294
- name: 'msgSender',
295
- type: 'address',
292
+ internalType: 'uint256',
293
+ name: 'minFillPrice',
294
+ type: 'uint256',
296
295
  },
297
- ],
298
- name: 'OnlyAuthorizedModule',
299
- type: 'error',
300
- },
301
- {
302
- inputs: [
303
296
  {
304
297
  internalType: 'uint256',
305
- name: 'tokenId',
298
+ name: 'currentPrice',
306
299
  type: 'uint256',
307
300
  },
308
301
  ],
309
- name: 'TaskNotFound',
310
- type: 'error',
311
- },
312
- {
313
- inputs: [],
314
- name: 'AdjustNotAllowed',
302
+ name: 'MinFillPriceTooHigh',
315
303
  type: 'error',
316
304
  },
317
305
  {
318
306
  inputs: [],
319
- name: 'InvalidLeverageCriteria',
307
+ name: 'ModuleKeyEmpty',
320
308
  type: 'error',
321
309
  },
322
310
  {
323
311
  inputs: [
312
+ {
313
+ internalType: 'address',
314
+ name: 'account',
315
+ type: 'address',
316
+ },
324
317
  {
325
318
  internalType: 'uint256',
326
- name: 'leverageMax',
319
+ name: 'totalBalance',
327
320
  type: 'uint256',
328
321
  },
329
322
  {
330
323
  internalType: 'uint256',
331
- name: 'leverage',
324
+ name: 'withdrawAmount',
332
325
  type: 'uint256',
333
326
  },
334
327
  ],
335
- name: 'LeverageTooHigh',
328
+ name: 'NotEnoughBalanceForWithdraw',
336
329
  type: 'error',
337
330
  },
338
331
  {
339
332
  inputs: [
340
333
  {
341
- internalType: 'uint256',
342
- name: 'leverageMin',
343
- type: 'uint256',
334
+ internalType: 'int256',
335
+ name: 'marginAmount',
336
+ type: 'int256',
344
337
  },
345
338
  {
346
339
  internalType: 'uint256',
347
- name: 'leverage',
340
+ name: 'feeAmount',
348
341
  type: 'uint256',
349
342
  },
350
343
  ],
351
- name: 'LeverageTooLow',
344
+ name: 'NotEnoughMarginForFees',
352
345
  type: 'error',
353
346
  },
354
347
  {
355
348
  inputs: [
356
349
  {
357
350
  internalType: 'uint256',
358
- name: 'marginMin',
351
+ name: 'tokenId',
359
352
  type: 'uint256',
360
353
  },
361
354
  {
362
- internalType: 'uint256',
363
- name: 'margin',
364
- type: 'uint256',
355
+ internalType: 'address',
356
+ name: 'msgSender',
357
+ type: 'address',
365
358
  },
366
359
  ],
367
- name: 'MarginTooSmall',
360
+ name: 'NotTokenOwner',
368
361
  type: 'error',
369
362
  },
370
363
  {
371
364
  inputs: [
372
365
  {
373
- internalType: 'int256',
374
- name: 'settledMargin',
375
- type: 'int256',
366
+ internalType: 'address',
367
+ name: 'msgSender',
368
+ type: 'address',
376
369
  },
377
370
  ],
378
- name: 'SettledMarginNotPositive',
371
+ name: 'OnlyAuthorizedModule',
379
372
  type: 'error',
380
373
  },
381
374
  {
382
375
  inputs: [
383
376
  {
384
- internalType: 'uint256',
385
- name: 'tokenId',
386
- type: 'uint256',
377
+ internalType: 'address',
378
+ name: 'msgSender',
379
+ type: 'address',
387
380
  },
388
381
  ],
389
- name: 'CannotLiquidate',
382
+ name: 'OnlyOwner',
390
383
  type: 'error',
391
384
  },
392
385
  {
393
- inputs: [
394
- {
395
- internalType: 'uint256',
396
- name: 'lower',
397
- type: 'uint256',
398
- },
399
- {
400
- internalType: 'uint256',
401
- name: 'upper',
402
- type: 'uint256',
403
- },
404
- ],
405
- name: 'InvalidBounds',
386
+ inputs: [],
387
+ name: 'OracleConfigInvalid',
406
388
  type: 'error',
407
389
  },
408
390
  {
409
391
  inputs: [],
410
- name: 'ETHPriceExpired',
392
+ name: 'OrderHasExpired',
393
+ type: 'error',
394
+ },
395
+ {
396
+ inputs: [],
397
+ name: 'OrderHasNotExpired',
398
+ type: 'error',
399
+ },
400
+ {
401
+ inputs: [
402
+ {
403
+ internalType: 'bytes32',
404
+ name: 'moduleKey',
405
+ type: 'bytes32',
406
+ },
407
+ ],
408
+ name: 'Paused',
411
409
  type: 'error',
412
410
  },
413
411
  {
@@ -417,12 +415,12 @@ exports.FlatcoinErrors = [
417
415
  },
418
416
  {
419
417
  inputs: [],
420
- name: 'ETHPriceInvalid',
418
+ name: 'PriceImpactDuringFullWithdraw',
421
419
  type: 'error',
422
420
  },
423
421
  {
424
422
  inputs: [],
425
- name: 'ETHPriceStale',
423
+ name: 'PriceImpactDuringWithdraw',
426
424
  type: 'error',
427
425
  },
428
426
  {
@@ -439,12 +437,12 @@ exports.FlatcoinErrors = [
439
437
  {
440
438
  inputs: [
441
439
  {
442
- internalType: 'enum FlatcoinErrors.PriceSource',
443
- name: 'priceSource',
444
- type: 'uint8',
440
+ internalType: 'uint256',
441
+ name: 'diffPercent',
442
+ type: 'uint256',
445
443
  },
446
444
  ],
447
- name: 'PriceStale',
445
+ name: 'PriceMismatch',
448
446
  type: 'error',
449
447
  },
450
448
  {
@@ -455,102 +453,61 @@ exports.FlatcoinErrors = [
455
453
  type: 'uint8',
456
454
  },
457
455
  ],
458
- name: 'PriceExpired',
456
+ name: 'PriceStale',
459
457
  type: 'error',
460
458
  },
461
459
  {
462
460
  inputs: [],
463
- name: 'OracleConfigInvalid',
461
+ name: 'RefundFailed',
464
462
  type: 'error',
465
463
  },
466
464
  {
467
465
  inputs: [
468
466
  {
469
- internalType: 'uint256',
470
- name: 'diffPercent',
471
- type: 'uint256',
467
+ internalType: 'string',
468
+ name: 'variableName',
469
+ type: 'string',
472
470
  },
473
471
  ],
474
- name: 'PriceMismatch',
475
- type: 'error',
476
- },
477
- {
478
- inputs: [],
479
- name: 'RefundFailed',
480
- type: 'error',
481
- },
482
- {
483
- inputs: [],
484
- name: 'PriceImpactDuringFullWithdraw',
485
- type: 'error',
486
- },
487
- {
488
- inputs: [],
489
- name: 'PriceImpactDuringWithdraw',
472
+ name: 'ValueNotPositive',
490
473
  type: 'error',
491
474
  },
492
475
  {
493
476
  inputs: [
494
477
  {
495
478
  internalType: 'uint256',
496
- name: 'priceLowerThreshold',
497
- type: 'uint256',
498
- },
499
- {
500
- internalType: 'uint256',
501
- name: 'priceUpperThreshold',
479
+ name: 'withdrawAmount',
502
480
  type: 'uint256',
503
481
  },
504
- ],
505
- name: 'InvalidThresholds',
506
- type: 'error',
507
- },
508
- {
509
- inputs: [
510
482
  {
511
483
  internalType: 'uint256',
512
- name: 'tokenId',
484
+ name: 'keeperFee',
513
485
  type: 'uint256',
514
486
  },
515
487
  ],
516
- name: 'LimitOrderInvalid',
488
+ name: 'WithdrawalTooSmall',
517
489
  type: 'error',
518
490
  },
519
491
  {
520
492
  inputs: [
521
493
  {
522
- internalType: 'uint256',
523
- name: 'amount',
524
- type: 'uint256',
494
+ internalType: 'string',
495
+ name: 'variableName',
496
+ type: 'string',
525
497
  },
526
498
  ],
527
- name: 'MintAmountTooLow',
499
+ name: 'ZeroAddress',
528
500
  type: 'error',
529
501
  },
530
502
  {
531
503
  inputs: [
532
504
  {
533
- internalType: 'uint256',
534
- name: 'price',
535
- type: 'uint256',
536
- },
537
- {
538
- internalType: 'uint256',
539
- name: 'priceLowerThreshold',
540
- type: 'uint256',
541
- },
542
- {
543
- internalType: 'uint256',
544
- name: 'priceUpperThreshold',
545
- type: 'uint256',
505
+ internalType: 'string',
506
+ name: 'variableName',
507
+ type: 'string',
546
508
  },
547
509
  ],
548
- name: 'LimitOrderPriceNotInRange',
549
- type: 'error',
550
- },
551
- {
552
- inputs: [],
553
- name: 'ModuleKeyEmpty',
510
+ name: 'ZeroValue',
554
511
  type: 'error',
555
512
  },
556
513
  ];
@@ -81,7 +81,13 @@ exports.LeverageModule = [
81
81
  {
82
82
  indexed: false,
83
83
  internalType: 'uint256',
84
- name: 'lastPrice',
84
+ name: 'averagePrice',
85
+ type: 'uint256',
86
+ },
87
+ {
88
+ indexed: false,
89
+ internalType: 'uint256',
90
+ name: 'adjustPrice',
85
91
  type: 'uint256',
86
92
  },
87
93
  ],
@@ -2,6 +2,8 @@ import { Logger } from '@nestjs/common';
2
2
  export declare class NotificationService {
3
3
  private readonly logger;
4
4
  private readonly slackUri;
5
+ private readonly telegramUri;
5
6
  constructor(logger: Logger);
6
7
  sendNotification(message: string): Promise<void>;
8
+ sendTelegramNotification(message: string): Promise<void>;
7
9
  }
@@ -24,6 +24,9 @@ let NotificationService = class NotificationService {
24
24
  else {
25
25
  throw new Error('NotificationService -> env property SLACK_CHANNEL is not provided');
26
26
  }
27
+ if (process.env.TELEGRAM_CHANNEL) {
28
+ this.telegramUri = process.env.TELEGRAM_CHANNEL;
29
+ }
27
30
  }
28
31
  async sendNotification(message) {
29
32
  try {
@@ -33,6 +36,19 @@ let NotificationService = class NotificationService {
33
36
  this.logger.error(`Error sending notification '${message}' to slack channel ${process.env.SLACK_CHANNEL}`, error);
34
37
  }
35
38
  }
39
+ async sendTelegramNotification(message) {
40
+ if (this.telegramUri) {
41
+ try {
42
+ await axios_1.default.get(`${process.env.TELEGRAM_CHANNEL}${message}`);
43
+ }
44
+ catch (error) {
45
+ this.logger.error(`Error sending notification '${message}' to telegram ${process.env.TELEGRAM_CHANNEL}`, error);
46
+ }
47
+ }
48
+ else {
49
+ this.logger.error(`Error sending notification '${message}' to telegram, TELEGRAM_CHANNEL env property not provided`);
50
+ }
51
+ }
36
52
  };
37
53
  exports.NotificationService = NotificationService;
38
54
  exports.NotificationService = NotificationService = __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/backend-flatcoin-core",
3
- "version": "0.2.10",
3
+ "version": "0.2.13",
4
4
  "description": "Backend Flatcoin Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",