@defisaver/automation-sdk 3.3.21-debt-switch-dev-dev → 3.3.21-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 +10 -40
- package/cjs/services/strategiesService.js +21 -9
- package/cjs/services/strategiesService.test.js +62 -0
- package/cjs/services/strategySubService.d.ts +1 -1
- package/cjs/services/strategySubService.js +7 -6
- package/cjs/services/strategySubService.test.js +111 -71
- package/cjs/services/subDataService.d.ts +12 -10
- package/cjs/services/subDataService.js +36 -30
- package/cjs/services/subDataService.test.js +70 -104
- package/cjs/types/enums.d.ts +9 -15
- package/cjs/types/enums.js +4 -10
- package/esm/constants/index.js +10 -40
- package/esm/services/strategiesService.js +21 -9
- package/esm/services/strategiesService.test.js +63 -1
- package/esm/services/strategySubService.d.ts +1 -1
- package/esm/services/strategySubService.js +7 -6
- package/esm/services/strategySubService.test.js +111 -71
- package/esm/services/subDataService.d.ts +12 -10
- package/esm/services/subDataService.js +35 -29
- package/esm/services/subDataService.test.js +70 -104
- package/esm/types/enums.d.ts +9 -15
- package/esm/types/enums.js +4 -10
- package/package.json +1 -1
- package/src/constants/index.ts +10 -40
- package/src/services/strategiesService.test.ts +78 -1
- package/src/services/strategiesService.ts +27 -9
- package/src/services/strategySubService.test.ts +125 -84
- package/src/services/strategySubService.ts +20 -16
- package/src/services/subDataService.test.ts +98 -108
- package/src/services/subDataService.ts +51 -40
- package/src/types/enums.ts +4 -10
|
@@ -549,114 +549,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
549
549
|
});
|
|
550
550
|
});
|
|
551
551
|
|
|
552
|
-
describe('When testing subDataService.aaveV3DebtSwitchSubData', () => {
|
|
553
|
-
describe('encode()', () => {
|
|
554
|
-
const examples: Array<[SubData, [fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress]]> = [
|
|
555
|
-
// USDC -> DAI
|
|
556
|
-
[
|
|
557
|
-
[
|
|
558
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
559
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
560
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
561
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
562
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
563
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
564
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
565
|
-
],
|
|
566
|
-
[
|
|
567
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
568
|
-
1,
|
|
569
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
570
|
-
3,
|
|
571
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
572
|
-
'10000000000000000000', // 10 tokens
|
|
573
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
574
|
-
]
|
|
575
|
-
],
|
|
576
|
-
// DAI -> USDC (MaxUint256)
|
|
577
|
-
[
|
|
578
|
-
[
|
|
579
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
580
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
581
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
582
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
583
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
584
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
585
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
586
|
-
],
|
|
587
|
-
[
|
|
588
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
589
|
-
3,
|
|
590
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
591
|
-
1,
|
|
592
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
593
|
-
MAXUINT, // MaxUint256
|
|
594
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
595
|
-
]
|
|
596
|
-
],
|
|
597
|
-
];
|
|
598
|
-
|
|
599
|
-
examples.forEach(([expected, actual]) => {
|
|
600
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
601
|
-
expect(subDataService.aaveV3DebtSwitchSubData.encode(...actual)).to.eql(expected);
|
|
602
|
-
});
|
|
603
|
-
});
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
describe('decode()', () => {
|
|
607
|
-
const examples: Array<[{ fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress }, SubData]> = [
|
|
608
|
-
// USDC -> DAI
|
|
609
|
-
[
|
|
610
|
-
{
|
|
611
|
-
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
612
|
-
fromAssetId: 1,
|
|
613
|
-
toAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
614
|
-
toAssetId: 3,
|
|
615
|
-
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
616
|
-
amountToSwitch: '10000000000000000000',
|
|
617
|
-
user: web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
618
|
-
},
|
|
619
|
-
[
|
|
620
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
621
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
622
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
623
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
624
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
625
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
626
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
627
|
-
],
|
|
628
|
-
],
|
|
629
|
-
// DAI -> USDC (MaxUint256)
|
|
630
|
-
[
|
|
631
|
-
{
|
|
632
|
-
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
633
|
-
fromAssetId: 3,
|
|
634
|
-
toAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
635
|
-
toAssetId: 1,
|
|
636
|
-
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
637
|
-
amountToSwitch: MAXUINT,
|
|
638
|
-
user: web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
639
|
-
},
|
|
640
|
-
[
|
|
641
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
642
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
643
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
644
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
645
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
646
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
647
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
648
|
-
],
|
|
649
|
-
],
|
|
650
|
-
];
|
|
651
|
-
|
|
652
|
-
examples.forEach(([expected, actual]) => {
|
|
653
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
654
|
-
expect(subDataService.aaveV3DebtSwitchSubData.decode(actual)).to.eql(expected);
|
|
655
|
-
});
|
|
656
|
-
});
|
|
657
|
-
});
|
|
658
|
-
});
|
|
659
|
-
|
|
660
552
|
describe('When testing subDataService.sparkCollateralSwitchSubData', () => {
|
|
661
553
|
describe('encode()', () => {
|
|
662
554
|
const examples: Array<[SubData, [fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, useOnBehalf?: boolean]]> = [
|
|
@@ -2603,6 +2495,104 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2603
2495
|
});
|
|
2604
2496
|
});
|
|
2605
2497
|
});
|
|
2498
|
+
|
|
2499
|
+
describe("When testing subDataService.aaveV3InstantCloseGenericSubData", () => {
|
|
2500
|
+
const WETH = web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address);
|
|
2501
|
+
const USDC = web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address);
|
|
2502
|
+
const MARKET = web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39');
|
|
2503
|
+
const USER = web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890');
|
|
2504
|
+
|
|
2505
|
+
const examples: Array<
|
|
2506
|
+
[
|
|
2507
|
+
string[],
|
|
2508
|
+
[
|
|
2509
|
+
collAsset: EthereumAddress,
|
|
2510
|
+
collAssetId: number,
|
|
2511
|
+
debtAsset: EthereumAddress,
|
|
2512
|
+
debtAssetId: number,
|
|
2513
|
+
closeType: CloseStrategyType,
|
|
2514
|
+
marketAddr: EthereumAddress,
|
|
2515
|
+
user: EthereumAddress,
|
|
2516
|
+
tsi: string,
|
|
2517
|
+
slippage: string
|
|
2518
|
+
]
|
|
2519
|
+
]
|
|
2520
|
+
> = [
|
|
2521
|
+
// TAKE_PROFIT_IN_COLLATERAL, zero tsi and slippage
|
|
2522
|
+
[
|
|
2523
|
+
[
|
|
2524
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2525
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2526
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2527
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2528
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2529
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2530
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2531
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2532
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2533
|
+
],
|
|
2534
|
+
[WETH, 0, USDC, 1, CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL, MARKET, USER, '0', '0'],
|
|
2535
|
+
],
|
|
2536
|
+
// STOP_LOSS_IN_DEBT
|
|
2537
|
+
[
|
|
2538
|
+
[
|
|
2539
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2540
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2541
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2542
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2543
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
2544
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2545
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2546
|
+
'0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
|
|
2547
|
+
'0x000000000000000000000000000000000000000000000000002386f26fc10000',
|
|
2548
|
+
],
|
|
2549
|
+
[WETH, 0, USDC, 1, CloseStrategyType.STOP_LOSS_IN_DEBT, MARKET, USER, '1000000000000000000', '10000000000000000'],
|
|
2550
|
+
],
|
|
2551
|
+
// TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL, asset ids above uint8 range
|
|
2552
|
+
[
|
|
2553
|
+
[
|
|
2554
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2555
|
+
'0x000000000000000000000000000000000000000000000000000000000000012c',
|
|
2556
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2557
|
+
'0x0000000000000000000000000000000000000000000000000000000000000190',
|
|
2558
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
2559
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2560
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2561
|
+
'0x00000000000000000000000000000000000000000000000000b1a2bc2ec50000',
|
|
2562
|
+
'0x0000000000000000000000000000000000000000000000000011c37937e08000',
|
|
2563
|
+
],
|
|
2564
|
+
[WETH, 300, USDC, 400, CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL, MARKET, USER, '50000000000000000', '5000000000000000'],
|
|
2565
|
+
],
|
|
2566
|
+
];
|
|
2567
|
+
|
|
2568
|
+
describe("encode()", () => {
|
|
2569
|
+
examples.forEach(([expected, actual]) => {
|
|
2570
|
+
it(`Given ${JSON.stringify(
|
|
2571
|
+
actual
|
|
2572
|
+
)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2573
|
+
expect(
|
|
2574
|
+
subDataService.aaveV3InstantCloseGenericSubData.encode(...actual)
|
|
2575
|
+
).to.eql(expected);
|
|
2576
|
+
});
|
|
2577
|
+
});
|
|
2578
|
+
});
|
|
2579
|
+
|
|
2580
|
+
describe("decode()", () => {
|
|
2581
|
+
examples.forEach(([encoded, [collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage]]) => {
|
|
2582
|
+
const expected = {
|
|
2583
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner: user, tsi, slippage,
|
|
2584
|
+
};
|
|
2585
|
+
|
|
2586
|
+
it(`Given ${JSON.stringify(
|
|
2587
|
+
encoded
|
|
2588
|
+
)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2589
|
+
expect(
|
|
2590
|
+
subDataService.aaveV3InstantCloseGenericSubData.decode(encoded)
|
|
2591
|
+
).to.eql(expected);
|
|
2592
|
+
});
|
|
2593
|
+
});
|
|
2594
|
+
});
|
|
2595
|
+
});
|
|
2606
2596
|
describe('When testing subDataService.sparkLeverageManagementOnPriceSubData', () => {
|
|
2607
2597
|
describe('encode()', () => {
|
|
2608
2598
|
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]] > =
|
|
@@ -687,55 +687,68 @@ export const aaveV3CloseGenericSubData = {
|
|
|
687
687
|
};
|
|
688
688
|
},
|
|
689
689
|
};
|
|
690
|
-
export const
|
|
690
|
+
export const aaveV3InstantCloseGenericSubData = {
|
|
691
691
|
encode(
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
692
|
+
collAsset: EthereumAddress,
|
|
693
|
+
collAssetId: number,
|
|
694
|
+
debtAsset: EthereumAddress,
|
|
695
|
+
debtAssetId: number,
|
|
696
|
+
closeType: CloseStrategyType,
|
|
696
697
|
marketAddr: EthereumAddress,
|
|
697
|
-
|
|
698
|
-
|
|
698
|
+
user: EthereumAddress,
|
|
699
|
+
tsi: string,
|
|
700
|
+
slippage: string,
|
|
699
701
|
): SubData {
|
|
700
|
-
const
|
|
701
|
-
const
|
|
702
|
-
const
|
|
703
|
-
const
|
|
704
|
-
const
|
|
705
|
-
const
|
|
706
|
-
const
|
|
702
|
+
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
703
|
+
const encodedCollId = AbiCoder.encodeParameter('uint16', collAssetId);
|
|
704
|
+
const encodedDebt = AbiCoder.encodeParameter('address', debtAsset);
|
|
705
|
+
const encodedDebtId = AbiCoder.encodeParameter('uint16', debtAssetId);
|
|
706
|
+
const encodedCloseType = AbiCoder.encodeParameter('uint8', closeType);
|
|
707
|
+
const encodedMarket = AbiCoder.encodeParameter('address', marketAddr);
|
|
708
|
+
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
709
|
+
const encodedTsi = AbiCoder.encodeParameter('uint256', tsi);
|
|
710
|
+
const encodedSlippage = AbiCoder.encodeParameter('uint256', slippage);
|
|
707
711
|
|
|
708
712
|
return [
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
713
|
+
encodedColl,
|
|
714
|
+
encodedCollId,
|
|
715
|
+
encodedDebt,
|
|
716
|
+
encodedDebtId,
|
|
717
|
+
encodedCloseType,
|
|
718
|
+
encodedMarket,
|
|
719
|
+
encodedUser,
|
|
720
|
+
encodedTsi,
|
|
721
|
+
encodedSlippage,
|
|
716
722
|
];
|
|
717
723
|
},
|
|
724
|
+
|
|
718
725
|
decode(subData: SubData): {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
726
|
+
collAsset: EthereumAddress,
|
|
727
|
+
collAssetId: number,
|
|
728
|
+
debtAsset: EthereumAddress,
|
|
729
|
+
debtAssetId: number,
|
|
730
|
+
closeType: CloseStrategyType,
|
|
723
731
|
marketAddr: EthereumAddress,
|
|
724
|
-
|
|
732
|
+
owner: EthereumAddress,
|
|
733
|
+
tsi: string,
|
|
734
|
+
slippage: string,
|
|
725
735
|
} {
|
|
726
|
-
const
|
|
727
|
-
const
|
|
728
|
-
const
|
|
729
|
-
const
|
|
730
|
-
const
|
|
731
|
-
const
|
|
736
|
+
const collAsset = AbiCoder.decodeParameter('address', subData[0]) as unknown as EthereumAddress;
|
|
737
|
+
const collAssetId = Number(AbiCoder.decodeParameter('uint16', subData[1]));
|
|
738
|
+
const debtAsset = AbiCoder.decodeParameter('address', subData[2]) as unknown as EthereumAddress;
|
|
739
|
+
const debtAssetId = Number(AbiCoder.decodeParameter('uint16', subData[3]));
|
|
740
|
+
const closeType = Number(AbiCoder.decodeParameter('uint8', subData[4])) as CloseStrategyType;
|
|
741
|
+
const marketAddr = AbiCoder.decodeParameter('address', subData[5]) as unknown as EthereumAddress;
|
|
742
|
+
const owner = AbiCoder.decodeParameter('address', subData[6]) as unknown as EthereumAddress;
|
|
743
|
+
const tsi = AbiCoder.decodeParameter('uint256', subData[7]) as unknown as string;
|
|
744
|
+
const slippage = AbiCoder.decodeParameter('uint256', subData[8]) as unknown as string;
|
|
732
745
|
|
|
733
746
|
return {
|
|
734
|
-
|
|
747
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner, tsi, slippage,
|
|
735
748
|
};
|
|
736
749
|
},
|
|
737
750
|
};
|
|
738
|
-
export const
|
|
751
|
+
export const aaveV3CollateralSwitchSubData = {
|
|
739
752
|
encode(
|
|
740
753
|
fromAsset: EthereumAddress,
|
|
741
754
|
fromAssetId: number,
|
|
@@ -743,7 +756,7 @@ export const aaveV3DebtSwitchSubData = {
|
|
|
743
756
|
toAssetId: number,
|
|
744
757
|
marketAddr: EthereumAddress,
|
|
745
758
|
amountToSwitch: string,
|
|
746
|
-
|
|
759
|
+
useOnBehalf: boolean = false,
|
|
747
760
|
): SubData {
|
|
748
761
|
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
749
762
|
const encodedFromAssetId = AbiCoder.encodeParameter('uint8', fromAssetId);
|
|
@@ -751,7 +764,7 @@ export const aaveV3DebtSwitchSubData = {
|
|
|
751
764
|
const encodedToAssetId = AbiCoder.encodeParameter('uint8', toAssetId);
|
|
752
765
|
const encodedMarketAddr = AbiCoder.encodeParameter('address', marketAddr);
|
|
753
766
|
const encodedAmountToSwitch = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
754
|
-
const
|
|
767
|
+
const encodedUseOnBehalf = AbiCoder.encodeParameter('bool', useOnBehalf);
|
|
755
768
|
|
|
756
769
|
return [
|
|
757
770
|
encodedFromAsset,
|
|
@@ -760,7 +773,7 @@ export const aaveV3DebtSwitchSubData = {
|
|
|
760
773
|
encodedToAssetId,
|
|
761
774
|
encodedMarketAddr,
|
|
762
775
|
encodedAmountToSwitch,
|
|
763
|
-
|
|
776
|
+
encodedUseOnBehalf,
|
|
764
777
|
];
|
|
765
778
|
},
|
|
766
779
|
decode(subData: SubData): {
|
|
@@ -770,7 +783,6 @@ export const aaveV3DebtSwitchSubData = {
|
|
|
770
783
|
toAssetId: number,
|
|
771
784
|
marketAddr: EthereumAddress,
|
|
772
785
|
amountToSwitch: string,
|
|
773
|
-
user: EthereumAddress,
|
|
774
786
|
} {
|
|
775
787
|
const fromAsset = AbiCoder.decodeParameter('address', subData[0]) as unknown as EthereumAddress;
|
|
776
788
|
const fromAssetId = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
@@ -778,10 +790,9 @@ export const aaveV3DebtSwitchSubData = {
|
|
|
778
790
|
const toAssetId = Number(AbiCoder.decodeParameter('uint8', subData[3]));
|
|
779
791
|
const marketAddr = AbiCoder.decodeParameter('address', subData[4]) as unknown as EthereumAddress;
|
|
780
792
|
const amountToSwitch = AbiCoder.decodeParameter('uint256', subData[5]) as unknown as string;
|
|
781
|
-
const user = AbiCoder.decodeParameter('address', subData[6]) as unknown as EthereumAddress;
|
|
782
793
|
|
|
783
794
|
return {
|
|
784
|
-
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
795
|
+
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch,
|
|
785
796
|
};
|
|
786
797
|
},
|
|
787
798
|
};
|
package/src/types/enums.ts
CHANGED
|
@@ -102,32 +102,24 @@ export namespace Strategies {
|
|
|
102
102
|
AAVE_V4_COLLATERAL_SWITCH_EOA = 155,
|
|
103
103
|
SPARK_COLLATERAL_SWITCH = 156,
|
|
104
104
|
SPARK_GENERIC_FL_COLLATERAL_SWITCH = 167,
|
|
105
|
-
AAVE_V3_DEBT_SWITCH = 168,
|
|
106
|
-
AAVE_V3_DEBT_SWITCH_EOA = 169,
|
|
107
105
|
}
|
|
108
106
|
|
|
109
107
|
export enum OptimismIds {
|
|
110
108
|
EXCHANGE_DCA = 8,
|
|
111
109
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
112
110
|
AAVE_V3_COLLATERAL_SWITCH = 24,
|
|
113
|
-
AAVE_V3_DEBT_SWITCH = 25,
|
|
114
|
-
AAVE_V3_DEBT_SWITCH_EOA = 26,
|
|
115
111
|
}
|
|
116
112
|
|
|
117
113
|
export enum BaseIds {
|
|
118
114
|
EXCHANGE_DCA = 8,
|
|
119
115
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
120
116
|
AAVE_V3_COLLATERAL_SWITCH = 56,
|
|
121
|
-
AAVE_V3_DEBT_SWITCH = 61,
|
|
122
|
-
AAVE_V3_DEBT_SWITCH_EOA = 62,
|
|
123
117
|
}
|
|
124
118
|
|
|
125
119
|
export enum ArbitrumIds {
|
|
126
120
|
EXCHANGE_DCA = 8,
|
|
127
121
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
128
122
|
AAVE_V3_COLLATERAL_SWITCH = 50,
|
|
129
|
-
AAVE_V3_DEBT_SWITCH = 55,
|
|
130
|
-
AAVE_V3_DEBT_SWITCH_EOA = 56,
|
|
131
123
|
}
|
|
132
124
|
|
|
133
125
|
export enum Identifiers {
|
|
@@ -146,6 +138,8 @@ export namespace Strategies {
|
|
|
146
138
|
CloseOnPriceToColl = 'close-on-price-to-collateral',
|
|
147
139
|
CloseOnPrice = 'close-on-price',
|
|
148
140
|
EoaCloseOnPrice = 'eoa-close-on-price',
|
|
141
|
+
InstantCloseOnPrice = 'instant-close-on-price',
|
|
142
|
+
EoaInstantCloseOnPrice = 'eoa-instant-close-on-price',
|
|
149
143
|
TrailingStopToColl = 'trailing-stop-to-collateral',
|
|
150
144
|
TrailingStopToDebt = 'trailing-stop-to-debt',
|
|
151
145
|
Rebond = 'rebond',
|
|
@@ -162,8 +156,6 @@ export namespace Strategies {
|
|
|
162
156
|
EoaRepayOnPrice = 'eoa-repay-on-price',
|
|
163
157
|
CollateralSwitch = 'collateral-switch',
|
|
164
158
|
EoaCollateralSwitch = 'eoa-collateral-switch',
|
|
165
|
-
DebtSwitch = 'debt-switch',
|
|
166
|
-
EoaDebtSwitch = 'eoa-debt-switch',
|
|
167
159
|
LiquidationProtection = 'liquidation-protection',
|
|
168
160
|
EoaLiquidationProtection = 'liquidation-protection-eoa',
|
|
169
161
|
}
|
|
@@ -276,6 +268,8 @@ export namespace Bundles {
|
|
|
276
268
|
SPARK_EOA_BOOST_ON_PRICE = 91,
|
|
277
269
|
SPARK_EOA_CLOSE = 92,
|
|
278
270
|
SPARK_EOA_LIQUIDATION_PROTECTION = 93,
|
|
271
|
+
AAVE_V3_SW_INSTANT_CLOSE = 94,
|
|
272
|
+
AAVE_V3_EOA_INSTANT_CLOSE = 95,
|
|
279
273
|
}
|
|
280
274
|
|
|
281
275
|
export enum OptimismIds {
|