@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
|
@@ -831,77 +831,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
831
831
|
});
|
|
832
832
|
});
|
|
833
833
|
});
|
|
834
|
-
describe('debtSwitch()', () => {
|
|
835
|
-
const examples = [
|
|
836
|
-
// USDC -> DAI, price 100000, state UNDER
|
|
837
|
-
[
|
|
838
|
-
[
|
|
839
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
840
|
-
false,
|
|
841
|
-
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000009184e72a0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
842
|
-
[
|
|
843
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
844
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
845
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
846
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
847
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
848
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
849
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
850
|
-
],
|
|
851
|
-
],
|
|
852
|
-
[
|
|
853
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
854
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
855
|
-
1,
|
|
856
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
857
|
-
3,
|
|
858
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
859
|
-
'10000000000000000000',
|
|
860
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
861
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
862
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
863
|
-
100000,
|
|
864
|
-
RatioState.UNDER,
|
|
865
|
-
]
|
|
866
|
-
],
|
|
867
|
-
// DAI -> USDC (MaxUint256), price 1, state OVER
|
|
868
|
-
[
|
|
869
|
-
[
|
|
870
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
871
|
-
false,
|
|
872
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000'],
|
|
873
|
-
[
|
|
874
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
875
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
876
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
877
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
878
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
879
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
880
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
881
|
-
],
|
|
882
|
-
],
|
|
883
|
-
[
|
|
884
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
885
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
886
|
-
3,
|
|
887
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
888
|
-
1,
|
|
889
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
890
|
-
MAXUINT,
|
|
891
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
892
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
893
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
894
|
-
1,
|
|
895
|
-
RatioState.OVER,
|
|
896
|
-
]
|
|
897
|
-
],
|
|
898
|
-
];
|
|
899
|
-
examples.forEach(([expected, actual]) => {
|
|
900
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
901
|
-
expect(aaveV3Encode.debtSwitch(...actual)).to.eql(expected);
|
|
902
|
-
});
|
|
903
|
-
});
|
|
904
|
-
});
|
|
905
834
|
});
|
|
906
835
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
907
836
|
describe('leverageManagementOnPrice()', () => {
|
|
@@ -259,18 +259,6 @@ export declare const aaveV3CollateralSwitchSubData: {
|
|
|
259
259
|
amountToSwitch: string;
|
|
260
260
|
};
|
|
261
261
|
};
|
|
262
|
-
export declare const aaveV3DebtSwitchSubData: {
|
|
263
|
-
encode(fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress): string[];
|
|
264
|
-
decode(subData: string[]): {
|
|
265
|
-
fromAsset: EthereumAddress;
|
|
266
|
-
fromAssetId: number;
|
|
267
|
-
toAsset: EthereumAddress;
|
|
268
|
-
toAssetId: number;
|
|
269
|
-
marketAddr: EthereumAddress;
|
|
270
|
-
amountToSwitch: string;
|
|
271
|
-
user: EthereumAddress;
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
262
|
export declare const aaveV3QuotePriceSubData: {
|
|
275
263
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress): string[];
|
|
276
264
|
decode(subData: string[]): {
|
|
@@ -542,38 +542,6 @@ export const aaveV3CollateralSwitchSubData = {
|
|
|
542
542
|
};
|
|
543
543
|
},
|
|
544
544
|
};
|
|
545
|
-
export const aaveV3DebtSwitchSubData = {
|
|
546
|
-
encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user) {
|
|
547
|
-
const encodedFromAsset = AbiCoder.encodeParameter('address', fromAsset);
|
|
548
|
-
const encodedFromAssetId = AbiCoder.encodeParameter('uint8', fromAssetId);
|
|
549
|
-
const encodedToAsset = AbiCoder.encodeParameter('address', toAsset);
|
|
550
|
-
const encodedToAssetId = AbiCoder.encodeParameter('uint8', toAssetId);
|
|
551
|
-
const encodedMarketAddr = AbiCoder.encodeParameter('address', marketAddr);
|
|
552
|
-
const encodedAmountToSwitch = AbiCoder.encodeParameter('uint256', amountToSwitch);
|
|
553
|
-
const encodedUser = AbiCoder.encodeParameter('address', user);
|
|
554
|
-
return [
|
|
555
|
-
encodedFromAsset,
|
|
556
|
-
encodedFromAssetId,
|
|
557
|
-
encodedToAsset,
|
|
558
|
-
encodedToAssetId,
|
|
559
|
-
encodedMarketAddr,
|
|
560
|
-
encodedAmountToSwitch,
|
|
561
|
-
encodedUser,
|
|
562
|
-
];
|
|
563
|
-
},
|
|
564
|
-
decode(subData) {
|
|
565
|
-
const fromAsset = AbiCoder.decodeParameter('address', subData[0]);
|
|
566
|
-
const fromAssetId = Number(AbiCoder.decodeParameter('uint8', subData[1]));
|
|
567
|
-
const toAsset = AbiCoder.decodeParameter('address', subData[2]);
|
|
568
|
-
const toAssetId = Number(AbiCoder.decodeParameter('uint8', subData[3]));
|
|
569
|
-
const marketAddr = AbiCoder.decodeParameter('address', subData[4]);
|
|
570
|
-
const amountToSwitch = AbiCoder.decodeParameter('uint256', subData[5]);
|
|
571
|
-
const user = AbiCoder.decodeParameter('address', subData[6]);
|
|
572
|
-
return {
|
|
573
|
-
fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user,
|
|
574
|
-
};
|
|
575
|
-
},
|
|
576
|
-
};
|
|
577
545
|
export const aaveV3QuotePriceSubData = {
|
|
578
546
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, nullAddress = ZERO_ADDRESS) {
|
|
579
547
|
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
@@ -510,110 +510,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
510
510
|
});
|
|
511
511
|
});
|
|
512
512
|
});
|
|
513
|
-
describe('When testing subDataService.aaveV3DebtSwitchSubData', () => {
|
|
514
|
-
describe('encode()', () => {
|
|
515
|
-
const examples = [
|
|
516
|
-
// USDC -> DAI
|
|
517
|
-
[
|
|
518
|
-
[
|
|
519
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
520
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
521
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
522
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
523
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
524
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
525
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
526
|
-
],
|
|
527
|
-
[
|
|
528
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
529
|
-
1,
|
|
530
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
531
|
-
3,
|
|
532
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
533
|
-
'10000000000000000000',
|
|
534
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
535
|
-
]
|
|
536
|
-
],
|
|
537
|
-
// DAI -> USDC (MaxUint256)
|
|
538
|
-
[
|
|
539
|
-
[
|
|
540
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
541
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
542
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
543
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
544
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
545
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
546
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
547
|
-
],
|
|
548
|
-
[
|
|
549
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
550
|
-
3,
|
|
551
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
552
|
-
1,
|
|
553
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
554
|
-
MAXUINT,
|
|
555
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
556
|
-
]
|
|
557
|
-
],
|
|
558
|
-
];
|
|
559
|
-
examples.forEach(([expected, actual]) => {
|
|
560
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
561
|
-
expect(subDataService.aaveV3DebtSwitchSubData.encode(...actual)).to.eql(expected);
|
|
562
|
-
});
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
describe('decode()', () => {
|
|
566
|
-
const examples = [
|
|
567
|
-
// USDC -> DAI
|
|
568
|
-
[
|
|
569
|
-
{
|
|
570
|
-
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
571
|
-
fromAssetId: 1,
|
|
572
|
-
toAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
573
|
-
toAssetId: 3,
|
|
574
|
-
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
575
|
-
amountToSwitch: '10000000000000000000',
|
|
576
|
-
user: web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
577
|
-
},
|
|
578
|
-
[
|
|
579
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
580
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
581
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
582
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
583
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
584
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
585
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
586
|
-
],
|
|
587
|
-
],
|
|
588
|
-
// DAI -> USDC (MaxUint256)
|
|
589
|
-
[
|
|
590
|
-
{
|
|
591
|
-
fromAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
592
|
-
fromAssetId: 3,
|
|
593
|
-
toAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
594
|
-
toAssetId: 1,
|
|
595
|
-
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
596
|
-
amountToSwitch: MAXUINT,
|
|
597
|
-
user: web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
598
|
-
},
|
|
599
|
-
[
|
|
600
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
601
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
602
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
603
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
604
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
605
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
606
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
607
|
-
],
|
|
608
|
-
],
|
|
609
|
-
];
|
|
610
|
-
examples.forEach(([expected, actual]) => {
|
|
611
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
612
|
-
expect(subDataService.aaveV3DebtSwitchSubData.decode(actual)).to.eql(expected);
|
|
613
|
-
});
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
});
|
|
617
513
|
describe('When testing subDataService.sparkCollateralSwitchSubData', () => {
|
|
618
514
|
describe('encode()', () => {
|
|
619
515
|
const examples = [
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -91,30 +91,22 @@ export declare namespace Strategies {
|
|
|
91
91
|
AAVE_V4_COLLATERAL_SWITCH = 154,
|
|
92
92
|
AAVE_V4_COLLATERAL_SWITCH_EOA = 155,
|
|
93
93
|
SPARK_COLLATERAL_SWITCH = 156,
|
|
94
|
-
SPARK_GENERIC_FL_COLLATERAL_SWITCH = 167
|
|
95
|
-
AAVE_V3_DEBT_SWITCH = 168,
|
|
96
|
-
AAVE_V3_DEBT_SWITCH_EOA = 169
|
|
94
|
+
SPARK_GENERIC_FL_COLLATERAL_SWITCH = 167
|
|
97
95
|
}
|
|
98
96
|
enum OptimismIds {
|
|
99
97
|
EXCHANGE_DCA = 8,
|
|
100
98
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
101
|
-
AAVE_V3_COLLATERAL_SWITCH = 24
|
|
102
|
-
AAVE_V3_DEBT_SWITCH = 25,
|
|
103
|
-
AAVE_V3_DEBT_SWITCH_EOA = 26
|
|
99
|
+
AAVE_V3_COLLATERAL_SWITCH = 24
|
|
104
100
|
}
|
|
105
101
|
enum BaseIds {
|
|
106
102
|
EXCHANGE_DCA = 8,
|
|
107
103
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
108
|
-
AAVE_V3_COLLATERAL_SWITCH = 56
|
|
109
|
-
AAVE_V3_DEBT_SWITCH = 61,
|
|
110
|
-
AAVE_V3_DEBT_SWITCH_EOA = 62
|
|
104
|
+
AAVE_V3_COLLATERAL_SWITCH = 56
|
|
111
105
|
}
|
|
112
106
|
enum ArbitrumIds {
|
|
113
107
|
EXCHANGE_DCA = 8,
|
|
114
108
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
115
|
-
AAVE_V3_COLLATERAL_SWITCH = 50
|
|
116
|
-
AAVE_V3_DEBT_SWITCH = 55,
|
|
117
|
-
AAVE_V3_DEBT_SWITCH_EOA = 56
|
|
109
|
+
AAVE_V3_COLLATERAL_SWITCH = 50
|
|
118
110
|
}
|
|
119
111
|
enum Identifiers {
|
|
120
112
|
SavingsLiqProtection = "smart-savings-liquidation-protection",
|
|
@@ -148,8 +140,6 @@ export declare namespace Strategies {
|
|
|
148
140
|
EoaRepayOnPrice = "eoa-repay-on-price",
|
|
149
141
|
CollateralSwitch = "collateral-switch",
|
|
150
142
|
EoaCollateralSwitch = "eoa-collateral-switch",
|
|
151
|
-
DebtSwitch = "debt-switch",
|
|
152
|
-
EoaDebtSwitch = "eoa-debt-switch",
|
|
153
143
|
LiquidationProtection = "liquidation-protection",
|
|
154
144
|
EoaLiquidationProtection = "liquidation-protection-eoa"
|
|
155
145
|
}
|
package/esm/types/enums.js
CHANGED
|
@@ -105,32 +105,24 @@ export var Strategies;
|
|
|
105
105
|
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH_EOA"] = 155] = "AAVE_V4_COLLATERAL_SWITCH_EOA";
|
|
106
106
|
MainnetIds[MainnetIds["SPARK_COLLATERAL_SWITCH"] = 156] = "SPARK_COLLATERAL_SWITCH";
|
|
107
107
|
MainnetIds[MainnetIds["SPARK_GENERIC_FL_COLLATERAL_SWITCH"] = 167] = "SPARK_GENERIC_FL_COLLATERAL_SWITCH";
|
|
108
|
-
MainnetIds[MainnetIds["AAVE_V3_DEBT_SWITCH"] = 168] = "AAVE_V3_DEBT_SWITCH";
|
|
109
|
-
MainnetIds[MainnetIds["AAVE_V3_DEBT_SWITCH_EOA"] = 169] = "AAVE_V3_DEBT_SWITCH_EOA";
|
|
110
108
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
111
109
|
let OptimismIds;
|
|
112
110
|
(function (OptimismIds) {
|
|
113
111
|
OptimismIds[OptimismIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
114
112
|
OptimismIds[OptimismIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
115
113
|
OptimismIds[OptimismIds["AAVE_V3_COLLATERAL_SWITCH"] = 24] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
116
|
-
OptimismIds[OptimismIds["AAVE_V3_DEBT_SWITCH"] = 25] = "AAVE_V3_DEBT_SWITCH";
|
|
117
|
-
OptimismIds[OptimismIds["AAVE_V3_DEBT_SWITCH_EOA"] = 26] = "AAVE_V3_DEBT_SWITCH_EOA";
|
|
118
114
|
})(OptimismIds = Strategies.OptimismIds || (Strategies.OptimismIds = {}));
|
|
119
115
|
let BaseIds;
|
|
120
116
|
(function (BaseIds) {
|
|
121
117
|
BaseIds[BaseIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
122
118
|
BaseIds[BaseIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
123
119
|
BaseIds[BaseIds["AAVE_V3_COLLATERAL_SWITCH"] = 56] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
124
|
-
BaseIds[BaseIds["AAVE_V3_DEBT_SWITCH"] = 61] = "AAVE_V3_DEBT_SWITCH";
|
|
125
|
-
BaseIds[BaseIds["AAVE_V3_DEBT_SWITCH_EOA"] = 62] = "AAVE_V3_DEBT_SWITCH_EOA";
|
|
126
120
|
})(BaseIds = Strategies.BaseIds || (Strategies.BaseIds = {}));
|
|
127
121
|
let ArbitrumIds;
|
|
128
122
|
(function (ArbitrumIds) {
|
|
129
123
|
ArbitrumIds[ArbitrumIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
130
124
|
ArbitrumIds[ArbitrumIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
131
125
|
ArbitrumIds[ArbitrumIds["AAVE_V3_COLLATERAL_SWITCH"] = 50] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
132
|
-
ArbitrumIds[ArbitrumIds["AAVE_V3_DEBT_SWITCH"] = 55] = "AAVE_V3_DEBT_SWITCH";
|
|
133
|
-
ArbitrumIds[ArbitrumIds["AAVE_V3_DEBT_SWITCH_EOA"] = 56] = "AAVE_V3_DEBT_SWITCH_EOA";
|
|
134
126
|
})(ArbitrumIds = Strategies.ArbitrumIds || (Strategies.ArbitrumIds = {}));
|
|
135
127
|
let Identifiers;
|
|
136
128
|
(function (Identifiers) {
|
|
@@ -165,8 +157,6 @@ export var Strategies;
|
|
|
165
157
|
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
166
158
|
Identifiers["CollateralSwitch"] = "collateral-switch";
|
|
167
159
|
Identifiers["EoaCollateralSwitch"] = "eoa-collateral-switch";
|
|
168
|
-
Identifiers["DebtSwitch"] = "debt-switch";
|
|
169
|
-
Identifiers["EoaDebtSwitch"] = "eoa-debt-switch";
|
|
170
160
|
Identifiers["LiquidationProtection"] = "liquidation-protection";
|
|
171
161
|
Identifiers["EoaLiquidationProtection"] = "liquidation-protection-eoa";
|
|
172
162
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -145,16 +145,6 @@ export const MAINNET_STRATEGIES_INFO: MainnetStrategiesInfo = {
|
|
|
145
145
|
strategyId: Strategies.Identifiers.EoaCollateralSwitch,
|
|
146
146
|
protocol: PROTOCOLS.Spark,
|
|
147
147
|
},
|
|
148
|
-
[Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH]: {
|
|
149
|
-
strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
150
|
-
strategyId: Strategies.Identifiers.DebtSwitch,
|
|
151
|
-
protocol: PROTOCOLS.AaveV3,
|
|
152
|
-
},
|
|
153
|
-
[Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
154
|
-
strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
155
|
-
strategyId: Strategies.Identifiers.EoaDebtSwitch,
|
|
156
|
-
protocol: PROTOCOLS.AaveV3,
|
|
157
|
-
},
|
|
158
148
|
};
|
|
159
149
|
|
|
160
150
|
export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
@@ -173,16 +163,6 @@ export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
|
173
163
|
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
174
164
|
protocol: PROTOCOLS.AaveV3,
|
|
175
165
|
},
|
|
176
|
-
[Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH]: {
|
|
177
|
-
strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH,
|
|
178
|
-
strategyId: Strategies.Identifiers.DebtSwitch,
|
|
179
|
-
protocol: PROTOCOLS.AaveV3,
|
|
180
|
-
},
|
|
181
|
-
[Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
182
|
-
strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
183
|
-
strategyId: Strategies.Identifiers.EoaDebtSwitch,
|
|
184
|
-
protocol: PROTOCOLS.AaveV3,
|
|
185
|
-
},
|
|
186
166
|
};
|
|
187
167
|
|
|
188
168
|
export const BASE_STRATEGIES_INFO: BaseStrategiesInfo = {
|
|
@@ -201,16 +181,6 @@ export const BASE_STRATEGIES_INFO: BaseStrategiesInfo = {
|
|
|
201
181
|
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
202
182
|
protocol: PROTOCOLS.AaveV3,
|
|
203
183
|
},
|
|
204
|
-
[Strategies.BaseIds.AAVE_V3_DEBT_SWITCH]: {
|
|
205
|
-
strategyOrBundleId: Strategies.BaseIds.AAVE_V3_DEBT_SWITCH,
|
|
206
|
-
strategyId: Strategies.Identifiers.DebtSwitch,
|
|
207
|
-
protocol: PROTOCOLS.AaveV3,
|
|
208
|
-
},
|
|
209
|
-
[Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
210
|
-
strategyOrBundleId: Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
211
|
-
strategyId: Strategies.Identifiers.EoaDebtSwitch,
|
|
212
|
-
protocol: PROTOCOLS.AaveV3,
|
|
213
|
-
},
|
|
214
184
|
};
|
|
215
185
|
|
|
216
186
|
export const ARBITRUM_STRATEGIES_INFO: ArbitrumStrategiesInfo = {
|
|
@@ -229,16 +199,6 @@ export const ARBITRUM_STRATEGIES_INFO: ArbitrumStrategiesInfo = {
|
|
|
229
199
|
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
230
200
|
protocol: PROTOCOLS.AaveV3,
|
|
231
201
|
},
|
|
232
|
-
[Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH]: {
|
|
233
|
-
strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH,
|
|
234
|
-
strategyId: Strategies.Identifiers.DebtSwitch,
|
|
235
|
-
protocol: PROTOCOLS.AaveV3,
|
|
236
|
-
},
|
|
237
|
-
[Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
238
|
-
strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
239
|
-
strategyId: Strategies.Identifiers.EoaDebtSwitch,
|
|
240
|
-
protocol: PROTOCOLS.AaveV3,
|
|
241
|
-
},
|
|
242
202
|
};
|
|
243
203
|
|
|
244
204
|
export const STRATEGIES_INFO: StrategiesInfo = {
|
|
@@ -445,19 +445,6 @@ function parseAaveV3CollateralSwitch(position: Position.Automated, parseData: Pa
|
|
|
445
445
|
return _position;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
function parseAaveV3DebtSwitch(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
449
|
-
const _position = cloneDeep(position);
|
|
450
|
-
const { subStruct } = parseData.subscriptionEventData;
|
|
451
|
-
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
452
|
-
const subData = subDataService.aaveV3DebtSwitchSubData.decode(subStruct.subData);
|
|
453
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
454
|
-
_position.strategyData.decoded.subData = subData;
|
|
455
|
-
// TODO -> This isn't enough for ID
|
|
456
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
457
|
-
|
|
458
|
-
return _position;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
448
|
function parseSparkCollateralSwitch(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
462
449
|
const _position = cloneDeep(position);
|
|
463
450
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -1610,8 +1597,6 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1610
1597
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1611
1598
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1612
1599
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1613
|
-
[Strategies.Identifiers.DebtSwitch]: parseAaveV3DebtSwitch,
|
|
1614
|
-
[Strategies.Identifiers.EoaDebtSwitch]: parseAaveV3DebtSwitch,
|
|
1615
1600
|
[Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1616
1601
|
[Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1617
1602
|
},
|
|
@@ -1002,95 +1002,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1002
1002
|
});
|
|
1003
1003
|
});
|
|
1004
1004
|
});
|
|
1005
|
-
|
|
1006
|
-
describe('debtSwitch()', () => {
|
|
1007
|
-
const examples: Array<[
|
|
1008
|
-
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
1009
|
-
[
|
|
1010
|
-
strategyOrBundleId: number,
|
|
1011
|
-
fromAsset: EthereumAddress,
|
|
1012
|
-
fromAssetId: number,
|
|
1013
|
-
toAsset: EthereumAddress,
|
|
1014
|
-
toAssetId: number,
|
|
1015
|
-
marketAddr: EthereumAddress,
|
|
1016
|
-
amountToSwitch: string,
|
|
1017
|
-
user: EthereumAddress,
|
|
1018
|
-
baseTokenAddress: EthereumAddress,
|
|
1019
|
-
quoteTokenAddress: EthereumAddress,
|
|
1020
|
-
price: number,
|
|
1021
|
-
state: RatioState,
|
|
1022
|
-
]
|
|
1023
|
-
]> = [
|
|
1024
|
-
// USDC -> DAI, price 100000, state UNDER
|
|
1025
|
-
[
|
|
1026
|
-
[
|
|
1027
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
1028
|
-
false,
|
|
1029
|
-
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000009184e72a0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1030
|
-
[
|
|
1031
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1032
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1033
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1034
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
1035
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1036
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
1037
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
1038
|
-
],
|
|
1039
|
-
],
|
|
1040
|
-
[
|
|
1041
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
1042
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1043
|
-
1,
|
|
1044
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1045
|
-
3,
|
|
1046
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1047
|
-
'10000000000000000000', // 10 tokens
|
|
1048
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
1049
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1050
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1051
|
-
100000,
|
|
1052
|
-
RatioState.UNDER,
|
|
1053
|
-
]
|
|
1054
|
-
],
|
|
1055
|
-
// DAI -> USDC (MaxUint256), price 1, state OVER
|
|
1056
|
-
[
|
|
1057
|
-
[
|
|
1058
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
1059
|
-
false,
|
|
1060
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1061
|
-
[
|
|
1062
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1063
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
1064
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1065
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1066
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1067
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
1068
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
1069
|
-
],
|
|
1070
|
-
],
|
|
1071
|
-
[
|
|
1072
|
-
Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
1073
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1074
|
-
3,
|
|
1075
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1076
|
-
1,
|
|
1077
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1078
|
-
MAXUINT, // MaxUint256
|
|
1079
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
1080
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1081
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1082
|
-
1,
|
|
1083
|
-
RatioState.OVER,
|
|
1084
|
-
]
|
|
1085
|
-
],
|
|
1086
|
-
];
|
|
1087
|
-
|
|
1088
|
-
examples.forEach(([expected, actual]) => {
|
|
1089
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1090
|
-
expect(aaveV3Encode.debtSwitch(...actual)).to.eql(expected);
|
|
1091
|
-
});
|
|
1092
|
-
});
|
|
1093
|
-
});
|
|
1094
1005
|
});
|
|
1095
1006
|
|
|
1096
1007
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
@@ -444,28 +444,6 @@ export const aaveV3Encode = {
|
|
|
444
444
|
|
|
445
445
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
446
446
|
},
|
|
447
|
-
|
|
448
|
-
debtSwitch(
|
|
449
|
-
strategyOrBundleId: number,
|
|
450
|
-
fromAsset: EthereumAddress,
|
|
451
|
-
fromAssetId: number,
|
|
452
|
-
toAsset: EthereumAddress,
|
|
453
|
-
toAssetId: number,
|
|
454
|
-
marketAddr: EthereumAddress,
|
|
455
|
-
amountToSwitch: string,
|
|
456
|
-
user: EthereumAddress,
|
|
457
|
-
baseTokenAddress: EthereumAddress,
|
|
458
|
-
quoteTokenAddress: EthereumAddress,
|
|
459
|
-
price: number,
|
|
460
|
-
state: RatioState,
|
|
461
|
-
) {
|
|
462
|
-
const isBundle = false;
|
|
463
|
-
|
|
464
|
-
const subDataEncoded = subDataService.aaveV3DebtSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user);
|
|
465
|
-
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
466
|
-
|
|
467
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
468
|
-
},
|
|
469
447
|
};
|
|
470
448
|
|
|
471
449
|
export const compoundV2Encode = {
|