@defisaver/automation-sdk 3.2.4-dev-1 → 3.2.5
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 -90
- package/cjs/services/strategiesService.js +1 -48
- package/cjs/services/strategySubService.d.ts +1 -2
- package/cjs/services/strategySubService.js +6 -13
- package/cjs/services/strategySubService.test.js +0 -108
- package/cjs/services/subDataService.d.ts +7 -18
- package/cjs/services/subDataService.js +15 -48
- package/cjs/services/subDataService.test.js +48 -124
- package/cjs/services/triggerService.d.ts +0 -18
- package/cjs/services/triggerService.js +1 -36
- package/cjs/services/triggerService.test.js +0 -92
- package/cjs/types/enums.d.ts +5 -28
- package/cjs/types/enums.js +0 -23
- package/cjs/types/index.d.ts +1 -17
- package/esm/constants/index.js +0 -90
- package/esm/services/strategiesService.js +1 -48
- package/esm/services/strategySubService.d.ts +1 -2
- package/esm/services/strategySubService.js +6 -13
- package/esm/services/strategySubService.test.js +1 -109
- package/esm/services/subDataService.d.ts +7 -18
- package/esm/services/subDataService.js +14 -47
- package/esm/services/subDataService.test.js +48 -124
- package/esm/services/triggerService.d.ts +0 -18
- package/esm/services/triggerService.js +0 -35
- package/esm/services/triggerService.test.js +1 -93
- package/esm/types/enums.d.ts +5 -28
- package/esm/types/enums.js +0 -23
- package/esm/types/index.d.ts +1 -17
- package/package.json +2 -2
- package/src/constants/index.ts +1 -90
- package/src/services/strategiesService.ts +1 -62
- package/src/services/strategySubService.test.ts +1 -115
- package/src/services/strategySubService.ts +14 -33
- package/src/services/subDataService.test.ts +73 -128
- package/src/services/subDataService.ts +20 -73
- package/src/services/triggerService.test.ts +0 -102
- package/src/services/triggerService.ts +0 -55
- package/src/types/enums.ts +0 -23
- package/src/types/index.ts +1 -22
|
@@ -1042,96 +1042,4 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1042
1042
|
});
|
|
1043
1043
|
});
|
|
1044
1044
|
});
|
|
1045
|
-
describe('When testing triggerService.compoundV3PriceTrigger', () => {
|
|
1046
|
-
describe('encode()', () => {
|
|
1047
|
-
const examples = [
|
|
1048
|
-
[
|
|
1049
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1050
|
-
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 2000, enums_1.RatioState.UNDER]
|
|
1051
|
-
],
|
|
1052
|
-
[
|
|
1053
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1054
|
-
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 3000, enums_1.RatioState.OVER]
|
|
1055
|
-
],
|
|
1056
|
-
];
|
|
1057
|
-
examples.forEach(([expected, actual]) => {
|
|
1058
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1059
|
-
(0, chai_1.expect)(triggerService_1.compoundV3PriceTrigger.encode(...actual)).to.eql(expected);
|
|
1060
|
-
});
|
|
1061
|
-
});
|
|
1062
|
-
});
|
|
1063
|
-
describe('decode()', () => {
|
|
1064
|
-
const examples = [
|
|
1065
|
-
[
|
|
1066
|
-
{
|
|
1067
|
-
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1068
|
-
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1069
|
-
price: '2000',
|
|
1070
|
-
priceState: enums_1.RatioState.UNDER,
|
|
1071
|
-
},
|
|
1072
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1073
|
-
],
|
|
1074
|
-
[
|
|
1075
|
-
{
|
|
1076
|
-
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1077
|
-
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1078
|
-
price: '3000',
|
|
1079
|
-
priceState: enums_1.RatioState.OVER,
|
|
1080
|
-
},
|
|
1081
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1082
|
-
],
|
|
1083
|
-
];
|
|
1084
|
-
examples.forEach(([expected, actual]) => {
|
|
1085
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1086
|
-
(0, chai_1.expect)(triggerService_1.compoundV3PriceTrigger.decode(actual)).to.eql(expected);
|
|
1087
|
-
});
|
|
1088
|
-
});
|
|
1089
|
-
});
|
|
1090
|
-
});
|
|
1091
|
-
describe('When testing triggerService.compoundV3PriceRangeTrigger', () => {
|
|
1092
|
-
describe('encode()', () => {
|
|
1093
|
-
const examples = [
|
|
1094
|
-
[
|
|
1095
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1096
|
-
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
|
|
1097
|
-
],
|
|
1098
|
-
[
|
|
1099
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1100
|
-
[web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
|
|
1101
|
-
],
|
|
1102
|
-
];
|
|
1103
|
-
examples.forEach(([expected, actual]) => {
|
|
1104
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1105
|
-
(0, chai_1.expect)(triggerService_1.compoundV3PriceRangeTrigger.encode(...actual)).to.eql(expected);
|
|
1106
|
-
});
|
|
1107
|
-
});
|
|
1108
|
-
});
|
|
1109
|
-
describe('decode()', () => {
|
|
1110
|
-
const examples = [
|
|
1111
|
-
[
|
|
1112
|
-
{
|
|
1113
|
-
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1114
|
-
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1115
|
-
lowerPrice: '1500',
|
|
1116
|
-
upperPrice: '4000',
|
|
1117
|
-
},
|
|
1118
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1119
|
-
],
|
|
1120
|
-
[
|
|
1121
|
-
{
|
|
1122
|
-
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1123
|
-
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1124
|
-
lowerPrice: '0',
|
|
1125
|
-
upperPrice: '5000',
|
|
1126
|
-
},
|
|
1127
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1128
|
-
],
|
|
1129
|
-
];
|
|
1130
|
-
examples.forEach(([expected, actual]) => {
|
|
1131
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1132
|
-
(0, chai_1.expect)(triggerService_1.compoundV3PriceRangeTrigger.decode(actual)).to.eql(expected);
|
|
1133
|
-
});
|
|
1134
|
-
});
|
|
1135
|
-
});
|
|
1136
|
-
});
|
|
1137
1045
|
});
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -114,7 +114,6 @@ export declare namespace Strategies {
|
|
|
114
114
|
CloseOnPriceToDebt = "close-on-price-to-debt",
|
|
115
115
|
CloseOnPriceToColl = "close-on-price-to-collateral",
|
|
116
116
|
CloseOnPrice = "close-on-price",
|
|
117
|
-
EoaCloseOnPrice = "eoa-close-on-price",
|
|
118
117
|
TrailingStopToColl = "trailing-stop-to-collateral",
|
|
119
118
|
TrailingStopToDebt = "trailing-stop-to-debt",
|
|
120
119
|
Rebond = "rebond",
|
|
@@ -126,9 +125,7 @@ export declare namespace Strategies {
|
|
|
126
125
|
OpenOrderFromCollateral = "open-order-from-collateral",
|
|
127
126
|
OpenOrderFromDebt = "open-order-from-debt",
|
|
128
127
|
BoostOnPrice = "boost-on-price",
|
|
129
|
-
RepayOnPrice = "repay-on-price"
|
|
130
|
-
EoaBoostOnPrice = "eoa-boost-on-price",
|
|
131
|
-
EoaRepayOnPrice = "eoa-repay-on-price"
|
|
128
|
+
RepayOnPrice = "repay-on-price"
|
|
132
129
|
}
|
|
133
130
|
enum IdOverrides {
|
|
134
131
|
TakeProfit = "take-profit",
|
|
@@ -137,9 +134,7 @@ export declare namespace Strategies {
|
|
|
137
134
|
StopLossWithGasPrice = "stop-loss-with-gas-price",
|
|
138
135
|
TrailingStop = "trailing-stop",
|
|
139
136
|
LeverageManagement = "leverage-management",
|
|
140
|
-
EoaLeverageManagement = "leverage-management-eoa"
|
|
141
|
-
LeverageManagementOnPrice = "leverage-management-on-price",
|
|
142
|
-
EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa"
|
|
137
|
+
EoaLeverageManagement = "leverage-management-eoa"
|
|
143
138
|
}
|
|
144
139
|
}
|
|
145
140
|
export declare namespace Bundles {
|
|
@@ -191,13 +186,7 @@ export declare namespace Bundles {
|
|
|
191
186
|
LIQUITY_V2_REPAY_ON_PRICE = 42,
|
|
192
187
|
LIQUITY_V2_BOOST_ON_PRICE = 43,
|
|
193
188
|
FLUID_T1_REPAY = 44,
|
|
194
|
-
FLUID_T1_BOOST = 45
|
|
195
|
-
COMP_V3_SW_REPAY_ON_PRICE = 46,
|
|
196
|
-
COMP_V3_SW_BOOST_ON_PRICE = 47,
|
|
197
|
-
COMP_V3_SW_CLOSE = 48,
|
|
198
|
-
COMP_V3_EOA_REPAY_ON_PRICE = 49,
|
|
199
|
-
COMP_V3_EOA_BOOST_ON_PRICE = 50,
|
|
200
|
-
COMP_V3_EOA_CLOSE = 51
|
|
189
|
+
FLUID_T1_BOOST = 45
|
|
201
190
|
}
|
|
202
191
|
enum OptimismIds {
|
|
203
192
|
AAVE_V3_REPAY = 0,
|
|
@@ -220,13 +209,7 @@ export declare namespace Bundles {
|
|
|
220
209
|
AAVE_V3_REPAY_ON_PRICE = 11,
|
|
221
210
|
MORPHO_BLUE_BOOST_ON_PRICE = 12,
|
|
222
211
|
FLUID_T1_REPAY = 13,
|
|
223
|
-
FLUID_T1_BOOST = 14
|
|
224
|
-
COMP_V3_SW_REPAY_ON_PRICE = 15,
|
|
225
|
-
COMP_V3_SW_BOOST_ON_PRICE = 16,
|
|
226
|
-
COMP_V3_SW_CLOSE = 17,
|
|
227
|
-
COMP_V3_EOA_REPAY_ON_PRICE = 18,
|
|
228
|
-
COMP_V3_EOA_BOOST_ON_PRICE = 19,
|
|
229
|
-
COMP_V3_EOA_CLOSE = 20
|
|
212
|
+
FLUID_T1_BOOST = 14
|
|
230
213
|
}
|
|
231
214
|
enum ArbitrumIds {
|
|
232
215
|
AAVE_V3_REPAY = 0,
|
|
@@ -238,12 +221,6 @@ export declare namespace Bundles {
|
|
|
238
221
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 6,
|
|
239
222
|
AAVE_V3_REPAY_ON_PRICE = 7,
|
|
240
223
|
FLUID_T1_REPAY = 8,
|
|
241
|
-
FLUID_T1_BOOST = 9
|
|
242
|
-
COMP_V3_SW_REPAY_ON_PRICE = 10,
|
|
243
|
-
COMP_V3_SW_BOOST_ON_PRICE = 11,
|
|
244
|
-
COMP_V3_SW_CLOSE = 12,
|
|
245
|
-
COMP_V3_EOA_REPAY_ON_PRICE = 13,
|
|
246
|
-
COMP_V3_EOA_BOOST_ON_PRICE = 14,
|
|
247
|
-
COMP_V3_EOA_CLOSE = 15
|
|
224
|
+
FLUID_T1_BOOST = 9
|
|
248
225
|
}
|
|
249
226
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -134,7 +134,6 @@ var Strategies;
|
|
|
134
134
|
Identifiers["CloseOnPriceToDebt"] = "close-on-price-to-debt";
|
|
135
135
|
Identifiers["CloseOnPriceToColl"] = "close-on-price-to-collateral";
|
|
136
136
|
Identifiers["CloseOnPrice"] = "close-on-price";
|
|
137
|
-
Identifiers["EoaCloseOnPrice"] = "eoa-close-on-price";
|
|
138
137
|
Identifiers["TrailingStopToColl"] = "trailing-stop-to-collateral";
|
|
139
138
|
Identifiers["TrailingStopToDebt"] = "trailing-stop-to-debt";
|
|
140
139
|
Identifiers["Rebond"] = "rebond";
|
|
@@ -147,8 +146,6 @@ var Strategies;
|
|
|
147
146
|
Identifiers["OpenOrderFromDebt"] = "open-order-from-debt";
|
|
148
147
|
Identifiers["BoostOnPrice"] = "boost-on-price";
|
|
149
148
|
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
150
|
-
Identifiers["EoaBoostOnPrice"] = "eoa-boost-on-price";
|
|
151
|
-
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
152
149
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
153
150
|
let IdOverrides;
|
|
154
151
|
(function (IdOverrides) {
|
|
@@ -159,8 +156,6 @@ var Strategies;
|
|
|
159
156
|
IdOverrides["TrailingStop"] = "trailing-stop";
|
|
160
157
|
IdOverrides["LeverageManagement"] = "leverage-management";
|
|
161
158
|
IdOverrides["EoaLeverageManagement"] = "leverage-management-eoa";
|
|
162
|
-
IdOverrides["LeverageManagementOnPrice"] = "leverage-management-on-price";
|
|
163
|
-
IdOverrides["EoaLeverageManagementOnPrice"] = "leverage-management-on-price-eoa";
|
|
164
159
|
})(IdOverrides = Strategies.IdOverrides || (Strategies.IdOverrides = {}));
|
|
165
160
|
})(Strategies = exports.Strategies || (exports.Strategies = {}));
|
|
166
161
|
var Bundles;
|
|
@@ -215,12 +210,6 @@ var Bundles;
|
|
|
215
210
|
MainnetIds[MainnetIds["LIQUITY_V2_BOOST_ON_PRICE"] = 43] = "LIQUITY_V2_BOOST_ON_PRICE";
|
|
216
211
|
MainnetIds[MainnetIds["FLUID_T1_REPAY"] = 44] = "FLUID_T1_REPAY";
|
|
217
212
|
MainnetIds[MainnetIds["FLUID_T1_BOOST"] = 45] = "FLUID_T1_BOOST";
|
|
218
|
-
MainnetIds[MainnetIds["COMP_V3_SW_REPAY_ON_PRICE"] = 46] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
219
|
-
MainnetIds[MainnetIds["COMP_V3_SW_BOOST_ON_PRICE"] = 47] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
220
|
-
MainnetIds[MainnetIds["COMP_V3_SW_CLOSE"] = 48] = "COMP_V3_SW_CLOSE";
|
|
221
|
-
MainnetIds[MainnetIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 49] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
222
|
-
MainnetIds[MainnetIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 50] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
223
|
-
MainnetIds[MainnetIds["COMP_V3_EOA_CLOSE"] = 51] = "COMP_V3_EOA_CLOSE";
|
|
224
213
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
225
214
|
let OptimismIds;
|
|
226
215
|
(function (OptimismIds) {
|
|
@@ -246,12 +235,6 @@ var Bundles;
|
|
|
246
235
|
BaseIds[BaseIds["MORPHO_BLUE_BOOST_ON_PRICE"] = 12] = "MORPHO_BLUE_BOOST_ON_PRICE";
|
|
247
236
|
BaseIds[BaseIds["FLUID_T1_REPAY"] = 13] = "FLUID_T1_REPAY";
|
|
248
237
|
BaseIds[BaseIds["FLUID_T1_BOOST"] = 14] = "FLUID_T1_BOOST";
|
|
249
|
-
BaseIds[BaseIds["COMP_V3_SW_REPAY_ON_PRICE"] = 15] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
250
|
-
BaseIds[BaseIds["COMP_V3_SW_BOOST_ON_PRICE"] = 16] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
251
|
-
BaseIds[BaseIds["COMP_V3_SW_CLOSE"] = 17] = "COMP_V3_SW_CLOSE";
|
|
252
|
-
BaseIds[BaseIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 18] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
253
|
-
BaseIds[BaseIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 19] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
254
|
-
BaseIds[BaseIds["COMP_V3_EOA_CLOSE"] = 20] = "COMP_V3_EOA_CLOSE";
|
|
255
238
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
256
239
|
let ArbitrumIds;
|
|
257
240
|
(function (ArbitrumIds) {
|
|
@@ -265,11 +248,5 @@ var Bundles;
|
|
|
265
248
|
ArbitrumIds[ArbitrumIds["AAVE_V3_REPAY_ON_PRICE"] = 7] = "AAVE_V3_REPAY_ON_PRICE";
|
|
266
249
|
ArbitrumIds[ArbitrumIds["FLUID_T1_REPAY"] = 8] = "FLUID_T1_REPAY";
|
|
267
250
|
ArbitrumIds[ArbitrumIds["FLUID_T1_BOOST"] = 9] = "FLUID_T1_BOOST";
|
|
268
|
-
ArbitrumIds[ArbitrumIds["COMP_V3_SW_REPAY_ON_PRICE"] = 10] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
269
|
-
ArbitrumIds[ArbitrumIds["COMP_V3_SW_BOOST_ON_PRICE"] = 11] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
270
|
-
ArbitrumIds[ArbitrumIds["COMP_V3_SW_CLOSE"] = 12] = "COMP_V3_SW_CLOSE";
|
|
271
|
-
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 13] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
272
|
-
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 14] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
273
|
-
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_CLOSE"] = 15] = "COMP_V3_EOA_CLOSE";
|
|
274
251
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
275
252
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|
package/cjs/types/index.d.ts
CHANGED
|
@@ -171,24 +171,8 @@ export declare namespace Position {
|
|
|
171
171
|
subHashBoost?: string;
|
|
172
172
|
subHashRepay?: string;
|
|
173
173
|
}
|
|
174
|
-
interface CompoundV3Base extends Base {
|
|
175
|
-
market: EthereumAddress;
|
|
176
|
-
collToken: EthereumAddress;
|
|
177
|
-
baseToken: EthereumAddress;
|
|
178
|
-
}
|
|
179
|
-
interface CompoundV3LeverageManagementOnPrice extends CompoundV3Base {
|
|
180
|
-
ratio: number;
|
|
181
|
-
price: string;
|
|
182
|
-
priceState: RatioState;
|
|
183
|
-
}
|
|
184
|
-
interface CompoundV3CloseOnPrice extends CompoundV3Base {
|
|
185
|
-
stopLossPrice: string;
|
|
186
|
-
takeProfitPrice: string;
|
|
187
|
-
stopLossType: CloseToAssetType | undefined;
|
|
188
|
-
takeProfitType: CloseToAssetType | undefined;
|
|
189
|
-
}
|
|
190
174
|
}
|
|
191
|
-
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2
|
|
175
|
+
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2;
|
|
192
176
|
interface Automated {
|
|
193
177
|
chainId: ChainId;
|
|
194
178
|
positionId: string;
|
package/esm/constants/index.js
CHANGED
|
@@ -392,36 +392,6 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
392
392
|
strategyId: Strategies.Identifiers.Boost,
|
|
393
393
|
protocol: PROTOCOLS.FluidT1,
|
|
394
394
|
},
|
|
395
|
-
[Bundles.MainnetIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
396
|
-
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
397
|
-
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
398
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
399
|
-
},
|
|
400
|
-
[Bundles.MainnetIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
401
|
-
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
402
|
-
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
403
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
404
|
-
},
|
|
405
|
-
[Bundles.MainnetIds.COMP_V3_SW_CLOSE]: {
|
|
406
|
-
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_CLOSE,
|
|
407
|
-
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
408
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
409
|
-
},
|
|
410
|
-
[Bundles.MainnetIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
411
|
-
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
412
|
-
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
413
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
414
|
-
},
|
|
415
|
-
[Bundles.MainnetIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
416
|
-
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
417
|
-
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
418
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
419
|
-
},
|
|
420
|
-
[Bundles.MainnetIds.COMP_V3_EOA_CLOSE]: {
|
|
421
|
-
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_CLOSE,
|
|
422
|
-
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
423
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
424
|
-
},
|
|
425
395
|
};
|
|
426
396
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
427
397
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -521,36 +491,6 @@ export const BASE_BUNDLES_INFO = {
|
|
|
521
491
|
strategyId: Strategies.Identifiers.Boost,
|
|
522
492
|
protocol: PROTOCOLS.FluidT1,
|
|
523
493
|
},
|
|
524
|
-
[Bundles.BaseIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
525
|
-
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
526
|
-
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
527
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
528
|
-
},
|
|
529
|
-
[Bundles.BaseIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
530
|
-
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
531
|
-
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
532
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
533
|
-
},
|
|
534
|
-
[Bundles.BaseIds.COMP_V3_SW_CLOSE]: {
|
|
535
|
-
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_CLOSE,
|
|
536
|
-
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
537
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
538
|
-
},
|
|
539
|
-
[Bundles.BaseIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
540
|
-
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
541
|
-
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
542
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
543
|
-
},
|
|
544
|
-
[Bundles.BaseIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
545
|
-
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
546
|
-
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
547
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
548
|
-
},
|
|
549
|
-
[Bundles.BaseIds.COMP_V3_EOA_CLOSE]: {
|
|
550
|
-
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_CLOSE,
|
|
551
|
-
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
552
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
553
|
-
},
|
|
554
494
|
};
|
|
555
495
|
export const ARBITRUM_BUNDLES_INFO = {
|
|
556
496
|
[Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -603,36 +543,6 @@ export const ARBITRUM_BUNDLES_INFO = {
|
|
|
603
543
|
strategyId: Strategies.Identifiers.Boost,
|
|
604
544
|
protocol: PROTOCOLS.FluidT1,
|
|
605
545
|
},
|
|
606
|
-
[Bundles.ArbitrumIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
607
|
-
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
608
|
-
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
609
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
610
|
-
},
|
|
611
|
-
[Bundles.ArbitrumIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
612
|
-
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
613
|
-
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
614
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
615
|
-
},
|
|
616
|
-
[Bundles.ArbitrumIds.COMP_V3_SW_CLOSE]: {
|
|
617
|
-
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_CLOSE,
|
|
618
|
-
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
619
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
620
|
-
},
|
|
621
|
-
[Bundles.ArbitrumIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
622
|
-
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
623
|
-
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
624
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
625
|
-
},
|
|
626
|
-
[Bundles.ArbitrumIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
627
|
-
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
628
|
-
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
629
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
630
|
-
},
|
|
631
|
-
[Bundles.ArbitrumIds.COMP_V3_EOA_CLOSE]: {
|
|
632
|
-
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_CLOSE,
|
|
633
|
-
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
634
|
-
protocol: PROTOCOLS.CompoundV3,
|
|
635
|
-
},
|
|
636
546
|
};
|
|
637
547
|
export const BUNDLES_INFO = {
|
|
638
548
|
[ChainId.Ethereum]: MAINNET_BUNDLES_INFO,
|
|
@@ -334,48 +334,6 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
334
334
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
335
335
|
return _position;
|
|
336
336
|
}
|
|
337
|
-
function parseCompoundV3LeverageManagementOnPrice(position, parseData) {
|
|
338
|
-
const _position = cloneDeep(position);
|
|
339
|
-
const { subStruct } = parseData.subscriptionEventData;
|
|
340
|
-
const triggerData = triggerService.compoundV3PriceTrigger.decode(subStruct.triggerData);
|
|
341
|
-
const subData = subDataService.compoundV3LeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
342
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
343
|
-
_position.strategyData.decoded.subData = subData;
|
|
344
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.market, Math.random());
|
|
345
|
-
_position.specific = {
|
|
346
|
-
market: subData.market,
|
|
347
|
-
collToken: subData.collToken,
|
|
348
|
-
baseToken: subData.baseToken,
|
|
349
|
-
ratio: subData.targetRatio,
|
|
350
|
-
price: triggerData.price,
|
|
351
|
-
priceState: triggerData.priceState,
|
|
352
|
-
};
|
|
353
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
354
|
-
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagementOnPrice : Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
355
|
-
return _position;
|
|
356
|
-
}
|
|
357
|
-
function parseCompoundV3CloseOnPrice(position, parseData) {
|
|
358
|
-
const _position = cloneDeep(position);
|
|
359
|
-
const { subStruct } = parseData.subscriptionEventData;
|
|
360
|
-
const triggerData = triggerService.compoundV3PriceRangeTrigger.decode(subStruct.triggerData);
|
|
361
|
-
const subData = subDataService.compoundV3CloseSubData.decode(subStruct.subData);
|
|
362
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
363
|
-
_position.strategyData.decoded.subData = subData;
|
|
364
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.market, Math.random());
|
|
365
|
-
const { takeProfitType, stopLossType } = getStopLossAndTakeProfitTypeByCloseStrategyType(+subData.closeType);
|
|
366
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
367
|
-
_position.strategy.strategyId = isEOA ? Strategies.Identifiers.EoaCloseOnPrice : Strategies.Identifiers.CloseOnPrice;
|
|
368
|
-
_position.specific = {
|
|
369
|
-
market: subData.market,
|
|
370
|
-
collToken: subData.collToken,
|
|
371
|
-
baseToken: subData.baseToken,
|
|
372
|
-
stopLossPrice: triggerData.lowerPrice,
|
|
373
|
-
takeProfitPrice: triggerData.upperPrice,
|
|
374
|
-
takeProfitType,
|
|
375
|
-
stopLossType,
|
|
376
|
-
};
|
|
377
|
-
return _position;
|
|
378
|
-
}
|
|
379
337
|
function parseChickenBondsRebond(position, parseData) {
|
|
380
338
|
const _position = cloneDeep(position);
|
|
381
339
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -701,6 +659,7 @@ function parseLiquityV2CloseOnPrice(position, parseData) {
|
|
|
701
659
|
// - Only TakeProfit
|
|
702
660
|
// - Only StopLoss
|
|
703
661
|
// - Both
|
|
662
|
+
// TODO: see on frontend what specific data we need here because stop-loss and take-profit is one bundle now
|
|
704
663
|
_position.strategy.strategyId = Strategies.Identifiers.CloseOnPrice;
|
|
705
664
|
_position.specific = {
|
|
706
665
|
market: subData.market,
|
|
@@ -835,12 +794,6 @@ const parsingMethodsMapping = {
|
|
|
835
794
|
[Strategies.Identifiers.Boost]: parseCompoundV3LeverageManagement,
|
|
836
795
|
[Strategies.Identifiers.EoaRepay]: parseCompoundV3LeverageManagement,
|
|
837
796
|
[Strategies.Identifiers.EoaBoost]: parseCompoundV3LeverageManagement,
|
|
838
|
-
[Strategies.Identifiers.RepayOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
839
|
-
[Strategies.Identifiers.BoostOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
840
|
-
[Strategies.Identifiers.EoaRepayOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
841
|
-
[Strategies.Identifiers.EoaBoostOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
842
|
-
[Strategies.Identifiers.CloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
843
|
-
[Strategies.Identifiers.EoaCloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
844
797
|
},
|
|
845
798
|
[ProtocolIdentifiers.StrategiesAutomation.ChickenBonds]: {
|
|
846
799
|
[Strategies.Identifiers.Rebond]: parseChickenBondsRebond,
|
|
@@ -60,14 +60,13 @@ export declare const aaveV3Encode: {
|
|
|
60
60
|
marketAddr: EthereumAddress;
|
|
61
61
|
targetRatio: number;
|
|
62
62
|
}): (number | boolean | string[])[];
|
|
63
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
63
64
|
};
|
|
64
65
|
export declare const compoundV2Encode: {
|
|
65
66
|
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
66
67
|
};
|
|
67
68
|
export declare const compoundV3Encode: {
|
|
68
69
|
leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
|
|
69
|
-
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState): (number | boolean | string[])[];
|
|
70
|
-
closeOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
71
70
|
};
|
|
72
71
|
export declare const compoundV3L2Encode: {
|
|
73
72
|
leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
@@ -146,6 +146,12 @@ export const aaveV3Encode = {
|
|
|
146
146
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
147
147
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
148
148
|
},
|
|
149
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
150
|
+
const isBundle = true;
|
|
151
|
+
const subData = subDataService.aaveV3LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
152
|
+
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
153
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
154
|
+
},
|
|
149
155
|
};
|
|
150
156
|
export const compoundV2Encode = {
|
|
151
157
|
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
@@ -156,19 +162,6 @@ export const compoundV3Encode = {
|
|
|
156
162
|
leverageManagement(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
157
163
|
return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA);
|
|
158
164
|
},
|
|
159
|
-
leverageManagementOnPrice(strategyOrBundleId, market, collToken, baseToken, targetRatio, price, priceState) {
|
|
160
|
-
const isBundle = true;
|
|
161
|
-
const subDataEncoded = subDataService.compoundV3LeverageManagementOnPriceSubData.encode(market, collToken, baseToken, targetRatio);
|
|
162
|
-
const triggerDataEncoded = triggerService.compoundV3PriceTrigger.encode(market, collToken, price, priceState);
|
|
163
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
164
|
-
},
|
|
165
|
-
closeOnPrice(strategyOrBundleId, market, collToken, baseToken, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL) {
|
|
166
|
-
const isBundle = true;
|
|
167
|
-
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
168
|
-
const subDataEncoded = subDataService.compoundV3CloseSubData.encode(market, collToken, baseToken, closeType);
|
|
169
|
-
const triggerDataEncoded = triggerService.compoundV3PriceRangeTrigger.encode(market, collToken, stopLossPrice, takeProfitPrice);
|
|
170
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
171
|
-
},
|
|
172
165
|
};
|
|
173
166
|
export const compoundV3L2Encode = {
|
|
174
167
|
leverageManagement(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
@@ -3,7 +3,7 @@ import Dec from 'decimal.js';
|
|
|
3
3
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
4
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
5
5
|
import * as web3Utils from 'web3-utils';
|
|
6
|
-
import { Bundles, ChainId,
|
|
6
|
+
import { Bundles, ChainId, OrderType, RatioState, Strategies } from '../types/enums';
|
|
7
7
|
import '../configuration';
|
|
8
8
|
import { aaveV2Encode, chickenBondsEncode, liquityEncode, makerEncode, aaveV3Encode, compoundV2Encode, compoundV3Encode, morphoAaveV2Encode, exchangeEncode, sparkEncode, crvUSDEncode, compoundV3L2Encode, morphoBlueEncode, } from './strategySubService';
|
|
9
9
|
describe('Feature: strategySubService.ts', () => {
|
|
@@ -530,114 +530,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
530
530
|
});
|
|
531
531
|
});
|
|
532
532
|
});
|
|
533
|
-
describe('leverageManagementOnPrice()', () => {
|
|
534
|
-
const examples = [
|
|
535
|
-
[
|
|
536
|
-
[
|
|
537
|
-
Bundles.MainnetIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
538
|
-
true,
|
|
539
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
540
|
-
[
|
|
541
|
-
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
542
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
543
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
544
|
-
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000'
|
|
545
|
-
],
|
|
546
|
-
],
|
|
547
|
-
[
|
|
548
|
-
Bundles.MainnetIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
549
|
-
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
550
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
551
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
552
|
-
200,
|
|
553
|
-
2000,
|
|
554
|
-
RatioState.UNDER,
|
|
555
|
-
],
|
|
556
|
-
],
|
|
557
|
-
[
|
|
558
|
-
[
|
|
559
|
-
Bundles.MainnetIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
560
|
-
true,
|
|
561
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
562
|
-
[
|
|
563
|
-
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
564
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
565
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
566
|
-
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000'
|
|
567
|
-
],
|
|
568
|
-
],
|
|
569
|
-
[
|
|
570
|
-
Bundles.MainnetIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
571
|
-
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
572
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
573
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
574
|
-
190,
|
|
575
|
-
3000,
|
|
576
|
-
RatioState.OVER,
|
|
577
|
-
],
|
|
578
|
-
]
|
|
579
|
-
];
|
|
580
|
-
examples.forEach(([expected, actual]) => {
|
|
581
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
582
|
-
expect(compoundV3Encode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
583
|
-
});
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
describe('closeOnPrice()', () => {
|
|
587
|
-
const examples = [
|
|
588
|
-
[
|
|
589
|
-
[
|
|
590
|
-
Bundles.MainnetIds.COMP_V3_SW_CLOSE,
|
|
591
|
-
true,
|
|
592
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
593
|
-
[
|
|
594
|
-
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
595
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
596
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
597
|
-
'0x0000000000000000000000000000000000000000000000000000000000000006'
|
|
598
|
-
],
|
|
599
|
-
],
|
|
600
|
-
[
|
|
601
|
-
Bundles.MainnetIds.COMP_V3_SW_CLOSE,
|
|
602
|
-
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
603
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
604
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
605
|
-
1500,
|
|
606
|
-
CloseToAssetType.DEBT,
|
|
607
|
-
4000,
|
|
608
|
-
CloseToAssetType.DEBT,
|
|
609
|
-
],
|
|
610
|
-
],
|
|
611
|
-
[
|
|
612
|
-
[
|
|
613
|
-
Bundles.MainnetIds.COMP_V3_EOA_CLOSE,
|
|
614
|
-
true,
|
|
615
|
-
['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
616
|
-
[
|
|
617
|
-
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
618
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
619
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
620
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000'
|
|
621
|
-
],
|
|
622
|
-
],
|
|
623
|
-
[
|
|
624
|
-
Bundles.MainnetIds.COMP_V3_EOA_CLOSE,
|
|
625
|
-
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
626
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
627
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
628
|
-
0,
|
|
629
|
-
CloseToAssetType.DEBT,
|
|
630
|
-
5000,
|
|
631
|
-
CloseToAssetType.COLLATERAL,
|
|
632
|
-
],
|
|
633
|
-
]
|
|
634
|
-
];
|
|
635
|
-
examples.forEach(([expected, actual]) => {
|
|
636
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
637
|
-
expect(compoundV3Encode.closeOnPrice(...actual)).to.eql(expected);
|
|
638
|
-
});
|
|
639
|
-
});
|
|
640
|
-
});
|
|
641
533
|
});
|
|
642
534
|
describe('When testing strategySubService.morphoAaveV2Encode', () => {
|
|
643
535
|
describe('leverageManagement()', () => {
|
|
@@ -51,6 +51,13 @@ export declare const aaveV3LeverageManagementSubData: {
|
|
|
51
51
|
targetRatio: number;
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
|
+
export declare const aaveV3LeverageManagementSubDataWithoutSubProxy: {
|
|
55
|
+
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
56
|
+
decode(subData: string[]): {
|
|
57
|
+
targetRatio: number;
|
|
58
|
+
ratioState: RatioState;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
54
61
|
export declare const aaveV3QuotePriceSubData: {
|
|
55
62
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress): string[];
|
|
56
63
|
decode(subData: string[]): {
|
|
@@ -252,21 +259,3 @@ export declare const fluidLeverageManagementSubData: {
|
|
|
252
259
|
targetRatio: number;
|
|
253
260
|
};
|
|
254
261
|
};
|
|
255
|
-
export declare const compoundV3LeverageManagementOnPriceSubData: {
|
|
256
|
-
encode(market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number): string[];
|
|
257
|
-
decode(subData: string[]): {
|
|
258
|
-
market: EthereumAddress;
|
|
259
|
-
collToken: EthereumAddress;
|
|
260
|
-
baseToken: EthereumAddress;
|
|
261
|
-
targetRatio: number;
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
export declare const compoundV3CloseSubData: {
|
|
265
|
-
encode(market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, closeType: CloseStrategyType): string[];
|
|
266
|
-
decode(subData: string[]): {
|
|
267
|
-
market: EthereumAddress;
|
|
268
|
-
collToken: EthereumAddress;
|
|
269
|
-
baseToken: EthereumAddress;
|
|
270
|
-
closeType: CloseStrategyType;
|
|
271
|
-
};
|
|
272
|
-
};
|