@defisaver/automation-sdk 3.3.21-debt-switch-dev-dev → 3.3.21
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/automation/private/StrategiesAutomation.d.ts +5 -1
- package/cjs/automation/private/StrategiesAutomation.js +12 -0
- package/cjs/automation/private/StrategiesAutomation.test.js +51 -0
- package/cjs/constants/index.js +0 -40
- package/cjs/services/apiSubscriptionsService.d.ts +7 -0
- package/cjs/services/apiSubscriptionsService.js +33 -0
- package/cjs/services/apiSubscriptionsService.test.d.ts +1 -0
- package/cjs/services/apiSubscriptionsService.test.js +67 -0
- package/cjs/services/strategiesService.js +0 -13
- package/cjs/services/strategiesService.test.js +0 -1
- 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/cjs/types/index.d.ts +24 -2
- package/esm/automation/private/StrategiesAutomation.d.ts +5 -1
- package/esm/automation/private/StrategiesAutomation.js +12 -0
- package/esm/automation/private/StrategiesAutomation.test.js +51 -0
- package/esm/constants/index.js +0 -40
- package/esm/services/apiSubscriptionsService.d.ts +7 -0
- package/esm/services/apiSubscriptionsService.js +29 -0
- package/esm/services/apiSubscriptionsService.test.d.ts +1 -0
- package/esm/services/apiSubscriptionsService.test.js +65 -0
- package/esm/services/strategiesService.js +0 -13
- package/esm/services/strategiesService.test.js +0 -1
- 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/esm/types/index.d.ts +24 -2
- package/package.json +1 -1
- package/src/automation/private/StrategiesAutomation.test.ts +65 -1
- package/src/automation/private/StrategiesAutomation.ts +17 -0
- package/src/constants/index.ts +0 -40
- package/src/services/apiSubscriptionsService.test.ts +73 -0
- package/src/services/apiSubscriptionsService.ts +33 -0
- package/src/services/strategiesService.test.ts +0 -1
- 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
- package/src/types/index.ts +26 -2
|
@@ -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 = {
|
|
@@ -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
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type Web3 from 'web3';
|
|
2
2
|
import type { AbiItem } from 'web3-utils';
|
|
3
3
|
import type { BaseContract, BlockType } from './contracts/generated/types';
|
|
4
|
-
import type {
|
|
4
|
+
import type { StrategyModel } from './contracts/generated/SubStorage';
|
|
5
5
|
import type {
|
|
6
6
|
ChainId, Strategies, Bundles, ProtocolIdentifiers,
|
|
7
7
|
RatioState,
|
|
@@ -72,6 +72,22 @@ interface _SubscriptionOptions {
|
|
|
72
72
|
|
|
73
73
|
export type SubscriptionOptions = Partial<_SubscriptionOptions>;
|
|
74
74
|
|
|
75
|
+
/** Subscription record as returned by the automation API (GET /v1/subscriptions) */
|
|
76
|
+
export interface ApiSubscriptionRecord {
|
|
77
|
+
id: number,
|
|
78
|
+
wallet: EthereumAddress,
|
|
79
|
+
wallet_type: string,
|
|
80
|
+
is_enabled: boolean,
|
|
81
|
+
is_bundle: boolean,
|
|
82
|
+
strategy_or_bundle_id: number,
|
|
83
|
+
strategy_ids: number[],
|
|
84
|
+
sub_data_hash: string,
|
|
85
|
+
trigger_data: string[],
|
|
86
|
+
sub_data: string[],
|
|
87
|
+
block_number: number,
|
|
88
|
+
additional_triggers: string[] | null,
|
|
89
|
+
}
|
|
90
|
+
|
|
75
91
|
export declare namespace Interfaces {
|
|
76
92
|
interface ProtocolBase {
|
|
77
93
|
id: ProtocolIdentifiers.StrategiesAutomation | ProtocolIdentifiers.LegacyAutomation,
|
|
@@ -369,10 +385,18 @@ export type StrategyOrBundleIds =
|
|
|
369
385
|
| typeof Bundles.ArbitrumIds[keyof typeof Bundles.ArbitrumIds]
|
|
370
386
|
| typeof Bundles.BaseIds[keyof typeof Bundles.BaseIds];
|
|
371
387
|
|
|
388
|
+
/** Fields of the Subscribe event that parsing relies on */
|
|
389
|
+
export interface SubscriptionEventData {
|
|
390
|
+
subId: string,
|
|
391
|
+
proxy: EthereumAddress,
|
|
392
|
+
subHash: string,
|
|
393
|
+
subStruct: StrategyModel.StrategySubStructOutputStruct,
|
|
394
|
+
}
|
|
395
|
+
|
|
372
396
|
export interface ParseData {
|
|
373
397
|
chainId: ChainId,
|
|
374
398
|
blockNumber: BlockNumber,
|
|
375
|
-
subscriptionEventData:
|
|
399
|
+
subscriptionEventData: SubscriptionEventData,
|
|
376
400
|
strategiesSubsData: StrategyModel.StoredSubDataStructOutputStruct,
|
|
377
401
|
}
|
|
378
402
|
|