@defisaver/automation-sdk 3.3.21-debt-switch-dev-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 -40
- package/cjs/services/strategiesService.js +0 -13
- package/cjs/services/strategySubService.d.ts +0 -1
- package/cjs/services/strategySubService.js +0 -6
- package/cjs/services/strategySubService.test.js +0 -71
- package/cjs/services/subDataService.d.ts +0 -12
- package/cjs/services/subDataService.js +2 -34
- package/cjs/services/subDataService.test.js +0 -104
- package/cjs/types/enums.d.ts +4 -14
- package/cjs/types/enums.js +0 -10
- package/esm/constants/index.js +0 -40
- package/esm/services/strategiesService.js +0 -13
- package/esm/services/strategySubService.d.ts +0 -1
- package/esm/services/strategySubService.js +0 -6
- package/esm/services/strategySubService.test.js +0 -71
- package/esm/services/subDataService.d.ts +0 -12
- package/esm/services/subDataService.js +0 -32
- package/esm/services/subDataService.test.js +0 -104
- package/esm/types/enums.d.ts +4 -14
- package/esm/types/enums.js +0 -10
- package/package.json +1 -1
- package/src/constants/index.ts +0 -40
- package/src/services/strategiesService.ts +0 -15
- package/src/services/strategySubService.test.ts +0 -89
- package/src/services/strategySubService.ts +0 -22
- package/src/services/subDataService.test.ts +0 -108
- package/src/services/subDataService.ts +0 -50
- package/src/types/enums.ts +0 -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]]> = [
|
|
@@ -735,56 +735,6 @@ export const aaveV3CollateralSwitchSubData = {
|
|
|
735
735
|
};
|
|
736
736
|
},
|
|
737
737
|
};
|
|
738
|
-
export const aaveV3DebtSwitchSubData = {
|
|
739
|
-
encode(
|
|
740
|
-
fromAsset: EthereumAddress,
|
|
741
|
-
fromAssetId: number,
|
|
742
|
-
toAsset: EthereumAddress,
|
|
743
|
-
toAssetId: number,
|
|
744
|
-
marketAddr: EthereumAddress,
|
|
745
|
-
amountToSwitch: string,
|
|
746
|
-
user: EthereumAddress,
|
|
747
|
-
): SubData {
|
|
748
|
-
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
749
|
-
const encodedFromAssetId = AbiCoder.encodeParameter('uint8', fromAssetId);
|
|
750
|
-
const encodedToAsset = AbiCoder.encodeParameter('address', toAsset);
|
|
751
|
-
const encodedToAssetId = AbiCoder.encodeParameter('uint8', toAssetId);
|
|
752
|
-
const encodedMarketAddr = AbiCoder.encodeParameter('address', marketAddr);
|
|
753
|
-
const encodedAmountToSwitch = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
754
|
-
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
755
|
-
|
|
756
|
-
return [
|
|
757
|
-
encodedFromAsset,
|
|
758
|
-
encodedFromAssetId,
|
|
759
|
-
encodedToAsset,
|
|
760
|
-
encodedToAssetId,
|
|
761
|
-
encodedMarketAddr,
|
|
762
|
-
encodedAmountToSwitch,
|
|
763
|
-
encodedUser,
|
|
764
|
-
];
|
|
765
|
-
},
|
|
766
|
-
decode(subData: SubData): {
|
|
767
|
-
fromAsset: EthereumAddress,
|
|
768
|
-
fromAssetId: number,
|
|
769
|
-
toAsset: EthereumAddress,
|
|
770
|
-
toAssetId: number,
|
|
771
|
-
marketAddr: EthereumAddress,
|
|
772
|
-
amountToSwitch: string,
|
|
773
|
-
user: EthereumAddress,
|
|
774
|
-
} {
|
|
775
|
-
const fromAsset = AbiCoder.decodeParameter('address', subData[0]) as unknown as EthereumAddress;
|
|
776
|
-
const fromAssetId = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
777
|
-
const toAsset = AbiCoder.decodeParameter('address', subData[2]) as unknown as EthereumAddress;
|
|
778
|
-
const toAssetId = Number(AbiCoder.decodeParameter('uint8', subData[3]));
|
|
779
|
-
const marketAddr = AbiCoder.decodeParameter('address', subData[4]) as unknown as EthereumAddress;
|
|
780
|
-
const amountToSwitch = AbiCoder.decodeParameter('uint256', subData[5]) as unknown as string;
|
|
781
|
-
const user = AbiCoder.decodeParameter('address', subData[6]) as unknown as EthereumAddress;
|
|
782
|
-
|
|
783
|
-
return {
|
|
784
|
-
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user,
|
|
785
|
-
};
|
|
786
|
-
},
|
|
787
|
-
};
|
|
788
738
|
export const aaveV3QuotePriceSubData = {
|
|
789
739
|
encode(
|
|
790
740
|
collAsset: EthereumAddress,
|
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 {
|
|
@@ -162,8 +154,6 @@ export namespace Strategies {
|
|
|
162
154
|
EoaRepayOnPrice = 'eoa-repay-on-price',
|
|
163
155
|
CollateralSwitch = 'collateral-switch',
|
|
164
156
|
EoaCollateralSwitch = 'eoa-collateral-switch',
|
|
165
|
-
DebtSwitch = 'debt-switch',
|
|
166
|
-
EoaDebtSwitch = 'eoa-debt-switch',
|
|
167
157
|
LiquidationProtection = 'liquidation-protection',
|
|
168
158
|
EoaLiquidationProtection = 'liquidation-protection-eoa',
|
|
169
159
|
}
|