@defisaver/automation-sdk 3.3.18-audit-dev → 3.3.18-spark-eoa-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 +35 -0
- package/cjs/services/ethereumService.test.js +4 -7
- package/cjs/services/strategiesService.js +40 -8
- 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 +9 -2
- package/cjs/types/enums.js +7 -0
- package/esm/constants/index.js +35 -0
- package/esm/services/ethereumService.test.js +4 -7
- package/esm/services/strategiesService.js +40 -8
- 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 +9 -2
- package/esm/types/enums.js +7 -0
- package/package.json +2 -10
- package/src/constants/index.ts +35 -0
- package/src/services/ethereumService.test.ts +5 -8
- package/src/services/strategiesService.ts +43 -9
- 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 +7 -0
|
@@ -933,6 +933,21 @@ export const sparkLeverageManagementSubData = {
|
|
|
933
933
|
},
|
|
934
934
|
};
|
|
935
935
|
export const sparkLiquidationProtectionSubData = sparkLeverageManagementSubData;
|
|
936
|
+
export const sparkGenericLeverageManagementSubData = {
|
|
937
|
+
encode(targetRatio, ratioState, market, user) {
|
|
938
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
939
|
+
const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
|
|
940
|
+
const encodedMarket = AbiCoder.encodeParameter('address', market);
|
|
941
|
+
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
942
|
+
return [encodedTargetRatio, encodedRatioState, encodedMarket, encodedUser];
|
|
943
|
+
},
|
|
944
|
+
decode(subData) {
|
|
945
|
+
const targetRatio = weiToRatioPercentage(String(AbiCoder.decodeParameter('uint256', subData[0])));
|
|
946
|
+
const ratioState = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
947
|
+
return { targetRatio, ratioState };
|
|
948
|
+
},
|
|
949
|
+
};
|
|
950
|
+
export const sparkGenericLiquidationProtectionSubData = sparkGenericLeverageManagementSubData;
|
|
936
951
|
export const sparkCloseGenericSubData = {
|
|
937
952
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
938
953
|
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
@@ -989,6 +1004,33 @@ export const sparkLeverageManagementOnPriceSubData = {
|
|
|
989
1004
|
};
|
|
990
1005
|
},
|
|
991
1006
|
};
|
|
1007
|
+
export const sparkLeverageManagementOnPriceGenericSubData = {
|
|
1008
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
1009
|
+
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
1010
|
+
const encodedCollId = AbiCoder.encodeParameter('uint16', collAssetId);
|
|
1011
|
+
const encodedDebt = AbiCoder.encodeParameter('address', debtAsset);
|
|
1012
|
+
const encodedDebtId = AbiCoder.encodeParameter('uint16', debtAssetId);
|
|
1013
|
+
const encodedMarket = AbiCoder.encodeParameter('address', marketAddr);
|
|
1014
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
1015
|
+
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
1016
|
+
return [
|
|
1017
|
+
encodedColl, encodedCollId, encodedDebt, encodedDebtId,
|
|
1018
|
+
encodedMarket, encodedTargetRatio, encodedUser,
|
|
1019
|
+
];
|
|
1020
|
+
},
|
|
1021
|
+
decode(subData) {
|
|
1022
|
+
const collAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
1023
|
+
const collAssetId = Number(AbiCoder.decodeParameter('uint16', subData[1]));
|
|
1024
|
+
const debtAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
1025
|
+
const debtAssetId = Number(AbiCoder.decodeParameter('uint16', subData[3]));
|
|
1026
|
+
const marketAddr = AbiCoder.decodeParameter('address', subData[4]);
|
|
1027
|
+
const targetRatio = weiToRatioPercentage(String(AbiCoder.decodeParameter('uint256', subData[5])));
|
|
1028
|
+
const user = AbiCoder.decodeParameter('address', subData[6]);
|
|
1029
|
+
return {
|
|
1030
|
+
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user,
|
|
1031
|
+
};
|
|
1032
|
+
},
|
|
1033
|
+
};
|
|
992
1034
|
export const sparkCollateralSwitchSubData = {
|
|
993
1035
|
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, useOnBehalf = false) {
|
|
994
1036
|
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
@@ -1020,6 +1062,38 @@ export const sparkCollateralSwitchSubData = {
|
|
|
1020
1062
|
};
|
|
1021
1063
|
},
|
|
1022
1064
|
};
|
|
1065
|
+
export const sparkGenericFLCollateralSwitchSubData = {
|
|
1066
|
+
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user) {
|
|
1067
|
+
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
1068
|
+
const encodedFromAssetId = AbiCoder.encodeParameter('uint16', fromAssetId);
|
|
1069
|
+
const encodedToAsset = AbiCoder.encodeParameter('address', toAsset);
|
|
1070
|
+
const encodedToAssetId = AbiCoder.encodeParameter('uint16', toAssetId);
|
|
1071
|
+
const encodedMarketAddr = AbiCoder.encodeParameter('address', marketAddr);
|
|
1072
|
+
const encodedAmountToSwitch = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
1073
|
+
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
1074
|
+
return [
|
|
1075
|
+
encodedFromAsset,
|
|
1076
|
+
encodedFromAssetId,
|
|
1077
|
+
encodedToAsset,
|
|
1078
|
+
encodedToAssetId,
|
|
1079
|
+
encodedMarketAddr,
|
|
1080
|
+
encodedAmountToSwitch,
|
|
1081
|
+
encodedUser,
|
|
1082
|
+
];
|
|
1083
|
+
},
|
|
1084
|
+
decode(subData) {
|
|
1085
|
+
const fromAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
1086
|
+
const fromAssetId = Number(AbiCoder.decodeParameter('uint16', subData[1]));
|
|
1087
|
+
const toAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
1088
|
+
const toAssetId = Number(AbiCoder.decodeParameter('uint16', subData[3]));
|
|
1089
|
+
const marketAddr = AbiCoder.decodeParameter('address', subData[4]);
|
|
1090
|
+
const amountToSwitch = AbiCoder.decodeParameter('uint256', subData[5]);
|
|
1091
|
+
const user = AbiCoder.decodeParameter('address', subData[6]);
|
|
1092
|
+
return {
|
|
1093
|
+
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user,
|
|
1094
|
+
};
|
|
1095
|
+
},
|
|
1096
|
+
};
|
|
1023
1097
|
/**
|
|
1024
1098
|
______ .______ ____ ____ __ __ _______. _______
|
|
1025
1099
|
/ || _ \ \ \ / / | | | | / || \
|
|
@@ -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
|
@@ -90,7 +90,8 @@ export declare namespace Strategies {
|
|
|
90
90
|
AAVE_V3_COLLATERAL_SWITCH = 135,
|
|
91
91
|
AAVE_V4_COLLATERAL_SWITCH = 154,
|
|
92
92
|
AAVE_V4_COLLATERAL_SWITCH_EOA = 155,
|
|
93
|
-
SPARK_COLLATERAL_SWITCH = 156
|
|
93
|
+
SPARK_COLLATERAL_SWITCH = 156,
|
|
94
|
+
SPARK_GENERIC_FL_COLLATERAL_SWITCH = 167
|
|
94
95
|
}
|
|
95
96
|
enum OptimismIds {
|
|
96
97
|
EXCHANGE_DCA = 8,
|
|
@@ -243,7 +244,13 @@ export declare namespace Bundles {
|
|
|
243
244
|
MORPHO_BLUE_REPAY_ON_PRICE = 84,
|
|
244
245
|
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 85,
|
|
245
246
|
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 86,
|
|
246
|
-
MORPHO_BLUE_EOA_CLOSE = 87
|
|
247
|
+
MORPHO_BLUE_EOA_CLOSE = 87,
|
|
248
|
+
SPARK_EOA_REPAY = 88,
|
|
249
|
+
SPARK_EOA_BOOST = 89,
|
|
250
|
+
SPARK_EOA_REPAY_ON_PRICE = 90,
|
|
251
|
+
SPARK_EOA_BOOST_ON_PRICE = 91,
|
|
252
|
+
SPARK_EOA_CLOSE = 92,
|
|
253
|
+
SPARK_EOA_LIQUIDATION_PROTECTION = 93
|
|
247
254
|
}
|
|
248
255
|
enum OptimismIds {
|
|
249
256
|
AAVE_V3_REPAY = 0,
|