@defisaver/automation-sdk 3.1.10 → 3.1.14-spark-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.
- package/cjs/automation/private/StrategiesAutomation.d.ts +5 -3
- package/cjs/automation/private/StrategiesAutomation.js +27 -10
- package/cjs/automation/private/StrategiesAutomation.test.js +25 -0
- package/cjs/constants/index.d.ts +1 -0
- package/cjs/constants/index.js +352 -11
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +1 -1
- package/cjs/services/ethereumService.js +21 -14
- package/cjs/services/ethereumService.test.js +3 -0
- package/cjs/services/strategiesService.js +329 -54
- package/cjs/services/strategiesService.test.js +1 -0
- package/cjs/services/strategySubService.d.ts +24 -5
- package/cjs/services/strategySubService.js +116 -10
- package/cjs/services/strategySubService.test.js +1049 -173
- package/cjs/services/subDataService.d.ts +361 -88
- package/cjs/services/subDataService.js +799 -249
- package/cjs/services/subDataService.test.js +1287 -142
- package/cjs/services/triggerService.d.ts +100 -9
- package/cjs/services/triggerService.js +188 -19
- package/cjs/services/triggerService.test.js +437 -46
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +10 -2
- package/cjs/services/utils.test.js +0 -77
- package/cjs/types/enums.d.ts +88 -12
- package/cjs/types/enums.js +78 -2
- package/cjs/types/index.d.ts +59 -1
- package/esm/automation/private/StrategiesAutomation.d.ts +5 -3
- package/esm/automation/private/StrategiesAutomation.js +27 -10
- package/esm/automation/private/StrategiesAutomation.test.js +25 -0
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +351 -10
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/services/ethereumService.js +21 -14
- package/esm/services/ethereumService.test.js +3 -0
- package/esm/services/strategiesService.js +330 -55
- package/esm/services/strategiesService.test.js +1 -0
- package/esm/services/strategySubService.d.ts +24 -5
- package/esm/services/strategySubService.js +115 -9
- package/esm/services/strategySubService.test.js +1052 -176
- package/esm/services/subDataService.d.ts +361 -88
- package/esm/services/subDataService.js +799 -249
- package/esm/services/subDataService.test.js +1288 -143
- package/esm/services/triggerService.d.ts +100 -9
- package/esm/services/triggerService.js +187 -18
- package/esm/services/triggerService.test.js +438 -47
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +10 -2
- package/esm/services/utils.test.js +1 -52
- package/esm/types/enums.d.ts +88 -12
- package/esm/types/enums.js +78 -2
- package/esm/types/index.d.ts +59 -1
- package/package.json +4 -5
- package/src/automation/private/StrategiesAutomation.test.ts +40 -0
- package/src/automation/private/StrategiesAutomation.ts +38 -15
- package/src/constants/index.ts +353 -11
- package/src/index.ts +4 -2
- package/src/services/ethereumService.test.ts +3 -0
- package/src/services/ethereumService.ts +23 -16
- package/src/services/strategiesService.test.ts +1 -0
- package/src/services/strategiesService.ts +387 -72
- package/src/services/strategySubService.test.ts +1330 -316
- package/src/services/strategySubService.ts +365 -12
- package/src/services/subDataService.test.ts +1413 -170
- package/src/services/subDataService.ts +1148 -431
- package/src/services/triggerService.test.ts +482 -52
- package/src/services/triggerService.ts +272 -27
- package/src/services/utils.test.ts +0 -59
- package/src/services/utils.ts +15 -4
- package/src/types/enums.ts +78 -2
- package/src/types/index.ts +74 -1
- package/umd/index.js +0 -34219
|
@@ -2,38 +2,13 @@ import Dec from 'decimal.js';
|
|
|
2
2
|
import { expect } from 'chai';
|
|
3
3
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
4
4
|
import * as web3Utils from 'web3-utils';
|
|
5
|
+
import { MAXUINT } from '@defisaver/tokens';
|
|
5
6
|
|
|
6
|
-
import { ChainId, OrderType, RatioState } from '../types/enums';
|
|
7
|
+
import { ChainId, CloseStrategyType, OrderType, RatioState } from '../types/enums';
|
|
7
8
|
import type { EthereumAddress, SubData } from '../types';
|
|
8
9
|
|
|
9
10
|
import '../configuration';
|
|
10
|
-
import
|
|
11
|
-
aaveV2LeverageManagementSubData,
|
|
12
|
-
aaveV3LeverageManagementSubData,
|
|
13
|
-
aaveV3QuotePriceSubData,
|
|
14
|
-
cBondsRebondSubData,
|
|
15
|
-
compoundV2LeverageManagementSubData,
|
|
16
|
-
compoundV3LeverageManagementSubData,
|
|
17
|
-
exchangeDcaSubData,
|
|
18
|
-
exchangeLimitOrderSubData,
|
|
19
|
-
liquityCloseSubData,
|
|
20
|
-
liquityDebtInFrontRepaySubData,
|
|
21
|
-
liquityDsrPaybackSubData,
|
|
22
|
-
liquityDsrSupplySubData,
|
|
23
|
-
liquityLeverageManagementSubData,
|
|
24
|
-
liquityPaybackUsingChickenBondSubData,
|
|
25
|
-
liquityRepayFromSavingsSubData,
|
|
26
|
-
makerCloseSubData,
|
|
27
|
-
makerLeverageManagementSubData,
|
|
28
|
-
makerRepayFromSavingsSubData,
|
|
29
|
-
morphoAaveV2LeverageManagementSubData,
|
|
30
|
-
sparkLeverageManagementSubData,
|
|
31
|
-
sparkQuotePriceSubData,
|
|
32
|
-
crvUSDLeverageManagementSubData,
|
|
33
|
-
compoundV3L2LeverageManagementSubData, morphoBlueLeverageManagementSubData, crvUSDPaybackSubData,
|
|
34
|
-
aaveV3LeverageManagementOnPriceSubData,
|
|
35
|
-
} from './subDataService';
|
|
36
|
-
import { AAVE_V3_VARIABLE_BORROW_RATE } from '../constants';
|
|
11
|
+
import * as subDataService from './subDataService';
|
|
37
12
|
|
|
38
13
|
describe('Feature: subDataService.ts', () => {
|
|
39
14
|
|
|
@@ -51,7 +26,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
51
26
|
|
|
52
27
|
examples.forEach(([expected, actual]) => {
|
|
53
28
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
54
|
-
expect(makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
|
|
29
|
+
expect(subDataService.makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
|
|
55
30
|
});
|
|
56
31
|
});
|
|
57
32
|
});
|
|
@@ -74,7 +49,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
74
49
|
|
|
75
50
|
examples.forEach(([expected, actual]) => {
|
|
76
51
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
77
|
-
expect(makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
52
|
+
expect(subDataService.makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
78
53
|
});
|
|
79
54
|
});
|
|
80
55
|
});
|
|
@@ -94,7 +69,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
94
69
|
|
|
95
70
|
examples.forEach(([expected, actual]) => {
|
|
96
71
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
97
|
-
expect(liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
72
|
+
expect(subDataService.liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
98
73
|
});
|
|
99
74
|
});
|
|
100
75
|
});
|
|
@@ -121,7 +96,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
121
96
|
|
|
122
97
|
examples.forEach(([expected, actual]) => {
|
|
123
98
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
124
|
-
expect(makerCloseSubData.encode(...actual)).to.eql(expected);
|
|
99
|
+
expect(subDataService.makerCloseSubData.encode(...actual)).to.eql(expected);
|
|
125
100
|
});
|
|
126
101
|
});
|
|
127
102
|
});
|
|
@@ -152,7 +127,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
152
127
|
|
|
153
128
|
examples.forEach(([expected, actual]) => {
|
|
154
129
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
155
|
-
expect(makerCloseSubData.decode(actual)).to.eql(expected);
|
|
130
|
+
expect(subDataService.makerCloseSubData.decode(actual)).to.eql(expected);
|
|
156
131
|
});
|
|
157
132
|
});
|
|
158
133
|
});
|
|
@@ -172,7 +147,67 @@ describe('Feature: subDataService.ts', () => {
|
|
|
172
147
|
|
|
173
148
|
examples.forEach(([expected, actual]) => {
|
|
174
149
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
175
|
-
expect(makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
150
|
+
expect(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('When testing subDataService.makerLeverageManagementWithoutSubProxy', () => {
|
|
157
|
+
describe('encode()', () => {
|
|
158
|
+
const examples: Array<[SubData, [vaultId: number, targetRatio: number, daiAddr?: EthereumAddress]]> = [
|
|
159
|
+
[
|
|
160
|
+
[
|
|
161
|
+
'0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
162
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
163
|
+
],
|
|
164
|
+
[222, 180], // Uses default DAI address
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
[
|
|
168
|
+
'0x000000000000000000000000000000000000000000000000000000000000014d', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
169
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
170
|
+
],
|
|
171
|
+
[333, 200, web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address)], // Custom address
|
|
172
|
+
],
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
examples.forEach(([expected, actual]) => {
|
|
176
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
177
|
+
expect(subDataService.makerLeverageManagementWithoutSubProxy.encode(...actual)).to.eql(expected);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe('decode()', () => {
|
|
183
|
+
const examples: Array<[{ vaultId: number, targetRatio: number, daiAddr: string }, SubData]> = [
|
|
184
|
+
[
|
|
185
|
+
{
|
|
186
|
+
vaultId: 222,
|
|
187
|
+
targetRatio: 180,
|
|
188
|
+
daiAddr: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
189
|
+
},
|
|
190
|
+
[
|
|
191
|
+
'0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
192
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
193
|
+
],
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
{
|
|
197
|
+
vaultId: 333,
|
|
198
|
+
targetRatio: 200,
|
|
199
|
+
daiAddr: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
200
|
+
},
|
|
201
|
+
[
|
|
202
|
+
'0x000000000000000000000000000000000000000000000000000000000000014d', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
203
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
204
|
+
],
|
|
205
|
+
],
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
examples.forEach(([expected, actual]) => {
|
|
209
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
210
|
+
expect(subDataService.makerLeverageManagementWithoutSubProxy.decode(actual)).to.eql(expected);
|
|
176
211
|
});
|
|
177
212
|
});
|
|
178
213
|
});
|
|
@@ -192,7 +227,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
192
227
|
|
|
193
228
|
examples.forEach(([expected, actual]) => {
|
|
194
229
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
195
|
-
expect(liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
230
|
+
expect(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
196
231
|
});
|
|
197
232
|
});
|
|
198
233
|
});
|
|
@@ -217,7 +252,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
217
252
|
|
|
218
253
|
examples.forEach(([expected, actual]) => {
|
|
219
254
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
220
|
-
expect(liquityCloseSubData.encode(...actual)).to.eql(expected);
|
|
255
|
+
expect(subDataService.liquityCloseSubData.encode(...actual)).to.eql(expected);
|
|
221
256
|
});
|
|
222
257
|
});
|
|
223
258
|
});
|
|
@@ -246,7 +281,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
246
281
|
|
|
247
282
|
examples.forEach(([expected, actual]) => {
|
|
248
283
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
249
|
-
expect(liquityCloseSubData.decode(actual)).to.eql(expected);
|
|
284
|
+
expect(subDataService.liquityCloseSubData.decode(actual)).to.eql(expected);
|
|
250
285
|
});
|
|
251
286
|
});
|
|
252
287
|
});
|
|
@@ -267,7 +302,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
267
302
|
|
|
268
303
|
examples.forEach(([expected, actual]) => {
|
|
269
304
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
270
|
-
expect(aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
305
|
+
expect(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
271
306
|
});
|
|
272
307
|
});
|
|
273
308
|
});
|
|
@@ -286,7 +321,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
286
321
|
|
|
287
322
|
examples.forEach(([expected, actual]) => {
|
|
288
323
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
289
|
-
expect(aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
324
|
+
expect(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
290
325
|
});
|
|
291
326
|
});
|
|
292
327
|
});
|
|
@@ -307,7 +342,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
307
342
|
|
|
308
343
|
examples.forEach(([expected, actual]) => {
|
|
309
344
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
310
|
-
expect(aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
345
|
+
expect(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
311
346
|
});
|
|
312
347
|
});
|
|
313
348
|
});
|
|
@@ -346,7 +381,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
346
381
|
|
|
347
382
|
examples.forEach(([expected, actual]) => {
|
|
348
383
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
349
|
-
expect(aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
384
|
+
expect(subDataService.aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
350
385
|
});
|
|
351
386
|
});
|
|
352
387
|
});
|
|
@@ -383,7 +418,277 @@ describe('Feature: subDataService.ts', () => {
|
|
|
383
418
|
|
|
384
419
|
examples.forEach(([expected, actual]) => {
|
|
385
420
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
386
|
-
expect(aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
|
|
421
|
+
expect(subDataService.aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
describe('When testing subDataService.aaveV3CollateralSwitchSubData', () => {
|
|
428
|
+
describe('encode()', () => {
|
|
429
|
+
const examples: Array<[SubData, [fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean]]> = [
|
|
430
|
+
// WETH -> USDC
|
|
431
|
+
[
|
|
432
|
+
[
|
|
433
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
434
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
435
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
436
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
437
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
438
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
439
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
440
|
+
],
|
|
441
|
+
[
|
|
442
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
443
|
+
0,
|
|
444
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
445
|
+
1,
|
|
446
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
447
|
+
'10000000000000000000', // 10 WETH
|
|
448
|
+
false,
|
|
449
|
+
]
|
|
450
|
+
],
|
|
451
|
+
// USDC -> WETH (MaxUint256)
|
|
452
|
+
[
|
|
453
|
+
[
|
|
454
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
455
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
456
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
457
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
458
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
459
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
460
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
461
|
+
],
|
|
462
|
+
[
|
|
463
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
464
|
+
1,
|
|
465
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
466
|
+
0,
|
|
467
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
468
|
+
MAXUINT, // MaxUint256
|
|
469
|
+
]
|
|
470
|
+
],
|
|
471
|
+
// WETH -> WBTC
|
|
472
|
+
[
|
|
473
|
+
[
|
|
474
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
475
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
476
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
477
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
478
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
479
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
480
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
481
|
+
],
|
|
482
|
+
[
|
|
483
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
484
|
+
0,
|
|
485
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
486
|
+
2,
|
|
487
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
488
|
+
'5000000000000000000', // 5 WETH
|
|
489
|
+
]
|
|
490
|
+
],
|
|
491
|
+
];
|
|
492
|
+
|
|
493
|
+
examples.forEach(([expected, actual]) => {
|
|
494
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
495
|
+
expect(subDataService.aaveV3CollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
describe('decode()', () => {
|
|
501
|
+
const examples: Array<[{ fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string }, SubData]> = [
|
|
502
|
+
// WETH -> USDC
|
|
503
|
+
[
|
|
504
|
+
{
|
|
505
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
506
|
+
fromAssetId: 0,
|
|
507
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
508
|
+
toAssetId: 1,
|
|
509
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
510
|
+
amountToSwitch: '10000000000000000000',
|
|
511
|
+
},
|
|
512
|
+
[
|
|
513
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
514
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
515
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
516
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
517
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
518
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
519
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
520
|
+
],
|
|
521
|
+
],
|
|
522
|
+
// USDC -> WETH (MaxUint256)
|
|
523
|
+
[
|
|
524
|
+
{
|
|
525
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
526
|
+
fromAssetId: 1,
|
|
527
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
528
|
+
toAssetId: 0,
|
|
529
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
530
|
+
amountToSwitch: MAXUINT,
|
|
531
|
+
},
|
|
532
|
+
[
|
|
533
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
534
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
535
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
536
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
537
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
538
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
539
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
540
|
+
],
|
|
541
|
+
],
|
|
542
|
+
// WETH -> WBTC
|
|
543
|
+
[
|
|
544
|
+
{
|
|
545
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
546
|
+
fromAssetId: 0,
|
|
547
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
548
|
+
toAssetId: 2,
|
|
549
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
550
|
+
amountToSwitch: '5000000000000000000',
|
|
551
|
+
},
|
|
552
|
+
[
|
|
553
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
554
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
555
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
556
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
557
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
558
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
559
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
560
|
+
],
|
|
561
|
+
],
|
|
562
|
+
];
|
|
563
|
+
|
|
564
|
+
examples.forEach(([expected, actual]) => {
|
|
565
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
566
|
+
expect(subDataService.aaveV3CollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
describe('When testing subDataService.sparkCollateralSwitchSubData', () => {
|
|
573
|
+
describe('encode()', () => {
|
|
574
|
+
const examples: Array<[SubData, [fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean]]> = [
|
|
575
|
+
// WETH -> cbBTC
|
|
576
|
+
[
|
|
577
|
+
[
|
|
578
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
579
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
580
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
581
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
582
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
583
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
584
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
585
|
+
],
|
|
586
|
+
[
|
|
587
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
588
|
+
0,
|
|
589
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
590
|
+
7,
|
|
591
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
592
|
+
'10000000000000000000', // 10 WETH
|
|
593
|
+
false,
|
|
594
|
+
]
|
|
595
|
+
],
|
|
596
|
+
// cbBTC -> WETH (MaxUint256)
|
|
597
|
+
[
|
|
598
|
+
[
|
|
599
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
600
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
601
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
602
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
603
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
604
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
605
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
606
|
+
],
|
|
607
|
+
[
|
|
608
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
609
|
+
7,
|
|
610
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
611
|
+
0,
|
|
612
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
613
|
+
MAXUINT,
|
|
614
|
+
]
|
|
615
|
+
],
|
|
616
|
+
// WETH -> cbBTC (5 WETH)
|
|
617
|
+
[
|
|
618
|
+
[
|
|
619
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
620
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
621
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
622
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
623
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
624
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
625
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
626
|
+
],
|
|
627
|
+
[
|
|
628
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
629
|
+
0,
|
|
630
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
631
|
+
7,
|
|
632
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
633
|
+
'5000000000000000000', // 5 WETH
|
|
634
|
+
]
|
|
635
|
+
],
|
|
636
|
+
];
|
|
637
|
+
|
|
638
|
+
examples.forEach(([expected, actual]) => {
|
|
639
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
640
|
+
expect(subDataService.sparkCollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
describe('decode()', () => {
|
|
646
|
+
const examples: Array<[{ fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string }, SubData]> = [
|
|
647
|
+
// WETH -> cbBTC
|
|
648
|
+
[
|
|
649
|
+
{
|
|
650
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
651
|
+
fromAssetId: 0,
|
|
652
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
653
|
+
toAssetId: 7,
|
|
654
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
655
|
+
amountToSwitch: '10000000000000000000',
|
|
656
|
+
},
|
|
657
|
+
[
|
|
658
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
659
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
660
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
661
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
662
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
663
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
664
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
665
|
+
],
|
|
666
|
+
],
|
|
667
|
+
// cbBTC -> WETH (MaxUint256)
|
|
668
|
+
[
|
|
669
|
+
{
|
|
670
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
671
|
+
fromAssetId: 7,
|
|
672
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
673
|
+
toAssetId: 0,
|
|
674
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
675
|
+
amountToSwitch: MAXUINT,
|
|
676
|
+
},
|
|
677
|
+
[
|
|
678
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
679
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
680
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
681
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
682
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
683
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
684
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
685
|
+
],
|
|
686
|
+
],
|
|
687
|
+
];
|
|
688
|
+
|
|
689
|
+
examples.forEach(([expected, actual]) => {
|
|
690
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
691
|
+
expect(subDataService.sparkCollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
387
692
|
});
|
|
388
693
|
});
|
|
389
694
|
});
|
|
@@ -404,7 +709,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
404
709
|
|
|
405
710
|
examples.forEach(([expected, actual]) => {
|
|
406
711
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
407
|
-
expect(compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
712
|
+
expect(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
408
713
|
});
|
|
409
714
|
});
|
|
410
715
|
});
|
|
@@ -423,7 +728,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
423
728
|
|
|
424
729
|
examples.forEach(([expected, actual]) => {
|
|
425
730
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
426
|
-
expect(compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
731
|
+
expect(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
427
732
|
});
|
|
428
733
|
});
|
|
429
734
|
});
|
|
@@ -470,7 +775,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
470
775
|
|
|
471
776
|
examples.forEach(([expected, actual]) => {
|
|
472
777
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
473
|
-
expect(compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
778
|
+
expect(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
474
779
|
});
|
|
475
780
|
});
|
|
476
781
|
});
|
|
@@ -495,7 +800,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
495
800
|
|
|
496
801
|
examples.forEach(([expected, actual]) => {
|
|
497
802
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
498
|
-
expect(compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
803
|
+
expect(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
499
804
|
});
|
|
500
805
|
});
|
|
501
806
|
});
|
|
@@ -516,7 +821,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
516
821
|
|
|
517
822
|
examples.forEach(([expected, actual]) => {
|
|
518
823
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
519
|
-
expect(morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
824
|
+
expect(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
520
825
|
});
|
|
521
826
|
});
|
|
522
827
|
});
|
|
@@ -535,7 +840,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
535
840
|
|
|
536
841
|
examples.forEach(([expected, actual]) => {
|
|
537
842
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
538
|
-
expect(morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
843
|
+
expect(subDataService.morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
539
844
|
});
|
|
540
845
|
});
|
|
541
846
|
});
|
|
@@ -556,7 +861,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
556
861
|
|
|
557
862
|
examples.forEach(([expected, actual]) => {
|
|
558
863
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
559
|
-
expect(cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
864
|
+
expect(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
560
865
|
});
|
|
561
866
|
});
|
|
562
867
|
});
|
|
@@ -575,7 +880,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
575
880
|
|
|
576
881
|
examples.forEach(([expected, actual]) => {
|
|
577
882
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
578
|
-
expect(cBondsRebondSubData.decode(actual)).to.eql(expected);
|
|
883
|
+
expect(subDataService.cBondsRebondSubData.decode(actual)).to.eql(expected);
|
|
579
884
|
});
|
|
580
885
|
});
|
|
581
886
|
});
|
|
@@ -602,7 +907,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
602
907
|
|
|
603
908
|
examples.forEach(([expected, actual]) => {
|
|
604
909
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
605
|
-
expect(liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
|
|
910
|
+
expect(subDataService.liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
|
|
606
911
|
});
|
|
607
912
|
});
|
|
608
913
|
});
|
|
@@ -627,7 +932,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
627
932
|
|
|
628
933
|
examples.forEach(([expected, actual]) => {
|
|
629
934
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
630
|
-
expect(liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
|
|
935
|
+
expect(subDataService.liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
|
|
631
936
|
});
|
|
632
937
|
});
|
|
633
938
|
});
|
|
@@ -664,7 +969,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
664
969
|
|
|
665
970
|
examples.forEach(([expected, actual]) => {
|
|
666
971
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
667
|
-
expect(exchangeDcaSubData.encode(...actual)).to.eql(expected);
|
|
972
|
+
expect(subDataService.exchangeDcaSubData.encode(...actual)).to.eql(expected);
|
|
668
973
|
});
|
|
669
974
|
});
|
|
670
975
|
});
|
|
@@ -705,7 +1010,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
705
1010
|
|
|
706
1011
|
examples.forEach(([expected, actual]) => {
|
|
707
1012
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
708
|
-
expect(exchangeDcaSubData.decode(...actual)).to.eql(expected);
|
|
1013
|
+
expect(subDataService.exchangeDcaSubData.decode(...actual)).to.eql(expected);
|
|
709
1014
|
});
|
|
710
1015
|
});
|
|
711
1016
|
});
|
|
@@ -754,7 +1059,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
754
1059
|
|
|
755
1060
|
examples.forEach(([expected, actual]) => {
|
|
756
1061
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
757
|
-
expect(exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
1062
|
+
expect(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
758
1063
|
});
|
|
759
1064
|
});
|
|
760
1065
|
});
|
|
@@ -793,7 +1098,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
793
1098
|
|
|
794
1099
|
examples.forEach(([expected, actual]) => {
|
|
795
1100
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
796
|
-
expect(exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
1101
|
+
expect(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
797
1102
|
});
|
|
798
1103
|
});
|
|
799
1104
|
});
|
|
@@ -814,145 +1119,69 @@ describe('Feature: subDataService.ts', () => {
|
|
|
814
1119
|
|
|
815
1120
|
examples.forEach(([expected, actual]) => {
|
|
816
1121
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
817
|
-
expect(sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1122
|
+
expect(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
818
1123
|
});
|
|
819
1124
|
});
|
|
820
1125
|
});
|
|
821
1126
|
});
|
|
822
1127
|
|
|
823
|
-
describe('When testing subDataService.
|
|
1128
|
+
describe('When testing subDataService.liquityDsrPaybackSubData', () => {
|
|
824
1129
|
describe('encode()', () => {
|
|
825
|
-
const examples: Array<[SubData, [
|
|
1130
|
+
const examples: Array<[SubData, [targetRatio: number]]> = [
|
|
826
1131
|
[
|
|
827
1132
|
[
|
|
828
|
-
'
|
|
829
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '
|
|
830
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1133
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1134
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
831
1135
|
],
|
|
832
|
-
[
|
|
833
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
834
|
-
2,
|
|
835
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
836
|
-
4,
|
|
837
|
-
]
|
|
1136
|
+
[123]
|
|
838
1137
|
],
|
|
839
1138
|
[
|
|
840
1139
|
[
|
|
841
|
-
'
|
|
842
|
-
'
|
|
843
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1140
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
1141
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
844
1142
|
],
|
|
845
|
-
[
|
|
846
|
-
web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
847
|
-
6,
|
|
848
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
849
|
-
2,
|
|
850
|
-
]
|
|
1143
|
+
[420]
|
|
851
1144
|
],
|
|
852
1145
|
];
|
|
853
1146
|
|
|
854
1147
|
examples.forEach(([expected, actual]) => {
|
|
855
1148
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
856
|
-
expect(
|
|
1149
|
+
expect(subDataService.liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
|
|
857
1150
|
});
|
|
858
1151
|
});
|
|
859
1152
|
});
|
|
860
1153
|
|
|
861
1154
|
describe('decode()', () => {
|
|
862
|
-
const examples: Array<[{
|
|
1155
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
863
1156
|
[
|
|
864
1157
|
{
|
|
865
|
-
|
|
866
|
-
collAssetId: 2,
|
|
867
|
-
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
868
|
-
debtAssetId: 4,
|
|
1158
|
+
targetRatio: 123,
|
|
869
1159
|
},
|
|
870
1160
|
[
|
|
871
|
-
'
|
|
872
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '
|
|
873
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1161
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1162
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
874
1163
|
],
|
|
875
1164
|
],
|
|
876
1165
|
[
|
|
877
1166
|
{
|
|
878
|
-
|
|
879
|
-
collAssetId: 6,
|
|
880
|
-
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
881
|
-
debtAssetId: 2,
|
|
1167
|
+
targetRatio: 420,
|
|
882
1168
|
},
|
|
883
1169
|
[
|
|
884
|
-
'
|
|
885
|
-
'
|
|
886
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1170
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
1171
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
887
1172
|
],
|
|
888
1173
|
],
|
|
889
1174
|
];
|
|
890
1175
|
|
|
891
1176
|
examples.forEach(([expected, actual]) => {
|
|
892
1177
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
893
|
-
expect(
|
|
1178
|
+
expect(subDataService.liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
|
|
894
1179
|
});
|
|
895
1180
|
});
|
|
896
1181
|
});
|
|
897
1182
|
});
|
|
898
1183
|
|
|
899
|
-
describe('When testing subDataService.
|
|
900
|
-
describe('encode()', () => {
|
|
901
|
-
const examples: Array<[SubData, [targetRatio: number]]> = [
|
|
902
|
-
[
|
|
903
|
-
[
|
|
904
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
905
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
906
|
-
],
|
|
907
|
-
[123]
|
|
908
|
-
],
|
|
909
|
-
[
|
|
910
|
-
[
|
|
911
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
912
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
913
|
-
],
|
|
914
|
-
[420]
|
|
915
|
-
],
|
|
916
|
-
];
|
|
917
|
-
|
|
918
|
-
examples.forEach(([expected, actual]) => {
|
|
919
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
920
|
-
expect(liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
|
|
921
|
-
});
|
|
922
|
-
});
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
describe('decode()', () => {
|
|
926
|
-
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
927
|
-
[
|
|
928
|
-
{
|
|
929
|
-
targetRatio: 123,
|
|
930
|
-
},
|
|
931
|
-
[
|
|
932
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
933
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
934
|
-
],
|
|
935
|
-
],
|
|
936
|
-
[
|
|
937
|
-
{
|
|
938
|
-
targetRatio: 420,
|
|
939
|
-
},
|
|
940
|
-
[
|
|
941
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
942
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
943
|
-
],
|
|
944
|
-
],
|
|
945
|
-
];
|
|
946
|
-
|
|
947
|
-
examples.forEach(([expected, actual]) => {
|
|
948
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
949
|
-
expect(liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
|
|
950
|
-
});
|
|
951
|
-
});
|
|
952
|
-
});
|
|
953
|
-
});
|
|
954
|
-
|
|
955
|
-
describe('When testing subDataService.liquityDsrSupplySubData', () => {
|
|
1184
|
+
describe('When testing subDataService.liquityDsrSupplySubData', () => {
|
|
956
1185
|
describe('encode()', () => {
|
|
957
1186
|
const examples: Array<[SubData, [targetRatio: number]]> = [
|
|
958
1187
|
[
|
|
@@ -973,7 +1202,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
973
1202
|
|
|
974
1203
|
examples.forEach(([expected, actual]) => {
|
|
975
1204
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
976
|
-
expect(liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
|
|
1205
|
+
expect(subDataService.liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
|
|
977
1206
|
});
|
|
978
1207
|
});
|
|
979
1208
|
});
|
|
@@ -1002,7 +1231,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1002
1231
|
|
|
1003
1232
|
examples.forEach(([expected, actual]) => {
|
|
1004
1233
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1005
|
-
expect(liquityDsrSupplySubData.decode(actual)).to.eql(expected);
|
|
1234
|
+
expect(subDataService.liquityDsrSupplySubData.decode(actual)).to.eql(expected);
|
|
1006
1235
|
});
|
|
1007
1236
|
});
|
|
1008
1237
|
});
|
|
@@ -1031,7 +1260,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1031
1260
|
|
|
1032
1261
|
examples.forEach(([expected, actual]) => {
|
|
1033
1262
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1034
|
-
expect(liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
|
|
1263
|
+
expect(subDataService.liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
|
|
1035
1264
|
});
|
|
1036
1265
|
});
|
|
1037
1266
|
});
|
|
@@ -1062,7 +1291,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1062
1291
|
|
|
1063
1292
|
examples.forEach(([expected, actual]) => {
|
|
1064
1293
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1065
|
-
expect(liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
|
|
1294
|
+
expect(subDataService.liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
|
|
1066
1295
|
});
|
|
1067
1296
|
});
|
|
1068
1297
|
});
|
|
@@ -1094,7 +1323,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1094
1323
|
];
|
|
1095
1324
|
examples.forEach(([expected, actual]) => {
|
|
1096
1325
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1097
|
-
expect(crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1326
|
+
expect(subDataService.crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1098
1327
|
});
|
|
1099
1328
|
});
|
|
1100
1329
|
});
|
|
@@ -1121,7 +1350,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1121
1350
|
|
|
1122
1351
|
examples.forEach(([expected, actual]) => {
|
|
1123
1352
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1124
|
-
expect(crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1353
|
+
expect(subDataService.crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1125
1354
|
});
|
|
1126
1355
|
});
|
|
1127
1356
|
});
|
|
@@ -1143,7 +1372,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1143
1372
|
];
|
|
1144
1373
|
examples.forEach(([expected, actual]) => {
|
|
1145
1374
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1146
|
-
expect(crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
|
|
1375
|
+
expect(subDataService.crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
|
|
1147
1376
|
});
|
|
1148
1377
|
});
|
|
1149
1378
|
});
|
|
@@ -1173,7 +1402,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1173
1402
|
|
|
1174
1403
|
examples.forEach(([expected, actual]) => {
|
|
1175
1404
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1176
|
-
expect(crvUSDPaybackSubData.decode(actual)).to.eql(expected);
|
|
1405
|
+
expect(subDataService.crvUSDPaybackSubData.decode(actual)).to.eql(expected);
|
|
1177
1406
|
});
|
|
1178
1407
|
});
|
|
1179
1408
|
});
|
|
@@ -1183,21 +1412,21 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1183
1412
|
describe('encode()', () => {
|
|
1184
1413
|
const examples: Array<[
|
|
1185
1414
|
string,
|
|
1186
|
-
[market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean],
|
|
1415
|
+
[market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean],
|
|
1187
1416
|
]> = [
|
|
1188
1417
|
[
|
|
1189
|
-
'
|
|
1190
|
-
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true]
|
|
1418
|
+
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1419
|
+
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true, false]
|
|
1191
1420
|
],
|
|
1192
1421
|
[
|
|
1193
|
-
'
|
|
1194
|
-
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false]
|
|
1422
|
+
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1423
|
+
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false, false]
|
|
1195
1424
|
],
|
|
1196
1425
|
];
|
|
1197
1426
|
|
|
1198
1427
|
examples.forEach(([expected, actual]) => {
|
|
1199
1428
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1200
|
-
expect(compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1429
|
+
expect(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1201
1430
|
});
|
|
1202
1431
|
});
|
|
1203
1432
|
});
|
|
@@ -1221,7 +1450,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1221
1450
|
|
|
1222
1451
|
examples.forEach(([expected, actual]) => {
|
|
1223
1452
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1224
|
-
expect(compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1453
|
+
expect(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1225
1454
|
});
|
|
1226
1455
|
});
|
|
1227
1456
|
});
|
|
@@ -1265,7 +1494,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1265
1494
|
|
|
1266
1495
|
examples.forEach(([expected, actual]) => {
|
|
1267
1496
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1268
|
-
expect(morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1497
|
+
expect(subDataService.morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1269
1498
|
});
|
|
1270
1499
|
});
|
|
1271
1500
|
});
|
|
@@ -1318,7 +1547,66 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1318
1547
|
|
|
1319
1548
|
examples.forEach(([expected, actual]) => {
|
|
1320
1549
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1321
|
-
expect(morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1550
|
+
expect(subDataService.morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1551
|
+
});
|
|
1552
|
+
});
|
|
1553
|
+
});
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1556
|
+
describe('When testing subDataService.morphoBlueCloseOnPriceSubData', () => {
|
|
1557
|
+
describe('encode()', () => {
|
|
1558
|
+
const examples: Array<[
|
|
1559
|
+
SubData,
|
|
1560
|
+
[loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, closeType: CloseStrategyType],
|
|
1561
|
+
]> = [
|
|
1562
|
+
[
|
|
1563
|
+
[
|
|
1564
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1565
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1566
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1567
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1568
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1569
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1570
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1571
|
+
],
|
|
1572
|
+
[web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'), '945000000000000000', web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT]
|
|
1573
|
+
],
|
|
1574
|
+
];
|
|
1575
|
+
|
|
1576
|
+
examples.forEach(([expected, actual]) => {
|
|
1577
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1578
|
+
expect(subDataService.morphoBlueCloseOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1579
|
+
});
|
|
1580
|
+
});
|
|
1581
|
+
});
|
|
1582
|
+
|
|
1583
|
+
describe('decode()', () => {
|
|
1584
|
+
const examples: Array<[{ loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, closeType: CloseStrategyType }, SubData]> = [
|
|
1585
|
+
[
|
|
1586
|
+
{
|
|
1587
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1588
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1589
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1590
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1591
|
+
lltv: '945000000000000000',
|
|
1592
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1593
|
+
closeType: CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1594
|
+
},
|
|
1595
|
+
[
|
|
1596
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1597
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1598
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1599
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1600
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1601
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1602
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1603
|
+
],
|
|
1604
|
+
],
|
|
1605
|
+
];
|
|
1606
|
+
|
|
1607
|
+
examples.forEach(([expected, actual]) => {
|
|
1608
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1609
|
+
expect(subDataService.morphoBlueCloseOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1322
1610
|
});
|
|
1323
1611
|
});
|
|
1324
1612
|
});
|
|
@@ -1350,7 +1638,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1350
1638
|
|
|
1351
1639
|
examples.forEach(([expected, actual]) => {
|
|
1352
1640
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1353
|
-
expect(aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1641
|
+
expect(subDataService.aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1354
1642
|
});
|
|
1355
1643
|
});
|
|
1356
1644
|
});
|
|
@@ -1379,7 +1667,962 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1379
1667
|
|
|
1380
1668
|
examples.forEach(([expected, actual]) => {
|
|
1381
1669
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1382
|
-
expect(aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1670
|
+
expect(subDataService.aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1671
|
+
});
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1674
|
+
});
|
|
1675
|
+
|
|
1676
|
+
describe('When testing subDataService.compoundV3LeverageManagementOnPriceSubData', () => {
|
|
1677
|
+
describe('encode()', () => {
|
|
1678
|
+
const examples: Array<[string[], [market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState, user: EthereumAddress]]> = [
|
|
1679
|
+
[
|
|
1680
|
+
[
|
|
1681
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1682
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1683
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1684
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1685
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1686
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1687
|
+
],
|
|
1688
|
+
[
|
|
1689
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1690
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1691
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1692
|
+
200,
|
|
1693
|
+
RatioState.UNDER,
|
|
1694
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1695
|
+
]
|
|
1696
|
+
],
|
|
1697
|
+
[
|
|
1698
|
+
[
|
|
1699
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1700
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1701
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1702
|
+
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
|
|
1703
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1704
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c'
|
|
1705
|
+
],
|
|
1706
|
+
[
|
|
1707
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1708
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1709
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1710
|
+
190,
|
|
1711
|
+
RatioState.OVER,
|
|
1712
|
+
web3Utils.toChecksumAddress('0x0043d218133afab8f2b829b106633e434ad94e2c')
|
|
1713
|
+
]
|
|
1714
|
+
],
|
|
1715
|
+
];
|
|
1716
|
+
|
|
1717
|
+
examples.forEach(([expected, actual]) => {
|
|
1718
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1719
|
+
expect(subDataService.compoundV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1720
|
+
});
|
|
1721
|
+
});
|
|
1722
|
+
});
|
|
1723
|
+
|
|
1724
|
+
describe('decode()', () => {
|
|
1725
|
+
const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState, owner: EthereumAddress }, string[]]> = [
|
|
1726
|
+
[
|
|
1727
|
+
{
|
|
1728
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1729
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1730
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1731
|
+
targetRatio: 200,
|
|
1732
|
+
ratioState: RatioState.UNDER,
|
|
1733
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1734
|
+
},
|
|
1735
|
+
[
|
|
1736
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1737
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1738
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1739
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1740
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1741
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1742
|
+
]
|
|
1743
|
+
],
|
|
1744
|
+
[
|
|
1745
|
+
{
|
|
1746
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1747
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1748
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1749
|
+
targetRatio: 190,
|
|
1750
|
+
ratioState: RatioState.OVER,
|
|
1751
|
+
owner: web3Utils.toChecksumAddress('0x0043d218133afab8f2b829b106633e434ad94e2c')
|
|
1752
|
+
},
|
|
1753
|
+
[
|
|
1754
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1755
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1756
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1757
|
+
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
|
|
1758
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1759
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c'
|
|
1760
|
+
]
|
|
1761
|
+
],
|
|
1762
|
+
];
|
|
1763
|
+
|
|
1764
|
+
examples.forEach(([expected, actual]) => {
|
|
1765
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1766
|
+
expect(subDataService.compoundV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1767
|
+
});
|
|
1768
|
+
});
|
|
1769
|
+
});
|
|
1770
|
+
});
|
|
1771
|
+
|
|
1772
|
+
describe('When testing subDataService.compoundV3CloseSubData', () => {
|
|
1773
|
+
describe('encode()', () => {
|
|
1774
|
+
const examples: Array<[string[], [market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, closeType: CloseStrategyType, user: EthereumAddress]]> = [
|
|
1775
|
+
[
|
|
1776
|
+
[
|
|
1777
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1778
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1779
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1780
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1781
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1782
|
+
],
|
|
1783
|
+
[
|
|
1784
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1785
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1786
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1787
|
+
CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1788
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c'),
|
|
1789
|
+
]
|
|
1790
|
+
],
|
|
1791
|
+
[
|
|
1792
|
+
[
|
|
1793
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1794
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1795
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1796
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1797
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1798
|
+
],
|
|
1799
|
+
[
|
|
1800
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1801
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1802
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1803
|
+
CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1804
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c'),
|
|
1805
|
+
]
|
|
1806
|
+
],
|
|
1807
|
+
];
|
|
1808
|
+
|
|
1809
|
+
examples.forEach(([expected, actual]) => {
|
|
1810
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1811
|
+
expect(subDataService.compoundV3CloseSubData.encode(...actual)).to.eql(expected);
|
|
1812
|
+
});
|
|
1813
|
+
});
|
|
1814
|
+
});
|
|
1815
|
+
|
|
1816
|
+
describe('decode()', () => {
|
|
1817
|
+
const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, closeType: CloseStrategyType, owner: EthereumAddress }, string[]]> = [
|
|
1818
|
+
[
|
|
1819
|
+
{
|
|
1820
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1821
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1822
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1823
|
+
closeType: CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1824
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1825
|
+
},
|
|
1826
|
+
[
|
|
1827
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1828
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1829
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1830
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1831
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1832
|
+
]
|
|
1833
|
+
],
|
|
1834
|
+
[
|
|
1835
|
+
{
|
|
1836
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1837
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1838
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1839
|
+
closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1840
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1841
|
+
},
|
|
1842
|
+
[
|
|
1843
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1844
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1845
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1846
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1847
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1848
|
+
]
|
|
1849
|
+
],
|
|
1850
|
+
];
|
|
1851
|
+
|
|
1852
|
+
examples.forEach(([expected, actual]) => {
|
|
1853
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1854
|
+
expect(subDataService.compoundV3CloseSubData.decode(actual)).to.eql(expected);
|
|
1855
|
+
});
|
|
1856
|
+
});
|
|
1857
|
+
});
|
|
1858
|
+
});
|
|
1859
|
+
|
|
1860
|
+
describe("When testing subDataService.aaveV3LeverageManagementOnPriceGeneric", () => {
|
|
1861
|
+
describe("encode()", () => {
|
|
1862
|
+
const examples: Array<
|
|
1863
|
+
[
|
|
1864
|
+
string[],
|
|
1865
|
+
[
|
|
1866
|
+
collAsset: EthereumAddress,
|
|
1867
|
+
collAssetId: number,
|
|
1868
|
+
debtAsset: EthereumAddress,
|
|
1869
|
+
debtAssetId: number,
|
|
1870
|
+
marketAddr: EthereumAddress,
|
|
1871
|
+
targetRatio: number,
|
|
1872
|
+
owner: EthereumAddress
|
|
1873
|
+
]
|
|
1874
|
+
]
|
|
1875
|
+
> = [
|
|
1876
|
+
[
|
|
1877
|
+
[
|
|
1878
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1879
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1880
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1881
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1882
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1883
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1884
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1885
|
+
],
|
|
1886
|
+
[
|
|
1887
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1888
|
+
0,
|
|
1889
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1890
|
+
1,
|
|
1891
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1892
|
+
200,
|
|
1893
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1894
|
+
]
|
|
1895
|
+
],
|
|
1896
|
+
[
|
|
1897
|
+
[
|
|
1898
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1899
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1900
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1901
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1902
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1903
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1904
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1905
|
+
],
|
|
1906
|
+
[
|
|
1907
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1908
|
+
2,
|
|
1909
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1910
|
+
1,
|
|
1911
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1912
|
+
200,
|
|
1913
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1914
|
+
]
|
|
1915
|
+
],
|
|
1916
|
+
];
|
|
1917
|
+
|
|
1918
|
+
examples.forEach(([expected, actual]) => {
|
|
1919
|
+
it(`Given ${JSON.stringify(
|
|
1920
|
+
actual
|
|
1921
|
+
)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1922
|
+
expect(
|
|
1923
|
+
subDataService.aaveV3LeverageManagementOnPriceGeneric.encode(...actual)
|
|
1924
|
+
).to.eql(expected);
|
|
1925
|
+
});
|
|
1926
|
+
});
|
|
1927
|
+
});
|
|
1928
|
+
|
|
1929
|
+
describe("decode()", () => {
|
|
1930
|
+
const examples: Array<
|
|
1931
|
+
[
|
|
1932
|
+
{
|
|
1933
|
+
collAsset: EthereumAddress,
|
|
1934
|
+
collAssetId: number,
|
|
1935
|
+
debtAsset: EthereumAddress,
|
|
1936
|
+
debtAssetId: number,
|
|
1937
|
+
marketAddr: EthereumAddress,
|
|
1938
|
+
targetRatio: number,
|
|
1939
|
+
owner: EthereumAddress,
|
|
1940
|
+
},
|
|
1941
|
+
string[]
|
|
1942
|
+
]
|
|
1943
|
+
> = [
|
|
1944
|
+
[
|
|
1945
|
+
{
|
|
1946
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1947
|
+
collAssetId: 0,
|
|
1948
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1949
|
+
debtAssetId: 1,
|
|
1950
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1951
|
+
targetRatio: 200,
|
|
1952
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1953
|
+
},
|
|
1954
|
+
[
|
|
1955
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1956
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1957
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1958
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1959
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1960
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1961
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1962
|
+
]
|
|
1963
|
+
],
|
|
1964
|
+
[
|
|
1965
|
+
{
|
|
1966
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1967
|
+
collAssetId: 2,
|
|
1968
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1969
|
+
debtAssetId: 1,
|
|
1970
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1971
|
+
targetRatio: 200,
|
|
1972
|
+
owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1973
|
+
},
|
|
1974
|
+
[
|
|
1975
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1976
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1977
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1978
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1979
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1980
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1981
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1982
|
+
]
|
|
1983
|
+
],
|
|
1984
|
+
];
|
|
1985
|
+
|
|
1986
|
+
examples.forEach(([expected, actual]) => {
|
|
1987
|
+
it(`Given ${JSON.stringify(
|
|
1988
|
+
actual
|
|
1989
|
+
)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1990
|
+
expect(
|
|
1991
|
+
subDataService.aaveV3LeverageManagementOnPriceGeneric.decode(actual)
|
|
1992
|
+
).to.eql(expected);
|
|
1993
|
+
});
|
|
1994
|
+
});
|
|
1995
|
+
});
|
|
1996
|
+
});
|
|
1997
|
+
|
|
1998
|
+
describe("When testing subDataService.aaveV3CloseGenericSubData", () => {
|
|
1999
|
+
describe("encode()", () => {
|
|
2000
|
+
const examples: Array<
|
|
2001
|
+
[
|
|
2002
|
+
string[],
|
|
2003
|
+
[
|
|
2004
|
+
collAsset: EthereumAddress,
|
|
2005
|
+
collAssetId: number,
|
|
2006
|
+
debtAsset: EthereumAddress,
|
|
2007
|
+
debtAssetId: number,
|
|
2008
|
+
closeType: CloseStrategyType,
|
|
2009
|
+
marketAddr: EthereumAddress,
|
|
2010
|
+
owner: EthereumAddress
|
|
2011
|
+
]
|
|
2012
|
+
]
|
|
2013
|
+
> = [
|
|
2014
|
+
// TAKE_PROFIT_IN_COLLATERAL
|
|
2015
|
+
[
|
|
2016
|
+
[
|
|
2017
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2018
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2019
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2020
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2021
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2022
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2023
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2024
|
+
],
|
|
2025
|
+
[
|
|
2026
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2027
|
+
0,
|
|
2028
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2029
|
+
1,
|
|
2030
|
+
CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
2031
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2032
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2033
|
+
]
|
|
2034
|
+
],
|
|
2035
|
+
// STOP_LOSS_IN_COLLATERAL
|
|
2036
|
+
[
|
|
2037
|
+
[
|
|
2038
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2039
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2040
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2041
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2042
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2043
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2044
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2045
|
+
],
|
|
2046
|
+
[
|
|
2047
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2048
|
+
0,
|
|
2049
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2050
|
+
1,
|
|
2051
|
+
CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
2052
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2053
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2054
|
+
]
|
|
2055
|
+
],
|
|
2056
|
+
// TAKE_PROFIT_IN_DEBT
|
|
2057
|
+
[
|
|
2058
|
+
[
|
|
2059
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2060
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2061
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2062
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2063
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2064
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2065
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2066
|
+
],
|
|
2067
|
+
[
|
|
2068
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2069
|
+
0,
|
|
2070
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2071
|
+
1,
|
|
2072
|
+
CloseStrategyType.TAKE_PROFIT_IN_DEBT,
|
|
2073
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2074
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2075
|
+
]
|
|
2076
|
+
],
|
|
2077
|
+
// STOP_LOSS_IN_DEBT
|
|
2078
|
+
[
|
|
2079
|
+
[
|
|
2080
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2081
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2082
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2083
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2084
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
2085
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2086
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2087
|
+
],
|
|
2088
|
+
[
|
|
2089
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2090
|
+
0,
|
|
2091
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2092
|
+
1,
|
|
2093
|
+
CloseStrategyType.STOP_LOSS_IN_DEBT,
|
|
2094
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2095
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2096
|
+
]
|
|
2097
|
+
],
|
|
2098
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL
|
|
2099
|
+
[
|
|
2100
|
+
[
|
|
2101
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2102
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2103
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2104
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2105
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2106
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2107
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2108
|
+
],
|
|
2109
|
+
[
|
|
2110
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2111
|
+
0,
|
|
2112
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2113
|
+
1,
|
|
2114
|
+
CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
2115
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2116
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2117
|
+
]
|
|
2118
|
+
],
|
|
2119
|
+
// TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
|
|
2120
|
+
[
|
|
2121
|
+
[
|
|
2122
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2123
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2124
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2125
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2126
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
2127
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2128
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2129
|
+
],
|
|
2130
|
+
[
|
|
2131
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2132
|
+
2,
|
|
2133
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2134
|
+
1,
|
|
2135
|
+
CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
2136
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2137
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2138
|
+
]
|
|
2139
|
+
],
|
|
2140
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
|
|
2141
|
+
[
|
|
2142
|
+
[
|
|
2143
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2144
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2145
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2146
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2147
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
2148
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2149
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2150
|
+
],
|
|
2151
|
+
[
|
|
2152
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2153
|
+
2,
|
|
2154
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2155
|
+
1,
|
|
2156
|
+
CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
2157
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2158
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2159
|
+
]
|
|
2160
|
+
],
|
|
2161
|
+
// TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
|
|
2162
|
+
[
|
|
2163
|
+
[
|
|
2164
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2165
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2166
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2167
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2168
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
2169
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2170
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2171
|
+
],
|
|
2172
|
+
[
|
|
2173
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2174
|
+
2,
|
|
2175
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2176
|
+
1,
|
|
2177
|
+
CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
2178
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2179
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2180
|
+
]
|
|
2181
|
+
],
|
|
2182
|
+
];
|
|
2183
|
+
|
|
2184
|
+
examples.forEach(([expected, actual]) => {
|
|
2185
|
+
it(`Given ${JSON.stringify(
|
|
2186
|
+
actual
|
|
2187
|
+
)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2188
|
+
expect(
|
|
2189
|
+
subDataService.aaveV3CloseGenericSubData.encode(...actual)
|
|
2190
|
+
).to.eql(expected);
|
|
2191
|
+
});
|
|
2192
|
+
});
|
|
2193
|
+
});
|
|
2194
|
+
|
|
2195
|
+
describe("decode()", () => {
|
|
2196
|
+
const examples: Array<
|
|
2197
|
+
[
|
|
2198
|
+
{
|
|
2199
|
+
collAsset: EthereumAddress,
|
|
2200
|
+
collAssetId: number,
|
|
2201
|
+
debtAsset: EthereumAddress,
|
|
2202
|
+
debtAssetId: number,
|
|
2203
|
+
closeType: CloseStrategyType,
|
|
2204
|
+
marketAddr: EthereumAddress,
|
|
2205
|
+
owner: EthereumAddress,
|
|
2206
|
+
},
|
|
2207
|
+
string[]
|
|
2208
|
+
]
|
|
2209
|
+
> = [
|
|
2210
|
+
// TAKE_PROFIT_IN_COLLATERAL
|
|
2211
|
+
[
|
|
2212
|
+
{
|
|
2213
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2214
|
+
collAssetId: 0,
|
|
2215
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2216
|
+
debtAssetId: 1,
|
|
2217
|
+
closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
2218
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2219
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2220
|
+
},
|
|
2221
|
+
[
|
|
2222
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2223
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2224
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2225
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2226
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2227
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2228
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2229
|
+
]
|
|
2230
|
+
],
|
|
2231
|
+
// STOP_LOSS_IN_COLLATERAL
|
|
2232
|
+
[
|
|
2233
|
+
{
|
|
2234
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2235
|
+
collAssetId: 0,
|
|
2236
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2237
|
+
debtAssetId: 1,
|
|
2238
|
+
closeType: CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
2239
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2240
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2241
|
+
},
|
|
2242
|
+
[
|
|
2243
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2244
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2245
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2246
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2247
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2248
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2249
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2250
|
+
]
|
|
2251
|
+
],
|
|
2252
|
+
// TAKE_PROFIT_IN_DEBT
|
|
2253
|
+
[
|
|
2254
|
+
{
|
|
2255
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2256
|
+
collAssetId: 0,
|
|
2257
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2258
|
+
debtAssetId: 1,
|
|
2259
|
+
closeType: CloseStrategyType.TAKE_PROFIT_IN_DEBT,
|
|
2260
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2261
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2262
|
+
},
|
|
2263
|
+
[
|
|
2264
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2265
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2266
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2267
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2268
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2269
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2270
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2271
|
+
]
|
|
2272
|
+
],
|
|
2273
|
+
// STOP_LOSS_IN_DEBT
|
|
2274
|
+
[
|
|
2275
|
+
{
|
|
2276
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2277
|
+
collAssetId: 0,
|
|
2278
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2279
|
+
debtAssetId: 1,
|
|
2280
|
+
closeType: CloseStrategyType.STOP_LOSS_IN_DEBT,
|
|
2281
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2282
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2283
|
+
},
|
|
2284
|
+
[
|
|
2285
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2286
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2287
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2288
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2289
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
2290
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2291
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2292
|
+
]
|
|
2293
|
+
],
|
|
2294
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL
|
|
2295
|
+
[
|
|
2296
|
+
{
|
|
2297
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2298
|
+
collAssetId: 0,
|
|
2299
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2300
|
+
debtAssetId: 1,
|
|
2301
|
+
closeType: CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
2302
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2303
|
+
owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2304
|
+
},
|
|
2305
|
+
[
|
|
2306
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2307
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2308
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2309
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2310
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2311
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2312
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2313
|
+
]
|
|
2314
|
+
],
|
|
2315
|
+
// TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
|
|
2316
|
+
[
|
|
2317
|
+
{
|
|
2318
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2319
|
+
collAssetId: 2,
|
|
2320
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2321
|
+
debtAssetId: 1,
|
|
2322
|
+
closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
2323
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2324
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2325
|
+
},
|
|
2326
|
+
[
|
|
2327
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2328
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2329
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2330
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2331
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
2332
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2333
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2334
|
+
]
|
|
2335
|
+
],
|
|
2336
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
|
|
2337
|
+
[
|
|
2338
|
+
{
|
|
2339
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2340
|
+
collAssetId: 2,
|
|
2341
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2342
|
+
debtAssetId: 1,
|
|
2343
|
+
closeType: CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
2344
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2345
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2346
|
+
},
|
|
2347
|
+
[
|
|
2348
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2349
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2350
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2351
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2352
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
2353
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2354
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2355
|
+
]
|
|
2356
|
+
],
|
|
2357
|
+
// TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
|
|
2358
|
+
[
|
|
2359
|
+
{
|
|
2360
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2361
|
+
collAssetId: 2,
|
|
2362
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2363
|
+
debtAssetId: 1,
|
|
2364
|
+
closeType: CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
2365
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2366
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2367
|
+
},
|
|
2368
|
+
[
|
|
2369
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2370
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2371
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2372
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2373
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
2374
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2375
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2376
|
+
]
|
|
2377
|
+
],
|
|
2378
|
+
];
|
|
2379
|
+
|
|
2380
|
+
examples.forEach(([expected, actual]) => {
|
|
2381
|
+
it(`Given ${JSON.stringify(
|
|
2382
|
+
actual
|
|
2383
|
+
)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2384
|
+
expect(
|
|
2385
|
+
subDataService.aaveV3CloseGenericSubData.decode(actual)
|
|
2386
|
+
).to.eql(expected);
|
|
2387
|
+
});
|
|
2388
|
+
});
|
|
2389
|
+
});
|
|
2390
|
+
});
|
|
2391
|
+
describe('When testing subDataService.sparkLeverageManagementOnPriceSubData', () => {
|
|
2392
|
+
describe('encode()', () => {
|
|
2393
|
+
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]] > =
|
|
2394
|
+
[
|
|
2395
|
+
[
|
|
2396
|
+
[
|
|
2397
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2398
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2399
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2400
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2401
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2402
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
2403
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2404
|
+
],
|
|
2405
|
+
[
|
|
2406
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2407
|
+
0,
|
|
2408
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2409
|
+
1,
|
|
2410
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2411
|
+
200,
|
|
2412
|
+
]
|
|
2413
|
+
]
|
|
2414
|
+
];
|
|
2415
|
+
|
|
2416
|
+
examples.forEach(([expected, actual]) => {
|
|
2417
|
+
it(`Given ${JSON.stringify(
|
|
2418
|
+
actual
|
|
2419
|
+
)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2420
|
+
expect(subDataService.sparkLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
2421
|
+
});
|
|
2422
|
+
});
|
|
2423
|
+
});
|
|
2424
|
+
|
|
2425
|
+
describe('decode()', () => {
|
|
2426
|
+
const examples: Array<[{ collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number}, SubData]> =
|
|
2427
|
+
[
|
|
2428
|
+
[
|
|
2429
|
+
{
|
|
2430
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2431
|
+
collAssetId: 2,
|
|
2432
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
2433
|
+
debtAssetId: 4,
|
|
2434
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2435
|
+
targetRatio: 175
|
|
2436
|
+
}
|
|
2437
|
+
,
|
|
2438
|
+
[
|
|
2439
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2440
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2441
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2442
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2443
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2444
|
+
'0x00000000000000000000000000000000000000000000000018493fba64ef0000'
|
|
2445
|
+
]
|
|
2446
|
+
]
|
|
2447
|
+
];
|
|
2448
|
+
|
|
2449
|
+
examples.forEach(([expected, actual]) => {
|
|
2450
|
+
it(`Given ${JSON.stringify(
|
|
2451
|
+
actual
|
|
2452
|
+
)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2453
|
+
expect(subDataService.sparkLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
2454
|
+
});
|
|
2455
|
+
});
|
|
2456
|
+
});
|
|
2457
|
+
});
|
|
2458
|
+
describe('When testing subDataService.aaveV4LeverageManagementSubData', () => {
|
|
2459
|
+
describe('encode()', () => {
|
|
2460
|
+
const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, ratioState: RatioState, targetRatio: number]]> = [
|
|
2461
|
+
[
|
|
2462
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2463
|
+
[web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), RatioState.UNDER, 150]
|
|
2464
|
+
],
|
|
2465
|
+
];
|
|
2466
|
+
|
|
2467
|
+
examples.forEach(([expected, actual]) => {
|
|
2468
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
2469
|
+
expect(subDataService.aaveV4LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
2470
|
+
});
|
|
2471
|
+
});
|
|
2472
|
+
});
|
|
2473
|
+
|
|
2474
|
+
describe('decode()', () => {
|
|
2475
|
+
const examples: Array<[{ spoke: EthereumAddress, owner: EthereumAddress, ratioState: RatioState, targetRatio: number }, SubData]> = [
|
|
2476
|
+
[
|
|
2477
|
+
{
|
|
2478
|
+
spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
2479
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2480
|
+
ratioState: RatioState.UNDER,
|
|
2481
|
+
targetRatio: 150,
|
|
2482
|
+
},
|
|
2483
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2484
|
+
],
|
|
2485
|
+
];
|
|
2486
|
+
|
|
2487
|
+
examples.forEach(([expected, actual]) => {
|
|
2488
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2489
|
+
expect(subDataService.aaveV4LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
2490
|
+
});
|
|
2491
|
+
});
|
|
2492
|
+
});
|
|
2493
|
+
});
|
|
2494
|
+
|
|
2495
|
+
describe('When testing subDataService.aaveV4LeverageManagementOnPriceSubData', () => {
|
|
2496
|
+
describe('encode()', () => {
|
|
2497
|
+
const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, ratioState: RatioState, targetRatio: number]]> = [
|
|
2498
|
+
[
|
|
2499
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2500
|
+
[
|
|
2501
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2502
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
2503
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
|
|
2504
|
+
RatioState.OVER, 160
|
|
2505
|
+
]
|
|
2506
|
+
],
|
|
2507
|
+
];
|
|
2508
|
+
|
|
2509
|
+
examples.forEach(([expected, actual]) => {
|
|
2510
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
2511
|
+
expect(subDataService.aaveV4LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
2512
|
+
});
|
|
2513
|
+
});
|
|
2514
|
+
});
|
|
2515
|
+
|
|
2516
|
+
describe('decode()', () => {
|
|
2517
|
+
const examples: Array<[{ spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, ratioState: RatioState, targetRatio: number }, SubData]> = [
|
|
2518
|
+
[
|
|
2519
|
+
{
|
|
2520
|
+
spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
2521
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2522
|
+
collAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
2523
|
+
collAssetId: 10,
|
|
2524
|
+
debtAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
2525
|
+
debtAssetId: 20,
|
|
2526
|
+
ratioState: RatioState.OVER,
|
|
2527
|
+
targetRatio: 160,
|
|
2528
|
+
},
|
|
2529
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2530
|
+
],
|
|
2531
|
+
];
|
|
2532
|
+
|
|
2533
|
+
examples.forEach(([expected, actual]) => {
|
|
2534
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2535
|
+
expect(subDataService.aaveV4LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
2536
|
+
});
|
|
2537
|
+
});
|
|
2538
|
+
});
|
|
2539
|
+
});
|
|
2540
|
+
|
|
2541
|
+
describe('When testing subDataService.aaveV4CloseSubData', () => {
|
|
2542
|
+
describe('encode()', () => {
|
|
2543
|
+
const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType]]> = [
|
|
2544
|
+
[
|
|
2545
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2546
|
+
[
|
|
2547
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2548
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
2549
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
|
|
2550
|
+
CloseStrategyType.STOP_LOSS_IN_COLLATERAL
|
|
2551
|
+
]
|
|
2552
|
+
],
|
|
2553
|
+
];
|
|
2554
|
+
|
|
2555
|
+
examples.forEach(([expected, actual]) => {
|
|
2556
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
2557
|
+
expect(subDataService.aaveV4CloseSubData.encode(...actual)).to.eql(expected);
|
|
2558
|
+
});
|
|
2559
|
+
});
|
|
2560
|
+
});
|
|
2561
|
+
|
|
2562
|
+
describe('decode()', () => {
|
|
2563
|
+
const examples: Array<[{ spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType }, SubData]> = [
|
|
2564
|
+
[
|
|
2565
|
+
{
|
|
2566
|
+
spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
2567
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2568
|
+
collAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
2569
|
+
collAssetId: 10,
|
|
2570
|
+
debtAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
2571
|
+
debtAssetId: 20,
|
|
2572
|
+
closeType: CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
2573
|
+
},
|
|
2574
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2575
|
+
],
|
|
2576
|
+
];
|
|
2577
|
+
|
|
2578
|
+
examples.forEach(([expected, actual]) => {
|
|
2579
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2580
|
+
expect(subDataService.aaveV4CloseSubData.decode(actual)).to.eql(expected);
|
|
2581
|
+
});
|
|
2582
|
+
});
|
|
2583
|
+
});
|
|
2584
|
+
});
|
|
2585
|
+
|
|
2586
|
+
describe('When testing subDataService.aaveV4CollateralSwitchSubData', () => {
|
|
2587
|
+
describe('encode()', () => {
|
|
2588
|
+
const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, amountToSwitch: string]]> = [
|
|
2589
|
+
[
|
|
2590
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2591
|
+
[
|
|
2592
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2593
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
2594
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
|
|
2595
|
+
'1000000000000000000'
|
|
2596
|
+
]
|
|
2597
|
+
],
|
|
2598
|
+
];
|
|
2599
|
+
|
|
2600
|
+
examples.forEach(([expected, actual]) => {
|
|
2601
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
2602
|
+
expect(subDataService.aaveV4CollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
2603
|
+
});
|
|
2604
|
+
});
|
|
2605
|
+
});
|
|
2606
|
+
|
|
2607
|
+
describe('decode()', () => {
|
|
2608
|
+
const examples: Array<[{ spoke: EthereumAddress, owner: EthereumAddress, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, amountToSwitch: string }, SubData]> = [
|
|
2609
|
+
[
|
|
2610
|
+
{
|
|
2611
|
+
spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
2612
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2613
|
+
fromAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
2614
|
+
fromAssetId: 10,
|
|
2615
|
+
toAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
2616
|
+
toAssetId: 20,
|
|
2617
|
+
amountToSwitch: '1000000000000000000'
|
|
2618
|
+
},
|
|
2619
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2620
|
+
],
|
|
2621
|
+
];
|
|
2622
|
+
|
|
2623
|
+
examples.forEach(([expected, actual]) => {
|
|
2624
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2625
|
+
expect(subDataService.aaveV4CollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
1383
2626
|
});
|
|
1384
2627
|
});
|
|
1385
2628
|
});
|