@defisaver/automation-sdk 3.0.0 → 3.0.2-dev

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.
Files changed (52) hide show
  1. package/.env.dev +1 -1
  2. package/README.md +3 -3
  3. package/esm/automation/private/LegacyAutomation.js +2 -2
  4. package/esm/automation/private/StrategiesAutomation.d.ts +1 -0
  5. package/esm/automation/private/StrategiesAutomation.js +34 -24
  6. package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -0
  7. package/esm/automation/private/StrategiesAutomation.test.js +671 -0
  8. package/esm/constants/index.js +10 -0
  9. package/esm/services/ethereumService.test.d.ts +1 -1
  10. package/esm/services/ethereumService.test.js +1 -0
  11. package/esm/services/strategiesService.js +37 -0
  12. package/esm/services/strategiesService.test.d.ts +1 -1
  13. package/esm/services/strategiesService.test.js +1 -0
  14. package/esm/services/strategySubService.d.ts +3 -0
  15. package/esm/services/strategySubService.js +11 -1
  16. package/esm/services/strategySubService.test.d.ts +1 -1
  17. package/esm/services/strategySubService.test.js +74 -0
  18. package/esm/services/subDataService.d.ts +12 -0
  19. package/esm/services/subDataService.js +33 -1
  20. package/esm/services/subDataService.test.d.ts +1 -1
  21. package/esm/services/subDataService.test.js +89 -0
  22. package/esm/services/triggerService.d.ts +9 -0
  23. package/esm/services/triggerService.js +17 -1
  24. package/esm/services/triggerService.test.d.ts +1 -1
  25. package/esm/services/triggerService.test.js +37 -0
  26. package/esm/services/utils.test.d.ts +1 -1
  27. package/esm/services/utils.test.js +1 -0
  28. package/esm/types/enums.d.ts +5 -2
  29. package/esm/types/enums.js +3 -0
  30. package/esm/types/index.d.ts +1 -1
  31. package/package.json +2 -2
  32. package/scripts/generateContractTypes.js +1 -1
  33. package/src/automation/private/LegacyAutomation.ts +2 -2
  34. package/src/automation/private/StrategiesAutomation.test.ts +663 -0
  35. package/src/automation/private/StrategiesAutomation.ts +56 -41
  36. package/src/constants/index.ts +10 -0
  37. package/src/services/ethereumService.test.ts +1 -0
  38. package/src/services/strategiesService.test.ts +1 -0
  39. package/src/services/strategiesService.ts +42 -0
  40. package/src/services/strategySubService.test.ts +90 -1
  41. package/src/services/strategySubService.ts +25 -0
  42. package/src/services/subDataService.test.ts +97 -1
  43. package/src/services/subDataService.ts +43 -0
  44. package/src/services/triggerService.test.ts +40 -0
  45. package/src/services/triggerService.ts +23 -0
  46. package/src/services/utils.test.ts +1 -0
  47. package/src/types/enums.ts +3 -0
  48. package/src/types/index.ts +1 -1
  49. package/umd/index.js +162 -33
  50. package/.env +0 -4
  51. package/.yarn/releases/yarn-1.22.1.cjs +0 -147386
  52. package/.yarnrc.yml +0 -3
@@ -0,0 +1,663 @@
1
+ import Web3 from 'web3';
2
+ import { expect } from 'chai';
3
+
4
+ import {ChainId} from '../../types/enums';
5
+
6
+ import '../../configuration';
7
+ import StrategiesAutomation from './StrategiesAutomation';
8
+
9
+ require('dotenv').config({ path: '.env' });
10
+
11
+ const Web3_1 = new Web3(process.env.RPC_1!);
12
+
13
+ describe('Feature: StrategiesAutomation.ts', () => {
14
+ describe('When testing class StrategiesAutomation', async () => {
15
+ const exampleStrategiesAutomation = new StrategiesAutomation({
16
+ chainId:ChainId.Ethereum,
17
+ provider: Web3_1,
18
+ providerFork: null!,
19
+ });
20
+
21
+ const examples: Array<[any, any]> = [
22
+ [
23
+ [
24
+ {
25
+ 'isEnabled': true,
26
+ 'chainId': 1,
27
+ 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
28
+ 'blockNumber': 0,
29
+ 'positionId': '1-aave__v3',
30
+ 'subId': 0,
31
+ 'protocol': {
32
+ 'id': 'Aave__V3',
33
+ 'name': 'Aave',
34
+ 'slug': 'aave',
35
+ 'version': 'V3',
36
+ 'fullName': 'Aave V3'
37
+ },
38
+ 'strategy': {
39
+ 'isBundle': true,
40
+ 'strategyOrBundleId': 0,
41
+ 'strategyId': 'leverage-management',
42
+ 'protocol': {
43
+ 'id': 'Aave__V3',
44
+ 'name': 'Aave',
45
+ 'slug': 'aave',
46
+ 'version': 'V3',
47
+ 'fullName': 'Aave V3'
48
+ }
49
+ },
50
+ 'strategyData': {
51
+ 'encoded': {
52
+ 'subData': [
53
+ '0x000000000000000000000000000000000000000000000000120a871cc0020000',
54
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
55
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
56
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
57
+ ]
58
+ },
59
+ 'decoded': {
60
+ 'triggerData': {
61
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
62
+ 'ratio': 120,
63
+ 'ratioState': 1
64
+ },
65
+ 'subData': {
66
+ 'targetRatio': 130
67
+ }
68
+ }
69
+ },
70
+ 'specific': {
71
+ 'triggerRepayRatio': 120,
72
+ 'targetRepayRatio': 130,
73
+ 'repayEnabled': true,
74
+ 'subId1': 0,
75
+ 'mergeWithId': 'boost'
76
+ }
77
+ },
78
+ {
79
+ 'isEnabled': false,
80
+ 'chainId': 1,
81
+ 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
82
+ 'blockNumber': 0,
83
+ 'positionId': '1-aave__v3',
84
+ 'subId': 1,
85
+ 'protocol': {
86
+ 'id': 'Aave__V3',
87
+ 'name': 'Aave',
88
+ 'slug': 'aave',
89
+ 'version': 'V3',
90
+ 'fullName': 'Aave V3'
91
+ },
92
+ 'strategy': {
93
+ 'isBundle': true,
94
+ 'strategyOrBundleId': 0,
95
+ 'strategyId': 'leverage-management',
96
+ 'protocol': {
97
+ 'id': 'Aave__V3',
98
+ 'name': 'Aave',
99
+ 'slug': 'aave',
100
+ 'version': 'V3',
101
+ 'fullName': 'Aave V3'
102
+ }
103
+ },
104
+ 'strategyData': {
105
+ 'encoded': {
106
+ 'subData': [
107
+ '0x000000000000000000000000000000000000000000000000120a871cc0020000',
108
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
109
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
110
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
111
+ ]
112
+ },
113
+ 'decoded': {
114
+ 'triggerData': {
115
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
116
+ 'ratio': 120,
117
+ 'ratioState': 1
118
+ },
119
+ 'subData': {
120
+ 'targetRatio': 130
121
+ }
122
+ }
123
+ },
124
+ 'specific': {
125
+ 'triggerRepayRatio': 120,
126
+ 'targetRepayRatio': 130,
127
+ 'repayEnabled': true,
128
+ 'subId1': 1,
129
+ 'mergeWithId': 'boost'
130
+ }
131
+ },
132
+ {
133
+ 'isEnabled': false,
134
+ 'chainId': 1,
135
+ 'subHash': '0xe55917c42ac3e8f6c080e3780c5e0ea7a0a3da6c05e7ced5fe69fee48133a5eb',
136
+ 'blockNumber': 0,
137
+ 'positionId': '1-aave__v3',
138
+ 'subId': 2,
139
+ 'protocol': {
140
+ 'id': 'Aave__V3',
141
+ 'name': 'Aave',
142
+ 'slug': 'aave',
143
+ 'version': 'V3',
144
+ 'fullName': 'Aave V3'
145
+ },
146
+ 'strategy': {
147
+ 'isBundle': true,
148
+ 'strategyOrBundleId': 0,
149
+ 'strategyId': 'leverage-management',
150
+ 'protocol': {
151
+ 'id': 'Aave__V3',
152
+ 'name': 'Aave',
153
+ 'slug': 'aave',
154
+ 'version': 'V3',
155
+ 'fullName': 'Aave V3'
156
+ }
157
+ },
158
+ 'strategyData': {
159
+ 'encoded': {
160
+ 'subData': [
161
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
162
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
163
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
164
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
165
+ ]
166
+ },
167
+ 'decoded': {
168
+ 'triggerData': {
169
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
170
+ 'ratio': 135,
171
+ 'ratioState': 1
172
+ },
173
+ 'subData': {
174
+ 'targetRatio': 150
175
+ }
176
+ }
177
+ },
178
+ 'specific': {
179
+ 'triggerRepayRatio': 135,
180
+ 'targetRepayRatio': 150,
181
+ 'repayEnabled': true,
182
+ 'subId1': 2,
183
+ 'mergeWithId': 'boost'
184
+ }
185
+ },
186
+ {
187
+ 'isEnabled': false,
188
+ 'chainId': 1,
189
+ 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
190
+ 'blockNumber': 0,
191
+ 'positionId': '1-aave__v3',
192
+ 'subId': 3,
193
+ 'protocol': {
194
+ 'id': 'Aave__V3',
195
+ 'name': 'Aave',
196
+ 'slug': 'aave',
197
+ 'version': 'V3',
198
+ 'fullName': 'Aave V3'
199
+ },
200
+ 'strategy': {
201
+ 'isBundle': true,
202
+ 'strategyOrBundleId': 1,
203
+ 'strategyId': 'leverage-management',
204
+ 'protocol': {
205
+ 'id': 'Aave__V3',
206
+ 'name': 'Aave',
207
+ 'slug': 'aave',
208
+ 'version': 'V3',
209
+ 'fullName': 'Aave V3'
210
+ }
211
+ },
212
+ 'strategyData': {
213
+ 'encoded': {
214
+ 'subData': [
215
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
216
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
217
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
218
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
219
+ '0x0000000000000000000000000000000000000000000000000000000000000001'
220
+ ]
221
+ },
222
+ 'decoded': {
223
+ 'triggerData': {
224
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
225
+ 'ratio': 165,
226
+ 'ratioState': 0
227
+ },
228
+ 'subData': {
229
+ 'targetRatio': 150
230
+ }
231
+ }
232
+ },
233
+ 'specific': {
234
+ 'triggerBoostRatio': 165,
235
+ 'targetBoostRatio': 150,
236
+ 'boostEnabled': false,
237
+ 'subId2': 3,
238
+ 'mergeId': 'boost'
239
+ }
240
+ },
241
+ {
242
+ 'isEnabled': false,
243
+ 'chainId': 1,
244
+ 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
245
+ 'blockNumber': 1,
246
+ 'positionId': '1-aave__v3',
247
+ 'subId': 4,
248
+ 'protocol': {
249
+ 'id': 'Aave__V3',
250
+ 'name': 'Aave',
251
+ 'slug': 'aave',
252
+ 'version': 'V3',
253
+ 'fullName': 'Aave V3'
254
+ },
255
+ 'strategy': {
256
+ 'isBundle': true,
257
+ 'strategyOrBundleId': 1,
258
+ 'strategyId': 'leverage-management',
259
+ 'protocol': {
260
+ 'id': 'Aave__V3',
261
+ 'name': 'Aave',
262
+ 'slug': 'aave',
263
+ 'version': 'V3',
264
+ 'fullName': 'Aave V3'
265
+ }
266
+ },
267
+ 'strategyData': {
268
+ 'encoded': {
269
+ 'subData': [
270
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
271
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
272
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
273
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
274
+ '0x0000000000000000000000000000000000000000000000000000000000000001'
275
+ ]
276
+ },
277
+ 'decoded': {
278
+ 'triggerData': {
279
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
280
+ 'ratio': 165,
281
+ 'ratioState': 0
282
+ },
283
+ 'subData': {
284
+ 'targetRatio': 150
285
+ }
286
+ }
287
+ },
288
+ 'specific': {
289
+ 'triggerBoostRatio': 165,
290
+ 'targetBoostRatio': 150,
291
+ 'boostEnabled': false,
292
+ 'subId2': 4,
293
+ 'mergeId': 'boost'
294
+ }
295
+ },
296
+ {
297
+ 'isEnabled': false,
298
+ 'chainId': 1,
299
+ 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
300
+ 'blockNumber': 1,
301
+ 'positionId': '1-aave__v3',
302
+ 'subId': 5,
303
+ 'protocol': {
304
+ 'id': 'Aave__V3',
305
+ 'name': 'Aave',
306
+ 'slug': 'aave',
307
+ 'version': 'V3',
308
+ 'fullName': 'Aave V3'
309
+ },
310
+ 'strategy': {
311
+ 'isBundle': true,
312
+ 'strategyOrBundleId': 1,
313
+ 'strategyId': 'leverage-management',
314
+ 'protocol': {
315
+ 'id': 'Aave__V3',
316
+ 'name': 'Aave',
317
+ 'slug': 'aave',
318
+ 'version': 'V3',
319
+ 'fullName': 'Aave V3'
320
+ }
321
+ },
322
+ 'strategyData': {
323
+ 'encoded': {
324
+ 'subData': [
325
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
326
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
327
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
328
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
329
+ '0x0000000000000000000000000000000000000000000000000000000000000001'
330
+ ]
331
+ },
332
+ 'decoded': {
333
+ 'triggerData': {
334
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
335
+ 'ratio': 165,
336
+ 'ratioState': 0
337
+ },
338
+ 'subData': {
339
+ 'targetRatio': 150
340
+ }
341
+ }
342
+ },
343
+ 'specific': {
344
+ 'triggerBoostRatio': 165,
345
+ 'targetBoostRatio': 150,
346
+ 'boostEnabled': false,
347
+ 'subId2': 5,
348
+ 'mergeId': 'boost'
349
+ }
350
+ },
351
+ {
352
+ 'isEnabled': false,
353
+ 'chainId': 1,
354
+ 'subHash': '0x52cd11186443c2734f027a7175bccf80158c6a45906f4b33b5713b77244aa7f6',
355
+ 'blockNumber': 1,
356
+ 'positionId': '1-aave__v3',
357
+ 'subId': 6,
358
+ 'protocol': {
359
+ 'id': 'Aave__V3',
360
+ 'name': 'Aave',
361
+ 'slug': 'aave',
362
+ 'version': 'V3',
363
+ 'fullName': 'Aave V3'
364
+ },
365
+ 'strategy': {
366
+ 'isBundle': true,
367
+ 'strategyOrBundleId': 0,
368
+ 'strategyId': 'leverage-management',
369
+ 'protocol': {
370
+ 'id': 'Aave__V3',
371
+ 'name': 'Aave',
372
+ 'slug': 'aave',
373
+ 'version': 'V3',
374
+ 'fullName': 'Aave V3'
375
+ }
376
+ },
377
+ 'strategyData': {
378
+ 'encoded': {
379
+ 'subData': [
380
+ '0x00000000000000000000000000000000000000000000000012bc29d8eec70000',
381
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
382
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
383
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
384
+ ]
385
+ },
386
+ 'decoded': {
387
+ 'triggerData': {
388
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
389
+ 'ratio': 120,
390
+ 'ratioState': 1
391
+ },
392
+ 'subData': {
393
+ 'targetRatio': 135
394
+ }
395
+ }
396
+ },
397
+ 'specific': {
398
+ 'triggerRepayRatio': 120,
399
+ 'targetRepayRatio': 135,
400
+ 'repayEnabled': true,
401
+ 'subId1': 6,
402
+ 'mergeWithId': 'boost'
403
+ }
404
+ }
405
+ ],[
406
+ {
407
+ 'isEnabled': true,
408
+ 'chainId': 1,
409
+ 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
410
+ 'blockNumber': 0,
411
+ 'positionId': '1-aave__v3',
412
+ 'subId': 0,
413
+ 'protocol': {
414
+ 'id': 'Aave__V3',
415
+ 'name': 'Aave',
416
+ 'slug': 'aave',
417
+ 'version': 'V3',
418
+ 'fullName': 'Aave V3'
419
+ },
420
+ 'strategy': {
421
+ 'isBundle': true,
422
+ 'strategyOrBundleId': 0,
423
+ 'strategyId': 'leverage-management',
424
+ 'protocol': {
425
+ 'id': 'Aave__V3',
426
+ 'name': 'Aave',
427
+ 'slug': 'aave',
428
+ 'version': 'V3',
429
+ 'fullName': 'Aave V3'
430
+ }
431
+ },
432
+ 'strategyData': {
433
+ 'encoded': {
434
+ 'subData': [
435
+ '0x000000000000000000000000000000000000000000000000120a871cc0020000',
436
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
437
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
438
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
439
+ ]
440
+ },
441
+ 'decoded': {
442
+ 'triggerData': {
443
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
444
+ 'ratio': 120,
445
+ 'ratioState': 1
446
+ },
447
+ 'subData': {
448
+ 'targetRatio': 130
449
+ }
450
+ }
451
+ },
452
+ 'specific': {
453
+ 'triggerBoostRatio': 165,
454
+ 'targetBoostRatio': 150,
455
+ 'boostEnabled': false,
456
+ 'subId2': 3,
457
+ 'mergeId': 'boost',
458
+ 'triggerRepayRatio': 120,
459
+ 'targetRepayRatio': 130,
460
+ 'repayEnabled': true,
461
+ 'subId1': 0,
462
+ 'mergeWithId': 'boost'
463
+ },
464
+ 'subIds': [
465
+ 0,
466
+ 3
467
+ ]
468
+ },
469
+ {
470
+ 'isEnabled': false,
471
+ 'chainId': 1,
472
+ 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
473
+ 'blockNumber': 1,
474
+ 'positionId': '1-aave__v3',
475
+ 'subId': 1,
476
+ 'protocol': {
477
+ 'id': 'Aave__V3',
478
+ 'name': 'Aave',
479
+ 'slug': 'aave',
480
+ 'version': 'V3',
481
+ 'fullName': 'Aave V3'
482
+ },
483
+ 'strategy': {
484
+ 'isBundle': true,
485
+ 'strategyOrBundleId': 0,
486
+ 'strategyId': 'leverage-management',
487
+ 'protocol': {
488
+ 'id': 'Aave__V3',
489
+ 'name': 'Aave',
490
+ 'slug': 'aave',
491
+ 'version': 'V3',
492
+ 'fullName': 'Aave V3'
493
+ }
494
+ },
495
+ 'strategyData': {
496
+ 'encoded': {
497
+ 'subData': [
498
+ '0x000000000000000000000000000000000000000000000000120a871cc0020000',
499
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
500
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
501
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
502
+ ]
503
+ },
504
+ 'decoded': {
505
+ 'triggerData': {
506
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
507
+ 'ratio': 120,
508
+ 'ratioState': 1
509
+ },
510
+ 'subData': {
511
+ 'targetRatio': 130
512
+ }
513
+ }
514
+ },
515
+ 'specific': {
516
+ 'triggerBoostRatio': 165,
517
+ 'targetBoostRatio': 150,
518
+ 'boostEnabled': false,
519
+ 'subId2': 4,
520
+ 'mergeId': 'boost',
521
+ 'triggerRepayRatio': 120,
522
+ 'targetRepayRatio': 130,
523
+ 'repayEnabled': true,
524
+ 'subId1': 1,
525
+ 'mergeWithId': 'boost'
526
+ },
527
+ 'subIds': [
528
+ 1,
529
+ 4
530
+ ]
531
+ },
532
+ {
533
+ 'isEnabled': false,
534
+ 'chainId': 1,
535
+ 'subHash': '0xe55917c42ac3e8f6c080e3780c5e0ea7a0a3da6c05e7ced5fe69fee48133a5eb',
536
+ 'blockNumber': 1,
537
+ 'positionId': '1-aave__v3',
538
+ 'subId': 2,
539
+ 'protocol': {
540
+ 'id': 'Aave__V3',
541
+ 'name': 'Aave',
542
+ 'slug': 'aave',
543
+ 'version': 'V3',
544
+ 'fullName': 'Aave V3'
545
+ },
546
+ 'strategy': {
547
+ 'isBundle': true,
548
+ 'strategyOrBundleId': 0,
549
+ 'strategyId': 'leverage-management',
550
+ 'protocol': {
551
+ 'id': 'Aave__V3',
552
+ 'name': 'Aave',
553
+ 'slug': 'aave',
554
+ 'version': 'V3',
555
+ 'fullName': 'Aave V3'
556
+ }
557
+ },
558
+ 'strategyData': {
559
+ 'encoded': {
560
+ 'subData': [
561
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
562
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
563
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
564
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
565
+ ]
566
+ },
567
+ 'decoded': {
568
+ 'triggerData': {
569
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
570
+ 'ratio': 135,
571
+ 'ratioState': 1
572
+ },
573
+ 'subData': {
574
+ 'targetRatio': 150
575
+ }
576
+ }
577
+ },
578
+ 'specific': {
579
+ 'triggerBoostRatio': 165,
580
+ 'targetBoostRatio': 150,
581
+ 'boostEnabled': false,
582
+ 'subId2': 5,
583
+ 'mergeId': 'boost',
584
+ 'triggerRepayRatio': 135,
585
+ 'targetRepayRatio': 150,
586
+ 'repayEnabled': true,
587
+ 'subId1': 2,
588
+ 'mergeWithId': 'boost'
589
+ },
590
+ 'subIds': [
591
+ 2,
592
+ 5
593
+ ]
594
+ },
595
+ {
596
+ 'isEnabled': false,
597
+ 'chainId': 1,
598
+ 'subHash': '0x52cd11186443c2734f027a7175bccf80158c6a45906f4b33b5713b77244aa7f6',
599
+ 'blockNumber': 1,
600
+ 'positionId': '1-aave__v3',
601
+ 'subId': 6,
602
+ 'protocol': {
603
+ 'id': 'Aave__V3',
604
+ 'name': 'Aave',
605
+ 'slug': 'aave',
606
+ 'version': 'V3',
607
+ 'fullName': 'Aave V3'
608
+ },
609
+ 'strategy': {
610
+ 'isBundle': true,
611
+ 'strategyOrBundleId': 0,
612
+ 'strategyId': 'leverage-management',
613
+ 'protocol': {
614
+ 'id': 'Aave__V3',
615
+ 'name': 'Aave',
616
+ 'slug': 'aave',
617
+ 'version': 'V3',
618
+ 'fullName': 'Aave V3'
619
+ }
620
+ },
621
+ 'strategyData': {
622
+ 'encoded': {
623
+ 'subData': [
624
+ '0x00000000000000000000000000000000000000000000000012bc29d8eec70000',
625
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
626
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
627
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
628
+ ]
629
+ },
630
+ 'decoded': {
631
+ 'triggerData': {
632
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
633
+ 'ratio': 120,
634
+ 'ratioState': 1
635
+ },
636
+ 'subData': {
637
+ 'targetRatio': 135
638
+ }
639
+ }
640
+ },
641
+ 'specific': {
642
+ 'triggerRepayRatio': 120,
643
+ 'targetRepayRatio': 135,
644
+ 'repayEnabled': true,
645
+ 'subId1': 6,
646
+ 'mergeWithId': 'boost'
647
+ },
648
+ 'subIds': [
649
+ 6
650
+ ]
651
+ }
652
+ ]
653
+ ],
654
+ ];
655
+ examples.forEach(([input, actual]) => {
656
+ it(`Given ${input} should return expected value:`, async () => {
657
+ // @ts-ignore
658
+ const expected = exampleStrategiesAutomation.mergeSubs(input);
659
+ expect(JSON.stringify(actual)).to.equal(JSON.stringify(expected));
660
+ });
661
+ });
662
+ });
663
+ });