@defisaver/automation-sdk 3.3.12 → 3.3.14-strategies-refactor-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 +5 -0
- package/cjs/services/strategiesService.js +41 -17
- package/cjs/services/strategySubService.d.ts +6 -11
- package/cjs/services/strategySubService.js +33 -62
- package/cjs/services/strategySubService.test.js +99 -234
- package/cjs/services/subDataService.d.ts +46 -2
- package/cjs/services/subDataService.js +115 -20
- package/cjs/services/subDataService.test.js +121 -42
- package/cjs/types/enums.d.ts +2 -1
- package/cjs/types/enums.js +1 -0
- package/esm/constants/index.js +5 -0
- package/esm/services/strategiesService.js +41 -17
- package/esm/services/strategySubService.d.ts +6 -11
- package/esm/services/strategySubService.js +32 -58
- package/esm/services/strategySubService.test.js +101 -236
- package/esm/services/subDataService.d.ts +46 -2
- package/esm/services/subDataService.js +113 -19
- package/esm/services/subDataService.test.js +121 -42
- package/esm/types/enums.d.ts +2 -1
- package/esm/types/enums.js +1 -0
- package/package.json +1 -1
- package/src/constants/index.ts +5 -0
- package/src/services/strategiesService.ts +42 -17
- package/src/services/strategySubService.test.ts +117 -279
- package/src/services/strategySubService.ts +81 -111
- package/src/services/subDataService.test.ts +125 -48
- package/src/services/subDataService.ts +156 -28
- package/src/types/enums.ts +1 -0
|
@@ -556,6 +556,127 @@ describe('Feature: subDataService.ts', () => {
|
|
|
556
556
|
});
|
|
557
557
|
});
|
|
558
558
|
});
|
|
559
|
+
describe('When testing subDataService.sparkCollateralSwitchSubData', () => {
|
|
560
|
+
describe('encode()', () => {
|
|
561
|
+
const examples = [
|
|
562
|
+
// WETH -> cbBTC
|
|
563
|
+
[
|
|
564
|
+
[
|
|
565
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
566
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
567
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
568
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
569
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
570
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
571
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
572
|
+
],
|
|
573
|
+
[
|
|
574
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
575
|
+
0,
|
|
576
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
577
|
+
7,
|
|
578
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
579
|
+
'10000000000000000000',
|
|
580
|
+
false,
|
|
581
|
+
]
|
|
582
|
+
],
|
|
583
|
+
// cbBTC -> WETH (MaxUint256)
|
|
584
|
+
[
|
|
585
|
+
[
|
|
586
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
587
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
588
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
589
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
590
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
591
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
592
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
593
|
+
],
|
|
594
|
+
[
|
|
595
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
596
|
+
7,
|
|
597
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
598
|
+
0,
|
|
599
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
600
|
+
tokens_2.MAXUINT,
|
|
601
|
+
]
|
|
602
|
+
],
|
|
603
|
+
// WETH -> cbBTC (5 WETH)
|
|
604
|
+
[
|
|
605
|
+
[
|
|
606
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
607
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
608
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
609
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
610
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
611
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
612
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
613
|
+
],
|
|
614
|
+
[
|
|
615
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
616
|
+
0,
|
|
617
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
618
|
+
7,
|
|
619
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
620
|
+
'5000000000000000000', // 5 WETH
|
|
621
|
+
]
|
|
622
|
+
],
|
|
623
|
+
];
|
|
624
|
+
examples.forEach(([expected, actual]) => {
|
|
625
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
626
|
+
(0, chai_1.expect)(subDataService.sparkCollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
describe('decode()', () => {
|
|
631
|
+
const examples = [
|
|
632
|
+
// WETH -> cbBTC
|
|
633
|
+
[
|
|
634
|
+
{
|
|
635
|
+
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
636
|
+
fromAssetId: 0,
|
|
637
|
+
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
638
|
+
toAssetId: 7,
|
|
639
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
640
|
+
amountToSwitch: '10000000000000000000',
|
|
641
|
+
},
|
|
642
|
+
[
|
|
643
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
644
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
645
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
646
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
647
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
648
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
649
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
650
|
+
],
|
|
651
|
+
],
|
|
652
|
+
// cbBTC -> WETH (MaxUint256)
|
|
653
|
+
[
|
|
654
|
+
{
|
|
655
|
+
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
656
|
+
fromAssetId: 7,
|
|
657
|
+
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
658
|
+
toAssetId: 0,
|
|
659
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
660
|
+
amountToSwitch: tokens_2.MAXUINT,
|
|
661
|
+
},
|
|
662
|
+
[
|
|
663
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
664
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
665
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
666
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
667
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
668
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
669
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
670
|
+
],
|
|
671
|
+
],
|
|
672
|
+
];
|
|
673
|
+
examples.forEach(([expected, actual]) => {
|
|
674
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
675
|
+
(0, chai_1.expect)(subDataService.sparkCollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
});
|
|
559
680
|
describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
|
|
560
681
|
describe('encode()', () => {
|
|
561
682
|
const examples = [
|
|
@@ -1216,48 +1337,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1216
1337
|
});
|
|
1217
1338
|
});
|
|
1218
1339
|
});
|
|
1219
|
-
describe('When testing subDataService.compoundV3L2LeverageManagementSubData', () => {
|
|
1220
|
-
describe('encode()', () => {
|
|
1221
|
-
const examples = [
|
|
1222
|
-
[
|
|
1223
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1224
|
-
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true, false]
|
|
1225
|
-
],
|
|
1226
|
-
[
|
|
1227
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1228
|
-
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false, false]
|
|
1229
|
-
],
|
|
1230
|
-
];
|
|
1231
|
-
examples.forEach(([expected, actual]) => {
|
|
1232
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1233
|
-
(0, chai_1.expect)(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1234
|
-
});
|
|
1235
|
-
});
|
|
1236
|
-
});
|
|
1237
|
-
describe('decode()', () => {
|
|
1238
|
-
const examples = [
|
|
1239
|
-
[
|
|
1240
|
-
{ targetRatio: 200 },
|
|
1241
|
-
[
|
|
1242
|
-
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000213d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1243
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1244
|
-
],
|
|
1245
|
-
],
|
|
1246
|
-
[
|
|
1247
|
-
{ targetRatio: 123 },
|
|
1248
|
-
[
|
|
1249
|
-
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000413d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1250
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1251
|
-
],
|
|
1252
|
-
],
|
|
1253
|
-
];
|
|
1254
|
-
examples.forEach(([expected, actual]) => {
|
|
1255
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1256
|
-
(0, chai_1.expect)(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1257
|
-
});
|
|
1258
|
-
});
|
|
1259
|
-
});
|
|
1260
|
-
});
|
|
1261
1340
|
describe('When testing subDataService.morphoBlueLeverageManagementSubData', () => {
|
|
1262
1341
|
describe('encode()', () => {
|
|
1263
1342
|
const examples = [
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -89,7 +89,8 @@ export declare namespace Strategies {
|
|
|
89
89
|
LIQUITY_V2_PAYBACK = 113,
|
|
90
90
|
AAVE_V3_COLLATERAL_SWITCH = 135,
|
|
91
91
|
AAVE_V4_COLLATERAL_SWITCH = 154,
|
|
92
|
-
AAVE_V4_COLLATERAL_SWITCH_EOA = 155
|
|
92
|
+
AAVE_V4_COLLATERAL_SWITCH_EOA = 155,
|
|
93
|
+
SPARK_COLLATERAL_SWITCH = 156
|
|
93
94
|
}
|
|
94
95
|
enum OptimismIds {
|
|
95
96
|
EXCHANGE_DCA = 8,
|
package/cjs/types/enums.js
CHANGED
|
@@ -106,6 +106,7 @@ var Strategies;
|
|
|
106
106
|
MainnetIds[MainnetIds["AAVE_V3_COLLATERAL_SWITCH"] = 135] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
107
107
|
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH"] = 154] = "AAVE_V4_COLLATERAL_SWITCH";
|
|
108
108
|
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH_EOA"] = 155] = "AAVE_V4_COLLATERAL_SWITCH_EOA";
|
|
109
|
+
MainnetIds[MainnetIds["SPARK_COLLATERAL_SWITCH"] = 156] = "SPARK_COLLATERAL_SWITCH";
|
|
109
110
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
110
111
|
let OptimismIds;
|
|
111
112
|
(function (OptimismIds) {
|
package/esm/constants/index.js
CHANGED
|
@@ -111,6 +111,11 @@ export const MAINNET_STRATEGIES_INFO = {
|
|
|
111
111
|
strategyId: Strategies.Identifiers.EoaCollateralSwitch,
|
|
112
112
|
protocol: PROTOCOLS.AaveV4,
|
|
113
113
|
},
|
|
114
|
+
[Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH]: {
|
|
115
|
+
strategyOrBundleId: Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
116
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
117
|
+
protocol: PROTOCOLS.Spark,
|
|
118
|
+
},
|
|
114
119
|
};
|
|
115
120
|
export const OPTIMISM_STRATEGIES_INFO = {
|
|
116
121
|
[Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -63,7 +63,7 @@ function parseMakerTrailingStop(position, parseData) {
|
|
|
63
63
|
}
|
|
64
64
|
function parseMakerLeverageManagement(position, parseData) {
|
|
65
65
|
const _position = cloneDeep(position);
|
|
66
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
66
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
67
67
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
68
68
|
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
69
69
|
const subData = subDataService.makerLeverageManagementSubData.decode(subStruct.subData);
|
|
@@ -75,9 +75,10 @@ function parseMakerLeverageManagement(position, parseData) {
|
|
|
75
75
|
_position.specific = {
|
|
76
76
|
triggerRepayRatio: triggerData.ratio,
|
|
77
77
|
targetRepayRatio: subData.targetRatio,
|
|
78
|
-
repayEnabled:
|
|
78
|
+
repayEnabled: isEnabled,
|
|
79
79
|
subId1: Number(subId),
|
|
80
80
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
81
|
+
subHashRepay: subHash,
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
else {
|
|
@@ -87,6 +88,7 @@ function parseMakerLeverageManagement(position, parseData) {
|
|
|
87
88
|
boostEnabled: isEnabled,
|
|
88
89
|
subId2: Number(subId),
|
|
89
90
|
mergeId: Strategies.Identifiers.Boost,
|
|
91
|
+
subHashBoost: subHash,
|
|
90
92
|
};
|
|
91
93
|
}
|
|
92
94
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
@@ -126,7 +128,7 @@ function parseLiquityTrailingStop(position, parseData) {
|
|
|
126
128
|
}
|
|
127
129
|
function parseAaveV2LeverageManagement(position, parseData) {
|
|
128
130
|
const _position = cloneDeep(position);
|
|
129
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
131
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
130
132
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
131
133
|
const triggerData = triggerService.aaveV2RatioTrigger.decode(subStruct.triggerData);
|
|
132
134
|
const subData = subDataService.aaveV2LeverageManagementSubData.decode(subStruct.subData);
|
|
@@ -138,9 +140,10 @@ function parseAaveV2LeverageManagement(position, parseData) {
|
|
|
138
140
|
_position.specific = {
|
|
139
141
|
triggerRepayRatio: triggerData.ratio,
|
|
140
142
|
targetRepayRatio: subData.targetRatio,
|
|
141
|
-
repayEnabled:
|
|
143
|
+
repayEnabled: isEnabled,
|
|
142
144
|
subId1: Number(subId),
|
|
143
145
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
146
|
+
subHashRepay: subHash,
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
else {
|
|
@@ -150,6 +153,7 @@ function parseAaveV2LeverageManagement(position, parseData) {
|
|
|
150
153
|
boostEnabled: isEnabled,
|
|
151
154
|
subId2: Number(subId),
|
|
152
155
|
mergeId: Strategies.Identifiers.Boost,
|
|
156
|
+
subHashBoost: subHash,
|
|
153
157
|
};
|
|
154
158
|
}
|
|
155
159
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
@@ -285,6 +289,16 @@ function parseAaveV3CollateralSwitch(position, parseData) {
|
|
|
285
289
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
286
290
|
return _position;
|
|
287
291
|
}
|
|
292
|
+
function parseSparkCollateralSwitch(position, parseData) {
|
|
293
|
+
const _position = cloneDeep(position);
|
|
294
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
295
|
+
const triggerData = triggerService.sparkQuotePriceTrigger.decode(subStruct.triggerData);
|
|
296
|
+
const subData = subDataService.sparkCollateralSwitchSubData.decode(subStruct.subData);
|
|
297
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
298
|
+
_position.strategyData.decoded.subData = subData;
|
|
299
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
300
|
+
return _position;
|
|
301
|
+
}
|
|
288
302
|
function parseAaveV4LeverageManagement(position, parseData) {
|
|
289
303
|
const _position = cloneDeep(position);
|
|
290
304
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
@@ -377,7 +391,7 @@ function parseAaveV4CollateralSwitch(position, parseData) {
|
|
|
377
391
|
}
|
|
378
392
|
function parseMorphoAaveV2LeverageManagement(position, parseData) {
|
|
379
393
|
const _position = cloneDeep(position);
|
|
380
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
394
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
381
395
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
382
396
|
const triggerData = triggerService.morphoAaveV2RatioTrigger.decode(subStruct.triggerData);
|
|
383
397
|
const subData = subDataService.morphoAaveV2LeverageManagementSubData.decode(subStruct.subData);
|
|
@@ -389,9 +403,10 @@ function parseMorphoAaveV2LeverageManagement(position, parseData) {
|
|
|
389
403
|
_position.specific = {
|
|
390
404
|
triggerRepayRatio: triggerData.ratio,
|
|
391
405
|
targetRepayRatio: subData.targetRatio,
|
|
392
|
-
repayEnabled:
|
|
406
|
+
repayEnabled: isEnabled,
|
|
393
407
|
subId1: Number(subId),
|
|
394
408
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
409
|
+
subHashRepay: subHash,
|
|
395
410
|
};
|
|
396
411
|
}
|
|
397
412
|
else {
|
|
@@ -401,6 +416,7 @@ function parseMorphoAaveV2LeverageManagement(position, parseData) {
|
|
|
401
416
|
boostEnabled: isEnabled,
|
|
402
417
|
subId2: Number(subId),
|
|
403
418
|
mergeId: Strategies.Identifiers.Boost,
|
|
419
|
+
subHashBoost: subHash,
|
|
404
420
|
};
|
|
405
421
|
}
|
|
406
422
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
@@ -433,7 +449,7 @@ function parseAaveV3CloseOnPriceWithMaximumGasPrice(position, parseData) {
|
|
|
433
449
|
}
|
|
434
450
|
function parseCompoundV2LeverageManagement(position, parseData) {
|
|
435
451
|
const _position = cloneDeep(position);
|
|
436
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
452
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
437
453
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
438
454
|
const triggerData = triggerService.compoundV2RatioTrigger.decode(subStruct.triggerData);
|
|
439
455
|
const subData = subDataService.compoundV2LeverageManagementSubData.decode(subStruct.subData);
|
|
@@ -446,9 +462,10 @@ function parseCompoundV2LeverageManagement(position, parseData) {
|
|
|
446
462
|
_position.specific = {
|
|
447
463
|
triggerRepayRatio: triggerData.ratio,
|
|
448
464
|
targetRepayRatio: subData.targetRatio,
|
|
449
|
-
repayEnabled:
|
|
465
|
+
repayEnabled: isEnabled,
|
|
450
466
|
subId1: Number(subId),
|
|
451
467
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
468
|
+
subHashRepay: subHash,
|
|
452
469
|
};
|
|
453
470
|
}
|
|
454
471
|
else {
|
|
@@ -458,6 +475,7 @@ function parseCompoundV2LeverageManagement(position, parseData) {
|
|
|
458
475
|
boostEnabled: isEnabled,
|
|
459
476
|
subId2: Number(subId),
|
|
460
477
|
mergeId: Strategies.Identifiers.Boost,
|
|
478
|
+
subHashBoost: subHash,
|
|
461
479
|
};
|
|
462
480
|
}
|
|
463
481
|
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
@@ -466,11 +484,9 @@ function parseCompoundV2LeverageManagement(position, parseData) {
|
|
|
466
484
|
}
|
|
467
485
|
function parseCompoundV3LeverageManagement(position, parseData) {
|
|
468
486
|
const _position = cloneDeep(position);
|
|
469
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
487
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
470
488
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
471
|
-
const subDataDecoder =
|
|
472
|
-
? subDataService.compoundV3L2LeverageManagementSubData
|
|
473
|
-
: subDataService.compoundV3LeverageManagementSubData;
|
|
489
|
+
const subDataDecoder = subDataService.compoundV3LeverageManagementSubDataWithoutSubProxy;
|
|
474
490
|
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
475
491
|
const subData = subDataDecoder.decode(subStruct.subData);
|
|
476
492
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -482,9 +498,10 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
482
498
|
_position.specific = {
|
|
483
499
|
triggerRepayRatio: triggerData.ratio,
|
|
484
500
|
targetRepayRatio: subData.targetRatio,
|
|
485
|
-
repayEnabled:
|
|
501
|
+
repayEnabled: isEnabled,
|
|
486
502
|
subId1: Number(subId),
|
|
487
503
|
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
504
|
+
subHashRepay: subHash,
|
|
488
505
|
};
|
|
489
506
|
}
|
|
490
507
|
else {
|
|
@@ -494,6 +511,7 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
494
511
|
boostEnabled: isEnabled,
|
|
495
512
|
subId2: Number(subId),
|
|
496
513
|
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
514
|
+
subHashBoost: subHash,
|
|
497
515
|
};
|
|
498
516
|
}
|
|
499
517
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
@@ -581,7 +599,7 @@ function parseExchangeLimitOrder(position, parseData, chainId) {
|
|
|
581
599
|
}
|
|
582
600
|
function parseLiquityLeverageManagement(position, parseData) {
|
|
583
601
|
const _position = cloneDeep(position);
|
|
584
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
602
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
585
603
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
586
604
|
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
587
605
|
const subData = subDataService.liquityLeverageManagementSubData.decode(subStruct.subData);
|
|
@@ -593,9 +611,10 @@ function parseLiquityLeverageManagement(position, parseData) {
|
|
|
593
611
|
_position.specific = {
|
|
594
612
|
triggerRepayRatio: triggerData.ratio,
|
|
595
613
|
targetRepayRatio: subData.targetRatio,
|
|
596
|
-
repayEnabled:
|
|
614
|
+
repayEnabled: isEnabled,
|
|
597
615
|
subId1: Number(subId),
|
|
598
616
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
617
|
+
subHashRepay: subHash,
|
|
599
618
|
};
|
|
600
619
|
}
|
|
601
620
|
else {
|
|
@@ -605,6 +624,7 @@ function parseLiquityLeverageManagement(position, parseData) {
|
|
|
605
624
|
boostEnabled: isEnabled,
|
|
606
625
|
subId2: Number(subId),
|
|
607
626
|
mergeId: Strategies.Identifiers.Boost,
|
|
627
|
+
subHashBoost: subHash,
|
|
608
628
|
};
|
|
609
629
|
}
|
|
610
630
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
@@ -645,7 +665,7 @@ function parseLiquityV2LeverageManagement(position, parseData) {
|
|
|
645
665
|
}
|
|
646
666
|
function parseSparkLeverageManagement(position, parseData) {
|
|
647
667
|
const _position = cloneDeep(position);
|
|
648
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
668
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
649
669
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
650
670
|
const triggerData = triggerService.sparkRatioTrigger.decode(subStruct.triggerData);
|
|
651
671
|
const subData = subDataService.sparkLeverageManagementSubData.decode(subStruct.subData);
|
|
@@ -657,9 +677,10 @@ function parseSparkLeverageManagement(position, parseData) {
|
|
|
657
677
|
_position.specific = {
|
|
658
678
|
triggerRepayRatio: triggerData.ratio,
|
|
659
679
|
targetRepayRatio: subData.targetRatio,
|
|
660
|
-
repayEnabled:
|
|
680
|
+
repayEnabled: isEnabled,
|
|
661
681
|
subId1: Number(subId),
|
|
662
682
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
683
|
+
subHashRepay: subHash,
|
|
663
684
|
};
|
|
664
685
|
}
|
|
665
686
|
else {
|
|
@@ -669,6 +690,7 @@ function parseSparkLeverageManagement(position, parseData) {
|
|
|
669
690
|
boostEnabled: isEnabled,
|
|
670
691
|
subId2: Number(subId),
|
|
671
692
|
mergeId: Strategies.Identifiers.Boost,
|
|
693
|
+
subHashBoost: subHash,
|
|
672
694
|
};
|
|
673
695
|
}
|
|
674
696
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
@@ -851,6 +873,7 @@ function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
|
851
873
|
debtAsset: subData.loanToken,
|
|
852
874
|
price: triggerData.price,
|
|
853
875
|
ratio: subData.targetRatio,
|
|
876
|
+
ratioState: triggerData.priceState,
|
|
854
877
|
};
|
|
855
878
|
return _position;
|
|
856
879
|
}
|
|
@@ -1074,6 +1097,7 @@ const parsingMethodsMapping = {
|
|
|
1074
1097
|
[Strategies.Identifiers.RepayOnPrice]: parseSparkLeverageManagementOnPrice,
|
|
1075
1098
|
[Strategies.Identifiers.BoostOnPrice]: parseSparkLeverageManagementOnPrice,
|
|
1076
1099
|
[Strategies.Identifiers.CloseOnPrice]: parseSparkCloseOnPrice,
|
|
1100
|
+
[Strategies.Identifiers.CollateralSwitch]: parseSparkCollateralSwitch,
|
|
1077
1101
|
},
|
|
1078
1102
|
[ProtocolIdentifiers.StrategiesAutomation.CrvUSD]: {
|
|
1079
1103
|
[Strategies.Identifiers.Repay]: parseCrvUSDLeverageManagement,
|
|
@@ -5,14 +5,13 @@ export declare const makerEncode: {
|
|
|
5
5
|
repayFromSavings(bundleId: StrategyOrBundleIds, vaultId: number, triggerRepayRatio: number, targetRepayRatio: number, isBundle?: boolean, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds | Bundles.MainnetIds | Bundles.OptimismIds | Bundles.ArbitrumIds | Bundles.BaseIds)[];
|
|
6
6
|
closeOnPrice(vaultId: number, ratioState: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
7
7
|
trailingStop(vaultId: number, triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
8
|
-
leverageManagement(vaultId: number, triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string, targetRepayRatio: string, boostEnabled: boolean): (string | number | boolean)[];
|
|
9
8
|
leverageManagementWithoutSubProxy(vaultId: number, triggerRatio: number, targetRatio: number, ratioState: RatioState, isBoost: boolean, daiAddr?: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
10
9
|
};
|
|
11
10
|
export declare const liquityEncode: {
|
|
12
11
|
closeOnPrice(priceOverOrUnder: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
13
12
|
trailingStop(triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
14
13
|
paybackFromChickenBondStrategySub(proxyAddress: EthereumAddress, ratio: number, sourceId: string, sourceType: number, ratioState?: RatioState): (boolean | string[] | Bundles.MainnetIds)[];
|
|
15
|
-
|
|
14
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
16
15
|
dsrPayback(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
17
16
|
dsrSupply(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
18
17
|
debtInFrontRepay(proxyAddress: EthereumAddress, debtInFrontMin: string, targetRatioIncrease: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
@@ -21,10 +20,9 @@ export declare const chickenBondsEncode: {
|
|
|
21
20
|
rebond(bondId: number): string[];
|
|
22
21
|
};
|
|
23
22
|
export declare const aaveV2Encode: {
|
|
24
|
-
|
|
23
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
25
24
|
};
|
|
26
25
|
export declare const aaveV3Encode: {
|
|
27
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
28
26
|
closeToAsset(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
29
27
|
baseTokenAddress: EthereumAddress;
|
|
30
28
|
quoteTokenAddress: EthereumAddress;
|
|
@@ -67,25 +65,21 @@ export declare const aaveV3Encode: {
|
|
|
67
65
|
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
68
66
|
};
|
|
69
67
|
export declare const compoundV2Encode: {
|
|
70
|
-
|
|
68
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
71
69
|
};
|
|
72
70
|
export declare const compoundV3Encode: {
|
|
73
|
-
|
|
71
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
74
72
|
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, ratioState: RatioState, user: EthereumAddress): (number | boolean | string[])[];
|
|
75
73
|
closeOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, stopLossPrice: number | undefined, stopLossType: CloseToAssetType | undefined, takeProfitPrice: number | undefined, takeProfitType: CloseToAssetType | undefined, user: EthereumAddress): (number | boolean | string[])[];
|
|
76
74
|
};
|
|
77
|
-
export declare const compoundV3L2Encode: {
|
|
78
|
-
leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA?: boolean): string;
|
|
79
|
-
};
|
|
80
75
|
export declare const morphoAaveV2Encode: {
|
|
81
76
|
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
82
77
|
};
|
|
83
78
|
export declare const exchangeEncode: {
|
|
84
79
|
dca(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, timestamp: number, interval: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
85
|
-
|
|
80
|
+
limitOrderWithoutSubProxy(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType, fromTokenDecimals: number, toTokenDecimals: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
86
81
|
};
|
|
87
82
|
export declare const sparkEncode: {
|
|
88
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
89
83
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
90
84
|
baseTokenAddr: EthereumAddress;
|
|
91
85
|
quoteTokenAddr: EthereumAddress;
|
|
@@ -101,6 +95,7 @@ export declare const sparkEncode: {
|
|
|
101
95
|
}): (number | boolean | string[])[];
|
|
102
96
|
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
103
97
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
98
|
+
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
104
99
|
};
|
|
105
100
|
export declare const crvUSDEncode: {
|
|
106
101
|
leverageManagement(owner: EthereumAddress, controllerAddr: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, collTokenAddr: EthereumAddress, crvUSDAddr: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|