@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
|
@@ -124,28 +124,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
|
-
describe('leverageManagement()', () => {
|
|
128
|
-
const examples = [
|
|
129
|
-
[
|
|
130
|
-
[
|
|
131
|
-
5791,
|
|
132
|
-
new decimal_js_1.default('210').mul(1e16).toString(),
|
|
133
|
-
new decimal_js_1.default('290').mul(1e16).toString(),
|
|
134
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
135
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
136
|
-
true,
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
5791, '210', '290', '240', '240', true,
|
|
140
|
-
]
|
|
141
|
-
]
|
|
142
|
-
];
|
|
143
|
-
examples.forEach(([expected, actual]) => {
|
|
144
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
145
|
-
(0, chai_1.expect)(strategySubService_1.makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
127
|
describe('leverageManagementWithoutSubProxy()', () => {
|
|
150
128
|
const examples = [
|
|
151
129
|
// Repay scenario (isBoost=false, RatioState.UNDER)
|
|
@@ -245,27 +223,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
245
223
|
});
|
|
246
224
|
});
|
|
247
225
|
});
|
|
248
|
-
describe('leverageManagement()', () => {
|
|
249
|
-
const examples = [
|
|
250
|
-
[
|
|
251
|
-
[
|
|
252
|
-
new decimal_js_1.default('210').mul(1e16).toString(),
|
|
253
|
-
new decimal_js_1.default('290').mul(1e16).toString(),
|
|
254
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
255
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
256
|
-
false,
|
|
257
|
-
],
|
|
258
|
-
[
|
|
259
|
-
'210', '290', '240', '240', false,
|
|
260
|
-
]
|
|
261
|
-
]
|
|
262
|
-
];
|
|
263
|
-
examples.forEach(([expected, actual]) => {
|
|
264
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
265
|
-
(0, chai_1.expect)(strategySubService_1.liquityEncode.leverageManagement(...actual)).to.eql(expected);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
226
|
describe('paybackFromChickenBondStrategySub()', () => {
|
|
270
227
|
const examples = [
|
|
271
228
|
[
|
|
@@ -352,43 +309,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
352
309
|
});
|
|
353
310
|
});
|
|
354
311
|
});
|
|
355
|
-
describe('When testing strategySubService.aaveV2Encode', () => {
|
|
356
|
-
describe('leverageManagement()', () => {
|
|
357
|
-
const examples = [
|
|
358
|
-
[
|
|
359
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
360
|
-
[160, 220, 180, 190, true]
|
|
361
|
-
],
|
|
362
|
-
[
|
|
363
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
364
|
-
[160, 200, 180, 190, false]
|
|
365
|
-
],
|
|
366
|
-
];
|
|
367
|
-
examples.forEach(([expected, actual]) => {
|
|
368
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
369
|
-
(0, chai_1.expect)(strategySubService_1.aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
312
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
375
|
-
describe('leverageManagement()', () => {
|
|
376
|
-
const examples = [
|
|
377
|
-
[
|
|
378
|
-
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
379
|
-
[160, 220, 180, 190, true]
|
|
380
|
-
],
|
|
381
|
-
[
|
|
382
|
-
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
383
|
-
[160, 200, 180, 190, false]
|
|
384
|
-
],
|
|
385
|
-
];
|
|
386
|
-
examples.forEach(([expected, actual]) => {
|
|
387
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
388
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
313
|
describe('closeToAsset()', () => {
|
|
393
314
|
const examples = [
|
|
394
315
|
[
|
|
@@ -955,69 +876,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
955
876
|
});
|
|
956
877
|
});
|
|
957
878
|
});
|
|
958
|
-
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
959
|
-
describe('leverageManagement()', () => {
|
|
960
|
-
const examples = [
|
|
961
|
-
[
|
|
962
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
963
|
-
[160, 220, 180, 190, true]
|
|
964
|
-
],
|
|
965
|
-
[
|
|
966
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
967
|
-
[160, 200, 180, 190, false]
|
|
968
|
-
],
|
|
969
|
-
];
|
|
970
|
-
examples.forEach(([expected, actual]) => {
|
|
971
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
972
|
-
(0, chai_1.expect)(strategySubService_1.compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
973
|
-
});
|
|
974
|
-
});
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
879
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
978
|
-
describe('leverageManagement()', () => {
|
|
979
|
-
const examples = [
|
|
980
|
-
[
|
|
981
|
-
[
|
|
982
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
983
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
984
|
-
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
985
|
-
new decimal_js_1.default(220).mul(1e16).toString(),
|
|
986
|
-
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
987
|
-
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
988
|
-
true, false,
|
|
989
|
-
],
|
|
990
|
-
[
|
|
991
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
992
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
993
|
-
160, 220, 180, 190,
|
|
994
|
-
true, false,
|
|
995
|
-
]
|
|
996
|
-
],
|
|
997
|
-
[
|
|
998
|
-
[
|
|
999
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1000
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1001
|
-
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
1002
|
-
new decimal_js_1.default(210).mul(1e16).toString(),
|
|
1003
|
-
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
1004
|
-
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
1005
|
-
false, true,
|
|
1006
|
-
],
|
|
1007
|
-
[
|
|
1008
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1009
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1010
|
-
160, 210, 180, 190,
|
|
1011
|
-
false, true,
|
|
1012
|
-
]
|
|
1013
|
-
],
|
|
1014
|
-
];
|
|
1015
|
-
examples.forEach(([expected, actual]) => {
|
|
1016
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1017
|
-
(0, chai_1.expect)(strategySubService_1.compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1018
|
-
});
|
|
1019
|
-
});
|
|
1020
|
-
});
|
|
1021
880
|
describe('leverageManagementOnPrice()', () => {
|
|
1022
881
|
const examples = [
|
|
1023
882
|
[
|
|
@@ -1192,51 +1051,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1192
1051
|
});
|
|
1193
1052
|
});
|
|
1194
1053
|
});
|
|
1195
|
-
describe('limitOrder()', () => {
|
|
1196
|
-
const examples = [
|
|
1197
|
-
[
|
|
1198
|
-
[
|
|
1199
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1200
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1201
|
-
'2131',
|
|
1202
|
-
'0.53123',
|
|
1203
|
-
'1696590921159',
|
|
1204
|
-
`${enums_1.OrderType.STOP_LOSS}`
|
|
1205
|
-
],
|
|
1206
|
-
[
|
|
1207
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1208
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1209
|
-
'2131',
|
|
1210
|
-
'0.53123',
|
|
1211
|
-
1696590921159,
|
|
1212
|
-
enums_1.OrderType.STOP_LOSS
|
|
1213
|
-
]
|
|
1214
|
-
],
|
|
1215
|
-
[
|
|
1216
|
-
[
|
|
1217
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1218
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1219
|
-
'2131',
|
|
1220
|
-
'0.43123',
|
|
1221
|
-
'1646590921159',
|
|
1222
|
-
`${enums_1.OrderType.TAKE_PROFIT}`
|
|
1223
|
-
],
|
|
1224
|
-
[
|
|
1225
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1226
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1227
|
-
'2131',
|
|
1228
|
-
'0.43123',
|
|
1229
|
-
1646590921159,
|
|
1230
|
-
enums_1.OrderType.TAKE_PROFIT
|
|
1231
|
-
]
|
|
1232
|
-
],
|
|
1233
|
-
];
|
|
1234
|
-
examples.forEach(([expected, actual]) => {
|
|
1235
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1236
|
-
(0, chai_1.expect)(strategySubService_1.exchangeEncode.limitOrder(...actual)).to.eql(expected);
|
|
1237
|
-
});
|
|
1238
|
-
});
|
|
1239
|
-
});
|
|
1240
1054
|
});
|
|
1241
1055
|
describe('When testing strategySubService.crvUSDEncode', () => {
|
|
1242
1056
|
describe('leverageManagement()', () => {
|
|
@@ -1450,55 +1264,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1450
1264
|
});
|
|
1451
1265
|
});
|
|
1452
1266
|
});
|
|
1453
|
-
describe('When testing strategySubService.compoundV3L2Encode', () => {
|
|
1454
|
-
describe('leverageManagement()', () => {
|
|
1455
|
-
const examples = [
|
|
1456
|
-
[
|
|
1457
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1458
|
-
[
|
|
1459
|
-
web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1460
|
-
web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1461
|
-
160, 220, 180, 190,
|
|
1462
|
-
true,
|
|
1463
|
-
false,
|
|
1464
|
-
],
|
|
1465
|
-
],
|
|
1466
|
-
[
|
|
1467
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1468
|
-
[
|
|
1469
|
-
web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1470
|
-
web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'),
|
|
1471
|
-
160, 220, 180, 110,
|
|
1472
|
-
false,
|
|
1473
|
-
false,
|
|
1474
|
-
],
|
|
1475
|
-
],
|
|
1476
|
-
];
|
|
1477
|
-
examples.forEach(([expected, actual]) => {
|
|
1478
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1479
|
-
(0, chai_1.expect)(strategySubService_1.compoundV3L2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1480
|
-
});
|
|
1481
|
-
});
|
|
1482
|
-
});
|
|
1483
|
-
});
|
|
1484
1267
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1485
|
-
describe('leverageManagement()', () => {
|
|
1486
|
-
const examples = [
|
|
1487
|
-
[
|
|
1488
|
-
'0x0000000000000000136dcc951d8c00000000000000000000214e8348c4f0000000000000000000001d24b2dfac52000000000000000000001a5e27eef13e000001',
|
|
1489
|
-
[140, 240, 210, 190, true]
|
|
1490
|
-
],
|
|
1491
|
-
[
|
|
1492
|
-
'0x0000000000000000130337bdce49000000000000000000001988fe4052b800000000000000000000281b57b028e1000000000000000000002223acf76376000000',
|
|
1493
|
-
[137, 184, 289, 246, false]
|
|
1494
|
-
]
|
|
1495
|
-
];
|
|
1496
|
-
examples.forEach(([expected, actual]) => {
|
|
1497
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1498
|
-
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1499
|
-
});
|
|
1500
|
-
});
|
|
1501
|
-
});
|
|
1502
1268
|
describe('leverageManagementOnPrice()', () => {
|
|
1503
1269
|
const examples = [
|
|
1504
1270
|
[
|
|
@@ -1613,6 +1379,105 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1613
1379
|
});
|
|
1614
1380
|
});
|
|
1615
1381
|
});
|
|
1382
|
+
describe('collateralSwitch()', () => {
|
|
1383
|
+
const examples = [
|
|
1384
|
+
// WETH -> cbBTC, price 0.025 WETH/cbBTC, state UNDER
|
|
1385
|
+
[
|
|
1386
|
+
[
|
|
1387
|
+
enums_1.Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1388
|
+
false,
|
|
1389
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf00000000000000000000000000000000000000000000000000000000002625a00000000000000000000000000000000000000000000000000000000000000001'],
|
|
1390
|
+
[
|
|
1391
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1392
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1393
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1394
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1395
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1396
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
1397
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1398
|
+
],
|
|
1399
|
+
],
|
|
1400
|
+
[
|
|
1401
|
+
enums_1.Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1402
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1403
|
+
0,
|
|
1404
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
1405
|
+
7,
|
|
1406
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1407
|
+
'10000000000000000000',
|
|
1408
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1409
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
1410
|
+
0.025,
|
|
1411
|
+
enums_1.RatioState.UNDER,
|
|
1412
|
+
]
|
|
1413
|
+
],
|
|
1414
|
+
// cbBTC -> WETH, price 25 cbBTC/WETH, state UNDER
|
|
1415
|
+
[
|
|
1416
|
+
[
|
|
1417
|
+
enums_1.Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1418
|
+
false,
|
|
1419
|
+
['0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000009502f9000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1420
|
+
[
|
|
1421
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1422
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1423
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1424
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1425
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1426
|
+
'0x0000000000000000000000000000000000000000000000000000000005f5e100',
|
|
1427
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1428
|
+
],
|
|
1429
|
+
],
|
|
1430
|
+
[
|
|
1431
|
+
enums_1.Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1432
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
1433
|
+
7,
|
|
1434
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1435
|
+
0,
|
|
1436
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1437
|
+
'100000000',
|
|
1438
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
1439
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1440
|
+
25,
|
|
1441
|
+
enums_1.RatioState.UNDER,
|
|
1442
|
+
]
|
|
1443
|
+
],
|
|
1444
|
+
// cbBTC -> WETH, price 40 cbBTC/WETH, state OVER
|
|
1445
|
+
[
|
|
1446
|
+
[
|
|
1447
|
+
enums_1.Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1448
|
+
false,
|
|
1449
|
+
['0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000ee6b28000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1450
|
+
[
|
|
1451
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1452
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1453
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1454
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1455
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1456
|
+
'0x0000000000000000000000000000000000000000000000000000000005f5e100',
|
|
1457
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1458
|
+
],
|
|
1459
|
+
],
|
|
1460
|
+
[
|
|
1461
|
+
enums_1.Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
1462
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
1463
|
+
7,
|
|
1464
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1465
|
+
0,
|
|
1466
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1467
|
+
'100000000',
|
|
1468
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
1469
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1470
|
+
40,
|
|
1471
|
+
enums_1.RatioState.OVER,
|
|
1472
|
+
]
|
|
1473
|
+
],
|
|
1474
|
+
];
|
|
1475
|
+
examples.forEach(([expected, actual]) => {
|
|
1476
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1477
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.collateralSwitch(...actual)).to.eql(expected);
|
|
1478
|
+
});
|
|
1479
|
+
});
|
|
1480
|
+
});
|
|
1616
1481
|
});
|
|
1617
1482
|
describe('When testing strategySubService.aaveV4Encode', () => {
|
|
1618
1483
|
describe('leverageManagement()', () => {
|
|
@@ -89,6 +89,13 @@ export declare const liquityLeverageManagementSubData: {
|
|
|
89
89
|
targetRatio: number;
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
|
+
export declare const liquityLeverageManagementSubDataWithoutSubProxy: {
|
|
93
|
+
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
94
|
+
decode(subData: string[]): {
|
|
95
|
+
targetRatio: number;
|
|
96
|
+
ratioState: RatioState;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
92
99
|
export declare const liquityCloseSubData: {
|
|
93
100
|
encode(closeToAssetAddr: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): string[];
|
|
94
101
|
decode(subData: string[]): {
|
|
@@ -177,6 +184,14 @@ export declare const aaveV2LeverageManagementSubData: {
|
|
|
177
184
|
targetRatio: number;
|
|
178
185
|
};
|
|
179
186
|
};
|
|
187
|
+
export declare const aaveV2LeverageManagementSubDataWithoutSubProxy: {
|
|
188
|
+
encode(market: EthereumAddress, targetRatio: number, ratioState: RatioState): string[];
|
|
189
|
+
decode(subData: string[]): {
|
|
190
|
+
market: EthereumAddress;
|
|
191
|
+
targetRatio: number;
|
|
192
|
+
ratioState: RatioState;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
180
195
|
/**
|
|
181
196
|
___ ___ ____ ____ _______ ____ ____ ____
|
|
182
197
|
/ \ / \ \ \ / / | ____| \ \ / / |___ \
|
|
@@ -320,6 +335,13 @@ export declare const compoundV2LeverageManagementSubData: {
|
|
|
320
335
|
targetRatio: number;
|
|
321
336
|
};
|
|
322
337
|
};
|
|
338
|
+
export declare const compoundV2LeverageManagementSubDataWithoutSubProxy: {
|
|
339
|
+
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
340
|
+
decode(subData: string[]): {
|
|
341
|
+
targetRatio: number;
|
|
342
|
+
ratioState: RatioState;
|
|
343
|
+
};
|
|
344
|
+
};
|
|
323
345
|
/**
|
|
324
346
|
______ ______ .___ ___. .______ ____ ____ ____
|
|
325
347
|
/ | / __ \ | \/ | | _ \ \ \ / / |___ \
|
|
@@ -334,10 +356,13 @@ export declare const compoundV3LeverageManagementSubData: {
|
|
|
334
356
|
targetRatio: number;
|
|
335
357
|
};
|
|
336
358
|
};
|
|
337
|
-
export declare const
|
|
338
|
-
encode(market: EthereumAddress, baseToken: EthereumAddress,
|
|
359
|
+
export declare const compoundV3LeverageManagementSubDataWithoutSubProxy: {
|
|
360
|
+
encode(market: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState): string[];
|
|
339
361
|
decode(subData: string[]): {
|
|
362
|
+
market: EthereumAddress;
|
|
363
|
+
baseToken: EthereumAddress;
|
|
340
364
|
targetRatio: number;
|
|
365
|
+
ratioState: RatioState;
|
|
341
366
|
};
|
|
342
367
|
};
|
|
343
368
|
export declare const compoundV3LeverageManagementOnPriceSubData: {
|
|
@@ -386,6 +411,14 @@ export declare const exchangeLimitOrderSubData: {
|
|
|
386
411
|
amount: string;
|
|
387
412
|
};
|
|
388
413
|
};
|
|
414
|
+
export declare const exchangeLimitOrderSubDataWithoutSubProxy: {
|
|
415
|
+
encode(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string): string[];
|
|
416
|
+
decode: (subData: string[], chainId: ChainId) => {
|
|
417
|
+
fromToken: string;
|
|
418
|
+
toToken: string;
|
|
419
|
+
amount: string;
|
|
420
|
+
};
|
|
421
|
+
};
|
|
389
422
|
/**
|
|
390
423
|
_______..______ ___ .______ __ ___
|
|
391
424
|
/ || _ \ / \ | _ \ | |/ /
|
|
@@ -429,6 +462,17 @@ export declare const sparkLeverageManagementOnPriceSubData: {
|
|
|
429
462
|
targetRatio: number;
|
|
430
463
|
};
|
|
431
464
|
};
|
|
465
|
+
export declare const sparkCollateralSwitchSubData: {
|
|
466
|
+
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean): string[];
|
|
467
|
+
decode(subData: string[]): {
|
|
468
|
+
fromAsset: EthereumAddress;
|
|
469
|
+
fromAssetId: number;
|
|
470
|
+
toAsset: EthereumAddress;
|
|
471
|
+
toAssetId: number;
|
|
472
|
+
marketAddr: EthereumAddress;
|
|
473
|
+
amountToSwitch: string;
|
|
474
|
+
};
|
|
475
|
+
};
|
|
432
476
|
/**
|
|
433
477
|
______ .______ ____ ____ __ __ _______. _______
|
|
434
478
|
/ || _ \ \ \ / / | | | | / || \
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkCollateralSwitchSubData = exports.sparkLeverageManagementOnPriceSubData = exports.sparkCloseGenericSubData = exports.sparkLeverageManagementSubDataWithoutSubProxy = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubDataWithoutSubProxy = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3LeverageManagementSubDataWithoutSubProxy = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubDataWithoutSubProxy = exports.compoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubDataWithoutSubProxy = exports.aaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubDataWithoutSubProxy = exports.liquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLeverageManagementWithoutSubProxy = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
7
|
+
exports.fluidLeverageManagementSubData = void 0;
|
|
7
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
9
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
10
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -167,6 +168,23 @@ exports.liquityLeverageManagementSubData = {
|
|
|
167
168
|
return { targetRatio };
|
|
168
169
|
},
|
|
169
170
|
};
|
|
171
|
+
exports.liquityLeverageManagementSubDataWithoutSubProxy = {
|
|
172
|
+
encode(targetRatio, ratioState) {
|
|
173
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
174
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
175
|
+
const isRepay = ratioState === enums_1.RatioState.UNDER;
|
|
176
|
+
const collActionType = isRepay ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
177
|
+
const debtActionType = isRepay ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
178
|
+
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
179
|
+
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
180
|
+
return [encodedRatioState, encodedTargetRatio, collActionTypeEncoded, debtActionTypeEncoded];
|
|
181
|
+
},
|
|
182
|
+
decode(subData) {
|
|
183
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[0]);
|
|
184
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[1]));
|
|
185
|
+
return { targetRatio, ratioState };
|
|
186
|
+
},
|
|
187
|
+
};
|
|
170
188
|
exports.liquityCloseSubData = {
|
|
171
189
|
encode(closeToAssetAddr, chainId = enums_1.ChainId.Ethereum, collAddr, debtAddr) {
|
|
172
190
|
const _collAddr = collAddr || (0, tokens_1.getAssetInfo)('WETH', chainId).address;
|
|
@@ -398,6 +416,25 @@ exports.aaveV2LeverageManagementSubData = {
|
|
|
398
416
|
return { targetRatio };
|
|
399
417
|
},
|
|
400
418
|
};
|
|
419
|
+
exports.aaveV2LeverageManagementSubDataWithoutSubProxy = {
|
|
420
|
+
encode(market, targetRatio, ratioState) {
|
|
421
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
422
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
423
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
424
|
+
const isBoost = ratioState === enums_1.RatioState.OVER;
|
|
425
|
+
if (isBoost) {
|
|
426
|
+
const enableAsCollEncoded = web3_eth_abi_1.default.encodeParameter('uint256', 1);
|
|
427
|
+
return [encodedMarket, encodedTargetRatio, encodedRatioState, enableAsCollEncoded];
|
|
428
|
+
}
|
|
429
|
+
return [encodedMarket, encodedTargetRatio, encodedRatioState];
|
|
430
|
+
},
|
|
431
|
+
decode(subData) {
|
|
432
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
433
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[1]));
|
|
434
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[2]);
|
|
435
|
+
return { market, targetRatio, ratioState };
|
|
436
|
+
},
|
|
437
|
+
};
|
|
401
438
|
/**
|
|
402
439
|
___ ___ ____ ____ _______ ____ ____ ____
|
|
403
440
|
/ \ / \ \ \ / / | ____| \ \ / / |___ \
|
|
@@ -752,6 +789,23 @@ exports.compoundV2LeverageManagementSubData = {
|
|
|
752
789
|
return { targetRatio };
|
|
753
790
|
},
|
|
754
791
|
};
|
|
792
|
+
exports.compoundV2LeverageManagementSubDataWithoutSubProxy = {
|
|
793
|
+
encode(targetRatio, ratioState) {
|
|
794
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
795
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
796
|
+
const isBoost = ratioState === enums_1.RatioState.OVER;
|
|
797
|
+
if (isBoost) {
|
|
798
|
+
const enableAsCollEncoded = web3_eth_abi_1.default.encodeParameter('uint256', 1);
|
|
799
|
+
return [encodedTargetRatio, encodedRatioState, enableAsCollEncoded];
|
|
800
|
+
}
|
|
801
|
+
return [encodedTargetRatio, encodedRatioState];
|
|
802
|
+
},
|
|
803
|
+
decode(subData) {
|
|
804
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[0]));
|
|
805
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[1]);
|
|
806
|
+
return { targetRatio, ratioState };
|
|
807
|
+
},
|
|
808
|
+
};
|
|
755
809
|
/**
|
|
756
810
|
______ ______ .___ ___. .______ ____ ____ ____
|
|
757
811
|
/ | / __ \ | \/ | | _ \ \ \ / / |___ \
|
|
@@ -779,27 +833,22 @@ exports.compoundV3LeverageManagementSubData = {
|
|
|
779
833
|
return { targetRatio };
|
|
780
834
|
},
|
|
781
835
|
};
|
|
782
|
-
exports.
|
|
783
|
-
encode(market, baseToken,
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
790
|
-
.padStart(32, '0'));
|
|
791
|
-
subInput = subInput.concat(new decimal_js_1.default(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
792
|
-
.padStart(32, '0'));
|
|
793
|
-
subInput = subInput.concat(new decimal_js_1.default(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
794
|
-
.padStart(32, '0'));
|
|
795
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
796
|
-
subInput = subInput.concat(isEOA ? '01' : '00');
|
|
797
|
-
return subInput;
|
|
836
|
+
exports.compoundV3LeverageManagementSubDataWithoutSubProxy = {
|
|
837
|
+
encode(market, baseToken, targetRatio, ratioState) {
|
|
838
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
839
|
+
const encodedBaseToken = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
840
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
841
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
842
|
+
return [encodedMarket, encodedBaseToken, encodedRatioState, encodedTargetRatio];
|
|
798
843
|
},
|
|
799
844
|
decode(subData) {
|
|
800
|
-
const
|
|
801
|
-
const
|
|
802
|
-
|
|
845
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
846
|
+
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
847
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[2]);
|
|
848
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
849
|
+
return {
|
|
850
|
+
market, baseToken, targetRatio, ratioState,
|
|
851
|
+
};
|
|
803
852
|
},
|
|
804
853
|
};
|
|
805
854
|
exports.compoundV3LeverageManagementOnPriceSubData = {
|
|
@@ -905,6 +954,21 @@ exports.exchangeLimitOrderSubData = {
|
|
|
905
954
|
return { fromToken, toToken, amount };
|
|
906
955
|
},
|
|
907
956
|
};
|
|
957
|
+
exports.exchangeLimitOrderSubDataWithoutSubProxy = {
|
|
958
|
+
encode(fromToken, toToken, amount) {
|
|
959
|
+
return [
|
|
960
|
+
web3_eth_abi_1.default.encodeParameter('address', fromToken),
|
|
961
|
+
web3_eth_abi_1.default.encodeParameter('address', toToken),
|
|
962
|
+
web3_eth_abi_1.default.encodeParameter('uint256', amount),
|
|
963
|
+
];
|
|
964
|
+
},
|
|
965
|
+
decode: (subData, chainId) => {
|
|
966
|
+
const fromToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]).toString();
|
|
967
|
+
const toToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]).toString();
|
|
968
|
+
const amount = (0, tokens_1.assetAmountInEth)(web3_eth_abi_1.default.decodeParameter('uint256', subData[2]).toString(), (0, tokens_1.getAssetInfoByAddress)(fromToken, chainId).symbol);
|
|
969
|
+
return { fromToken, toToken, amount };
|
|
970
|
+
},
|
|
971
|
+
};
|
|
908
972
|
/**
|
|
909
973
|
_______..______ ___ .______ __ ___
|
|
910
974
|
/ || _ \ / \ | _ \ | |/ /
|
|
@@ -990,6 +1054,37 @@ exports.sparkLeverageManagementOnPriceSubData = {
|
|
|
990
1054
|
};
|
|
991
1055
|
},
|
|
992
1056
|
};
|
|
1057
|
+
exports.sparkCollateralSwitchSubData = {
|
|
1058
|
+
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, useOnBehalf = false) {
|
|
1059
|
+
const encodedFromAsset = web3_eth_abi_1.default.encodeParameter('address', fromAsset);
|
|
1060
|
+
const encodedFromAssetId = web3_eth_abi_1.default.encodeParameter('uint8', fromAssetId);
|
|
1061
|
+
const encodedToAsset = web3_eth_abi_1.default.encodeParameter('address', toAsset);
|
|
1062
|
+
const encodedToAssetId = web3_eth_abi_1.default.encodeParameter('uint8', toAssetId);
|
|
1063
|
+
const encodedMarketAddr = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
1064
|
+
const encodedAmountToSwitch = web3_eth_abi_1.default.encodeParameter('uint256', amountToSwitch);
|
|
1065
|
+
const encodedUseOnBehalf = web3_eth_abi_1.default.encodeParameter('bool', useOnBehalf);
|
|
1066
|
+
return [
|
|
1067
|
+
encodedFromAsset,
|
|
1068
|
+
encodedFromAssetId,
|
|
1069
|
+
encodedToAsset,
|
|
1070
|
+
encodedToAssetId,
|
|
1071
|
+
encodedMarketAddr,
|
|
1072
|
+
encodedAmountToSwitch,
|
|
1073
|
+
encodedUseOnBehalf,
|
|
1074
|
+
];
|
|
1075
|
+
},
|
|
1076
|
+
decode(subData) {
|
|
1077
|
+
const fromAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
1078
|
+
const fromAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
1079
|
+
const toAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
1080
|
+
const toAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
1081
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
1082
|
+
const amountToSwitch = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
1083
|
+
return {
|
|
1084
|
+
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
1085
|
+
};
|
|
1086
|
+
},
|
|
1087
|
+
};
|
|
993
1088
|
/**
|
|
994
1089
|
______ .______ ____ ____ __ __ _______. _______
|
|
995
1090
|
/ || _ \ \ \ / / | | | | / || \
|