@defisaver/automation-sdk 2.1.2 → 2.1.4
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/.env +4 -0
- package/esm/automation/private/StrategiesAutomation.js +3 -1
- package/esm/constants/index.js +20 -0
- package/esm/services/strategiesService.js +40 -1
- package/esm/services/strategySubService.d.ts +6 -0
- package/esm/services/strategySubService.js +16 -1
- package/esm/services/strategySubService.test.js +91 -1
- package/esm/services/subDataService.d.ts +14 -1
- package/esm/services/subDataService.js +39 -1
- package/esm/services/subDataService.test.js +204 -108
- package/esm/services/triggerService.d.ts +9 -0
- package/esm/services/triggerService.js +16 -1
- package/esm/services/triggerService.test.js +36 -0
- package/esm/types/enums.d.ts +8 -3
- package/esm/types/enums.js +5 -0
- package/esm/types/index.d.ts +5 -1
- package/package.json +2 -2
- package/src/automation/private/StrategiesAutomation.ts +4 -0
- package/src/constants/index.ts +20 -0
- package/src/services/strategiesService.ts +46 -1
- package/src/services/strategySubService.test.ts +99 -1
- package/src/services/strategySubService.ts +35 -0
- package/src/services/subDataService.test.ts +225 -112
- package/src/services/subDataService.ts +58 -0
- package/src/services/triggerService.test.ts +37 -0
- package/src/services/triggerService.ts +24 -0
- package/src/types/enums.ts +5 -0
- package/src/types/index.ts +6 -1
- package/umd/index.js +145 -2
- package/.yarn/releases/yarn-1.22.1.cjs +0 -147386
- package/.yarnrc.yml +0 -3
|
@@ -3,7 +3,7 @@ import { expect } from 'chai';
|
|
|
3
3
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
4
4
|
import * as web3Utils from 'web3-utils';
|
|
5
5
|
|
|
6
|
-
import { ChainId, OrderType } from '../types/enums';
|
|
6
|
+
import { ChainId, OrderType, RatioState } from '../types/enums';
|
|
7
7
|
import type { EthereumAddress, SubData } from '../types';
|
|
8
8
|
|
|
9
9
|
import {
|
|
@@ -13,8 +13,12 @@ import {
|
|
|
13
13
|
cBondsRebondSubData,
|
|
14
14
|
compoundV2LeverageManagementSubData,
|
|
15
15
|
compoundV3LeverageManagementSubData,
|
|
16
|
-
exchangeDcaSubData,
|
|
17
|
-
|
|
16
|
+
exchangeDcaSubData,
|
|
17
|
+
exchangeLimitOrderSubData,
|
|
18
|
+
liquityCloseSubData,
|
|
19
|
+
liquityDebtInFrontRepaySubData,
|
|
20
|
+
liquityDsrPaybackSubData,
|
|
21
|
+
liquityDsrSupplySubData,
|
|
18
22
|
liquityLeverageManagementSubData,
|
|
19
23
|
liquityPaybackUsingChickenBondSubData,
|
|
20
24
|
liquityRepayFromSavingsSubData,
|
|
@@ -24,7 +28,8 @@ import {
|
|
|
24
28
|
morphoAaveV2LeverageManagementSubData,
|
|
25
29
|
sparkLeverageManagementSubData,
|
|
26
30
|
sparkQuotePriceSubData,
|
|
27
|
-
|
|
31
|
+
crvUSDLeverageManagementSubData,
|
|
32
|
+
compoundV3L2LeverageManagementSubData,
|
|
28
33
|
} from './subDataService';
|
|
29
34
|
|
|
30
35
|
describe('Feature: subDataService.ts', () => {
|
|
@@ -34,8 +39,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
34
39
|
const examples: Array<[SubData, [vaultId: number, targetRatioPercentage: number, chainId: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress]]> = [
|
|
35
40
|
[
|
|
36
41
|
[
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
'0x000000000000000000000000000000000000000000000000000000000000007b', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
43
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
39
44
|
],
|
|
40
45
|
[123, 120, ChainId.Ethereum, web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
41
46
|
],
|
|
@@ -58,8 +63,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
58
63
|
targetRatio: 120,
|
|
59
64
|
},
|
|
60
65
|
[
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
'0x000000000000000000000000000000000000000000000000000000000000007b', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
67
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
63
68
|
],
|
|
64
69
|
],
|
|
65
70
|
];
|
|
@@ -78,8 +83,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
78
83
|
[
|
|
79
84
|
{ targetRatio: 120 },
|
|
80
85
|
[
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
87
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
83
88
|
],
|
|
84
89
|
],
|
|
85
90
|
];
|
|
@@ -97,15 +102,15 @@ describe('Feature: subDataService.ts', () => {
|
|
|
97
102
|
const examples: Array<[SubData, [vaultId: number, closeToAssetAddr: EthereumAddress, chainId: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress]]> = [
|
|
98
103
|
[
|
|
99
104
|
[
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
'0x0000000000000000000000000000000000000000000000000000000000000141', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
106
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
102
107
|
],
|
|
103
108
|
[321, web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address), ChainId.Ethereum, web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
104
109
|
],
|
|
105
110
|
[
|
|
106
111
|
[
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
'0x00000000000000000000000000000000000000000000000000000000000001a4', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
113
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002439d218133afab8f2b819b1066c7e434ad94e9e',
|
|
109
114
|
],
|
|
110
115
|
[420, web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address), ChainId.Ethereum, web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2439d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
111
116
|
],
|
|
@@ -126,8 +131,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
126
131
|
closeToAssetAddr: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
127
132
|
},
|
|
128
133
|
[
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
'0x0000000000000000000000000000000000000000000000000000000000000141', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
135
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
131
136
|
],
|
|
132
137
|
],
|
|
133
138
|
[
|
|
@@ -136,8 +141,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
136
141
|
closeToAssetAddr: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
137
142
|
},
|
|
138
143
|
[
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
'0x00000000000000000000000000000000000000000000000000000000000001a4', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
145
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002439d218133afab8f2b819b1066c7e434ad94e9e',
|
|
141
146
|
],
|
|
142
147
|
],
|
|
143
148
|
];
|
|
@@ -195,13 +200,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
195
200
|
const examples: Array<[SubData, [closeToAssetAddr: EthereumAddress, chainId: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress]]> = [
|
|
196
201
|
[
|
|
197
202
|
[
|
|
198
|
-
|
|
203
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
199
204
|
],
|
|
200
205
|
[web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address), ChainId.Ethereum, web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address), web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address)]
|
|
201
206
|
],
|
|
202
207
|
[
|
|
203
208
|
[
|
|
204
|
-
|
|
209
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
205
210
|
],
|
|
206
211
|
[web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address), ChainId.Ethereum]
|
|
207
212
|
],
|
|
@@ -222,7 +227,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
222
227
|
debtAddr: web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address),
|
|
223
228
|
},
|
|
224
229
|
[
|
|
225
|
-
|
|
230
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
226
231
|
],
|
|
227
232
|
],
|
|
228
233
|
[
|
|
@@ -231,7 +236,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
231
236
|
debtAddr: web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address),
|
|
232
237
|
},
|
|
233
238
|
[
|
|
234
|
-
|
|
239
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
235
240
|
],
|
|
236
241
|
],
|
|
237
242
|
];
|
|
@@ -268,11 +273,11 @@ describe('Feature: subDataService.ts', () => {
|
|
|
268
273
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
269
274
|
[
|
|
270
275
|
{ targetRatio: 200 },
|
|
271
|
-
[
|
|
276
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
272
277
|
],
|
|
273
278
|
[
|
|
274
279
|
{ targetRatio: 123 },
|
|
275
|
-
[
|
|
280
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
276
281
|
],
|
|
277
282
|
];
|
|
278
283
|
|
|
@@ -289,11 +294,11 @@ describe('Feature: subDataService.ts', () => {
|
|
|
289
294
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
290
295
|
[
|
|
291
296
|
{ targetRatio: 200 },
|
|
292
|
-
[
|
|
297
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
293
298
|
],
|
|
294
299
|
[
|
|
295
300
|
{ targetRatio: 123 },
|
|
296
|
-
[
|
|
301
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
297
302
|
],
|
|
298
303
|
];
|
|
299
304
|
|
|
@@ -310,9 +315,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
310
315
|
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress]]> = [
|
|
311
316
|
[
|
|
312
317
|
[
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
318
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
319
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
320
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
316
321
|
],
|
|
317
322
|
[
|
|
318
323
|
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
@@ -323,9 +328,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
323
328
|
],
|
|
324
329
|
[
|
|
325
330
|
[
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
331
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
332
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
333
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
329
334
|
],
|
|
330
335
|
[
|
|
331
336
|
web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
@@ -353,9 +358,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
353
358
|
debtAssetId: 4,
|
|
354
359
|
},
|
|
355
360
|
[
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
361
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
362
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
363
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
359
364
|
],
|
|
360
365
|
],
|
|
361
366
|
[
|
|
@@ -366,9 +371,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
366
371
|
debtAssetId: 2,
|
|
367
372
|
},
|
|
368
373
|
[
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
374
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
375
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
376
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
372
377
|
],
|
|
373
378
|
],
|
|
374
379
|
];
|
|
@@ -405,11 +410,11 @@ describe('Feature: subDataService.ts', () => {
|
|
|
405
410
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
406
411
|
[
|
|
407
412
|
{ targetRatio: 200 },
|
|
408
|
-
[
|
|
413
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
409
414
|
],
|
|
410
415
|
[
|
|
411
416
|
{ targetRatio: 123 },
|
|
412
|
-
[
|
|
417
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
413
418
|
],
|
|
414
419
|
];
|
|
415
420
|
|
|
@@ -472,15 +477,15 @@ describe('Feature: subDataService.ts', () => {
|
|
|
472
477
|
[
|
|
473
478
|
{ targetRatio: 123 },
|
|
474
479
|
[
|
|
475
|
-
|
|
476
|
-
|
|
480
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
481
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
477
482
|
],
|
|
478
483
|
],
|
|
479
484
|
[
|
|
480
485
|
{ targetRatio: 200 },
|
|
481
486
|
[
|
|
482
|
-
|
|
483
|
-
|
|
487
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
488
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
484
489
|
],
|
|
485
490
|
],
|
|
486
491
|
];
|
|
@@ -517,11 +522,11 @@ describe('Feature: subDataService.ts', () => {
|
|
|
517
522
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
518
523
|
[
|
|
519
524
|
{ targetRatio: 200 },
|
|
520
|
-
[
|
|
525
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
521
526
|
],
|
|
522
527
|
[
|
|
523
528
|
{ targetRatio: 123 },
|
|
524
|
-
[
|
|
529
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
525
530
|
],
|
|
526
531
|
];
|
|
527
532
|
|
|
@@ -537,11 +542,11 @@ describe('Feature: subDataService.ts', () => {
|
|
|
537
542
|
describe('encode()', () => {
|
|
538
543
|
const examples: Array<[SubData, [bondId: number | string]]> = [
|
|
539
544
|
[
|
|
540
|
-
[
|
|
545
|
+
['0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
541
546
|
[200]
|
|
542
547
|
],
|
|
543
548
|
[
|
|
544
|
-
[
|
|
549
|
+
['0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
545
550
|
[41241]
|
|
546
551
|
],
|
|
547
552
|
];
|
|
@@ -557,11 +562,11 @@ describe('Feature: subDataService.ts', () => {
|
|
|
557
562
|
const examples: Array<[{ bondId: string }, SubData]> = [
|
|
558
563
|
[
|
|
559
564
|
{ bondId: '200' },
|
|
560
|
-
[
|
|
565
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
561
566
|
],
|
|
562
567
|
[
|
|
563
568
|
{ bondId: '41241' },
|
|
564
|
-
[
|
|
569
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
565
570
|
],
|
|
566
571
|
];
|
|
567
572
|
|
|
@@ -578,15 +583,15 @@ describe('Feature: subDataService.ts', () => {
|
|
|
578
583
|
const examples: Array<[SubData, [sourceId: string, sourceType: number, chainId?: ChainId]]> = [
|
|
579
584
|
[
|
|
580
585
|
[
|
|
581
|
-
|
|
582
|
-
|
|
586
|
+
'0x0000000000000000000000000000000000000000000000000000000000001076', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
587
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
583
588
|
],
|
|
584
589
|
['4214', 0, ChainId.Ethereum]
|
|
585
590
|
],
|
|
586
591
|
[
|
|
587
592
|
[
|
|
588
|
-
|
|
589
|
-
|
|
593
|
+
'0x00000000000000000000000000000000000000000000000000000000000002b8', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
594
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
590
595
|
],
|
|
591
596
|
['696', 1]
|
|
592
597
|
],
|
|
@@ -604,15 +609,15 @@ describe('Feature: subDataService.ts', () => {
|
|
|
604
609
|
[
|
|
605
610
|
{ sourceId: '4214', sourceType: '0' },
|
|
606
611
|
[
|
|
607
|
-
|
|
608
|
-
|
|
612
|
+
'0x0000000000000000000000000000000000000000000000000000000000001076', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
613
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
609
614
|
],
|
|
610
615
|
],
|
|
611
616
|
[
|
|
612
617
|
{ sourceId: '696', sourceType: '1' },
|
|
613
618
|
[
|
|
614
|
-
|
|
615
|
-
|
|
619
|
+
'0x00000000000000000000000000000000000000000000000000000000000002b8', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
620
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
616
621
|
],
|
|
617
622
|
],
|
|
618
623
|
];
|
|
@@ -630,8 +635,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
630
635
|
const examples: Array<[SubData, [fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, interval: number]]> = [
|
|
631
636
|
[
|
|
632
637
|
[
|
|
633
|
-
|
|
634
|
-
|
|
638
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
639
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
635
640
|
],
|
|
636
641
|
[
|
|
637
642
|
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
@@ -642,8 +647,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
642
647
|
],
|
|
643
648
|
[
|
|
644
649
|
[
|
|
645
|
-
|
|
646
|
-
|
|
650
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
651
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
647
652
|
],
|
|
648
653
|
[
|
|
649
654
|
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Arbitrum).address),
|
|
@@ -672,8 +677,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
672
677
|
},
|
|
673
678
|
[
|
|
674
679
|
[
|
|
675
|
-
|
|
676
|
-
|
|
680
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
681
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
677
682
|
],
|
|
678
683
|
ChainId.Ethereum
|
|
679
684
|
],
|
|
@@ -687,8 +692,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
687
692
|
},
|
|
688
693
|
[
|
|
689
694
|
[
|
|
690
|
-
|
|
691
|
-
|
|
695
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
696
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
692
697
|
],
|
|
693
698
|
ChainId.Arbitrum
|
|
694
699
|
]
|
|
@@ -761,8 +766,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
761
766
|
},
|
|
762
767
|
[
|
|
763
768
|
[
|
|
764
|
-
|
|
765
|
-
|
|
769
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
770
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
766
771
|
],
|
|
767
772
|
ChainId.Ethereum
|
|
768
773
|
],
|
|
@@ -775,8 +780,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
775
780
|
},
|
|
776
781
|
[
|
|
777
782
|
[
|
|
778
|
-
|
|
779
|
-
|
|
783
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
784
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
780
785
|
],
|
|
781
786
|
ChainId.Arbitrum
|
|
782
787
|
]
|
|
@@ -796,11 +801,11 @@ describe('Feature: subDataService.ts', () => {
|
|
|
796
801
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
797
802
|
[
|
|
798
803
|
{ targetRatio: 200 },
|
|
799
|
-
[
|
|
804
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
800
805
|
],
|
|
801
806
|
[
|
|
802
807
|
{ targetRatio: 123 },
|
|
803
|
-
[
|
|
808
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
804
809
|
],
|
|
805
810
|
];
|
|
806
811
|
|
|
@@ -817,9 +822,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
817
822
|
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress]]> = [
|
|
818
823
|
[
|
|
819
824
|
[
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
825
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
826
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
827
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
823
828
|
],
|
|
824
829
|
[
|
|
825
830
|
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
@@ -830,9 +835,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
830
835
|
],
|
|
831
836
|
[
|
|
832
837
|
[
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
838
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
839
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
840
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
836
841
|
],
|
|
837
842
|
[
|
|
838
843
|
web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
@@ -860,9 +865,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
860
865
|
debtAssetId: 4,
|
|
861
866
|
},
|
|
862
867
|
[
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
868
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
869
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
870
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
866
871
|
],
|
|
867
872
|
],
|
|
868
873
|
[
|
|
@@ -873,9 +878,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
873
878
|
debtAssetId: 2,
|
|
874
879
|
},
|
|
875
880
|
[
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
881
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
882
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
883
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
879
884
|
],
|
|
880
885
|
],
|
|
881
886
|
];
|
|
@@ -893,15 +898,15 @@ describe('Feature: subDataService.ts', () => {
|
|
|
893
898
|
const examples: Array<[SubData, [targetRatio: number]]> = [
|
|
894
899
|
[
|
|
895
900
|
[
|
|
896
|
-
|
|
897
|
-
|
|
901
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
902
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
898
903
|
],
|
|
899
904
|
[123]
|
|
900
905
|
],
|
|
901
906
|
[
|
|
902
907
|
[
|
|
903
|
-
|
|
904
|
-
|
|
908
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
909
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
905
910
|
],
|
|
906
911
|
[420]
|
|
907
912
|
],
|
|
@@ -921,8 +926,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
921
926
|
targetRatio: 123,
|
|
922
927
|
},
|
|
923
928
|
[
|
|
924
|
-
|
|
925
|
-
|
|
929
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
930
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
926
931
|
],
|
|
927
932
|
],
|
|
928
933
|
[
|
|
@@ -930,8 +935,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
930
935
|
targetRatio: 420,
|
|
931
936
|
},
|
|
932
937
|
[
|
|
933
|
-
|
|
934
|
-
|
|
938
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
939
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
935
940
|
],
|
|
936
941
|
],
|
|
937
942
|
];
|
|
@@ -949,15 +954,15 @@ describe('Feature: subDataService.ts', () => {
|
|
|
949
954
|
const examples: Array<[SubData, [targetRatio: number]]> = [
|
|
950
955
|
[
|
|
951
956
|
[
|
|
952
|
-
|
|
953
|
-
|
|
957
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000002c68af0bb1400000',
|
|
958
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
954
959
|
],
|
|
955
960
|
[320]
|
|
956
961
|
],
|
|
957
962
|
[
|
|
958
963
|
[
|
|
959
|
-
|
|
960
|
-
|
|
964
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001eab7f4a799d0000',
|
|
965
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
961
966
|
],
|
|
962
967
|
[221]
|
|
963
968
|
],
|
|
@@ -977,8 +982,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
977
982
|
targetRatio: 320,
|
|
978
983
|
},
|
|
979
984
|
[
|
|
980
|
-
|
|
981
|
-
|
|
985
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000002c68af0bb1400000',
|
|
986
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
982
987
|
],
|
|
983
988
|
],
|
|
984
989
|
[
|
|
@@ -986,8 +991,8 @@ describe('Feature: subDataService.ts', () => {
|
|
|
986
991
|
targetRatio: 221,
|
|
987
992
|
},
|
|
988
993
|
[
|
|
989
|
-
|
|
990
|
-
|
|
994
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001eab7f4a799d0000',
|
|
995
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
991
996
|
],
|
|
992
997
|
],
|
|
993
998
|
];
|
|
@@ -1005,17 +1010,17 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1005
1010
|
const examples: Array<[SubData, [targetRatioIncrease: number]]> = [
|
|
1006
1011
|
[
|
|
1007
1012
|
[
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1013
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1014
|
+
'0x000000000000000000000000000000000000000000000000016345785d8a0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1015
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1011
1016
|
],
|
|
1012
1017
|
[10]
|
|
1013
1018
|
],
|
|
1014
1019
|
[
|
|
1015
1020
|
[
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1021
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1022
|
+
'0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1023
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1019
1024
|
],
|
|
1020
1025
|
[45]
|
|
1021
1026
|
],
|
|
@@ -1035,9 +1040,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1035
1040
|
targetRatioIncrease: 10,
|
|
1036
1041
|
},
|
|
1037
1042
|
[
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1043
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1044
|
+
'0x000000000000000000000000000000000000000000000000016345785d8a0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1045
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1041
1046
|
],
|
|
1042
1047
|
],
|
|
1043
1048
|
[
|
|
@@ -1045,9 +1050,9 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1045
1050
|
targetRatioIncrease: 45,
|
|
1046
1051
|
},
|
|
1047
1052
|
[
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1053
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1054
|
+
'0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1055
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1051
1056
|
],
|
|
1052
1057
|
],
|
|
1053
1058
|
];
|
|
@@ -1060,4 +1065,112 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1060
1065
|
});
|
|
1061
1066
|
});
|
|
1062
1067
|
|
|
1068
|
+
describe('When testing subDataService.crvUSDLeverageManagementSubData', () => {
|
|
1069
|
+
describe('encode()', () => {
|
|
1070
|
+
const examples: Array<[SubData, [controller: EthereumAddress, ratioState: RatioState, targetRatio: number, collToken: EthereumAddress, crvUSD: EthereumAddress]]> = [
|
|
1071
|
+
[
|
|
1072
|
+
[
|
|
1073
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1074
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1075
|
+
'0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
1076
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1077
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1078
|
+
],
|
|
1079
|
+
['0xa920de414ea4ab66b97da1bfe9e6eca7d4219635', RatioState.UNDER, 120, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E'],
|
|
1080
|
+
],
|
|
1081
|
+
[
|
|
1082
|
+
[
|
|
1083
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1084
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1085
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1086
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1087
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1088
|
+
],
|
|
1089
|
+
['0xa920de414ea4ab66b97da1bfe9e6eca7d4219635', RatioState.OVER, 180, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E']
|
|
1090
|
+
],
|
|
1091
|
+
];
|
|
1092
|
+
examples.forEach(([expected, actual]) => {
|
|
1093
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1094
|
+
expect(crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
1097
|
+
});
|
|
1098
|
+
describe('decode()', () => {
|
|
1099
|
+
const examples: Array<[{
|
|
1100
|
+
controller: EthereumAddress,
|
|
1101
|
+
targetRatio: number,
|
|
1102
|
+
}, SubData]> = [
|
|
1103
|
+
[
|
|
1104
|
+
{
|
|
1105
|
+
controller: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
|
|
1106
|
+
targetRatio: 120,
|
|
1107
|
+
},
|
|
1108
|
+
['0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635', '0x0000000000000000000000000000000000000000000000000000000000000001', '0x00000000000000000000000000000000000000000000000010a741a462780000', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',],
|
|
1109
|
+
],
|
|
1110
|
+
[
|
|
1111
|
+
{
|
|
1112
|
+
controller: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
|
|
1113
|
+
targetRatio: 180,
|
|
1114
|
+
},
|
|
1115
|
+
['0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000018fae27693b40000', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',],
|
|
1116
|
+
],
|
|
1117
|
+
];
|
|
1118
|
+
|
|
1119
|
+
examples.forEach(([expected, actual]) => {
|
|
1120
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1121
|
+
expect(crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1122
|
+
});
|
|
1123
|
+
});
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
describe('When testing subDataService.compoundV3L2LeverageManagementSubData', () => {
|
|
1128
|
+
describe('encode()', () => {
|
|
1129
|
+
const examples: Array<[
|
|
1130
|
+
string,
|
|
1131
|
+
[market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean],
|
|
1132
|
+
]> = [
|
|
1133
|
+
[
|
|
1134
|
+
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
1135
|
+
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true]
|
|
1136
|
+
],
|
|
1137
|
+
[
|
|
1138
|
+
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee000000',
|
|
1139
|
+
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false]
|
|
1140
|
+
],
|
|
1141
|
+
];
|
|
1142
|
+
|
|
1143
|
+
examples.forEach(([expected, actual]) => {
|
|
1144
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1145
|
+
expect(compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1146
|
+
});
|
|
1147
|
+
});
|
|
1148
|
+
});
|
|
1149
|
+
describe('decode()', () => {
|
|
1150
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
1151
|
+
[
|
|
1152
|
+
{ targetRatio: 200 },
|
|
1153
|
+
[
|
|
1154
|
+
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000213d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1155
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1156
|
+
],
|
|
1157
|
+
],
|
|
1158
|
+
[
|
|
1159
|
+
{ targetRatio: 123 },
|
|
1160
|
+
[
|
|
1161
|
+
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000413d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1162
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1163
|
+
],
|
|
1164
|
+
],
|
|
1165
|
+
];
|
|
1166
|
+
|
|
1167
|
+
examples.forEach(([expected, actual]) => {
|
|
1168
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1169
|
+
expect(compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1170
|
+
});
|
|
1171
|
+
});
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
1174
|
+
|
|
1175
|
+
|
|
1063
1176
|
});
|