@defisaver/automation-sdk 3.3.21-instant-twap-close-dev → 3.3.21-npm-token-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 +0 -10
- package/cjs/services/strategiesService.js +0 -25
- package/cjs/services/strategiesService.test.js +0 -62
- package/cjs/services/strategySubService.d.ts +0 -1
- package/cjs/services/strategySubService.js +0 -7
- package/cjs/services/strategySubService.test.js +0 -111
- package/cjs/services/subDataService.d.ts +0 -14
- package/cjs/services/subDataService.js +2 -40
- package/cjs/services/subDataService.test.js +0 -70
- package/cjs/types/enums.d.ts +1 -5
- package/cjs/types/enums.js +0 -4
- package/esm/constants/index.js +0 -10
- package/esm/services/strategiesService.js +0 -25
- package/esm/services/strategiesService.test.js +1 -63
- package/esm/services/strategySubService.d.ts +0 -1
- package/esm/services/strategySubService.js +0 -7
- package/esm/services/strategySubService.test.js +0 -111
- package/esm/services/subDataService.d.ts +0 -14
- package/esm/services/subDataService.js +0 -38
- package/esm/services/subDataService.test.js +0 -70
- package/esm/types/enums.d.ts +1 -5
- package/esm/types/enums.js +0 -4
- package/package.json +1 -1
- package/src/constants/index.ts +0 -10
- package/src/services/strategiesService.test.ts +1 -78
- package/src/services/strategiesService.ts +0 -33
- package/src/services/strategySubService.test.ts +0 -130
- package/src/services/strategySubService.ts +0 -26
- package/src/services/subDataService.test.ts +0 -98
- package/src/services/subDataService.ts +0 -61
- package/src/types/enums.ts +0 -4
|
@@ -164,13 +164,6 @@ export const aaveV3Encode = {
|
|
|
164
164
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
165
165
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
166
166
|
},
|
|
167
|
-
instantCloseOnPriceGeneric(strategyOrBundleId, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, user, tsi, slippage, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL) {
|
|
168
|
-
const isBundle = true;
|
|
169
|
-
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
170
|
-
const subDataEncoded = subDataService.aaveV3InstantCloseGenericSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage);
|
|
171
|
-
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
172
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
173
|
-
},
|
|
174
167
|
collateralSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
175
168
|
const isBundle = false;
|
|
176
169
|
const subDataEncoded = subDataService.aaveV3CollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
@@ -732,117 +732,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
732
732
|
});
|
|
733
733
|
});
|
|
734
734
|
});
|
|
735
|
-
describe('instantCloseOnPriceGeneric()', () => {
|
|
736
|
-
const examples = [
|
|
737
|
-
// Stop loss only (to debt)
|
|
738
|
-
[
|
|
739
|
-
[
|
|
740
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
741
|
-
true,
|
|
742
|
-
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000'],
|
|
743
|
-
[
|
|
744
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
745
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
746
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
747
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
748
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
749
|
-
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
750
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
751
|
-
'0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
|
|
752
|
-
'0x000000000000000000000000000000000000000000000000002386f26fc10000',
|
|
753
|
-
],
|
|
754
|
-
],
|
|
755
|
-
[
|
|
756
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
757
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
758
|
-
0,
|
|
759
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
760
|
-
1,
|
|
761
|
-
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
762
|
-
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
763
|
-
'1000000000000000000',
|
|
764
|
-
'10000000000000000',
|
|
765
|
-
1500,
|
|
766
|
-
CloseToAssetType.DEBT,
|
|
767
|
-
0,
|
|
768
|
-
CloseToAssetType.COLLATERAL, // takeProfitType (not used since price is 0)
|
|
769
|
-
]
|
|
770
|
-
],
|
|
771
|
-
// Take profit only (to collateral), zero tsi and slippage
|
|
772
|
-
[
|
|
773
|
-
[
|
|
774
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
775
|
-
true,
|
|
776
|
-
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
777
|
-
[
|
|
778
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
779
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
780
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
781
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
782
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
783
|
-
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
784
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
785
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
786
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
787
|
-
],
|
|
788
|
-
],
|
|
789
|
-
[
|
|
790
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
791
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
792
|
-
0,
|
|
793
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
794
|
-
1,
|
|
795
|
-
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
796
|
-
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
797
|
-
'0',
|
|
798
|
-
'0',
|
|
799
|
-
0,
|
|
800
|
-
CloseToAssetType.DEBT,
|
|
801
|
-
5000,
|
|
802
|
-
CloseToAssetType.COLLATERAL, // takeProfitType
|
|
803
|
-
]
|
|
804
|
-
],
|
|
805
|
-
// Take profit (to debt) and stop loss (to collateral)
|
|
806
|
-
[
|
|
807
|
-
[
|
|
808
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
809
|
-
true,
|
|
810
|
-
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
811
|
-
[
|
|
812
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
813
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
814
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
815
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
816
|
-
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
817
|
-
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
818
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
819
|
-
'0x00000000000000000000000000000000000000000000000000b1a2bc2ec50000',
|
|
820
|
-
'0x0000000000000000000000000000000000000000000000000011c37937e08000',
|
|
821
|
-
],
|
|
822
|
-
],
|
|
823
|
-
[
|
|
824
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
825
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
826
|
-
0,
|
|
827
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
828
|
-
1,
|
|
829
|
-
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
830
|
-
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
831
|
-
'50000000000000000',
|
|
832
|
-
'5000000000000000',
|
|
833
|
-
1500,
|
|
834
|
-
CloseToAssetType.COLLATERAL,
|
|
835
|
-
4000,
|
|
836
|
-
CloseToAssetType.DEBT, // takeProfitType
|
|
837
|
-
]
|
|
838
|
-
],
|
|
839
|
-
];
|
|
840
|
-
examples.forEach(([expected, actual]) => {
|
|
841
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
842
|
-
expect(aaveV3Encode.instantCloseOnPriceGeneric(...actual)).to.eql(expected);
|
|
843
|
-
});
|
|
844
|
-
});
|
|
845
|
-
});
|
|
846
735
|
describe('collateralSwitch()', () => {
|
|
847
736
|
const examples = [
|
|
848
737
|
// WETH -> USDC, price 100000, state UNDER
|
|
@@ -248,20 +248,6 @@ export declare const aaveV3CloseGenericSubData: {
|
|
|
248
248
|
owner: EthereumAddress;
|
|
249
249
|
};
|
|
250
250
|
};
|
|
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[];
|
|
253
|
-
decode(subData: string[]): {
|
|
254
|
-
collAsset: EthereumAddress;
|
|
255
|
-
collAssetId: number;
|
|
256
|
-
debtAsset: EthereumAddress;
|
|
257
|
-
debtAssetId: number;
|
|
258
|
-
closeType: CloseStrategyType;
|
|
259
|
-
marketAddr: EthereumAddress;
|
|
260
|
-
owner: EthereumAddress;
|
|
261
|
-
tsi: string;
|
|
262
|
-
slippage: string;
|
|
263
|
-
};
|
|
264
|
-
};
|
|
265
251
|
export declare const aaveV3CollateralSwitchSubData: {
|
|
266
252
|
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean): string[];
|
|
267
253
|
decode(subData: string[]): {
|
|
@@ -511,44 +511,6 @@ export const aaveV3CloseGenericSubData = {
|
|
|
511
511
|
};
|
|
512
512
|
},
|
|
513
513
|
};
|
|
514
|
-
export const aaveV3InstantCloseGenericSubData = {
|
|
515
|
-
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage) {
|
|
516
|
-
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
517
|
-
const encodedCollId = AbiCoder.encodeParameter('uint16', collAssetId);
|
|
518
|
-
const encodedDebt = AbiCoder.encodeParameter('address', debtAsset);
|
|
519
|
-
const encodedDebtId = AbiCoder.encodeParameter('uint16', debtAssetId);
|
|
520
|
-
const encodedCloseType = AbiCoder.encodeParameter('uint8', closeType);
|
|
521
|
-
const encodedMarket = AbiCoder.encodeParameter('address', marketAddr);
|
|
522
|
-
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
523
|
-
const encodedTsi = AbiCoder.encodeParameter('uint256', tsi);
|
|
524
|
-
const encodedSlippage = AbiCoder.encodeParameter('uint256', slippage);
|
|
525
|
-
return [
|
|
526
|
-
encodedColl,
|
|
527
|
-
encodedCollId,
|
|
528
|
-
encodedDebt,
|
|
529
|
-
encodedDebtId,
|
|
530
|
-
encodedCloseType,
|
|
531
|
-
encodedMarket,
|
|
532
|
-
encodedUser,
|
|
533
|
-
encodedTsi,
|
|
534
|
-
encodedSlippage,
|
|
535
|
-
];
|
|
536
|
-
},
|
|
537
|
-
decode(subData) {
|
|
538
|
-
const collAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
539
|
-
const collAssetId = Number(AbiCoder.decodeParameter('uint16', subData[1]));
|
|
540
|
-
const debtAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
541
|
-
const debtAssetId = Number(AbiCoder.decodeParameter('uint16', subData[3]));
|
|
542
|
-
const closeType = Number(AbiCoder.decodeParameter('uint8', subData[4]));
|
|
543
|
-
const marketAddr = AbiCoder.decodeParameter('address', subData[5]);
|
|
544
|
-
const owner = AbiCoder.decodeParameter('address', subData[6]);
|
|
545
|
-
const tsi = AbiCoder.decodeParameter('uint256', subData[7]);
|
|
546
|
-
const slippage = AbiCoder.decodeParameter('uint256', subData[8]);
|
|
547
|
-
return {
|
|
548
|
-
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner, tsi, slippage,
|
|
549
|
-
};
|
|
550
|
-
},
|
|
551
|
-
};
|
|
552
514
|
export const aaveV3CollateralSwitchSubData = {
|
|
553
515
|
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, useOnBehalf = false) {
|
|
554
516
|
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
@@ -2256,76 +2256,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2256
2256
|
});
|
|
2257
2257
|
});
|
|
2258
2258
|
});
|
|
2259
|
-
describe("When testing subDataService.aaveV3InstantCloseGenericSubData", () => {
|
|
2260
|
-
const WETH = web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address);
|
|
2261
|
-
const USDC = web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address);
|
|
2262
|
-
const MARKET = web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39');
|
|
2263
|
-
const USER = web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890');
|
|
2264
|
-
const examples = [
|
|
2265
|
-
// TAKE_PROFIT_IN_COLLATERAL, zero tsi and slippage
|
|
2266
|
-
[
|
|
2267
|
-
[
|
|
2268
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2269
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2270
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2271
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2272
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2273
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2274
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2275
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2276
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2277
|
-
],
|
|
2278
|
-
[WETH, 0, USDC, 1, CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL, MARKET, USER, '0', '0'],
|
|
2279
|
-
],
|
|
2280
|
-
// STOP_LOSS_IN_DEBT
|
|
2281
|
-
[
|
|
2282
|
-
[
|
|
2283
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2284
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2285
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2286
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2287
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
2288
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2289
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2290
|
-
'0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
|
|
2291
|
-
'0x000000000000000000000000000000000000000000000000002386f26fc10000',
|
|
2292
|
-
],
|
|
2293
|
-
[WETH, 0, USDC, 1, CloseStrategyType.STOP_LOSS_IN_DEBT, MARKET, USER, '1000000000000000000', '10000000000000000'],
|
|
2294
|
-
],
|
|
2295
|
-
// TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL, asset ids above uint8 range
|
|
2296
|
-
[
|
|
2297
|
-
[
|
|
2298
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2299
|
-
'0x000000000000000000000000000000000000000000000000000000000000012c',
|
|
2300
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2301
|
-
'0x0000000000000000000000000000000000000000000000000000000000000190',
|
|
2302
|
-
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
2303
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2304
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2305
|
-
'0x00000000000000000000000000000000000000000000000000b1a2bc2ec50000',
|
|
2306
|
-
'0x0000000000000000000000000000000000000000000000000011c37937e08000',
|
|
2307
|
-
],
|
|
2308
|
-
[WETH, 300, USDC, 400, CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL, MARKET, USER, '50000000000000000', '5000000000000000'],
|
|
2309
|
-
],
|
|
2310
|
-
];
|
|
2311
|
-
describe("encode()", () => {
|
|
2312
|
-
examples.forEach(([expected, actual]) => {
|
|
2313
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2314
|
-
expect(subDataService.aaveV3InstantCloseGenericSubData.encode(...actual)).to.eql(expected);
|
|
2315
|
-
});
|
|
2316
|
-
});
|
|
2317
|
-
});
|
|
2318
|
-
describe("decode()", () => {
|
|
2319
|
-
examples.forEach(([encoded, [collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage]]) => {
|
|
2320
|
-
const expected = {
|
|
2321
|
-
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner: user, tsi, slippage,
|
|
2322
|
-
};
|
|
2323
|
-
it(`Given ${JSON.stringify(encoded)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2324
|
-
expect(subDataService.aaveV3InstantCloseGenericSubData.decode(encoded)).to.eql(expected);
|
|
2325
|
-
});
|
|
2326
|
-
});
|
|
2327
|
-
});
|
|
2328
|
-
});
|
|
2329
2259
|
describe('When testing subDataService.sparkLeverageManagementOnPriceSubData', () => {
|
|
2330
2260
|
describe('encode()', () => {
|
|
2331
2261
|
const examples = [
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -124,8 +124,6 @@ export declare namespace Strategies {
|
|
|
124
124
|
CloseOnPriceToColl = "close-on-price-to-collateral",
|
|
125
125
|
CloseOnPrice = "close-on-price",
|
|
126
126
|
EoaCloseOnPrice = "eoa-close-on-price",
|
|
127
|
-
InstantCloseOnPrice = "instant-close-on-price",
|
|
128
|
-
EoaInstantCloseOnPrice = "eoa-instant-close-on-price",
|
|
129
127
|
TrailingStopToColl = "trailing-stop-to-collateral",
|
|
130
128
|
TrailingStopToDebt = "trailing-stop-to-debt",
|
|
131
129
|
Rebond = "rebond",
|
|
@@ -252,9 +250,7 @@ export declare namespace Bundles {
|
|
|
252
250
|
SPARK_EOA_REPAY_ON_PRICE = 90,
|
|
253
251
|
SPARK_EOA_BOOST_ON_PRICE = 91,
|
|
254
252
|
SPARK_EOA_CLOSE = 92,
|
|
255
|
-
SPARK_EOA_LIQUIDATION_PROTECTION = 93
|
|
256
|
-
AAVE_V3_SW_INSTANT_CLOSE = 94,
|
|
257
|
-
AAVE_V3_EOA_INSTANT_CLOSE = 95
|
|
253
|
+
SPARK_EOA_LIQUIDATION_PROTECTION = 93
|
|
258
254
|
}
|
|
259
255
|
enum OptimismIds {
|
|
260
256
|
AAVE_V3_REPAY = 0,
|
package/esm/types/enums.js
CHANGED
|
@@ -141,8 +141,6 @@ export var Strategies;
|
|
|
141
141
|
Identifiers["CloseOnPriceToColl"] = "close-on-price-to-collateral";
|
|
142
142
|
Identifiers["CloseOnPrice"] = "close-on-price";
|
|
143
143
|
Identifiers["EoaCloseOnPrice"] = "eoa-close-on-price";
|
|
144
|
-
Identifiers["InstantCloseOnPrice"] = "instant-close-on-price";
|
|
145
|
-
Identifiers["EoaInstantCloseOnPrice"] = "eoa-instant-close-on-price";
|
|
146
144
|
Identifiers["TrailingStopToColl"] = "trailing-stop-to-collateral";
|
|
147
145
|
Identifiers["TrailingStopToDebt"] = "trailing-stop-to-debt";
|
|
148
146
|
Identifiers["Rebond"] = "rebond";
|
|
@@ -273,8 +271,6 @@ export var Bundles;
|
|
|
273
271
|
MainnetIds[MainnetIds["SPARK_EOA_BOOST_ON_PRICE"] = 91] = "SPARK_EOA_BOOST_ON_PRICE";
|
|
274
272
|
MainnetIds[MainnetIds["SPARK_EOA_CLOSE"] = 92] = "SPARK_EOA_CLOSE";
|
|
275
273
|
MainnetIds[MainnetIds["SPARK_EOA_LIQUIDATION_PROTECTION"] = 93] = "SPARK_EOA_LIQUIDATION_PROTECTION";
|
|
276
|
-
MainnetIds[MainnetIds["AAVE_V3_SW_INSTANT_CLOSE"] = 94] = "AAVE_V3_SW_INSTANT_CLOSE";
|
|
277
|
-
MainnetIds[MainnetIds["AAVE_V3_EOA_INSTANT_CLOSE"] = 95] = "AAVE_V3_EOA_INSTANT_CLOSE";
|
|
278
274
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
279
275
|
let OptimismIds;
|
|
280
276
|
(function (OptimismIds) {
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -684,16 +684,6 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
684
684
|
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
685
685
|
protocol: PROTOCOLS.Spark,
|
|
686
686
|
},
|
|
687
|
-
[Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE]: {
|
|
688
|
-
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE,
|
|
689
|
-
strategyId: Strategies.Identifiers.InstantCloseOnPrice,
|
|
690
|
-
protocol: PROTOCOLS.AaveV3,
|
|
691
|
-
},
|
|
692
|
-
[Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE]: {
|
|
693
|
-
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
694
|
-
strategyId: Strategies.Identifiers.EoaInstantCloseOnPrice,
|
|
695
|
-
protocol: PROTOCOLS.AaveV3,
|
|
696
|
-
},
|
|
697
687
|
};
|
|
698
688
|
|
|
699
689
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
Bundles, CloseStrategyType, CloseToAssetType, ProtocolIdentifiers, Strategies,
|
|
5
|
-
} from '../types/enums';
|
|
3
|
+
import { ProtocolIdentifiers, Strategies } from '../types/enums';
|
|
6
4
|
import type { ParseData, Position } from '../types';
|
|
7
5
|
|
|
8
6
|
import '../configuration';
|
|
9
7
|
import { parseStrategiesAutomatedPosition } from './strategiesService';
|
|
10
|
-
import { aaveV3Encode } from './strategySubService';
|
|
11
8
|
|
|
12
9
|
describe('Feature: strategiesService.ts', () => {
|
|
13
10
|
describe('When testing strategiesService.parseStrategiesAutomatedPosition', async () => {
|
|
@@ -106,78 +103,4 @@ describe('Feature: strategiesService.ts', () => {
|
|
|
106
103
|
});
|
|
107
104
|
});
|
|
108
105
|
});
|
|
109
|
-
|
|
110
|
-
describe('When parsing Aave V3 instant close bundles', () => {
|
|
111
|
-
const owner = '0x1234567890123456789012345678901234567890';
|
|
112
|
-
const market = '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e';
|
|
113
|
-
const weth = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
114
|
-
const usdc = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
115
|
-
|
|
116
|
-
const bundles: Array<[string, Bundles.MainnetIds, Strategies.Identifiers]> = [
|
|
117
|
-
['SW', Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE, Strategies.Identifiers.InstantCloseOnPrice],
|
|
118
|
-
['EOA', Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE, Strategies.Identifiers.EoaInstantCloseOnPrice],
|
|
119
|
-
];
|
|
120
|
-
|
|
121
|
-
bundles.forEach(([walletType, expectedBundleId, expectedStrategyId]) => {
|
|
122
|
-
describe(`${walletType} bundle`, () => {
|
|
123
|
-
const [bundleId, isBundle, triggerData, subData] = aaveV3Encode.instantCloseOnPriceGeneric(
|
|
124
|
-
expectedBundleId,
|
|
125
|
-
weth, 0, usdc, 1, market, owner,
|
|
126
|
-
'1000000000000000000', '10000000000000000',
|
|
127
|
-
1500, CloseToAssetType.DEBT, 5000, CloseToAssetType.COLLATERAL,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const parseData = {
|
|
131
|
-
chainId: 1,
|
|
132
|
-
blockNumber: 1,
|
|
133
|
-
subscriptionEventData: {
|
|
134
|
-
subId: '1',
|
|
135
|
-
proxy: owner,
|
|
136
|
-
subHash: '0xhash',
|
|
137
|
-
subStruct: {
|
|
138
|
-
strategyOrBundleId: String(bundleId), isBundle, triggerData, subData,
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
strategiesSubsData: { userProxy: owner, isEnabled: true, strategySubHash: '0xhash' },
|
|
142
|
-
} as unknown as ParseData;
|
|
143
|
-
|
|
144
|
-
const result = parseStrategiesAutomatedPosition(parseData) as Position.Automated;
|
|
145
|
-
|
|
146
|
-
it('should identify the strategy as instant close on price', () => {
|
|
147
|
-
expect(result.strategy.strategyOrBundleId).to.equal(expectedBundleId);
|
|
148
|
-
expect(result.strategy.strategyId).to.equal(expectedStrategyId);
|
|
149
|
-
expect(result.protocol.id).to.equal(ProtocolIdentifiers.StrategiesAutomation.AaveV3);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('should decode sub data including tsi and slippage', () => {
|
|
153
|
-
expect(result.strategyData.decoded.subData).to.eql({
|
|
154
|
-
collAsset: weth,
|
|
155
|
-
collAssetId: 0,
|
|
156
|
-
debtAsset: usdc,
|
|
157
|
-
debtAssetId: 1,
|
|
158
|
-
closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
159
|
-
marketAddr: market,
|
|
160
|
-
owner,
|
|
161
|
-
tsi: '1000000000000000000',
|
|
162
|
-
slippage: '10000000000000000',
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('should fill specific with prices and close types', () => {
|
|
167
|
-
expect(result.specific).to.eql({
|
|
168
|
-
collAsset: weth,
|
|
169
|
-
collAssetId: 0,
|
|
170
|
-
debtAsset: usdc,
|
|
171
|
-
debtAssetId: 1,
|
|
172
|
-
baseToken: weth,
|
|
173
|
-
quoteToken: usdc,
|
|
174
|
-
stopLossPrice: '1500',
|
|
175
|
-
takeProfitPrice: '5000',
|
|
176
|
-
stopLossType: CloseToAssetType.DEBT,
|
|
177
|
-
takeProfitType: CloseToAssetType.COLLATERAL,
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
106
|
});
|
|
@@ -433,37 +433,6 @@ function parseAaveV3CloseOnPrice(position: Position.Automated, parseData: ParseD
|
|
|
433
433
|
return _position;
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
-
function parseAaveV3InstantCloseOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
437
|
-
const _position = cloneDeep(position);
|
|
438
|
-
|
|
439
|
-
const { subStruct } = parseData.subscriptionEventData;
|
|
440
|
-
|
|
441
|
-
const triggerData = triggerService.aaveV3QuotePriceRangeTrigger.decode(subStruct.triggerData);
|
|
442
|
-
const subData = subDataService.aaveV3InstantCloseGenericSubData.decode(subStruct.subData);
|
|
443
|
-
|
|
444
|
-
const { takeProfitType, stopLossType } = getStopLossAndTakeProfitTypeByCloseStrategyType(+subData.closeType);
|
|
445
|
-
|
|
446
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, AAVE_V3_MARKET_ADDRESSES[_position.chainId]);
|
|
447
|
-
|
|
448
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
449
|
-
_position.strategyData.decoded.subData = subData;
|
|
450
|
-
|
|
451
|
-
_position.specific = {
|
|
452
|
-
collAsset: subData.collAsset,
|
|
453
|
-
collAssetId: subData.collAssetId,
|
|
454
|
-
debtAsset: subData.debtAsset,
|
|
455
|
-
debtAssetId: subData.debtAssetId,
|
|
456
|
-
baseToken: triggerData.collToken,
|
|
457
|
-
quoteToken: triggerData.debtToken,
|
|
458
|
-
stopLossPrice: triggerData.lowerPrice,
|
|
459
|
-
takeProfitPrice: triggerData.upperPrice,
|
|
460
|
-
stopLossType,
|
|
461
|
-
takeProfitType,
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
return _position;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
436
|
function parseAaveV3CollateralSwitch(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
468
437
|
const _position = cloneDeep(position);
|
|
469
438
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -1627,8 +1596,6 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1627
1596
|
[Strategies.Identifiers.EoaRepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1628
1597
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1629
1598
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1630
|
-
[Strategies.Identifiers.InstantCloseOnPrice]: parseAaveV3InstantCloseOnPrice,
|
|
1631
|
-
[Strategies.Identifiers.EoaInstantCloseOnPrice]: parseAaveV3InstantCloseOnPrice,
|
|
1632
1599
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1633
1600
|
[Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1634
1601
|
[Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
@@ -887,136 +887,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
887
887
|
});
|
|
888
888
|
});
|
|
889
889
|
|
|
890
|
-
describe('instantCloseOnPriceGeneric()', () => {
|
|
891
|
-
const examples: Array<[
|
|
892
|
-
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
893
|
-
[
|
|
894
|
-
strategyOrBundleId: number,
|
|
895
|
-
collAsset: EthereumAddress,
|
|
896
|
-
collAssetId: number,
|
|
897
|
-
debtAsset: EthereumAddress,
|
|
898
|
-
debtAssetId: number,
|
|
899
|
-
marketAddr: EthereumAddress,
|
|
900
|
-
user: EthereumAddress,
|
|
901
|
-
tsi: string,
|
|
902
|
-
slippage: string,
|
|
903
|
-
stopLossPrice: number,
|
|
904
|
-
stopLossType: CloseToAssetType,
|
|
905
|
-
takeProfitPrice: number,
|
|
906
|
-
takeProfitType: CloseToAssetType
|
|
907
|
-
]
|
|
908
|
-
]> = [
|
|
909
|
-
// Stop loss only (to debt)
|
|
910
|
-
[
|
|
911
|
-
[
|
|
912
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
913
|
-
true,
|
|
914
|
-
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000'],
|
|
915
|
-
[
|
|
916
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
917
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
918
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
919
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
920
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
921
|
-
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
922
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
923
|
-
'0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
|
|
924
|
-
'0x000000000000000000000000000000000000000000000000002386f26fc10000',
|
|
925
|
-
],
|
|
926
|
-
],
|
|
927
|
-
[
|
|
928
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
929
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
930
|
-
0,
|
|
931
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
932
|
-
1,
|
|
933
|
-
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
934
|
-
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
935
|
-
'1000000000000000000', // tsi
|
|
936
|
-
'10000000000000000', // slippage
|
|
937
|
-
1500, // stopLossPrice
|
|
938
|
-
CloseToAssetType.DEBT, // stopLossType
|
|
939
|
-
0, // takeProfitPrice
|
|
940
|
-
CloseToAssetType.COLLATERAL, // takeProfitType (not used since price is 0)
|
|
941
|
-
]
|
|
942
|
-
],
|
|
943
|
-
// Take profit only (to collateral), zero tsi and slippage
|
|
944
|
-
[
|
|
945
|
-
[
|
|
946
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
947
|
-
true,
|
|
948
|
-
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
949
|
-
[
|
|
950
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
951
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
952
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
953
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
954
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
955
|
-
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
956
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
957
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
958
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
959
|
-
],
|
|
960
|
-
],
|
|
961
|
-
[
|
|
962
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
963
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
964
|
-
0,
|
|
965
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
966
|
-
1,
|
|
967
|
-
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
968
|
-
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
969
|
-
'0', // tsi
|
|
970
|
-
'0', // slippage
|
|
971
|
-
0, // stopLossPrice
|
|
972
|
-
CloseToAssetType.DEBT, // stopLossType (not used since price is 0)
|
|
973
|
-
5000, // takeProfitPrice
|
|
974
|
-
CloseToAssetType.COLLATERAL, // takeProfitType
|
|
975
|
-
]
|
|
976
|
-
],
|
|
977
|
-
// Take profit (to debt) and stop loss (to collateral)
|
|
978
|
-
[
|
|
979
|
-
[
|
|
980
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
981
|
-
true,
|
|
982
|
-
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
983
|
-
[
|
|
984
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
985
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
986
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
987
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
988
|
-
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
989
|
-
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
990
|
-
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
991
|
-
'0x00000000000000000000000000000000000000000000000000b1a2bc2ec50000',
|
|
992
|
-
'0x0000000000000000000000000000000000000000000000000011c37937e08000',
|
|
993
|
-
],
|
|
994
|
-
],
|
|
995
|
-
[
|
|
996
|
-
Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
997
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
998
|
-
0,
|
|
999
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1000
|
-
1,
|
|
1001
|
-
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
1002
|
-
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1003
|
-
'50000000000000000', // tsi
|
|
1004
|
-
'5000000000000000', // slippage
|
|
1005
|
-
1500, // stopLossPrice
|
|
1006
|
-
CloseToAssetType.COLLATERAL, // stopLossType
|
|
1007
|
-
4000, // takeProfitPrice
|
|
1008
|
-
CloseToAssetType.DEBT, // takeProfitType
|
|
1009
|
-
]
|
|
1010
|
-
],
|
|
1011
|
-
];
|
|
1012
|
-
|
|
1013
|
-
examples.forEach(([expected, actual]) => {
|
|
1014
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1015
|
-
expect(aaveV3Encode.instantCloseOnPriceGeneric(...actual)).to.eql(expected);
|
|
1016
|
-
});
|
|
1017
|
-
});
|
|
1018
|
-
});
|
|
1019
|
-
|
|
1020
890
|
describe('collateralSwitch()', () => {
|
|
1021
891
|
const examples: Array<[
|
|
1022
892
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -424,32 +424,6 @@ export const aaveV3Encode = {
|
|
|
424
424
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
425
425
|
},
|
|
426
426
|
|
|
427
|
-
instantCloseOnPriceGeneric(
|
|
428
|
-
strategyOrBundleId: number,
|
|
429
|
-
collAsset: EthereumAddress,
|
|
430
|
-
collAssetId: number,
|
|
431
|
-
debtAsset: EthereumAddress,
|
|
432
|
-
debtAssetId: number,
|
|
433
|
-
marketAddr: EthereumAddress,
|
|
434
|
-
user: EthereumAddress,
|
|
435
|
-
tsi: string,
|
|
436
|
-
slippage: string,
|
|
437
|
-
stopLossPrice: number = 0,
|
|
438
|
-
stopLossType: CloseToAssetType = CloseToAssetType.DEBT,
|
|
439
|
-
takeProfitPrice: number = 0,
|
|
440
|
-
takeProfitType: CloseToAssetType = CloseToAssetType.COLLATERAL,
|
|
441
|
-
) {
|
|
442
|
-
const isBundle = true;
|
|
443
|
-
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
444
|
-
|
|
445
|
-
const subDataEncoded = subDataService.aaveV3InstantCloseGenericSubData.encode(
|
|
446
|
-
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage,
|
|
447
|
-
);
|
|
448
|
-
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
449
|
-
|
|
450
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
451
|
-
},
|
|
452
|
-
|
|
453
427
|
collateralSwitch(
|
|
454
428
|
strategyOrBundleId: number,
|
|
455
429
|
fromAsset: EthereumAddress,
|