@defisaver/automation-sdk 3.3.18 → 3.3.19-sub-fetching-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 +19 -2
- package/cjs/automation/private/StrategiesAutomation.test.js +55 -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 +29 -3
- package/esm/automation/private/StrategiesAutomation.d.ts +5 -1
- package/esm/automation/private/StrategiesAutomation.js +20 -3
- package/esm/automation/private/StrategiesAutomation.test.js +56 -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 +29 -3
- package/package.json +1 -1
- package/src/automation/private/StrategiesAutomation.test.ts +70 -1
- package/src/automation/private/StrategiesAutomation.ts +25 -1
- 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 +31 -2
|
@@ -656,6 +656,92 @@ describe('Feature: subDataService.ts', () => {
|
|
|
656
656
|
});
|
|
657
657
|
});
|
|
658
658
|
});
|
|
659
|
+
describe('When testing subDataService.sparkGenericFLCollateralSwitchSubData', () => {
|
|
660
|
+
describe('encode()', () => {
|
|
661
|
+
const examples = [
|
|
662
|
+
[
|
|
663
|
+
[
|
|
664
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
665
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
666
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
667
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
668
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
669
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
670
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
671
|
+
],
|
|
672
|
+
[
|
|
673
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
674
|
+
0,
|
|
675
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
676
|
+
7,
|
|
677
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
678
|
+
'10000000000000000000',
|
|
679
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
680
|
+
],
|
|
681
|
+
],
|
|
682
|
+
];
|
|
683
|
+
examples.forEach(([expected, actual]) => {
|
|
684
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
685
|
+
(0, chai_1.expect)(subDataService.sparkGenericFLCollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
describe('decode()', () => {
|
|
690
|
+
const examples = [
|
|
691
|
+
[
|
|
692
|
+
{
|
|
693
|
+
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
694
|
+
fromAssetId: 0,
|
|
695
|
+
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
696
|
+
toAssetId: 7,
|
|
697
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
698
|
+
amountToSwitch: '10000000000000000000',
|
|
699
|
+
user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
700
|
+
},
|
|
701
|
+
[
|
|
702
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
703
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
704
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
705
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
706
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
707
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
708
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
709
|
+
],
|
|
710
|
+
],
|
|
711
|
+
];
|
|
712
|
+
examples.forEach(([expected, actual]) => {
|
|
713
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
714
|
+
(0, chai_1.expect)(subDataService.sparkGenericFLCollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
|
|
720
|
+
describe('encode()', () => {
|
|
721
|
+
const examples = [
|
|
722
|
+
[
|
|
723
|
+
[
|
|
724
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
725
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
726
|
+
],
|
|
727
|
+
[180, enums_1.RatioState.UNDER],
|
|
728
|
+
],
|
|
729
|
+
[
|
|
730
|
+
[
|
|
731
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
732
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
733
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
734
|
+
],
|
|
735
|
+
[160, enums_1.RatioState.OVER],
|
|
736
|
+
],
|
|
737
|
+
];
|
|
738
|
+
examples.forEach(([expected, actual]) => {
|
|
739
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
740
|
+
(0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
});
|
|
659
745
|
describe('When testing subDataService.legacyCompoundV2LeverageManagementSubData', () => {
|
|
660
746
|
describe('decode()', () => {
|
|
661
747
|
const examples = [
|
|
@@ -874,16 +960,72 @@ describe('Feature: subDataService.ts', () => {
|
|
|
874
960
|
});
|
|
875
961
|
});
|
|
876
962
|
});
|
|
963
|
+
describe('When testing subDataService.sparkLeverageManagementSubData', () => {
|
|
964
|
+
describe('encode()', () => {
|
|
965
|
+
const examples = [
|
|
966
|
+
[
|
|
967
|
+
[
|
|
968
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
969
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
970
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
971
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
972
|
+
],
|
|
973
|
+
[180, enums_1.RatioState.UNDER],
|
|
974
|
+
],
|
|
975
|
+
[
|
|
976
|
+
[
|
|
977
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
978
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
979
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
980
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
981
|
+
],
|
|
982
|
+
[160, enums_1.RatioState.OVER],
|
|
983
|
+
],
|
|
984
|
+
];
|
|
985
|
+
examples.forEach(([expected, actual]) => {
|
|
986
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
987
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
});
|
|
991
|
+
describe('decode()', () => {
|
|
992
|
+
const examples = [
|
|
993
|
+
[
|
|
994
|
+
{ targetRatio: 180, ratioState: '1' },
|
|
995
|
+
[
|
|
996
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
997
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
998
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
999
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1000
|
+
],
|
|
1001
|
+
],
|
|
1002
|
+
[
|
|
1003
|
+
{ targetRatio: 160, ratioState: '0' },
|
|
1004
|
+
[
|
|
1005
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1006
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1007
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1008
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1009
|
+
],
|
|
1010
|
+
],
|
|
1011
|
+
];
|
|
1012
|
+
examples.forEach(([expected, actual]) => {
|
|
1013
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1014
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
877
1019
|
describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
|
|
878
1020
|
describe('decode()', () => {
|
|
879
1021
|
const examples = [
|
|
880
1022
|
[
|
|
881
|
-
{ targetRatio:
|
|
882
|
-
['
|
|
1023
|
+
{ targetRatio: 180 },
|
|
1024
|
+
['0x00000000000000000000000000000000000000000000000018fae27693b40000'],
|
|
883
1025
|
],
|
|
884
1026
|
[
|
|
885
|
-
{ targetRatio:
|
|
886
|
-
['
|
|
1027
|
+
{ targetRatio: 160 },
|
|
1028
|
+
['0x00000000000000000000000000000000000000000000000016345785d8a00000'],
|
|
887
1029
|
],
|
|
888
1030
|
];
|
|
889
1031
|
examples.forEach(([expected, actual]) => {
|
|
@@ -893,6 +1035,62 @@ describe('Feature: subDataService.ts', () => {
|
|
|
893
1035
|
});
|
|
894
1036
|
});
|
|
895
1037
|
});
|
|
1038
|
+
describe('When testing subDataService.sparkLiquidationProtectionSubData', () => {
|
|
1039
|
+
describe('encode()', () => {
|
|
1040
|
+
const examples = [
|
|
1041
|
+
[
|
|
1042
|
+
[
|
|
1043
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1044
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1045
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1046
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1047
|
+
],
|
|
1048
|
+
[180, enums_1.RatioState.UNDER],
|
|
1049
|
+
],
|
|
1050
|
+
[
|
|
1051
|
+
[
|
|
1052
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1053
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1054
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1055
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1056
|
+
],
|
|
1057
|
+
[160, enums_1.RatioState.OVER],
|
|
1058
|
+
],
|
|
1059
|
+
];
|
|
1060
|
+
examples.forEach(([expected, actual]) => {
|
|
1061
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1062
|
+
(0, chai_1.expect)(subDataService.sparkLiquidationProtectionSubData.encode(...actual)).to.eql(expected);
|
|
1063
|
+
});
|
|
1064
|
+
});
|
|
1065
|
+
});
|
|
1066
|
+
describe('decode()', () => {
|
|
1067
|
+
const examples = [
|
|
1068
|
+
[
|
|
1069
|
+
{ targetRatio: 180, ratioState: '1' },
|
|
1070
|
+
[
|
|
1071
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1072
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1073
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1074
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1075
|
+
],
|
|
1076
|
+
],
|
|
1077
|
+
[
|
|
1078
|
+
{ targetRatio: 160, ratioState: '0' },
|
|
1079
|
+
[
|
|
1080
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1081
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1082
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1083
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1084
|
+
],
|
|
1085
|
+
],
|
|
1086
|
+
];
|
|
1087
|
+
examples.forEach(([expected, actual]) => {
|
|
1088
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1089
|
+
(0, chai_1.expect)(subDataService.sparkLiquidationProtectionSubData.decode(actual)).to.eql(expected);
|
|
1090
|
+
});
|
|
1091
|
+
});
|
|
1092
|
+
});
|
|
1093
|
+
});
|
|
896
1094
|
describe('When testing subDataService.liquityDsrPaybackSubData', () => {
|
|
897
1095
|
describe('encode()', () => {
|
|
898
1096
|
const examples = [
|
|
@@ -2140,6 +2338,298 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2140
2338
|
});
|
|
2141
2339
|
});
|
|
2142
2340
|
});
|
|
2341
|
+
describe('When testing subDataService.sparkCloseGenericSubData', () => {
|
|
2342
|
+
describe('encode()', () => {
|
|
2343
|
+
const examples = [
|
|
2344
|
+
[
|
|
2345
|
+
[
|
|
2346
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2347
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2348
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2349
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2350
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
2351
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2352
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2353
|
+
],
|
|
2354
|
+
[
|
|
2355
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2356
|
+
2,
|
|
2357
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
2358
|
+
4,
|
|
2359
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
2360
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2361
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2362
|
+
],
|
|
2363
|
+
],
|
|
2364
|
+
];
|
|
2365
|
+
examples.forEach(([expected, actual]) => {
|
|
2366
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2367
|
+
(0, chai_1.expect)(subDataService.sparkCloseGenericSubData.encode(...actual)).to.eql(expected);
|
|
2368
|
+
});
|
|
2369
|
+
});
|
|
2370
|
+
});
|
|
2371
|
+
describe('decode()', () => {
|
|
2372
|
+
const examples = [
|
|
2373
|
+
[
|
|
2374
|
+
{
|
|
2375
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2376
|
+
collAssetId: 2,
|
|
2377
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
2378
|
+
debtAssetId: 4,
|
|
2379
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
2380
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2381
|
+
owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2382
|
+
},
|
|
2383
|
+
[
|
|
2384
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2385
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2386
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2387
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2388
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
2389
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2390
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2391
|
+
],
|
|
2392
|
+
],
|
|
2393
|
+
];
|
|
2394
|
+
examples.forEach(([expected, actual]) => {
|
|
2395
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2396
|
+
(0, chai_1.expect)(subDataService.sparkCloseGenericSubData.decode(actual)).to.eql(expected);
|
|
2397
|
+
});
|
|
2398
|
+
});
|
|
2399
|
+
});
|
|
2400
|
+
});
|
|
2401
|
+
describe('When testing subDataService.sparkGenericLeverageManagementSubData', () => {
|
|
2402
|
+
describe('encode()', () => {
|
|
2403
|
+
const examples = [
|
|
2404
|
+
[
|
|
2405
|
+
[
|
|
2406
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
2407
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2408
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2409
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2410
|
+
],
|
|
2411
|
+
[
|
|
2412
|
+
180,
|
|
2413
|
+
enums_1.RatioState.UNDER,
|
|
2414
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2415
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2416
|
+
],
|
|
2417
|
+
],
|
|
2418
|
+
[
|
|
2419
|
+
[
|
|
2420
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
2421
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2422
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2423
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2424
|
+
],
|
|
2425
|
+
[
|
|
2426
|
+
160,
|
|
2427
|
+
enums_1.RatioState.OVER,
|
|
2428
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2429
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2430
|
+
],
|
|
2431
|
+
],
|
|
2432
|
+
];
|
|
2433
|
+
examples.forEach(([expected, actual]) => {
|
|
2434
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2435
|
+
(0, chai_1.expect)(subDataService.sparkGenericLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
2436
|
+
});
|
|
2437
|
+
});
|
|
2438
|
+
});
|
|
2439
|
+
describe('decode()', () => {
|
|
2440
|
+
const examples = [
|
|
2441
|
+
[
|
|
2442
|
+
{ targetRatio: 180, ratioState: enums_1.RatioState.UNDER },
|
|
2443
|
+
[
|
|
2444
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
2445
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2446
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2447
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2448
|
+
],
|
|
2449
|
+
],
|
|
2450
|
+
[
|
|
2451
|
+
{ targetRatio: 160, ratioState: enums_1.RatioState.OVER },
|
|
2452
|
+
[
|
|
2453
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
2454
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2455
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2456
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2457
|
+
],
|
|
2458
|
+
],
|
|
2459
|
+
];
|
|
2460
|
+
examples.forEach(([expected, actual]) => {
|
|
2461
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2462
|
+
(0, chai_1.expect)(subDataService.sparkGenericLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
2463
|
+
});
|
|
2464
|
+
});
|
|
2465
|
+
});
|
|
2466
|
+
});
|
|
2467
|
+
describe('When testing subDataService.sparkGenericLiquidationProtectionSubData', () => {
|
|
2468
|
+
describe('encode()', () => {
|
|
2469
|
+
const examples = [
|
|
2470
|
+
[
|
|
2471
|
+
[
|
|
2472
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
2473
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2474
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2475
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2476
|
+
],
|
|
2477
|
+
[
|
|
2478
|
+
180,
|
|
2479
|
+
enums_1.RatioState.UNDER,
|
|
2480
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2481
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2482
|
+
],
|
|
2483
|
+
],
|
|
2484
|
+
[
|
|
2485
|
+
[
|
|
2486
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
2487
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2488
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2489
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2490
|
+
],
|
|
2491
|
+
[
|
|
2492
|
+
160,
|
|
2493
|
+
enums_1.RatioState.OVER,
|
|
2494
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2495
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2496
|
+
],
|
|
2497
|
+
],
|
|
2498
|
+
];
|
|
2499
|
+
examples.forEach(([expected, actual]) => {
|
|
2500
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2501
|
+
(0, chai_1.expect)(subDataService.sparkGenericLiquidationProtectionSubData.encode(...actual)).to.eql(expected);
|
|
2502
|
+
});
|
|
2503
|
+
});
|
|
2504
|
+
});
|
|
2505
|
+
describe('decode()', () => {
|
|
2506
|
+
const examples = [
|
|
2507
|
+
[
|
|
2508
|
+
{ targetRatio: 180, ratioState: enums_1.RatioState.UNDER },
|
|
2509
|
+
[
|
|
2510
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
2511
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2512
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2513
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2514
|
+
],
|
|
2515
|
+
],
|
|
2516
|
+
[
|
|
2517
|
+
{ targetRatio: 160, ratioState: enums_1.RatioState.OVER },
|
|
2518
|
+
[
|
|
2519
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
2520
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2521
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2522
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2523
|
+
],
|
|
2524
|
+
],
|
|
2525
|
+
];
|
|
2526
|
+
examples.forEach(([expected, actual]) => {
|
|
2527
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2528
|
+
(0, chai_1.expect)(subDataService.sparkGenericLiquidationProtectionSubData.decode(actual)).to.eql(expected);
|
|
2529
|
+
});
|
|
2530
|
+
});
|
|
2531
|
+
});
|
|
2532
|
+
});
|
|
2533
|
+
describe('When testing subDataService.sparkLeverageManagementOnPriceGenericSubData', () => {
|
|
2534
|
+
describe('encode()', () => {
|
|
2535
|
+
const examples = [
|
|
2536
|
+
[
|
|
2537
|
+
[
|
|
2538
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2539
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2540
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2541
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2542
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2543
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
2544
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2545
|
+
],
|
|
2546
|
+
[
|
|
2547
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2548
|
+
0,
|
|
2549
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2550
|
+
1,
|
|
2551
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2552
|
+
200,
|
|
2553
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2554
|
+
],
|
|
2555
|
+
],
|
|
2556
|
+
[
|
|
2557
|
+
[
|
|
2558
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2559
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2560
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2561
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2562
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2563
|
+
'0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
|
|
2564
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2565
|
+
],
|
|
2566
|
+
[
|
|
2567
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2568
|
+
2,
|
|
2569
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
2570
|
+
4,
|
|
2571
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2572
|
+
250,
|
|
2573
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2574
|
+
],
|
|
2575
|
+
],
|
|
2576
|
+
];
|
|
2577
|
+
examples.forEach(([expected, actual]) => {
|
|
2578
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2579
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementOnPriceGenericSubData.encode(...actual)).to.eql(expected);
|
|
2580
|
+
});
|
|
2581
|
+
});
|
|
2582
|
+
});
|
|
2583
|
+
describe('decode()', () => {
|
|
2584
|
+
const examples = [
|
|
2585
|
+
[
|
|
2586
|
+
{
|
|
2587
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2588
|
+
collAssetId: 0,
|
|
2589
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2590
|
+
debtAssetId: 1,
|
|
2591
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2592
|
+
targetRatio: 200,
|
|
2593
|
+
user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2594
|
+
},
|
|
2595
|
+
[
|
|
2596
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2597
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2598
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2599
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2600
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2601
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
2602
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2603
|
+
],
|
|
2604
|
+
],
|
|
2605
|
+
[
|
|
2606
|
+
{
|
|
2607
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2608
|
+
collAssetId: 2,
|
|
2609
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
2610
|
+
debtAssetId: 4,
|
|
2611
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2612
|
+
targetRatio: 250,
|
|
2613
|
+
user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2614
|
+
},
|
|
2615
|
+
[
|
|
2616
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2617
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2618
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2619
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2620
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2621
|
+
'0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
|
|
2622
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2623
|
+
],
|
|
2624
|
+
],
|
|
2625
|
+
];
|
|
2626
|
+
examples.forEach(([expected, actual]) => {
|
|
2627
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2628
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementOnPriceGenericSubData.decode(actual)).to.eql(expected);
|
|
2629
|
+
});
|
|
2630
|
+
});
|
|
2631
|
+
});
|
|
2632
|
+
});
|
|
2143
2633
|
describe('When testing subDataService.aaveV4LeverageManagementSubData', () => {
|
|
2144
2634
|
describe('encode()', () => {
|
|
2145
2635
|
const examples = [
|
package/cjs/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/cjs/types/enums.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Bundles = exports.Strategies = exports.ProtocolIdentifiers = exports.CloseToAssetType = exports.CloseStrategyType = exports.DebtActionType = exports.CollActionType = exports.BundleProtocols = exports.OrderType = exports.RatioState = exports.ChainId = void 0;
|
|
3
|
+
exports.Bundles = exports.Strategies = exports.ProtocolIdentifiers = exports.CloseToAssetType = exports.CloseStrategyType = exports.DebtActionType = exports.CollActionType = exports.BundleProtocols = exports.OrderType = exports.RatioState = exports.SubscriptionStatus = exports.ChainId = void 0;
|
|
4
4
|
var ChainId;
|
|
5
5
|
(function (ChainId) {
|
|
6
6
|
ChainId[ChainId["Ethereum"] = 1] = "Ethereum";
|
|
@@ -8,6 +8,13 @@ var ChainId;
|
|
|
8
8
|
ChainId[ChainId["Arbitrum"] = 42161] = "Arbitrum";
|
|
9
9
|
ChainId[ChainId["Base"] = 8453] = "Base";
|
|
10
10
|
})(ChainId = exports.ChainId || (exports.ChainId = {}));
|
|
11
|
+
var SubscriptionStatus;
|
|
12
|
+
(function (SubscriptionStatus) {
|
|
13
|
+
SubscriptionStatus["Active"] = "active";
|
|
14
|
+
SubscriptionStatus["Disabled"] = "disabled";
|
|
15
|
+
SubscriptionStatus["Finished"] = "finished";
|
|
16
|
+
SubscriptionStatus["Invalid"] = "invalid";
|
|
17
|
+
})(SubscriptionStatus = exports.SubscriptionStatus || (exports.SubscriptionStatus = {}));
|
|
11
18
|
var RatioState;
|
|
12
19
|
(function (RatioState) {
|
|
13
20
|
RatioState[RatioState["OVER"] = 0] = "OVER";
|
|
@@ -107,6 +114,7 @@ var Strategies;
|
|
|
107
114
|
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH"] = 154] = "AAVE_V4_COLLATERAL_SWITCH";
|
|
108
115
|
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH_EOA"] = 155] = "AAVE_V4_COLLATERAL_SWITCH_EOA";
|
|
109
116
|
MainnetIds[MainnetIds["SPARK_COLLATERAL_SWITCH"] = 156] = "SPARK_COLLATERAL_SWITCH";
|
|
117
|
+
MainnetIds[MainnetIds["SPARK_GENERIC_FL_COLLATERAL_SWITCH"] = 167] = "SPARK_GENERIC_FL_COLLATERAL_SWITCH";
|
|
110
118
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
111
119
|
let OptimismIds;
|
|
112
120
|
(function (OptimismIds) {
|
|
@@ -267,6 +275,12 @@ var Bundles;
|
|
|
267
275
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 85] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
268
276
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 86] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
269
277
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_CLOSE"] = 87] = "MORPHO_BLUE_EOA_CLOSE";
|
|
278
|
+
MainnetIds[MainnetIds["SPARK_EOA_REPAY"] = 88] = "SPARK_EOA_REPAY";
|
|
279
|
+
MainnetIds[MainnetIds["SPARK_EOA_BOOST"] = 89] = "SPARK_EOA_BOOST";
|
|
280
|
+
MainnetIds[MainnetIds["SPARK_EOA_REPAY_ON_PRICE"] = 90] = "SPARK_EOA_REPAY_ON_PRICE";
|
|
281
|
+
MainnetIds[MainnetIds["SPARK_EOA_BOOST_ON_PRICE"] = 91] = "SPARK_EOA_BOOST_ON_PRICE";
|
|
282
|
+
MainnetIds[MainnetIds["SPARK_EOA_CLOSE"] = 92] = "SPARK_EOA_CLOSE";
|
|
283
|
+
MainnetIds[MainnetIds["SPARK_EOA_LIQUIDATION_PROTECTION"] = 93] = "SPARK_EOA_LIQUIDATION_PROTECTION";
|
|
270
284
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
271
285
|
let OptimismIds;
|
|
272
286
|
(function (OptimismIds) {
|