@defisaver/automation-sdk 3.3.12 → 3.3.14-strategies-refactor-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/constants/index.js +5 -0
- package/cjs/services/strategiesService.js +41 -17
- package/cjs/services/strategySubService.d.ts +6 -11
- package/cjs/services/strategySubService.js +33 -62
- package/cjs/services/strategySubService.test.js +99 -234
- package/cjs/services/subDataService.d.ts +46 -2
- package/cjs/services/subDataService.js +115 -20
- package/cjs/services/subDataService.test.js +121 -42
- package/cjs/types/enums.d.ts +2 -1
- package/cjs/types/enums.js +1 -0
- package/esm/constants/index.js +5 -0
- package/esm/services/strategiesService.js +41 -17
- package/esm/services/strategySubService.d.ts +6 -11
- package/esm/services/strategySubService.js +32 -58
- package/esm/services/strategySubService.test.js +101 -236
- package/esm/services/subDataService.d.ts +46 -2
- package/esm/services/subDataService.js +113 -19
- package/esm/services/subDataService.test.js +121 -42
- package/esm/types/enums.d.ts +2 -1
- package/esm/types/enums.js +1 -0
- package/package.json +1 -1
- package/src/constants/index.ts +5 -0
- package/src/services/strategiesService.ts +42 -17
- package/src/services/strategySubService.test.ts +117 -279
- package/src/services/strategySubService.ts +81 -111
- package/src/services/subDataService.test.ts +125 -48
- package/src/services/subDataService.ts +156 -28
- package/src/types/enums.ts +1 -0
|
@@ -9,17 +9,14 @@ import type { EthereumAddress, StrategyOrBundleIds, SubData, TriggerData } from
|
|
|
9
9
|
|
|
10
10
|
import '../configuration';
|
|
11
11
|
import {
|
|
12
|
-
aaveV2Encode,
|
|
13
12
|
chickenBondsEncode,
|
|
14
13
|
liquityEncode,
|
|
15
14
|
makerEncode,
|
|
16
15
|
aaveV3Encode,
|
|
17
|
-
compoundV2Encode,
|
|
18
16
|
compoundV3Encode,
|
|
19
17
|
morphoAaveV2Encode,
|
|
20
18
|
exchangeEncode,
|
|
21
19
|
crvUSDEncode,
|
|
22
|
-
compoundV3L2Encode,
|
|
23
20
|
morphoBlueEncode,
|
|
24
21
|
sparkEncode,
|
|
25
22
|
aaveV4Encode,
|
|
@@ -140,39 +137,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
140
137
|
});
|
|
141
138
|
});
|
|
142
139
|
|
|
143
|
-
describe('leverageManagement()', () => {
|
|
144
|
-
const examples: Array<[
|
|
145
|
-
[
|
|
146
|
-
vaultId: number, triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string,
|
|
147
|
-
targetRepayRatio: string, boostEnabled: boolean,
|
|
148
|
-
],
|
|
149
|
-
[
|
|
150
|
-
vaultId: number, triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string,
|
|
151
|
-
targetRepayRatio: string, boostEnabled: boolean,
|
|
152
|
-
]
|
|
153
|
-
]> = [
|
|
154
|
-
[
|
|
155
|
-
[
|
|
156
|
-
5791,
|
|
157
|
-
new Dec('210').mul(1e16).toString(),
|
|
158
|
-
new Dec('290').mul(1e16).toString(),
|
|
159
|
-
new Dec('240').mul(1e16).toString(),
|
|
160
|
-
new Dec('240').mul(1e16).toString(),
|
|
161
|
-
true,
|
|
162
|
-
],
|
|
163
|
-
[
|
|
164
|
-
5791, '210', '290', '240', '240', true,
|
|
165
|
-
]
|
|
166
|
-
]
|
|
167
|
-
];
|
|
168
|
-
|
|
169
|
-
examples.forEach(([expected, actual]) => {
|
|
170
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
171
|
-
expect(makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
140
|
describe('leverageManagementWithoutSubProxy()', () => {
|
|
177
141
|
const examples: Array<[
|
|
178
142
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -296,38 +260,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
296
260
|
});
|
|
297
261
|
});
|
|
298
262
|
|
|
299
|
-
describe('leverageManagement()', () => {
|
|
300
|
-
const examples: Array<[
|
|
301
|
-
[
|
|
302
|
-
triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string,
|
|
303
|
-
targetRepayRatio: string, boostEnabled: boolean,
|
|
304
|
-
],
|
|
305
|
-
[
|
|
306
|
-
triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string,
|
|
307
|
-
targetRepayRatio: string, boostEnabled: boolean,
|
|
308
|
-
]
|
|
309
|
-
]> = [
|
|
310
|
-
[
|
|
311
|
-
[
|
|
312
|
-
new Dec('210').mul(1e16).toString(),
|
|
313
|
-
new Dec('290').mul(1e16).toString(),
|
|
314
|
-
new Dec('240').mul(1e16).toString(),
|
|
315
|
-
new Dec('240').mul(1e16).toString(),
|
|
316
|
-
false,
|
|
317
|
-
],
|
|
318
|
-
[
|
|
319
|
-
'210', '290', '240', '240', false,
|
|
320
|
-
]
|
|
321
|
-
]
|
|
322
|
-
];
|
|
323
|
-
|
|
324
|
-
examples.forEach(([expected, actual]) => {
|
|
325
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
326
|
-
expect(liquityEncode.leverageManagement(...actual)).to.eql(expected);
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
|
|
331
263
|
describe('paybackFromChickenBondStrategySub()', () => {
|
|
332
264
|
const examples: Array<[
|
|
333
265
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -436,53 +368,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
436
368
|
});
|
|
437
369
|
});
|
|
438
370
|
|
|
439
|
-
describe('When testing strategySubService.aaveV2Encode', () => {
|
|
440
|
-
describe('leverageManagement()', () => {
|
|
441
|
-
const examples: Array<[
|
|
442
|
-
[string, string, string, string, boolean],
|
|
443
|
-
[triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean],
|
|
444
|
-
]> = [
|
|
445
|
-
[
|
|
446
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
447
|
-
[160, 220, 180, 190, true]
|
|
448
|
-
],
|
|
449
|
-
[
|
|
450
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
451
|
-
[160, 200, 180, 190, false]
|
|
452
|
-
],
|
|
453
|
-
];
|
|
454
|
-
|
|
455
|
-
examples.forEach(([expected, actual]) => {
|
|
456
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
457
|
-
expect(aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
});
|
|
462
|
-
|
|
463
371
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
464
|
-
describe('leverageManagement()', () => {
|
|
465
|
-
const examples: Array<[
|
|
466
|
-
string,
|
|
467
|
-
[triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean],
|
|
468
|
-
]> = [
|
|
469
|
-
[
|
|
470
|
-
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
471
|
-
[160, 220, 180, 190, true]
|
|
472
|
-
],
|
|
473
|
-
[
|
|
474
|
-
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
475
|
-
[160, 200, 180, 190, false]
|
|
476
|
-
],
|
|
477
|
-
];
|
|
478
|
-
|
|
479
|
-
examples.forEach(([expected, actual]) => {
|
|
480
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
481
|
-
expect(aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
|
|
486
372
|
describe('closeToAsset()', () => {
|
|
487
373
|
const examples: Array<[
|
|
488
374
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -1141,74 +1027,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1141
1027
|
});
|
|
1142
1028
|
});
|
|
1143
1029
|
|
|
1144
|
-
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
1145
|
-
describe('leverageManagement()', () => {
|
|
1146
|
-
const examples: Array<[
|
|
1147
|
-
[string, string, string, string, boolean],
|
|
1148
|
-
[triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean],
|
|
1149
|
-
]> = [
|
|
1150
|
-
[
|
|
1151
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
1152
|
-
[160, 220, 180, 190, true]
|
|
1153
|
-
],
|
|
1154
|
-
[
|
|
1155
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
1156
|
-
[160, 200, 180, 190, false]
|
|
1157
|
-
],
|
|
1158
|
-
];
|
|
1159
|
-
|
|
1160
|
-
examples.forEach(([expected, actual]) => {
|
|
1161
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1162
|
-
expect(compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1163
|
-
});
|
|
1164
|
-
});
|
|
1165
|
-
});
|
|
1166
|
-
});
|
|
1167
|
-
|
|
1168
1030
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
1169
|
-
describe('leverageManagement()', () => {
|
|
1170
|
-
const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string, boolean, boolean], [market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean]]> = [
|
|
1171
|
-
[
|
|
1172
|
-
[
|
|
1173
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1174
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1175
|
-
new Dec(160).mul(1e16).toString(),
|
|
1176
|
-
new Dec(220).mul(1e16).toString(),
|
|
1177
|
-
new Dec(180).mul(1e16).toString(),
|
|
1178
|
-
new Dec(190).mul(1e16).toString(),
|
|
1179
|
-
true, false,
|
|
1180
|
-
],
|
|
1181
|
-
[
|
|
1182
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1183
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1184
|
-
160, 220, 180, 190,
|
|
1185
|
-
true, false,
|
|
1186
|
-
]
|
|
1187
|
-
],
|
|
1188
|
-
[
|
|
1189
|
-
[
|
|
1190
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1191
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1192
|
-
new Dec(160).mul(1e16).toString(),
|
|
1193
|
-
new Dec(210).mul(1e16).toString(),
|
|
1194
|
-
new Dec(180).mul(1e16).toString(),
|
|
1195
|
-
new Dec(190).mul(1e16).toString(),
|
|
1196
|
-
false, true,
|
|
1197
|
-
],
|
|
1198
|
-
[
|
|
1199
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1200
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1201
|
-
160, 210, 180, 190,
|
|
1202
|
-
false, true,
|
|
1203
|
-
]
|
|
1204
|
-
],
|
|
1205
|
-
];
|
|
1206
|
-
examples.forEach(([expected, actual]) => {
|
|
1207
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1208
|
-
expect(compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1209
|
-
});
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
1031
|
describe('leverageManagementOnPrice()', () => {
|
|
1213
1032
|
const examples: Array<[
|
|
1214
1033
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -1396,53 +1215,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1396
1215
|
});
|
|
1397
1216
|
});
|
|
1398
1217
|
});
|
|
1399
|
-
|
|
1400
|
-
describe('limitOrder()', () => {
|
|
1401
|
-
const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string], [fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType]]> = [
|
|
1402
|
-
[
|
|
1403
|
-
[
|
|
1404
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1405
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1406
|
-
'2131',
|
|
1407
|
-
'0.53123',
|
|
1408
|
-
'1696590921159',
|
|
1409
|
-
`${OrderType.STOP_LOSS}`
|
|
1410
|
-
],
|
|
1411
|
-
[
|
|
1412
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1413
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1414
|
-
'2131',
|
|
1415
|
-
'0.53123',
|
|
1416
|
-
1696590921159,
|
|
1417
|
-
OrderType.STOP_LOSS
|
|
1418
|
-
]
|
|
1419
|
-
],
|
|
1420
|
-
[
|
|
1421
|
-
[
|
|
1422
|
-
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
1423
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
1424
|
-
'2131',
|
|
1425
|
-
'0.43123',
|
|
1426
|
-
'1646590921159',
|
|
1427
|
-
`${OrderType.TAKE_PROFIT}`
|
|
1428
|
-
],
|
|
1429
|
-
[
|
|
1430
|
-
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
1431
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
1432
|
-
'2131',
|
|
1433
|
-
'0.43123',
|
|
1434
|
-
1646590921159,
|
|
1435
|
-
OrderType.TAKE_PROFIT
|
|
1436
|
-
]
|
|
1437
|
-
],
|
|
1438
|
-
];
|
|
1439
|
-
|
|
1440
|
-
examples.forEach(([expected, actual]) => {
|
|
1441
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1442
|
-
expect(exchangeEncode.limitOrder(...actual)).to.eql(expected);
|
|
1443
|
-
});
|
|
1444
|
-
});
|
|
1445
|
-
});
|
|
1446
1218
|
});
|
|
1447
1219
|
|
|
1448
1220
|
describe('When testing strategySubService.crvUSDEncode', () => {
|
|
@@ -1701,58 +1473,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1701
1473
|
});
|
|
1702
1474
|
});
|
|
1703
1475
|
|
|
1704
|
-
describe('When testing strategySubService.compoundV3L2Encode', () => {
|
|
1705
|
-
describe('leverageManagement()', () => {
|
|
1706
|
-
const examples: Array<[string, [EthereumAddress, EthereumAddress, number, number, number, number, boolean, boolean]]> = [
|
|
1707
|
-
[
|
|
1708
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1709
|
-
[
|
|
1710
|
-
web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1711
|
-
web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1712
|
-
160, 220, 180, 190,
|
|
1713
|
-
true,
|
|
1714
|
-
false,
|
|
1715
|
-
],
|
|
1716
|
-
],
|
|
1717
|
-
[
|
|
1718
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1719
|
-
[
|
|
1720
|
-
web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1721
|
-
web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1722
|
-
160, 220, 180, 110,
|
|
1723
|
-
false,
|
|
1724
|
-
false,
|
|
1725
|
-
],
|
|
1726
|
-
],
|
|
1727
|
-
];
|
|
1728
|
-
examples.forEach(([expected, actual]) => {
|
|
1729
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1730
|
-
expect(compoundV3L2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1731
|
-
});
|
|
1732
|
-
});
|
|
1733
|
-
});
|
|
1734
|
-
});
|
|
1735
|
-
|
|
1736
1476
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1737
|
-
describe('leverageManagement()', () => {
|
|
1738
|
-
const examples: Array<[string, [number, number, number, number, boolean]]> = [
|
|
1739
|
-
[
|
|
1740
|
-
'0x0000000000000000136dcc951d8c00000000000000000000214e8348c4f0000000000000000000001d24b2dfac52000000000000000000001a5e27eef13e000001',
|
|
1741
|
-
[140,240,210,190,true]
|
|
1742
|
-
],
|
|
1743
|
-
[
|
|
1744
|
-
'0x0000000000000000130337bdce49000000000000000000001988fe4052b800000000000000000000281b57b028e1000000000000000000002223acf76376000000',
|
|
1745
|
-
[137, 184, 289, 246, false]
|
|
1746
|
-
]
|
|
1747
|
-
];
|
|
1748
|
-
|
|
1749
|
-
examples.forEach(([expected, actual]) => {
|
|
1750
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1751
|
-
expect(sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1752
|
-
});
|
|
1753
|
-
});
|
|
1754
|
-
});
|
|
1755
|
-
|
|
1756
1477
|
describe('leverageManagementOnPrice()', () => {
|
|
1757
1478
|
const examples: Array<[[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
1758
1479
|
[
|
|
@@ -1892,7 +1613,124 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1892
1613
|
});
|
|
1893
1614
|
});
|
|
1894
1615
|
});
|
|
1616
|
+
|
|
1617
|
+
describe('collateralSwitch()', () => {
|
|
1618
|
+
const examples: Array<[
|
|
1619
|
+
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
1620
|
+
[
|
|
1621
|
+
strategyOrBundleId: number,
|
|
1622
|
+
fromAsset: EthereumAddress,
|
|
1623
|
+
fromAssetId: number,
|
|
1624
|
+
toAsset: EthereumAddress,
|
|
1625
|
+
toAssetId: number,
|
|
1626
|
+
marketAddr: EthereumAddress,
|
|
1627
|
+
amountToSwitch: string,
|
|
1628
|
+
baseTokenAddress: EthereumAddress,
|
|
1629
|
+
quoteTokenAddress: EthereumAddress,
|
|
1630
|
+
price: number,
|
|
1631
|
+
state: RatioState,
|
|
1632
|
+
]
|
|
1633
|
+
]> = [
|
|
1634
|
+
// WETH -> cbBTC, price 0.025 WETH/cbBTC, state UNDER
|
|
1635
|
+
[
|
|
1636
|
+
[
|
|
1637
|
+
Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1638
|
+
false,
|
|
1639
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf00000000000000000000000000000000000000000000000000000000002625a00000000000000000000000000000000000000000000000000000000000000001'],
|
|
1640
|
+
[
|
|
1641
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1642
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1643
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1644
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1645
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1646
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
1647
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1648
|
+
],
|
|
1649
|
+
],
|
|
1650
|
+
[
|
|
1651
|
+
Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1652
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1653
|
+
0,
|
|
1654
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1655
|
+
7,
|
|
1656
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1657
|
+
'10000000000000000000', // 10 WETH
|
|
1658
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1659
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1660
|
+
0.025,
|
|
1661
|
+
RatioState.UNDER,
|
|
1662
|
+
]
|
|
1663
|
+
],
|
|
1664
|
+
// cbBTC -> WETH, price 25 cbBTC/WETH, state UNDER
|
|
1665
|
+
[
|
|
1666
|
+
[
|
|
1667
|
+
Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1668
|
+
false,
|
|
1669
|
+
['0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000009502f9000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1670
|
+
[
|
|
1671
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1672
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1673
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1674
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1675
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1676
|
+
'0x0000000000000000000000000000000000000000000000000000000005f5e100',
|
|
1677
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1678
|
+
],
|
|
1679
|
+
],
|
|
1680
|
+
[
|
|
1681
|
+
Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1682
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1683
|
+
7,
|
|
1684
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1685
|
+
0,
|
|
1686
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1687
|
+
'100000000', // 1 cbBTC (8 decimals)
|
|
1688
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1689
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1690
|
+
25,
|
|
1691
|
+
RatioState.UNDER,
|
|
1692
|
+
]
|
|
1693
|
+
],
|
|
1694
|
+
// cbBTC -> WETH, price 40 cbBTC/WETH, state OVER
|
|
1695
|
+
[
|
|
1696
|
+
[
|
|
1697
|
+
Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1698
|
+
false,
|
|
1699
|
+
['0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000ee6b28000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1700
|
+
[
|
|
1701
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1702
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1703
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1704
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1705
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1706
|
+
'0x0000000000000000000000000000000000000000000000000000000005f5e100',
|
|
1707
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1708
|
+
],
|
|
1709
|
+
],
|
|
1710
|
+
[
|
|
1711
|
+
Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1712
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1713
|
+
7,
|
|
1714
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1715
|
+
0,
|
|
1716
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1717
|
+
'100000000', // 1 cbBTC (8 decimals)
|
|
1718
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1719
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1720
|
+
40,
|
|
1721
|
+
RatioState.OVER,
|
|
1722
|
+
]
|
|
1723
|
+
],
|
|
1724
|
+
];
|
|
1725
|
+
|
|
1726
|
+
examples.forEach(([expected, actual]) => {
|
|
1727
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1728
|
+
expect(sparkEncode.collateralSwitch(...actual)).to.eql(expected);
|
|
1729
|
+
});
|
|
1730
|
+
});
|
|
1731
|
+
});
|
|
1895
1732
|
});
|
|
1733
|
+
|
|
1896
1734
|
describe('When testing strategySubService.aaveV4Encode', () => {
|
|
1897
1735
|
describe('leverageManagement()', () => {
|
|
1898
1736
|
const examples: Array<[
|