@defisaver/automation-sdk 3.3.18 → 3.3.19-sub-fetching.1-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 -1
- package/cjs/automation/private/StrategiesAutomation.js +29 -2
- package/cjs/automation/private/StrategiesAutomation.test.js +66 -0
- package/cjs/constants/index.js +35 -0
- package/cjs/services/apiSubscriptionsService.d.ts +7 -0
- package/cjs/services/apiSubscriptionsService.js +33 -0
- package/cjs/services/apiSubscriptionsService.test.d.ts +1 -0
- package/cjs/services/apiSubscriptionsService.test.js +69 -0
- package/cjs/services/ethereumService.test.js +4 -7
- package/cjs/services/strategiesService.js +40 -9
- package/cjs/services/strategiesService.test.js +0 -1
- package/cjs/services/strategySubService.d.ts +4 -0
- package/cjs/services/strategySubService.js +24 -0
- package/cjs/services/strategySubService.test.js +295 -0
- package/cjs/services/subDataService.d.ts +38 -0
- package/cjs/services/subDataService.js +76 -2
- package/cjs/services/subDataService.test.js +494 -4
- package/cjs/types/enums.d.ts +15 -2
- package/cjs/types/enums.js +15 -1
- package/cjs/types/index.d.ts +32 -3
- package/esm/automation/private/StrategiesAutomation.d.ts +5 -1
- package/esm/automation/private/StrategiesAutomation.js +29 -2
- package/esm/automation/private/StrategiesAutomation.test.js +67 -1
- package/esm/constants/index.js +35 -0
- package/esm/services/apiSubscriptionsService.d.ts +7 -0
- package/esm/services/apiSubscriptionsService.js +29 -0
- package/esm/services/apiSubscriptionsService.test.d.ts +1 -0
- package/esm/services/apiSubscriptionsService.test.js +67 -0
- package/esm/services/ethereumService.test.js +4 -7
- package/esm/services/strategiesService.js +40 -9
- package/esm/services/strategiesService.test.js +0 -1
- package/esm/services/strategySubService.d.ts +4 -0
- package/esm/services/strategySubService.js +24 -0
- package/esm/services/strategySubService.test.js +295 -0
- package/esm/services/subDataService.d.ts +38 -0
- package/esm/services/subDataService.js +74 -0
- package/esm/services/subDataService.test.js +494 -4
- package/esm/types/enums.d.ts +15 -2
- package/esm/types/enums.js +14 -0
- package/esm/types/index.d.ts +32 -3
- package/package.json +1 -1
- package/src/automation/private/StrategiesAutomation.test.ts +84 -1
- package/src/automation/private/StrategiesAutomation.ts +33 -0
- package/src/constants/index.ts +35 -0
- package/src/services/apiSubscriptionsService.test.ts +75 -0
- package/src/services/apiSubscriptionsService.ts +33 -0
- package/src/services/ethereumService.test.ts +5 -8
- package/src/services/strategiesService.test.ts +0 -1
- package/src/services/strategiesService.ts +43 -10
- package/src/services/strategySubService.test.ts +382 -0
- package/src/services/strategySubService.ts +87 -0
- package/src/services/subDataService.test.ts +608 -4
- package/src/services/subDataService.ts +107 -0
- package/src/types/enums.ts +14 -0
- package/src/types/index.ts +34 -2
|
@@ -631,6 +631,92 @@ describe('Feature: subDataService.ts', () => {
|
|
|
631
631
|
});
|
|
632
632
|
});
|
|
633
633
|
});
|
|
634
|
+
describe('When testing subDataService.sparkGenericFLCollateralSwitchSubData', () => {
|
|
635
|
+
describe('encode()', () => {
|
|
636
|
+
const examples = [
|
|
637
|
+
[
|
|
638
|
+
[
|
|
639
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
640
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
641
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
642
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
643
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
644
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
645
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
646
|
+
],
|
|
647
|
+
[
|
|
648
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
649
|
+
0,
|
|
650
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
651
|
+
7,
|
|
652
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
653
|
+
'10000000000000000000',
|
|
654
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
655
|
+
],
|
|
656
|
+
],
|
|
657
|
+
];
|
|
658
|
+
examples.forEach(([expected, actual]) => {
|
|
659
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
660
|
+
expect(subDataService.sparkGenericFLCollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
describe('decode()', () => {
|
|
665
|
+
const examples = [
|
|
666
|
+
[
|
|
667
|
+
{
|
|
668
|
+
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
669
|
+
fromAssetId: 0,
|
|
670
|
+
toAsset: web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
671
|
+
toAssetId: 7,
|
|
672
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
673
|
+
amountToSwitch: '10000000000000000000',
|
|
674
|
+
user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
675
|
+
},
|
|
676
|
+
[
|
|
677
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
678
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
679
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
680
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
681
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
682
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
683
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
684
|
+
],
|
|
685
|
+
],
|
|
686
|
+
];
|
|
687
|
+
examples.forEach(([expected, actual]) => {
|
|
688
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
689
|
+
expect(subDataService.sparkGenericFLCollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
});
|
|
694
|
+
describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
|
|
695
|
+
describe('encode()', () => {
|
|
696
|
+
const examples = [
|
|
697
|
+
[
|
|
698
|
+
[
|
|
699
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
700
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
701
|
+
],
|
|
702
|
+
[180, RatioState.UNDER],
|
|
703
|
+
],
|
|
704
|
+
[
|
|
705
|
+
[
|
|
706
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
707
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
708
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
709
|
+
],
|
|
710
|
+
[160, RatioState.OVER],
|
|
711
|
+
],
|
|
712
|
+
];
|
|
713
|
+
examples.forEach(([expected, actual]) => {
|
|
714
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
715
|
+
expect(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
});
|
|
634
720
|
describe('When testing subDataService.legacyCompoundV2LeverageManagementSubData', () => {
|
|
635
721
|
describe('decode()', () => {
|
|
636
722
|
const examples = [
|
|
@@ -849,16 +935,72 @@ describe('Feature: subDataService.ts', () => {
|
|
|
849
935
|
});
|
|
850
936
|
});
|
|
851
937
|
});
|
|
938
|
+
describe('When testing subDataService.sparkLeverageManagementSubData', () => {
|
|
939
|
+
describe('encode()', () => {
|
|
940
|
+
const examples = [
|
|
941
|
+
[
|
|
942
|
+
[
|
|
943
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
944
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
945
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
946
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
947
|
+
],
|
|
948
|
+
[180, RatioState.UNDER],
|
|
949
|
+
],
|
|
950
|
+
[
|
|
951
|
+
[
|
|
952
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
953
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
954
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
955
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
956
|
+
],
|
|
957
|
+
[160, RatioState.OVER],
|
|
958
|
+
],
|
|
959
|
+
];
|
|
960
|
+
examples.forEach(([expected, actual]) => {
|
|
961
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
962
|
+
expect(subDataService.sparkLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
963
|
+
});
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
describe('decode()', () => {
|
|
967
|
+
const examples = [
|
|
968
|
+
[
|
|
969
|
+
{ targetRatio: 180, ratioState: '1' },
|
|
970
|
+
[
|
|
971
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
972
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
973
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
974
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
975
|
+
],
|
|
976
|
+
],
|
|
977
|
+
[
|
|
978
|
+
{ targetRatio: 160, ratioState: '0' },
|
|
979
|
+
[
|
|
980
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
981
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
982
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
983
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
984
|
+
],
|
|
985
|
+
],
|
|
986
|
+
];
|
|
987
|
+
examples.forEach(([expected, actual]) => {
|
|
988
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
989
|
+
expect(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
990
|
+
});
|
|
991
|
+
});
|
|
992
|
+
});
|
|
993
|
+
});
|
|
852
994
|
describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
|
|
853
995
|
describe('decode()', () => {
|
|
854
996
|
const examples = [
|
|
855
997
|
[
|
|
856
|
-
{ targetRatio:
|
|
857
|
-
['
|
|
998
|
+
{ targetRatio: 180 },
|
|
999
|
+
['0x00000000000000000000000000000000000000000000000018fae27693b40000'],
|
|
858
1000
|
],
|
|
859
1001
|
[
|
|
860
|
-
{ targetRatio:
|
|
861
|
-
['
|
|
1002
|
+
{ targetRatio: 160 },
|
|
1003
|
+
['0x00000000000000000000000000000000000000000000000016345785d8a00000'],
|
|
862
1004
|
],
|
|
863
1005
|
];
|
|
864
1006
|
examples.forEach(([expected, actual]) => {
|
|
@@ -868,6 +1010,62 @@ describe('Feature: subDataService.ts', () => {
|
|
|
868
1010
|
});
|
|
869
1011
|
});
|
|
870
1012
|
});
|
|
1013
|
+
describe('When testing subDataService.sparkLiquidationProtectionSubData', () => {
|
|
1014
|
+
describe('encode()', () => {
|
|
1015
|
+
const examples = [
|
|
1016
|
+
[
|
|
1017
|
+
[
|
|
1018
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1019
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1020
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1021
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1022
|
+
],
|
|
1023
|
+
[180, RatioState.UNDER],
|
|
1024
|
+
],
|
|
1025
|
+
[
|
|
1026
|
+
[
|
|
1027
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1028
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1029
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1030
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1031
|
+
],
|
|
1032
|
+
[160, RatioState.OVER],
|
|
1033
|
+
],
|
|
1034
|
+
];
|
|
1035
|
+
examples.forEach(([expected, actual]) => {
|
|
1036
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1037
|
+
expect(subDataService.sparkLiquidationProtectionSubData.encode(...actual)).to.eql(expected);
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
});
|
|
1041
|
+
describe('decode()', () => {
|
|
1042
|
+
const examples = [
|
|
1043
|
+
[
|
|
1044
|
+
{ targetRatio: 180, ratioState: '1' },
|
|
1045
|
+
[
|
|
1046
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1047
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1048
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1049
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1050
|
+
],
|
|
1051
|
+
],
|
|
1052
|
+
[
|
|
1053
|
+
{ targetRatio: 160, ratioState: '0' },
|
|
1054
|
+
[
|
|
1055
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1056
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1057
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1058
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1059
|
+
],
|
|
1060
|
+
],
|
|
1061
|
+
];
|
|
1062
|
+
examples.forEach(([expected, actual]) => {
|
|
1063
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1064
|
+
expect(subDataService.sparkLiquidationProtectionSubData.decode(actual)).to.eql(expected);
|
|
1065
|
+
});
|
|
1066
|
+
});
|
|
1067
|
+
});
|
|
1068
|
+
});
|
|
871
1069
|
describe('When testing subDataService.liquityDsrPaybackSubData', () => {
|
|
872
1070
|
describe('encode()', () => {
|
|
873
1071
|
const examples = [
|
|
@@ -2115,6 +2313,298 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2115
2313
|
});
|
|
2116
2314
|
});
|
|
2117
2315
|
});
|
|
2316
|
+
describe('When testing subDataService.sparkCloseGenericSubData', () => {
|
|
2317
|
+
describe('encode()', () => {
|
|
2318
|
+
const examples = [
|
|
2319
|
+
[
|
|
2320
|
+
[
|
|
2321
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2322
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2323
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2324
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2325
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
2326
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2327
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2328
|
+
],
|
|
2329
|
+
[
|
|
2330
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2331
|
+
2,
|
|
2332
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
2333
|
+
4,
|
|
2334
|
+
CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
2335
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2336
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2337
|
+
],
|
|
2338
|
+
],
|
|
2339
|
+
];
|
|
2340
|
+
examples.forEach(([expected, actual]) => {
|
|
2341
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2342
|
+
expect(subDataService.sparkCloseGenericSubData.encode(...actual)).to.eql(expected);
|
|
2343
|
+
});
|
|
2344
|
+
});
|
|
2345
|
+
});
|
|
2346
|
+
describe('decode()', () => {
|
|
2347
|
+
const examples = [
|
|
2348
|
+
[
|
|
2349
|
+
{
|
|
2350
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2351
|
+
collAssetId: 2,
|
|
2352
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
2353
|
+
debtAssetId: 4,
|
|
2354
|
+
closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
2355
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2356
|
+
owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2357
|
+
},
|
|
2358
|
+
[
|
|
2359
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2360
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2361
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2362
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2363
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
2364
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2365
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2366
|
+
],
|
|
2367
|
+
],
|
|
2368
|
+
];
|
|
2369
|
+
examples.forEach(([expected, actual]) => {
|
|
2370
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2371
|
+
expect(subDataService.sparkCloseGenericSubData.decode(actual)).to.eql(expected);
|
|
2372
|
+
});
|
|
2373
|
+
});
|
|
2374
|
+
});
|
|
2375
|
+
});
|
|
2376
|
+
describe('When testing subDataService.sparkGenericLeverageManagementSubData', () => {
|
|
2377
|
+
describe('encode()', () => {
|
|
2378
|
+
const examples = [
|
|
2379
|
+
[
|
|
2380
|
+
[
|
|
2381
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
2382
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2383
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2384
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2385
|
+
],
|
|
2386
|
+
[
|
|
2387
|
+
180,
|
|
2388
|
+
RatioState.UNDER,
|
|
2389
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2390
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2391
|
+
],
|
|
2392
|
+
],
|
|
2393
|
+
[
|
|
2394
|
+
[
|
|
2395
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
2396
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2397
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2398
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2399
|
+
],
|
|
2400
|
+
[
|
|
2401
|
+
160,
|
|
2402
|
+
RatioState.OVER,
|
|
2403
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2404
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2405
|
+
],
|
|
2406
|
+
],
|
|
2407
|
+
];
|
|
2408
|
+
examples.forEach(([expected, actual]) => {
|
|
2409
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2410
|
+
expect(subDataService.sparkGenericLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
2411
|
+
});
|
|
2412
|
+
});
|
|
2413
|
+
});
|
|
2414
|
+
describe('decode()', () => {
|
|
2415
|
+
const examples = [
|
|
2416
|
+
[
|
|
2417
|
+
{ targetRatio: 180, ratioState: RatioState.UNDER },
|
|
2418
|
+
[
|
|
2419
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
2420
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2421
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2422
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2423
|
+
],
|
|
2424
|
+
],
|
|
2425
|
+
[
|
|
2426
|
+
{ targetRatio: 160, ratioState: RatioState.OVER },
|
|
2427
|
+
[
|
|
2428
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
2429
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2430
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2431
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2432
|
+
],
|
|
2433
|
+
],
|
|
2434
|
+
];
|
|
2435
|
+
examples.forEach(([expected, actual]) => {
|
|
2436
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2437
|
+
expect(subDataService.sparkGenericLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
2438
|
+
});
|
|
2439
|
+
});
|
|
2440
|
+
});
|
|
2441
|
+
});
|
|
2442
|
+
describe('When testing subDataService.sparkGenericLiquidationProtectionSubData', () => {
|
|
2443
|
+
describe('encode()', () => {
|
|
2444
|
+
const examples = [
|
|
2445
|
+
[
|
|
2446
|
+
[
|
|
2447
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
2448
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2449
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2450
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2451
|
+
],
|
|
2452
|
+
[
|
|
2453
|
+
180,
|
|
2454
|
+
RatioState.UNDER,
|
|
2455
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2456
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2457
|
+
],
|
|
2458
|
+
],
|
|
2459
|
+
[
|
|
2460
|
+
[
|
|
2461
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
2462
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2463
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2464
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2465
|
+
],
|
|
2466
|
+
[
|
|
2467
|
+
160,
|
|
2468
|
+
RatioState.OVER,
|
|
2469
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2470
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2471
|
+
],
|
|
2472
|
+
],
|
|
2473
|
+
];
|
|
2474
|
+
examples.forEach(([expected, actual]) => {
|
|
2475
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2476
|
+
expect(subDataService.sparkGenericLiquidationProtectionSubData.encode(...actual)).to.eql(expected);
|
|
2477
|
+
});
|
|
2478
|
+
});
|
|
2479
|
+
});
|
|
2480
|
+
describe('decode()', () => {
|
|
2481
|
+
const examples = [
|
|
2482
|
+
[
|
|
2483
|
+
{ targetRatio: 180, ratioState: RatioState.UNDER },
|
|
2484
|
+
[
|
|
2485
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
2486
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2487
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2488
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2489
|
+
],
|
|
2490
|
+
],
|
|
2491
|
+
[
|
|
2492
|
+
{ targetRatio: 160, ratioState: RatioState.OVER },
|
|
2493
|
+
[
|
|
2494
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
2495
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2496
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2497
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2498
|
+
],
|
|
2499
|
+
],
|
|
2500
|
+
];
|
|
2501
|
+
examples.forEach(([expected, actual]) => {
|
|
2502
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2503
|
+
expect(subDataService.sparkGenericLiquidationProtectionSubData.decode(actual)).to.eql(expected);
|
|
2504
|
+
});
|
|
2505
|
+
});
|
|
2506
|
+
});
|
|
2507
|
+
});
|
|
2508
|
+
describe('When testing subDataService.sparkLeverageManagementOnPriceGenericSubData', () => {
|
|
2509
|
+
describe('encode()', () => {
|
|
2510
|
+
const examples = [
|
|
2511
|
+
[
|
|
2512
|
+
[
|
|
2513
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2514
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2515
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2516
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2517
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2518
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
2519
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2520
|
+
],
|
|
2521
|
+
[
|
|
2522
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2523
|
+
0,
|
|
2524
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2525
|
+
1,
|
|
2526
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2527
|
+
200,
|
|
2528
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2529
|
+
],
|
|
2530
|
+
],
|
|
2531
|
+
[
|
|
2532
|
+
[
|
|
2533
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2534
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2535
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2536
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2537
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2538
|
+
'0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
|
|
2539
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2540
|
+
],
|
|
2541
|
+
[
|
|
2542
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2543
|
+
2,
|
|
2544
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
2545
|
+
4,
|
|
2546
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2547
|
+
250,
|
|
2548
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2549
|
+
],
|
|
2550
|
+
],
|
|
2551
|
+
];
|
|
2552
|
+
examples.forEach(([expected, actual]) => {
|
|
2553
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2554
|
+
expect(subDataService.sparkLeverageManagementOnPriceGenericSubData.encode(...actual)).to.eql(expected);
|
|
2555
|
+
});
|
|
2556
|
+
});
|
|
2557
|
+
});
|
|
2558
|
+
describe('decode()', () => {
|
|
2559
|
+
const examples = [
|
|
2560
|
+
[
|
|
2561
|
+
{
|
|
2562
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
2563
|
+
collAssetId: 0,
|
|
2564
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
2565
|
+
debtAssetId: 1,
|
|
2566
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2567
|
+
targetRatio: 200,
|
|
2568
|
+
user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2569
|
+
},
|
|
2570
|
+
[
|
|
2571
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2572
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2573
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2574
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2575
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2576
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
2577
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2578
|
+
],
|
|
2579
|
+
],
|
|
2580
|
+
[
|
|
2581
|
+
{
|
|
2582
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
2583
|
+
collAssetId: 2,
|
|
2584
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
2585
|
+
debtAssetId: 4,
|
|
2586
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2587
|
+
targetRatio: 250,
|
|
2588
|
+
user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2589
|
+
},
|
|
2590
|
+
[
|
|
2591
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2592
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2593
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2594
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2595
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2596
|
+
'0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
|
|
2597
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2598
|
+
],
|
|
2599
|
+
],
|
|
2600
|
+
];
|
|
2601
|
+
examples.forEach(([expected, actual]) => {
|
|
2602
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2603
|
+
expect(subDataService.sparkLeverageManagementOnPriceGenericSubData.decode(actual)).to.eql(expected);
|
|
2604
|
+
});
|
|
2605
|
+
});
|
|
2606
|
+
});
|
|
2607
|
+
});
|
|
2118
2608
|
describe('When testing subDataService.aaveV4LeverageManagementSubData', () => {
|
|
2119
2609
|
describe('encode()', () => {
|
|
2120
2610
|
const examples = [
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ export declare enum ChainId {
|
|
|
4
4
|
Arbitrum = 42161,
|
|
5
5
|
Base = 8453
|
|
6
6
|
}
|
|
7
|
+
export declare enum SubscriptionStatus {
|
|
8
|
+
Active = "active",
|
|
9
|
+
Disabled = "disabled",
|
|
10
|
+
Finished = "finished",
|
|
11
|
+
Invalid = "invalid"
|
|
12
|
+
}
|
|
7
13
|
export declare enum RatioState {
|
|
8
14
|
OVER = 0,
|
|
9
15
|
UNDER = 1
|
|
@@ -90,7 +96,8 @@ export declare namespace Strategies {
|
|
|
90
96
|
AAVE_V3_COLLATERAL_SWITCH = 135,
|
|
91
97
|
AAVE_V4_COLLATERAL_SWITCH = 154,
|
|
92
98
|
AAVE_V4_COLLATERAL_SWITCH_EOA = 155,
|
|
93
|
-
SPARK_COLLATERAL_SWITCH = 156
|
|
99
|
+
SPARK_COLLATERAL_SWITCH = 156,
|
|
100
|
+
SPARK_GENERIC_FL_COLLATERAL_SWITCH = 167
|
|
94
101
|
}
|
|
95
102
|
enum OptimismIds {
|
|
96
103
|
EXCHANGE_DCA = 8,
|
|
@@ -243,7 +250,13 @@ export declare namespace Bundles {
|
|
|
243
250
|
MORPHO_BLUE_REPAY_ON_PRICE = 84,
|
|
244
251
|
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 85,
|
|
245
252
|
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 86,
|
|
246
|
-
MORPHO_BLUE_EOA_CLOSE = 87
|
|
253
|
+
MORPHO_BLUE_EOA_CLOSE = 87,
|
|
254
|
+
SPARK_EOA_REPAY = 88,
|
|
255
|
+
SPARK_EOA_BOOST = 89,
|
|
256
|
+
SPARK_EOA_REPAY_ON_PRICE = 90,
|
|
257
|
+
SPARK_EOA_BOOST_ON_PRICE = 91,
|
|
258
|
+
SPARK_EOA_CLOSE = 92,
|
|
259
|
+
SPARK_EOA_LIQUIDATION_PROTECTION = 93
|
|
247
260
|
}
|
|
248
261
|
enum OptimismIds {
|
|
249
262
|
AAVE_V3_REPAY = 0,
|
package/esm/types/enums.js
CHANGED
|
@@ -5,6 +5,13 @@ export var ChainId;
|
|
|
5
5
|
ChainId[ChainId["Arbitrum"] = 42161] = "Arbitrum";
|
|
6
6
|
ChainId[ChainId["Base"] = 8453] = "Base";
|
|
7
7
|
})(ChainId || (ChainId = {}));
|
|
8
|
+
export var SubscriptionStatus;
|
|
9
|
+
(function (SubscriptionStatus) {
|
|
10
|
+
SubscriptionStatus["Active"] = "active";
|
|
11
|
+
SubscriptionStatus["Disabled"] = "disabled";
|
|
12
|
+
SubscriptionStatus["Finished"] = "finished";
|
|
13
|
+
SubscriptionStatus["Invalid"] = "invalid";
|
|
14
|
+
})(SubscriptionStatus || (SubscriptionStatus = {}));
|
|
8
15
|
export var RatioState;
|
|
9
16
|
(function (RatioState) {
|
|
10
17
|
RatioState[RatioState["OVER"] = 0] = "OVER";
|
|
@@ -104,6 +111,7 @@ export var Strategies;
|
|
|
104
111
|
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH"] = 154] = "AAVE_V4_COLLATERAL_SWITCH";
|
|
105
112
|
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH_EOA"] = 155] = "AAVE_V4_COLLATERAL_SWITCH_EOA";
|
|
106
113
|
MainnetIds[MainnetIds["SPARK_COLLATERAL_SWITCH"] = 156] = "SPARK_COLLATERAL_SWITCH";
|
|
114
|
+
MainnetIds[MainnetIds["SPARK_GENERIC_FL_COLLATERAL_SWITCH"] = 167] = "SPARK_GENERIC_FL_COLLATERAL_SWITCH";
|
|
107
115
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
108
116
|
let OptimismIds;
|
|
109
117
|
(function (OptimismIds) {
|
|
@@ -264,6 +272,12 @@ export var Bundles;
|
|
|
264
272
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 85] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
265
273
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 86] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
266
274
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_CLOSE"] = 87] = "MORPHO_BLUE_EOA_CLOSE";
|
|
275
|
+
MainnetIds[MainnetIds["SPARK_EOA_REPAY"] = 88] = "SPARK_EOA_REPAY";
|
|
276
|
+
MainnetIds[MainnetIds["SPARK_EOA_BOOST"] = 89] = "SPARK_EOA_BOOST";
|
|
277
|
+
MainnetIds[MainnetIds["SPARK_EOA_REPAY_ON_PRICE"] = 90] = "SPARK_EOA_REPAY_ON_PRICE";
|
|
278
|
+
MainnetIds[MainnetIds["SPARK_EOA_BOOST_ON_PRICE"] = 91] = "SPARK_EOA_BOOST_ON_PRICE";
|
|
279
|
+
MainnetIds[MainnetIds["SPARK_EOA_CLOSE"] = 92] = "SPARK_EOA_CLOSE";
|
|
280
|
+
MainnetIds[MainnetIds["SPARK_EOA_LIQUIDATION_PROTECTION"] = 93] = "SPARK_EOA_LIQUIDATION_PROTECTION";
|
|
267
281
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
268
282
|
let OptimismIds;
|
|
269
283
|
(function (OptimismIds) {
|