@defisaver/automation-sdk 3.3.22-coll-switch-generic-dev → 3.3.22-instant-twap-close-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 +40 -60
- package/cjs/services/strategiesService.js +21 -16
- package/cjs/services/strategiesService.test.js +62 -92
- package/cjs/services/strategySubService.d.ts +1 -2
- package/cjs/services/strategySubService.js +7 -12
- package/cjs/services/strategySubService.test.js +111 -107
- package/cjs/services/subDataService.d.ts +12 -22
- package/cjs/services/subDataService.js +35 -61
- package/cjs/services/subDataService.test.js +70 -139
- package/cjs/types/enums.d.ts +18 -22
- package/cjs/types/enums.js +11 -14
- package/esm/constants/index.js +40 -60
- package/esm/services/strategiesService.js +21 -16
- package/esm/services/strategiesService.test.js +63 -93
- package/esm/services/strategySubService.d.ts +1 -2
- package/esm/services/strategySubService.js +7 -12
- package/esm/services/strategySubService.test.js +111 -107
- package/esm/services/subDataService.d.ts +12 -22
- package/esm/services/subDataService.js +33 -59
- package/esm/services/subDataService.test.js +70 -139
- package/esm/types/enums.d.ts +18 -22
- package/esm/types/enums.js +11 -14
- package/package.json +1 -1
- package/src/constants/index.ts +40 -60
- package/src/services/strategiesService.test.ts +78 -102
- package/src/services/strategiesService.ts +27 -16
- package/src/services/strategySubService.test.ts +125 -126
- package/src/services/strategySubService.ts +18 -38
- package/src/services/subDataService.test.ts +98 -149
- package/src/services/subDataService.ts +48 -88
- package/src/types/enums.ts +11 -14
|
@@ -757,6 +757,117 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
757
757
|
});
|
|
758
758
|
});
|
|
759
759
|
});
|
|
760
|
+
describe('instantCloseOnPriceGeneric()', () => {
|
|
761
|
+
const examples = [
|
|
762
|
+
// Stop loss only (to debt)
|
|
763
|
+
[
|
|
764
|
+
[
|
|
765
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
766
|
+
true,
|
|
767
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000'],
|
|
768
|
+
[
|
|
769
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
770
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
771
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
772
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
773
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
774
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
775
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
776
|
+
'0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
|
|
777
|
+
'0x000000000000000000000000000000000000000000000000002386f26fc10000',
|
|
778
|
+
],
|
|
779
|
+
],
|
|
780
|
+
[
|
|
781
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
782
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
783
|
+
0,
|
|
784
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
785
|
+
1,
|
|
786
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
787
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
788
|
+
'1000000000000000000',
|
|
789
|
+
'10000000000000000',
|
|
790
|
+
1500,
|
|
791
|
+
enums_1.CloseToAssetType.DEBT,
|
|
792
|
+
0,
|
|
793
|
+
enums_1.CloseToAssetType.COLLATERAL, // takeProfitType (not used since price is 0)
|
|
794
|
+
]
|
|
795
|
+
],
|
|
796
|
+
// Take profit only (to collateral), zero tsi and slippage
|
|
797
|
+
[
|
|
798
|
+
[
|
|
799
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
800
|
+
true,
|
|
801
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
802
|
+
[
|
|
803
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
804
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
805
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
806
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
807
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
808
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
809
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
810
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
811
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
812
|
+
],
|
|
813
|
+
],
|
|
814
|
+
[
|
|
815
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
816
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
817
|
+
0,
|
|
818
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
819
|
+
1,
|
|
820
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
821
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
822
|
+
'0',
|
|
823
|
+
'0',
|
|
824
|
+
0,
|
|
825
|
+
enums_1.CloseToAssetType.DEBT,
|
|
826
|
+
5000,
|
|
827
|
+
enums_1.CloseToAssetType.COLLATERAL, // takeProfitType
|
|
828
|
+
]
|
|
829
|
+
],
|
|
830
|
+
// Take profit (to debt) and stop loss (to collateral)
|
|
831
|
+
[
|
|
832
|
+
[
|
|
833
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
834
|
+
true,
|
|
835
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
836
|
+
[
|
|
837
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
838
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
839
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
840
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
841
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
842
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
843
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
844
|
+
'0x00000000000000000000000000000000000000000000000000b1a2bc2ec50000',
|
|
845
|
+
'0x0000000000000000000000000000000000000000000000000011c37937e08000',
|
|
846
|
+
],
|
|
847
|
+
],
|
|
848
|
+
[
|
|
849
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
850
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
851
|
+
0,
|
|
852
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
853
|
+
1,
|
|
854
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
855
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
856
|
+
'50000000000000000',
|
|
857
|
+
'5000000000000000',
|
|
858
|
+
1500,
|
|
859
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
860
|
+
4000,
|
|
861
|
+
enums_1.CloseToAssetType.DEBT, // takeProfitType
|
|
862
|
+
]
|
|
863
|
+
],
|
|
864
|
+
];
|
|
865
|
+
examples.forEach(([expected, actual]) => {
|
|
866
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
867
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.instantCloseOnPriceGeneric(...actual)).to.eql(expected);
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
});
|
|
760
871
|
describe('collateralSwitch()', () => {
|
|
761
872
|
const examples = [
|
|
762
873
|
// WETH -> USDC, price 100000, state UNDER
|
|
@@ -856,113 +967,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
856
967
|
});
|
|
857
968
|
});
|
|
858
969
|
});
|
|
859
|
-
describe('collateralSwitchGeneric()', () => {
|
|
860
|
-
const strategyId = 12345;
|
|
861
|
-
const fromAsset = web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address);
|
|
862
|
-
const toAsset = web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address);
|
|
863
|
-
const marketAddr = web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39');
|
|
864
|
-
const user = web3Utils.toChecksumAddress('0x1234567890abcdef1234567890abcdef12345678');
|
|
865
|
-
const examples = [
|
|
866
|
-
[
|
|
867
|
-
enums_1.RatioState.UNDER,
|
|
868
|
-
'10000000000000000000',
|
|
869
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
870
|
-
'0000000000000000000000000000000000000000000000000000000000000001',
|
|
871
|
-
],
|
|
872
|
-
[
|
|
873
|
-
enums_1.RatioState.OVER,
|
|
874
|
-
tokens_1.MAXUINT,
|
|
875
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
876
|
-
'0000000000000000000000000000000000000000000000000000000000000000',
|
|
877
|
-
],
|
|
878
|
-
];
|
|
879
|
-
examples.forEach(([state, amountToSwitch, encodedAmount, encodedState]) => {
|
|
880
|
-
it(`encodes a generic collateral switch with the supplied quote pair and state ${state}`, () => {
|
|
881
|
-
const expectedTrigger = `0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000003e8${encodedState}`;
|
|
882
|
-
const expectedSubData = [
|
|
883
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
884
|
-
'0x0000000000000000000000000000000000000000000000000000000000000100',
|
|
885
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
886
|
-
'0x000000000000000000000000000000000000000000000000000000000000ffff',
|
|
887
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
888
|
-
encodedAmount,
|
|
889
|
-
'0x0000000000000000000000001234567890abcdef1234567890abcdef12345678',
|
|
890
|
-
];
|
|
891
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.collateralSwitchGeneric(strategyId, fromAsset, 256, toAsset, 65535, marketAddr, amountToSwitch, user, toAsset, fromAsset, 0.00001, state)).to.eql([strategyId, false, [expectedTrigger], expectedSubData]);
|
|
892
|
-
});
|
|
893
|
-
});
|
|
894
|
-
});
|
|
895
|
-
describe('debtSwitch()', () => {
|
|
896
|
-
const examples = [
|
|
897
|
-
// USDC -> DAI, price 100000, state UNDER
|
|
898
|
-
[
|
|
899
|
-
[
|
|
900
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
901
|
-
false,
|
|
902
|
-
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000009184e72a0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
903
|
-
[
|
|
904
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
905
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
906
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
907
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
908
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
909
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
910
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
911
|
-
],
|
|
912
|
-
],
|
|
913
|
-
[
|
|
914
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
915
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
916
|
-
1,
|
|
917
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
918
|
-
3,
|
|
919
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
920
|
-
'10000000000000000000',
|
|
921
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
922
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
923
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
924
|
-
100000,
|
|
925
|
-
enums_1.RatioState.UNDER,
|
|
926
|
-
]
|
|
927
|
-
],
|
|
928
|
-
// DAI -> USDC (MaxUint256), price 1, state OVER
|
|
929
|
-
[
|
|
930
|
-
[
|
|
931
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
932
|
-
false,
|
|
933
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000'],
|
|
934
|
-
[
|
|
935
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
936
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
937
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
938
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
939
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
940
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
941
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
942
|
-
],
|
|
943
|
-
],
|
|
944
|
-
[
|
|
945
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
946
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
947
|
-
3,
|
|
948
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
949
|
-
1,
|
|
950
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
951
|
-
tokens_1.MAXUINT,
|
|
952
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
953
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
954
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
955
|
-
1,
|
|
956
|
-
enums_1.RatioState.OVER,
|
|
957
|
-
]
|
|
958
|
-
],
|
|
959
|
-
];
|
|
960
|
-
examples.forEach(([expected, actual]) => {
|
|
961
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
962
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.debtSwitch(...actual)).to.eql(expected);
|
|
963
|
-
});
|
|
964
|
-
});
|
|
965
|
-
});
|
|
966
970
|
});
|
|
967
971
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
968
972
|
describe('leverageManagementOnPrice()', () => {
|
|
@@ -248,31 +248,22 @@ export declare const aaveV3CloseGenericSubData: {
|
|
|
248
248
|
owner: EthereumAddress;
|
|
249
249
|
};
|
|
250
250
|
};
|
|
251
|
-
export declare const
|
|
252
|
-
encode(
|
|
253
|
-
decode(subData: string[]): {
|
|
254
|
-
fromAsset: EthereumAddress;
|
|
255
|
-
fromAssetId: number;
|
|
256
|
-
toAsset: EthereumAddress;
|
|
257
|
-
toAssetId: number;
|
|
258
|
-
marketAddr: EthereumAddress;
|
|
259
|
-
amountToSwitch: string;
|
|
260
|
-
};
|
|
261
|
-
};
|
|
262
|
-
export declare const aaveV3GenericFLCollateralSwitchSubData: {
|
|
263
|
-
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress): string[];
|
|
251
|
+
export declare const aaveV3InstantCloseGenericSubData: {
|
|
252
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress, tsi: string, slippage: string): string[];
|
|
264
253
|
decode(subData: string[]): {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
254
|
+
collAsset: EthereumAddress;
|
|
255
|
+
collAssetId: number;
|
|
256
|
+
debtAsset: EthereumAddress;
|
|
257
|
+
debtAssetId: number;
|
|
258
|
+
closeType: CloseStrategyType;
|
|
269
259
|
marketAddr: EthereumAddress;
|
|
270
|
-
|
|
271
|
-
|
|
260
|
+
owner: EthereumAddress;
|
|
261
|
+
tsi: string;
|
|
262
|
+
slippage: string;
|
|
272
263
|
};
|
|
273
264
|
};
|
|
274
|
-
export declare const
|
|
275
|
-
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string,
|
|
265
|
+
export declare const aaveV3CollateralSwitchSubData: {
|
|
266
|
+
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean): string[];
|
|
276
267
|
decode(subData: string[]): {
|
|
277
268
|
fromAsset: EthereumAddress;
|
|
278
269
|
fromAssetId: number;
|
|
@@ -280,7 +271,6 @@ export declare const aaveV3DebtSwitchSubData: {
|
|
|
280
271
|
toAssetId: number;
|
|
281
272
|
marketAddr: EthereumAddress;
|
|
282
273
|
amountToSwitch: string;
|
|
283
|
-
user: EthereumAddress;
|
|
284
274
|
};
|
|
285
275
|
};
|
|
286
276
|
export declare const aaveV3QuotePriceSubData: {
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sparkGenericLiquidationProtectionSubData = exports.sparkGenericLeverageManagementSubData = exports.sparkLiquidationProtectionSubData = exports.sparkLeverageManagementSubData = exports.legacySparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.legacyExchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3LiquidationProtectionSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.legacyCompoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LiquidationProtectionSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.
|
|
7
|
-
exports.fluidLiquidationProtectionSubData = exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLiquidationProtectionSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkGenericFLCollateralSwitchSubData = exports.sparkCollateralSwitchSubData = exports.sparkLeverageManagementOnPriceGenericSubData = exports.sparkLeverageManagementOnPriceSubData =
|
|
6
|
+
exports.sparkCloseGenericSubData = exports.sparkGenericLiquidationProtectionSubData = exports.sparkGenericLeverageManagementSubData = exports.sparkLiquidationProtectionSubData = exports.sparkLeverageManagementSubData = exports.legacySparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.legacyExchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3LiquidationProtectionSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.legacyCompoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LiquidationProtectionSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3InstantCloseGenericSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LiquidationProtectionSubData = exports.aaveV3LeverageManagementSubData = exports.legacyAaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.legacyAaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.legacyLiquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLiquidationProtectionSubData = exports.makerLeverageManagementSubData = exports.legacyMakerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
7
|
+
exports.fluidLiquidationProtectionSubData = exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLiquidationProtectionSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkGenericFLCollateralSwitchSubData = exports.sparkCollateralSwitchSubData = exports.sparkLeverageManagementOnPriceGenericSubData = exports.sparkLeverageManagementOnPriceSubData = void 0;
|
|
8
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
9
9
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
10
10
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -518,78 +518,53 @@ exports.aaveV3CloseGenericSubData = {
|
|
|
518
518
|
};
|
|
519
519
|
},
|
|
520
520
|
};
|
|
521
|
-
exports.
|
|
522
|
-
encode(
|
|
523
|
-
const
|
|
524
|
-
const
|
|
525
|
-
const
|
|
526
|
-
const
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
const encodedUseOnBehalf = web3_eth_abi_1.default.encodeParameter('bool', useOnBehalf);
|
|
530
|
-
return [
|
|
531
|
-
encodedFromAsset,
|
|
532
|
-
encodedFromAssetId,
|
|
533
|
-
encodedToAsset,
|
|
534
|
-
encodedToAssetId,
|
|
535
|
-
encodedMarketAddr,
|
|
536
|
-
encodedAmountToSwitch,
|
|
537
|
-
encodedUseOnBehalf,
|
|
538
|
-
];
|
|
539
|
-
},
|
|
540
|
-
decode(subData) {
|
|
541
|
-
const fromAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
542
|
-
const fromAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
543
|
-
const toAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
544
|
-
const toAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
545
|
-
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
546
|
-
const amountToSwitch = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
547
|
-
return {
|
|
548
|
-
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
549
|
-
};
|
|
550
|
-
},
|
|
551
|
-
};
|
|
552
|
-
exports.aaveV3GenericFLCollateralSwitchSubData = {
|
|
553
|
-
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user) {
|
|
554
|
-
const encodedFromAsset = web3_eth_abi_1.default.encodeParameter('address', fromAsset);
|
|
555
|
-
const encodedFromAssetId = web3_eth_abi_1.default.encodeParameter('uint16', fromAssetId);
|
|
556
|
-
const encodedToAsset = web3_eth_abi_1.default.encodeParameter('address', toAsset);
|
|
557
|
-
const encodedToAssetId = web3_eth_abi_1.default.encodeParameter('uint16', toAssetId);
|
|
558
|
-
const encodedMarketAddr = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
559
|
-
const encodedAmountToSwitch = web3_eth_abi_1.default.encodeParameter('uint256', amountToSwitch);
|
|
521
|
+
exports.aaveV3InstantCloseGenericSubData = {
|
|
522
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage) {
|
|
523
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
524
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint16', collAssetId);
|
|
525
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
526
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint16', debtAssetId);
|
|
527
|
+
const encodedCloseType = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
528
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
560
529
|
const encodedUser = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
530
|
+
const encodedTsi = web3_eth_abi_1.default.encodeParameter('uint256', tsi);
|
|
531
|
+
const encodedSlippage = web3_eth_abi_1.default.encodeParameter('uint256', slippage);
|
|
561
532
|
return [
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
533
|
+
encodedColl,
|
|
534
|
+
encodedCollId,
|
|
535
|
+
encodedDebt,
|
|
536
|
+
encodedDebtId,
|
|
537
|
+
encodedCloseType,
|
|
538
|
+
encodedMarket,
|
|
568
539
|
encodedUser,
|
|
540
|
+
encodedTsi,
|
|
541
|
+
encodedSlippage,
|
|
569
542
|
];
|
|
570
543
|
},
|
|
571
544
|
decode(subData) {
|
|
572
|
-
const
|
|
573
|
-
const
|
|
574
|
-
const
|
|
575
|
-
const
|
|
576
|
-
const
|
|
577
|
-
const
|
|
578
|
-
const
|
|
545
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
546
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint16', subData[1]));
|
|
547
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
548
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint16', subData[3]));
|
|
549
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
550
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
551
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
552
|
+
const tsi = web3_eth_abi_1.default.decodeParameter('uint256', subData[7]);
|
|
553
|
+
const slippage = web3_eth_abi_1.default.decodeParameter('uint256', subData[8]);
|
|
579
554
|
return {
|
|
580
|
-
|
|
555
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner, tsi, slippage,
|
|
581
556
|
};
|
|
582
557
|
},
|
|
583
558
|
};
|
|
584
|
-
exports.
|
|
585
|
-
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
559
|
+
exports.aaveV3CollateralSwitchSubData = {
|
|
560
|
+
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, useOnBehalf = false) {
|
|
586
561
|
const encodedFromAsset = web3_eth_abi_1.default.encodeParameter('address', fromAsset);
|
|
587
562
|
const encodedFromAssetId = web3_eth_abi_1.default.encodeParameter('uint8', fromAssetId);
|
|
588
563
|
const encodedToAsset = web3_eth_abi_1.default.encodeParameter('address', toAsset);
|
|
589
564
|
const encodedToAssetId = web3_eth_abi_1.default.encodeParameter('uint8', toAssetId);
|
|
590
565
|
const encodedMarketAddr = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
591
566
|
const encodedAmountToSwitch = web3_eth_abi_1.default.encodeParameter('uint256', amountToSwitch);
|
|
592
|
-
const
|
|
567
|
+
const encodedUseOnBehalf = web3_eth_abi_1.default.encodeParameter('bool', useOnBehalf);
|
|
593
568
|
return [
|
|
594
569
|
encodedFromAsset,
|
|
595
570
|
encodedFromAssetId,
|
|
@@ -597,7 +572,7 @@ exports.aaveV3DebtSwitchSubData = {
|
|
|
597
572
|
encodedToAssetId,
|
|
598
573
|
encodedMarketAddr,
|
|
599
574
|
encodedAmountToSwitch,
|
|
600
|
-
|
|
575
|
+
encodedUseOnBehalf,
|
|
601
576
|
];
|
|
602
577
|
},
|
|
603
578
|
decode(subData) {
|
|
@@ -607,9 +582,8 @@ exports.aaveV3DebtSwitchSubData = {
|
|
|
607
582
|
const toAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
608
583
|
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
609
584
|
const amountToSwitch = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
610
|
-
const user = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
611
585
|
return {
|
|
612
|
-
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
586
|
+
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
613
587
|
};
|
|
614
588
|
},
|
|
615
589
|
};
|