@defisaver/automation-sdk 3.3.12-strategies-refactor-4-dev → 3.3.12-strategies-refactor-5-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/services/strategySubService.d.ts +0 -8
- package/cjs/services/strategySubService.js +0 -61
- package/cjs/services/strategySubService.test.js +0 -203
- package/esm/services/strategySubService.d.ts +0 -8
- package/esm/services/strategySubService.js +0 -58
- package/esm/services/strategySubService.test.js +2 -205
- package/package.json +1 -1
- package/src/services/strategySubService.test.ts +0 -246
- package/src/services/strategySubService.ts +0 -114
|
@@ -5,14 +5,12 @@ 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
|
-
leverageManagement(triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string, targetRepayRatio: string, boostEnabled: boolean): (string | boolean)[];
|
|
16
14
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
17
15
|
dsrPayback(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
18
16
|
dsrSupply(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
@@ -22,11 +20,9 @@ export declare const chickenBondsEncode: {
|
|
|
22
20
|
rebond(bondId: number): string[];
|
|
23
21
|
};
|
|
24
22
|
export declare const aaveV2Encode: {
|
|
25
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
26
23
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
27
24
|
};
|
|
28
25
|
export declare const aaveV3Encode: {
|
|
29
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
30
26
|
closeToAsset(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
31
27
|
baseTokenAddress: EthereumAddress;
|
|
32
28
|
quoteTokenAddress: EthereumAddress;
|
|
@@ -69,11 +65,9 @@ export declare const aaveV3Encode: {
|
|
|
69
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[])[];
|
|
70
66
|
};
|
|
71
67
|
export declare const compoundV2Encode: {
|
|
72
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
73
68
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
74
69
|
};
|
|
75
70
|
export declare const compoundV3Encode: {
|
|
76
|
-
leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
|
|
77
71
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
78
72
|
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, ratioState: RatioState, user: EthereumAddress): (number | boolean | string[])[];
|
|
79
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[])[];
|
|
@@ -83,11 +77,9 @@ export declare const morphoAaveV2Encode: {
|
|
|
83
77
|
};
|
|
84
78
|
export declare const exchangeEncode: {
|
|
85
79
|
dca(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, timestamp: number, interval: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
86
|
-
limitOrder(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType): string[];
|
|
87
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)[];
|
|
88
81
|
};
|
|
89
82
|
export declare const sparkEncode: {
|
|
90
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
91
83
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
92
84
|
baseTokenAddr: EthereumAddress;
|
|
93
85
|
quoteTokenAddr: EthereumAddress;
|
|
@@ -22,12 +22,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.aaveV4Encode = exports.fluidEncode = exports.liquityV2Encode = exports.morphoBlueEncode = exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.morphoAaveV2Encode = exports.compoundV3Encode = exports.compoundV2Encode = exports.aaveV3Encode = exports.aaveV2Encode = exports.chickenBondsEncode = exports.liquityEncode = exports.makerEncode = void 0;
|
|
30
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
27
|
const tokens_1 = require("@defisaver/tokens");
|
|
32
28
|
const enums_1 = require("../types/enums");
|
|
33
29
|
const constants_1 = require("../constants");
|
|
@@ -60,16 +56,6 @@ exports.makerEncode = {
|
|
|
60
56
|
const isBundle = false;
|
|
61
57
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
62
58
|
},
|
|
63
|
-
leverageManagement(vaultId, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
64
|
-
return [
|
|
65
|
-
vaultId,
|
|
66
|
-
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
67
|
-
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
68
|
-
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
69
|
-
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
70
|
-
boostEnabled,
|
|
71
|
-
];
|
|
72
|
-
},
|
|
73
59
|
leverageManagementWithoutSubProxy(vaultId, triggerRatio, targetRatio, ratioState, isBoost, daiAddr) {
|
|
74
60
|
const bundleId = isBoost ? enums_1.Bundles.MainnetIds.MAKER_BOOST : enums_1.Bundles.MainnetIds.MAKER_REPAY;
|
|
75
61
|
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
@@ -107,15 +93,6 @@ exports.liquityEncode = {
|
|
|
107
93
|
const isBundle = true;
|
|
108
94
|
return [strategyId, isBundle, triggerData, subData];
|
|
109
95
|
},
|
|
110
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
111
|
-
return [
|
|
112
|
-
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
113
|
-
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
114
|
-
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
115
|
-
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
116
|
-
boostEnabled,
|
|
117
|
-
];
|
|
118
|
-
},
|
|
119
96
|
leverageManagementWithoutSubProxy(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
120
97
|
const isBundle = true;
|
|
121
98
|
const subData = subDataService.liquityLeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
@@ -153,9 +130,6 @@ exports.chickenBondsEncode = {
|
|
|
153
130
|
},
|
|
154
131
|
};
|
|
155
132
|
exports.aaveV2Encode = {
|
|
156
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
157
|
-
return subDataService.aaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
158
|
-
},
|
|
159
133
|
leverageManagementWithoutSubProxy(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
160
134
|
const isBundle = true;
|
|
161
135
|
const subData = subDataService.aaveV2LeverageManagementSubDataWithoutSubProxy.encode(market, targetRatio, ratioState);
|
|
@@ -164,19 +138,6 @@ exports.aaveV2Encode = {
|
|
|
164
138
|
},
|
|
165
139
|
};
|
|
166
140
|
exports.aaveV3Encode = {
|
|
167
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
168
|
-
let subInput = '0x';
|
|
169
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerRepayRatio).mul(1e16).toHex().slice(2)
|
|
170
|
-
.padStart(32, '0'));
|
|
171
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
172
|
-
.padStart(32, '0'));
|
|
173
|
-
subInput = subInput.concat(new decimal_js_1.default(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
174
|
-
.padStart(32, '0'));
|
|
175
|
-
subInput = subInput.concat(new decimal_js_1.default(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
176
|
-
.padStart(32, '0'));
|
|
177
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
178
|
-
return subInput;
|
|
179
|
-
},
|
|
180
141
|
closeToAsset(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
181
142
|
const { collAsset, collAssetId, debtAsset, debtAssetId, } = subData;
|
|
182
143
|
const subDataEncoded = subDataService.aaveV3QuotePriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId);
|
|
@@ -225,9 +186,6 @@ exports.aaveV3Encode = {
|
|
|
225
186
|
},
|
|
226
187
|
};
|
|
227
188
|
exports.compoundV2Encode = {
|
|
228
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
229
|
-
return subDataService.compoundV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
230
|
-
},
|
|
231
189
|
leverageManagementWithoutSubProxy(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
232
190
|
const isBundle = true;
|
|
233
191
|
const subData = subDataService.compoundV2LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
@@ -236,9 +194,6 @@ exports.compoundV2Encode = {
|
|
|
236
194
|
},
|
|
237
195
|
};
|
|
238
196
|
exports.compoundV3Encode = {
|
|
239
|
-
leverageManagement(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
240
|
-
return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA);
|
|
241
|
-
},
|
|
242
197
|
leverageManagementWithoutSubProxy(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
243
198
|
const isBundle = true;
|
|
244
199
|
const subData = subDataService.compoundV3LeverageManagementSubDataWithoutSubProxy.encode(market, baseToken, targetRatio, ratioState);
|
|
@@ -273,9 +228,6 @@ exports.exchangeEncode = {
|
|
|
273
228
|
const strategyId = constants_1.STRATEGY_IDS[network].EXCHANGE_DCA;
|
|
274
229
|
return [strategyId, false, triggerData, subData];
|
|
275
230
|
},
|
|
276
|
-
limitOrder(fromToken, toToken, amount, targetPrice, goodUntil, orderType) {
|
|
277
|
-
return subDataService.exchangeLimitOrderSubData.encode(fromToken, toToken, amount, targetPrice, goodUntil, orderType);
|
|
278
|
-
},
|
|
279
231
|
limitOrderWithoutSubProxy(fromToken, toToken, amount, targetPrice, goodUntil, orderType, fromTokenDecimals, toTokenDecimals, network) {
|
|
280
232
|
(0, utils_1.requireAddresses)([fromToken, toToken]);
|
|
281
233
|
const subData = subDataService.exchangeLimitOrderSubDataWithoutSubProxy.encode(fromToken, toToken, amount);
|
|
@@ -285,19 +237,6 @@ exports.exchangeEncode = {
|
|
|
285
237
|
},
|
|
286
238
|
};
|
|
287
239
|
exports.sparkEncode = {
|
|
288
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
289
|
-
let subInput = '0x';
|
|
290
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerRepayRatio).mul(1e16).toHex().slice(2)
|
|
291
|
-
.padStart(32, '0'));
|
|
292
|
-
subInput = subInput.concat(new decimal_js_1.default(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
293
|
-
.padStart(32, '0'));
|
|
294
|
-
subInput = subInput.concat(new decimal_js_1.default(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
295
|
-
.padStart(32, '0'));
|
|
296
|
-
subInput = subInput.concat(new decimal_js_1.default(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
297
|
-
.padStart(32, '0'));
|
|
298
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
299
|
-
return subInput;
|
|
300
|
-
},
|
|
301
240
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
302
241
|
const { collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, } = subData;
|
|
303
242
|
const subDataEncoded = subDataService.sparkLeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
@@ -124,28 +124,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
|
-
describe('leverageManagement()', () => {
|
|
128
|
-
const examples = [
|
|
129
|
-
[
|
|
130
|
-
[
|
|
131
|
-
5791,
|
|
132
|
-
new decimal_js_1.default('210').mul(1e16).toString(),
|
|
133
|
-
new decimal_js_1.default('290').mul(1e16).toString(),
|
|
134
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
135
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
136
|
-
true,
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
5791, '210', '290', '240', '240', true,
|
|
140
|
-
]
|
|
141
|
-
]
|
|
142
|
-
];
|
|
143
|
-
examples.forEach(([expected, actual]) => {
|
|
144
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
145
|
-
(0, chai_1.expect)(strategySubService_1.makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
127
|
describe('leverageManagementWithoutSubProxy()', () => {
|
|
150
128
|
const examples = [
|
|
151
129
|
// Repay scenario (isBoost=false, RatioState.UNDER)
|
|
@@ -245,27 +223,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
245
223
|
});
|
|
246
224
|
});
|
|
247
225
|
});
|
|
248
|
-
describe('leverageManagement()', () => {
|
|
249
|
-
const examples = [
|
|
250
|
-
[
|
|
251
|
-
[
|
|
252
|
-
new decimal_js_1.default('210').mul(1e16).toString(),
|
|
253
|
-
new decimal_js_1.default('290').mul(1e16).toString(),
|
|
254
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
255
|
-
new decimal_js_1.default('240').mul(1e16).toString(),
|
|
256
|
-
false,
|
|
257
|
-
],
|
|
258
|
-
[
|
|
259
|
-
'210', '290', '240', '240', false,
|
|
260
|
-
]
|
|
261
|
-
]
|
|
262
|
-
];
|
|
263
|
-
examples.forEach(([expected, actual]) => {
|
|
264
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
265
|
-
(0, chai_1.expect)(strategySubService_1.liquityEncode.leverageManagement(...actual)).to.eql(expected);
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
226
|
describe('paybackFromChickenBondStrategySub()', () => {
|
|
270
227
|
const examples = [
|
|
271
228
|
[
|
|
@@ -352,43 +309,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
352
309
|
});
|
|
353
310
|
});
|
|
354
311
|
});
|
|
355
|
-
describe('When testing strategySubService.aaveV2Encode', () => {
|
|
356
|
-
describe('leverageManagement()', () => {
|
|
357
|
-
const examples = [
|
|
358
|
-
[
|
|
359
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
360
|
-
[160, 220, 180, 190, true]
|
|
361
|
-
],
|
|
362
|
-
[
|
|
363
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
364
|
-
[160, 200, 180, 190, false]
|
|
365
|
-
],
|
|
366
|
-
];
|
|
367
|
-
examples.forEach(([expected, actual]) => {
|
|
368
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
369
|
-
(0, chai_1.expect)(strategySubService_1.aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
312
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
375
|
-
describe('leverageManagement()', () => {
|
|
376
|
-
const examples = [
|
|
377
|
-
[
|
|
378
|
-
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
379
|
-
[160, 220, 180, 190, true]
|
|
380
|
-
],
|
|
381
|
-
[
|
|
382
|
-
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
383
|
-
[160, 200, 180, 190, false]
|
|
384
|
-
],
|
|
385
|
-
];
|
|
386
|
-
examples.forEach(([expected, actual]) => {
|
|
387
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
388
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
313
|
describe('closeToAsset()', () => {
|
|
393
314
|
const examples = [
|
|
394
315
|
[
|
|
@@ -955,69 +876,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
955
876
|
});
|
|
956
877
|
});
|
|
957
878
|
});
|
|
958
|
-
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
959
|
-
describe('leverageManagement()', () => {
|
|
960
|
-
const examples = [
|
|
961
|
-
[
|
|
962
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
963
|
-
[160, 220, 180, 190, true]
|
|
964
|
-
],
|
|
965
|
-
[
|
|
966
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
967
|
-
[160, 200, 180, 190, false]
|
|
968
|
-
],
|
|
969
|
-
];
|
|
970
|
-
examples.forEach(([expected, actual]) => {
|
|
971
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
972
|
-
(0, chai_1.expect)(strategySubService_1.compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
973
|
-
});
|
|
974
|
-
});
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
879
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
978
|
-
describe('leverageManagement()', () => {
|
|
979
|
-
const examples = [
|
|
980
|
-
[
|
|
981
|
-
[
|
|
982
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
983
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
984
|
-
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
985
|
-
new decimal_js_1.default(220).mul(1e16).toString(),
|
|
986
|
-
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
987
|
-
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
988
|
-
true, false,
|
|
989
|
-
],
|
|
990
|
-
[
|
|
991
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
992
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
993
|
-
160, 220, 180, 190,
|
|
994
|
-
true, false,
|
|
995
|
-
]
|
|
996
|
-
],
|
|
997
|
-
[
|
|
998
|
-
[
|
|
999
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1000
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1001
|
-
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
1002
|
-
new decimal_js_1.default(210).mul(1e16).toString(),
|
|
1003
|
-
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
1004
|
-
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
1005
|
-
false, true,
|
|
1006
|
-
],
|
|
1007
|
-
[
|
|
1008
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1009
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1010
|
-
160, 210, 180, 190,
|
|
1011
|
-
false, true,
|
|
1012
|
-
]
|
|
1013
|
-
],
|
|
1014
|
-
];
|
|
1015
|
-
examples.forEach(([expected, actual]) => {
|
|
1016
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1017
|
-
(0, chai_1.expect)(strategySubService_1.compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1018
|
-
});
|
|
1019
|
-
});
|
|
1020
|
-
});
|
|
1021
880
|
describe('leverageManagementOnPrice()', () => {
|
|
1022
881
|
const examples = [
|
|
1023
882
|
[
|
|
@@ -1192,51 +1051,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1192
1051
|
});
|
|
1193
1052
|
});
|
|
1194
1053
|
});
|
|
1195
|
-
describe('limitOrder()', () => {
|
|
1196
|
-
const examples = [
|
|
1197
|
-
[
|
|
1198
|
-
[
|
|
1199
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1200
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1201
|
-
'2131',
|
|
1202
|
-
'0.53123',
|
|
1203
|
-
'1696590921159',
|
|
1204
|
-
`${enums_1.OrderType.STOP_LOSS}`
|
|
1205
|
-
],
|
|
1206
|
-
[
|
|
1207
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1208
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1209
|
-
'2131',
|
|
1210
|
-
'0.53123',
|
|
1211
|
-
1696590921159,
|
|
1212
|
-
enums_1.OrderType.STOP_LOSS
|
|
1213
|
-
]
|
|
1214
|
-
],
|
|
1215
|
-
[
|
|
1216
|
-
[
|
|
1217
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1218
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1219
|
-
'2131',
|
|
1220
|
-
'0.43123',
|
|
1221
|
-
'1646590921159',
|
|
1222
|
-
`${enums_1.OrderType.TAKE_PROFIT}`
|
|
1223
|
-
],
|
|
1224
|
-
[
|
|
1225
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1226
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1227
|
-
'2131',
|
|
1228
|
-
'0.43123',
|
|
1229
|
-
1646590921159,
|
|
1230
|
-
enums_1.OrderType.TAKE_PROFIT
|
|
1231
|
-
]
|
|
1232
|
-
],
|
|
1233
|
-
];
|
|
1234
|
-
examples.forEach(([expected, actual]) => {
|
|
1235
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1236
|
-
(0, chai_1.expect)(strategySubService_1.exchangeEncode.limitOrder(...actual)).to.eql(expected);
|
|
1237
|
-
});
|
|
1238
|
-
});
|
|
1239
|
-
});
|
|
1240
1054
|
});
|
|
1241
1055
|
describe('When testing strategySubService.crvUSDEncode', () => {
|
|
1242
1056
|
describe('leverageManagement()', () => {
|
|
@@ -1451,23 +1265,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1451
1265
|
});
|
|
1452
1266
|
});
|
|
1453
1267
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1454
|
-
describe('leverageManagement()', () => {
|
|
1455
|
-
const examples = [
|
|
1456
|
-
[
|
|
1457
|
-
'0x0000000000000000136dcc951d8c00000000000000000000214e8348c4f0000000000000000000001d24b2dfac52000000000000000000001a5e27eef13e000001',
|
|
1458
|
-
[140, 240, 210, 190, true]
|
|
1459
|
-
],
|
|
1460
|
-
[
|
|
1461
|
-
'0x0000000000000000130337bdce49000000000000000000001988fe4052b800000000000000000000281b57b028e1000000000000000000002223acf76376000000',
|
|
1462
|
-
[137, 184, 289, 246, false]
|
|
1463
|
-
]
|
|
1464
|
-
];
|
|
1465
|
-
examples.forEach(([expected, actual]) => {
|
|
1466
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1467
|
-
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1468
|
-
});
|
|
1469
|
-
});
|
|
1470
|
-
});
|
|
1471
1268
|
describe('leverageManagementOnPrice()', () => {
|
|
1472
1269
|
const examples = [
|
|
1473
1270
|
[
|
|
@@ -5,14 +5,12 @@ 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
|
-
leverageManagement(triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string, targetRepayRatio: string, boostEnabled: boolean): (string | boolean)[];
|
|
16
14
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
17
15
|
dsrPayback(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
18
16
|
dsrSupply(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
@@ -22,11 +20,9 @@ export declare const chickenBondsEncode: {
|
|
|
22
20
|
rebond(bondId: number): string[];
|
|
23
21
|
};
|
|
24
22
|
export declare const aaveV2Encode: {
|
|
25
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
26
23
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
27
24
|
};
|
|
28
25
|
export declare const aaveV3Encode: {
|
|
29
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
30
26
|
closeToAsset(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
31
27
|
baseTokenAddress: EthereumAddress;
|
|
32
28
|
quoteTokenAddress: EthereumAddress;
|
|
@@ -69,11 +65,9 @@ export declare const aaveV3Encode: {
|
|
|
69
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[])[];
|
|
70
66
|
};
|
|
71
67
|
export declare const compoundV2Encode: {
|
|
72
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
73
68
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
74
69
|
};
|
|
75
70
|
export declare const compoundV3Encode: {
|
|
76
|
-
leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
|
|
77
71
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
78
72
|
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, ratioState: RatioState, user: EthereumAddress): (number | boolean | string[])[];
|
|
79
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[])[];
|
|
@@ -83,11 +77,9 @@ export declare const morphoAaveV2Encode: {
|
|
|
83
77
|
};
|
|
84
78
|
export declare const exchangeEncode: {
|
|
85
79
|
dca(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, timestamp: number, interval: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
86
|
-
limitOrder(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType): string[];
|
|
87
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)[];
|
|
88
81
|
};
|
|
89
82
|
export declare const sparkEncode: {
|
|
90
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
91
83
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
92
84
|
baseTokenAddr: EthereumAddress;
|
|
93
85
|
quoteTokenAddr: EthereumAddress;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Dec from 'decimal.js';
|
|
2
1
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
3
2
|
import { CloseToAssetType, Bundles, ChainId, RatioState, Strategies, } from '../types/enums';
|
|
4
3
|
import { STRATEGY_IDS } from '../constants';
|
|
@@ -31,16 +30,6 @@ export const makerEncode = {
|
|
|
31
30
|
const isBundle = false;
|
|
32
31
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
33
32
|
},
|
|
34
|
-
leverageManagement(vaultId, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
35
|
-
return [
|
|
36
|
-
vaultId,
|
|
37
|
-
new Dec(triggerRepayRatio).mul(1e16).toString(),
|
|
38
|
-
new Dec(triggerBoostRatio).mul(1e16).toString(),
|
|
39
|
-
new Dec(targetBoostRatio).mul(1e16).toString(),
|
|
40
|
-
new Dec(targetRepayRatio).mul(1e16).toString(),
|
|
41
|
-
boostEnabled,
|
|
42
|
-
];
|
|
43
|
-
},
|
|
44
33
|
leverageManagementWithoutSubProxy(vaultId, triggerRatio, targetRatio, ratioState, isBoost, daiAddr) {
|
|
45
34
|
const bundleId = isBoost ? Bundles.MainnetIds.MAKER_BOOST : Bundles.MainnetIds.MAKER_REPAY;
|
|
46
35
|
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
@@ -78,15 +67,6 @@ export const liquityEncode = {
|
|
|
78
67
|
const isBundle = true;
|
|
79
68
|
return [strategyId, isBundle, triggerData, subData];
|
|
80
69
|
},
|
|
81
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
82
|
-
return [
|
|
83
|
-
new Dec(triggerRepayRatio).mul(1e16).toString(),
|
|
84
|
-
new Dec(triggerBoostRatio).mul(1e16).toString(),
|
|
85
|
-
new Dec(targetBoostRatio).mul(1e16).toString(),
|
|
86
|
-
new Dec(targetRepayRatio).mul(1e16).toString(),
|
|
87
|
-
boostEnabled,
|
|
88
|
-
];
|
|
89
|
-
},
|
|
90
70
|
leverageManagementWithoutSubProxy(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
91
71
|
const isBundle = true;
|
|
92
72
|
const subData = subDataService.liquityLeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
@@ -124,9 +104,6 @@ export const chickenBondsEncode = {
|
|
|
124
104
|
},
|
|
125
105
|
};
|
|
126
106
|
export const aaveV2Encode = {
|
|
127
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
128
|
-
return subDataService.aaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
129
|
-
},
|
|
130
107
|
leverageManagementWithoutSubProxy(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
131
108
|
const isBundle = true;
|
|
132
109
|
const subData = subDataService.aaveV2LeverageManagementSubDataWithoutSubProxy.encode(market, targetRatio, ratioState);
|
|
@@ -135,19 +112,6 @@ export const aaveV2Encode = {
|
|
|
135
112
|
},
|
|
136
113
|
};
|
|
137
114
|
export const aaveV3Encode = {
|
|
138
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
139
|
-
let subInput = '0x';
|
|
140
|
-
subInput = subInput.concat(new Dec(triggerRepayRatio).mul(1e16).toHex().slice(2)
|
|
141
|
-
.padStart(32, '0'));
|
|
142
|
-
subInput = subInput.concat(new Dec(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
143
|
-
.padStart(32, '0'));
|
|
144
|
-
subInput = subInput.concat(new Dec(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
145
|
-
.padStart(32, '0'));
|
|
146
|
-
subInput = subInput.concat(new Dec(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
147
|
-
.padStart(32, '0'));
|
|
148
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
149
|
-
return subInput;
|
|
150
|
-
},
|
|
151
115
|
closeToAsset(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
152
116
|
const { collAsset, collAssetId, debtAsset, debtAssetId, } = subData;
|
|
153
117
|
const subDataEncoded = subDataService.aaveV3QuotePriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId);
|
|
@@ -196,9 +160,6 @@ export const aaveV3Encode = {
|
|
|
196
160
|
},
|
|
197
161
|
};
|
|
198
162
|
export const compoundV2Encode = {
|
|
199
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
200
|
-
return subDataService.compoundV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
201
|
-
},
|
|
202
163
|
leverageManagementWithoutSubProxy(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
203
164
|
const isBundle = true;
|
|
204
165
|
const subData = subDataService.compoundV2LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
@@ -207,9 +168,6 @@ export const compoundV2Encode = {
|
|
|
207
168
|
},
|
|
208
169
|
};
|
|
209
170
|
export const compoundV3Encode = {
|
|
210
|
-
leverageManagement(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
211
|
-
return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA);
|
|
212
|
-
},
|
|
213
171
|
leverageManagementWithoutSubProxy(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
214
172
|
const isBundle = true;
|
|
215
173
|
const subData = subDataService.compoundV3LeverageManagementSubDataWithoutSubProxy.encode(market, baseToken, targetRatio, ratioState);
|
|
@@ -244,9 +202,6 @@ export const exchangeEncode = {
|
|
|
244
202
|
const strategyId = STRATEGY_IDS[network].EXCHANGE_DCA;
|
|
245
203
|
return [strategyId, false, triggerData, subData];
|
|
246
204
|
},
|
|
247
|
-
limitOrder(fromToken, toToken, amount, targetPrice, goodUntil, orderType) {
|
|
248
|
-
return subDataService.exchangeLimitOrderSubData.encode(fromToken, toToken, amount, targetPrice, goodUntil, orderType);
|
|
249
|
-
},
|
|
250
205
|
limitOrderWithoutSubProxy(fromToken, toToken, amount, targetPrice, goodUntil, orderType, fromTokenDecimals, toTokenDecimals, network) {
|
|
251
206
|
requireAddresses([fromToken, toToken]);
|
|
252
207
|
const subData = subDataService.exchangeLimitOrderSubDataWithoutSubProxy.encode(fromToken, toToken, amount);
|
|
@@ -256,19 +211,6 @@ export const exchangeEncode = {
|
|
|
256
211
|
},
|
|
257
212
|
};
|
|
258
213
|
export const sparkEncode = {
|
|
259
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
260
|
-
let subInput = '0x';
|
|
261
|
-
subInput = subInput.concat(new Dec(triggerRepayRatio).mul(1e16).toHex().slice(2)
|
|
262
|
-
.padStart(32, '0'));
|
|
263
|
-
subInput = subInput.concat(new Dec(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
264
|
-
.padStart(32, '0'));
|
|
265
|
-
subInput = subInput.concat(new Dec(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
266
|
-
.padStart(32, '0'));
|
|
267
|
-
subInput = subInput.concat(new Dec(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
268
|
-
.padStart(32, '0'));
|
|
269
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
270
|
-
return subInput;
|
|
271
|
-
},
|
|
272
214
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
273
215
|
const { collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, } = subData;
|
|
274
216
|
const subDataEncoded = subDataService.sparkLeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
@@ -3,9 +3,9 @@ import Dec from 'decimal.js';
|
|
|
3
3
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
4
|
import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
|
|
5
5
|
import * as web3Utils from 'web3-utils';
|
|
6
|
-
import { Bundles, ChainId, CloseToAssetType,
|
|
6
|
+
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies } from '../types/enums';
|
|
7
7
|
import '../configuration';
|
|
8
|
-
import {
|
|
8
|
+
import { chickenBondsEncode, liquityEncode, makerEncode, aaveV3Encode, compoundV3Encode, morphoAaveV2Encode, exchangeEncode, crvUSDEncode, morphoBlueEncode, sparkEncode, aaveV4Encode, } from './strategySubService';
|
|
9
9
|
describe('Feature: strategySubService.ts', () => {
|
|
10
10
|
describe('When testing strategySubService.makerEncode', () => {
|
|
11
11
|
// @ts-ignore // TODO - this requires change in @defisaver/tokens
|
|
@@ -96,28 +96,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
|
-
describe('leverageManagement()', () => {
|
|
100
|
-
const examples = [
|
|
101
|
-
[
|
|
102
|
-
[
|
|
103
|
-
5791,
|
|
104
|
-
new Dec('210').mul(1e16).toString(),
|
|
105
|
-
new Dec('290').mul(1e16).toString(),
|
|
106
|
-
new Dec('240').mul(1e16).toString(),
|
|
107
|
-
new Dec('240').mul(1e16).toString(),
|
|
108
|
-
true,
|
|
109
|
-
],
|
|
110
|
-
[
|
|
111
|
-
5791, '210', '290', '240', '240', true,
|
|
112
|
-
]
|
|
113
|
-
]
|
|
114
|
-
];
|
|
115
|
-
examples.forEach(([expected, actual]) => {
|
|
116
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
117
|
-
expect(makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
99
|
describe('leverageManagementWithoutSubProxy()', () => {
|
|
122
100
|
const examples = [
|
|
123
101
|
// Repay scenario (isBoost=false, RatioState.UNDER)
|
|
@@ -217,27 +195,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
217
195
|
});
|
|
218
196
|
});
|
|
219
197
|
});
|
|
220
|
-
describe('leverageManagement()', () => {
|
|
221
|
-
const examples = [
|
|
222
|
-
[
|
|
223
|
-
[
|
|
224
|
-
new Dec('210').mul(1e16).toString(),
|
|
225
|
-
new Dec('290').mul(1e16).toString(),
|
|
226
|
-
new Dec('240').mul(1e16).toString(),
|
|
227
|
-
new Dec('240').mul(1e16).toString(),
|
|
228
|
-
false,
|
|
229
|
-
],
|
|
230
|
-
[
|
|
231
|
-
'210', '290', '240', '240', false,
|
|
232
|
-
]
|
|
233
|
-
]
|
|
234
|
-
];
|
|
235
|
-
examples.forEach(([expected, actual]) => {
|
|
236
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
237
|
-
expect(liquityEncode.leverageManagement(...actual)).to.eql(expected);
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
198
|
describe('paybackFromChickenBondStrategySub()', () => {
|
|
242
199
|
const examples = [
|
|
243
200
|
[
|
|
@@ -324,43 +281,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
324
281
|
});
|
|
325
282
|
});
|
|
326
283
|
});
|
|
327
|
-
describe('When testing strategySubService.aaveV2Encode', () => {
|
|
328
|
-
describe('leverageManagement()', () => {
|
|
329
|
-
const examples = [
|
|
330
|
-
[
|
|
331
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
332
|
-
[160, 220, 180, 190, true]
|
|
333
|
-
],
|
|
334
|
-
[
|
|
335
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
336
|
-
[160, 200, 180, 190, false]
|
|
337
|
-
],
|
|
338
|
-
];
|
|
339
|
-
examples.forEach(([expected, actual]) => {
|
|
340
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
341
|
-
expect(aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
284
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
347
|
-
describe('leverageManagement()', () => {
|
|
348
|
-
const examples = [
|
|
349
|
-
[
|
|
350
|
-
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
351
|
-
[160, 220, 180, 190, true]
|
|
352
|
-
],
|
|
353
|
-
[
|
|
354
|
-
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
355
|
-
[160, 200, 180, 190, false]
|
|
356
|
-
],
|
|
357
|
-
];
|
|
358
|
-
examples.forEach(([expected, actual]) => {
|
|
359
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
360
|
-
expect(aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
285
|
describe('closeToAsset()', () => {
|
|
365
286
|
const examples = [
|
|
366
287
|
[
|
|
@@ -927,69 +848,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
927
848
|
});
|
|
928
849
|
});
|
|
929
850
|
});
|
|
930
|
-
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
931
|
-
describe('leverageManagement()', () => {
|
|
932
|
-
const examples = [
|
|
933
|
-
[
|
|
934
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
935
|
-
[160, 220, 180, 190, true]
|
|
936
|
-
],
|
|
937
|
-
[
|
|
938
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
939
|
-
[160, 200, 180, 190, false]
|
|
940
|
-
],
|
|
941
|
-
];
|
|
942
|
-
examples.forEach(([expected, actual]) => {
|
|
943
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
944
|
-
expect(compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
945
|
-
});
|
|
946
|
-
});
|
|
947
|
-
});
|
|
948
|
-
});
|
|
949
851
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
950
|
-
describe('leverageManagement()', () => {
|
|
951
|
-
const examples = [
|
|
952
|
-
[
|
|
953
|
-
[
|
|
954
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
955
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
956
|
-
new Dec(160).mul(1e16).toString(),
|
|
957
|
-
new Dec(220).mul(1e16).toString(),
|
|
958
|
-
new Dec(180).mul(1e16).toString(),
|
|
959
|
-
new Dec(190).mul(1e16).toString(),
|
|
960
|
-
true, false,
|
|
961
|
-
],
|
|
962
|
-
[
|
|
963
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
964
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
965
|
-
160, 220, 180, 190,
|
|
966
|
-
true, false,
|
|
967
|
-
]
|
|
968
|
-
],
|
|
969
|
-
[
|
|
970
|
-
[
|
|
971
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
972
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
973
|
-
new Dec(160).mul(1e16).toString(),
|
|
974
|
-
new Dec(210).mul(1e16).toString(),
|
|
975
|
-
new Dec(180).mul(1e16).toString(),
|
|
976
|
-
new Dec(190).mul(1e16).toString(),
|
|
977
|
-
false, true,
|
|
978
|
-
],
|
|
979
|
-
[
|
|
980
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
981
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
982
|
-
160, 210, 180, 190,
|
|
983
|
-
false, true,
|
|
984
|
-
]
|
|
985
|
-
],
|
|
986
|
-
];
|
|
987
|
-
examples.forEach(([expected, actual]) => {
|
|
988
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
989
|
-
expect(compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
990
|
-
});
|
|
991
|
-
});
|
|
992
|
-
});
|
|
993
852
|
describe('leverageManagementOnPrice()', () => {
|
|
994
853
|
const examples = [
|
|
995
854
|
[
|
|
@@ -1164,51 +1023,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1164
1023
|
});
|
|
1165
1024
|
});
|
|
1166
1025
|
});
|
|
1167
|
-
describe('limitOrder()', () => {
|
|
1168
|
-
const examples = [
|
|
1169
|
-
[
|
|
1170
|
-
[
|
|
1171
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1172
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1173
|
-
'2131',
|
|
1174
|
-
'0.53123',
|
|
1175
|
-
'1696590921159',
|
|
1176
|
-
`${OrderType.STOP_LOSS}`
|
|
1177
|
-
],
|
|
1178
|
-
[
|
|
1179
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1180
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1181
|
-
'2131',
|
|
1182
|
-
'0.53123',
|
|
1183
|
-
1696590921159,
|
|
1184
|
-
OrderType.STOP_LOSS
|
|
1185
|
-
]
|
|
1186
|
-
],
|
|
1187
|
-
[
|
|
1188
|
-
[
|
|
1189
|
-
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
1190
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
1191
|
-
'2131',
|
|
1192
|
-
'0.43123',
|
|
1193
|
-
'1646590921159',
|
|
1194
|
-
`${OrderType.TAKE_PROFIT}`
|
|
1195
|
-
],
|
|
1196
|
-
[
|
|
1197
|
-
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
1198
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
1199
|
-
'2131',
|
|
1200
|
-
'0.43123',
|
|
1201
|
-
1646590921159,
|
|
1202
|
-
OrderType.TAKE_PROFIT
|
|
1203
|
-
]
|
|
1204
|
-
],
|
|
1205
|
-
];
|
|
1206
|
-
examples.forEach(([expected, actual]) => {
|
|
1207
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1208
|
-
expect(exchangeEncode.limitOrder(...actual)).to.eql(expected);
|
|
1209
|
-
});
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
1026
|
});
|
|
1213
1027
|
describe('When testing strategySubService.crvUSDEncode', () => {
|
|
1214
1028
|
describe('leverageManagement()', () => {
|
|
@@ -1423,23 +1237,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1423
1237
|
});
|
|
1424
1238
|
});
|
|
1425
1239
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1426
|
-
describe('leverageManagement()', () => {
|
|
1427
|
-
const examples = [
|
|
1428
|
-
[
|
|
1429
|
-
'0x0000000000000000136dcc951d8c00000000000000000000214e8348c4f0000000000000000000001d24b2dfac52000000000000000000001a5e27eef13e000001',
|
|
1430
|
-
[140, 240, 210, 190, true]
|
|
1431
|
-
],
|
|
1432
|
-
[
|
|
1433
|
-
'0x0000000000000000130337bdce49000000000000000000001988fe4052b800000000000000000000281b57b028e1000000000000000000002223acf76376000000',
|
|
1434
|
-
[137, 184, 289, 246, false]
|
|
1435
|
-
]
|
|
1436
|
-
];
|
|
1437
|
-
examples.forEach(([expected, actual]) => {
|
|
1438
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1439
|
-
expect(sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1440
|
-
});
|
|
1441
|
-
});
|
|
1442
|
-
});
|
|
1443
1240
|
describe('leverageManagementOnPrice()', () => {
|
|
1444
1241
|
const examples = [
|
|
1445
1242
|
[
|
package/package.json
CHANGED
|
@@ -9,12 +9,10 @@ import type { EthereumAddress, StrategyOrBundleIds, SubData, TriggerData } from
|
|
|
9
9
|
|
|
10
10
|
import '../configuration';
|
|
11
11
|
import {
|
|
12
|
-
aaveV2Encode,
|
|
13
12
|
chickenBondsEncode,
|
|
14
13
|
liquityEncode,
|
|
15
14
|
makerEncode,
|
|
16
15
|
aaveV3Encode,
|
|
17
|
-
compoundV2Encode,
|
|
18
16
|
compoundV3Encode,
|
|
19
17
|
morphoAaveV2Encode,
|
|
20
18
|
exchangeEncode,
|
|
@@ -139,39 +137,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
139
137
|
});
|
|
140
138
|
});
|
|
141
139
|
|
|
142
|
-
describe('leverageManagement()', () => {
|
|
143
|
-
const examples: Array<[
|
|
144
|
-
[
|
|
145
|
-
vaultId: number, triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string,
|
|
146
|
-
targetRepayRatio: string, boostEnabled: boolean,
|
|
147
|
-
],
|
|
148
|
-
[
|
|
149
|
-
vaultId: number, triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string,
|
|
150
|
-
targetRepayRatio: string, boostEnabled: boolean,
|
|
151
|
-
]
|
|
152
|
-
]> = [
|
|
153
|
-
[
|
|
154
|
-
[
|
|
155
|
-
5791,
|
|
156
|
-
new Dec('210').mul(1e16).toString(),
|
|
157
|
-
new Dec('290').mul(1e16).toString(),
|
|
158
|
-
new Dec('240').mul(1e16).toString(),
|
|
159
|
-
new Dec('240').mul(1e16).toString(),
|
|
160
|
-
true,
|
|
161
|
-
],
|
|
162
|
-
[
|
|
163
|
-
5791, '210', '290', '240', '240', true,
|
|
164
|
-
]
|
|
165
|
-
]
|
|
166
|
-
];
|
|
167
|
-
|
|
168
|
-
examples.forEach(([expected, actual]) => {
|
|
169
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
170
|
-
expect(makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
140
|
describe('leverageManagementWithoutSubProxy()', () => {
|
|
176
141
|
const examples: Array<[
|
|
177
142
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -295,38 +260,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
295
260
|
});
|
|
296
261
|
});
|
|
297
262
|
|
|
298
|
-
describe('leverageManagement()', () => {
|
|
299
|
-
const examples: Array<[
|
|
300
|
-
[
|
|
301
|
-
triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string,
|
|
302
|
-
targetRepayRatio: string, boostEnabled: boolean,
|
|
303
|
-
],
|
|
304
|
-
[
|
|
305
|
-
triggerRepayRatio: string, triggerBoostRatio: string, targetBoostRatio: string,
|
|
306
|
-
targetRepayRatio: string, boostEnabled: boolean,
|
|
307
|
-
]
|
|
308
|
-
]> = [
|
|
309
|
-
[
|
|
310
|
-
[
|
|
311
|
-
new Dec('210').mul(1e16).toString(),
|
|
312
|
-
new Dec('290').mul(1e16).toString(),
|
|
313
|
-
new Dec('240').mul(1e16).toString(),
|
|
314
|
-
new Dec('240').mul(1e16).toString(),
|
|
315
|
-
false,
|
|
316
|
-
],
|
|
317
|
-
[
|
|
318
|
-
'210', '290', '240', '240', false,
|
|
319
|
-
]
|
|
320
|
-
]
|
|
321
|
-
];
|
|
322
|
-
|
|
323
|
-
examples.forEach(([expected, actual]) => {
|
|
324
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
325
|
-
expect(liquityEncode.leverageManagement(...actual)).to.eql(expected);
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
|
|
330
263
|
describe('paybackFromChickenBondStrategySub()', () => {
|
|
331
264
|
const examples: Array<[
|
|
332
265
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -435,53 +368,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
435
368
|
});
|
|
436
369
|
});
|
|
437
370
|
|
|
438
|
-
describe('When testing strategySubService.aaveV2Encode', () => {
|
|
439
|
-
describe('leverageManagement()', () => {
|
|
440
|
-
const examples: Array<[
|
|
441
|
-
[string, string, string, string, boolean],
|
|
442
|
-
[triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean],
|
|
443
|
-
]> = [
|
|
444
|
-
[
|
|
445
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
446
|
-
[160, 220, 180, 190, true]
|
|
447
|
-
],
|
|
448
|
-
[
|
|
449
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
450
|
-
[160, 200, 180, 190, false]
|
|
451
|
-
],
|
|
452
|
-
];
|
|
453
|
-
|
|
454
|
-
examples.forEach(([expected, actual]) => {
|
|
455
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
456
|
-
expect(aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
|
|
462
371
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
463
|
-
describe('leverageManagement()', () => {
|
|
464
|
-
const examples: Array<[
|
|
465
|
-
string,
|
|
466
|
-
[triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean],
|
|
467
|
-
]> = [
|
|
468
|
-
[
|
|
469
|
-
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
470
|
-
[160, 220, 180, 190, true]
|
|
471
|
-
],
|
|
472
|
-
[
|
|
473
|
-
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
474
|
-
[160, 200, 180, 190, false]
|
|
475
|
-
],
|
|
476
|
-
];
|
|
477
|
-
|
|
478
|
-
examples.forEach(([expected, actual]) => {
|
|
479
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
480
|
-
expect(aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
481
|
-
});
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
|
|
485
372
|
describe('closeToAsset()', () => {
|
|
486
373
|
const examples: Array<[
|
|
487
374
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -1140,74 +1027,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1140
1027
|
});
|
|
1141
1028
|
});
|
|
1142
1029
|
|
|
1143
|
-
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
1144
|
-
describe('leverageManagement()', () => {
|
|
1145
|
-
const examples: Array<[
|
|
1146
|
-
[string, string, string, string, boolean],
|
|
1147
|
-
[triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean],
|
|
1148
|
-
]> = [
|
|
1149
|
-
[
|
|
1150
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
1151
|
-
[160, 220, 180, 190, true]
|
|
1152
|
-
],
|
|
1153
|
-
[
|
|
1154
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
1155
|
-
[160, 200, 180, 190, false]
|
|
1156
|
-
],
|
|
1157
|
-
];
|
|
1158
|
-
|
|
1159
|
-
examples.forEach(([expected, actual]) => {
|
|
1160
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1161
|
-
expect(compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1162
|
-
});
|
|
1163
|
-
});
|
|
1164
|
-
});
|
|
1165
|
-
});
|
|
1166
|
-
|
|
1167
1030
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
1168
|
-
describe('leverageManagement()', () => {
|
|
1169
|
-
const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string, boolean, boolean], [market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean]]> = [
|
|
1170
|
-
[
|
|
1171
|
-
[
|
|
1172
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1173
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1174
|
-
new Dec(160).mul(1e16).toString(),
|
|
1175
|
-
new Dec(220).mul(1e16).toString(),
|
|
1176
|
-
new Dec(180).mul(1e16).toString(),
|
|
1177
|
-
new Dec(190).mul(1e16).toString(),
|
|
1178
|
-
true, false,
|
|
1179
|
-
],
|
|
1180
|
-
[
|
|
1181
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1182
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1183
|
-
160, 220, 180, 190,
|
|
1184
|
-
true, false,
|
|
1185
|
-
]
|
|
1186
|
-
],
|
|
1187
|
-
[
|
|
1188
|
-
[
|
|
1189
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1190
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1191
|
-
new Dec(160).mul(1e16).toString(),
|
|
1192
|
-
new Dec(210).mul(1e16).toString(),
|
|
1193
|
-
new Dec(180).mul(1e16).toString(),
|
|
1194
|
-
new Dec(190).mul(1e16).toString(),
|
|
1195
|
-
false, true,
|
|
1196
|
-
],
|
|
1197
|
-
[
|
|
1198
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
1199
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1200
|
-
160, 210, 180, 190,
|
|
1201
|
-
false, true,
|
|
1202
|
-
]
|
|
1203
|
-
],
|
|
1204
|
-
];
|
|
1205
|
-
examples.forEach(([expected, actual]) => {
|
|
1206
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1207
|
-
expect(compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1208
|
-
});
|
|
1209
|
-
});
|
|
1210
|
-
});
|
|
1211
1031
|
describe('leverageManagementOnPrice()', () => {
|
|
1212
1032
|
const examples: Array<[
|
|
1213
1033
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -1395,53 +1215,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1395
1215
|
});
|
|
1396
1216
|
});
|
|
1397
1217
|
});
|
|
1398
|
-
|
|
1399
|
-
describe('limitOrder()', () => {
|
|
1400
|
-
const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string], [fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType]]> = [
|
|
1401
|
-
[
|
|
1402
|
-
[
|
|
1403
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1404
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1405
|
-
'2131',
|
|
1406
|
-
'0.53123',
|
|
1407
|
-
'1696590921159',
|
|
1408
|
-
`${OrderType.STOP_LOSS}`
|
|
1409
|
-
],
|
|
1410
|
-
[
|
|
1411
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1412
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1413
|
-
'2131',
|
|
1414
|
-
'0.53123',
|
|
1415
|
-
1696590921159,
|
|
1416
|
-
OrderType.STOP_LOSS
|
|
1417
|
-
]
|
|
1418
|
-
],
|
|
1419
|
-
[
|
|
1420
|
-
[
|
|
1421
|
-
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
1422
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
1423
|
-
'2131',
|
|
1424
|
-
'0.43123',
|
|
1425
|
-
'1646590921159',
|
|
1426
|
-
`${OrderType.TAKE_PROFIT}`
|
|
1427
|
-
],
|
|
1428
|
-
[
|
|
1429
|
-
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
1430
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
1431
|
-
'2131',
|
|
1432
|
-
'0.43123',
|
|
1433
|
-
1646590921159,
|
|
1434
|
-
OrderType.TAKE_PROFIT
|
|
1435
|
-
]
|
|
1436
|
-
],
|
|
1437
|
-
];
|
|
1438
|
-
|
|
1439
|
-
examples.forEach(([expected, actual]) => {
|
|
1440
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1441
|
-
expect(exchangeEncode.limitOrder(...actual)).to.eql(expected);
|
|
1442
|
-
});
|
|
1443
|
-
});
|
|
1444
|
-
});
|
|
1445
1218
|
});
|
|
1446
1219
|
|
|
1447
1220
|
describe('When testing strategySubService.crvUSDEncode', () => {
|
|
@@ -1701,25 +1474,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1701
1474
|
});
|
|
1702
1475
|
|
|
1703
1476
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1704
|
-
describe('leverageManagement()', () => {
|
|
1705
|
-
const examples: Array<[string, [number, number, number, number, boolean]]> = [
|
|
1706
|
-
[
|
|
1707
|
-
'0x0000000000000000136dcc951d8c00000000000000000000214e8348c4f0000000000000000000001d24b2dfac52000000000000000000001a5e27eef13e000001',
|
|
1708
|
-
[140,240,210,190,true]
|
|
1709
|
-
],
|
|
1710
|
-
[
|
|
1711
|
-
'0x0000000000000000130337bdce49000000000000000000001988fe4052b800000000000000000000281b57b028e1000000000000000000002223acf76376000000',
|
|
1712
|
-
[137, 184, 289, 246, false]
|
|
1713
|
-
]
|
|
1714
|
-
];
|
|
1715
|
-
|
|
1716
|
-
examples.forEach(([expected, actual]) => {
|
|
1717
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1718
|
-
expect(sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1719
|
-
});
|
|
1720
|
-
});
|
|
1721
|
-
});
|
|
1722
|
-
|
|
1723
1477
|
describe('leverageManagementOnPrice()', () => {
|
|
1724
1478
|
const examples: Array<[[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
1725
1479
|
[
|
|
@@ -81,23 +81,6 @@ export const makerEncode = {
|
|
|
81
81
|
|
|
82
82
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
83
83
|
},
|
|
84
|
-
leverageManagement(
|
|
85
|
-
vaultId: number,
|
|
86
|
-
triggerRepayRatio: string,
|
|
87
|
-
triggerBoostRatio: string,
|
|
88
|
-
targetBoostRatio: string,
|
|
89
|
-
targetRepayRatio: string,
|
|
90
|
-
boostEnabled: boolean,
|
|
91
|
-
) {
|
|
92
|
-
return [
|
|
93
|
-
vaultId,
|
|
94
|
-
new Dec(triggerRepayRatio).mul(1e16).toString(),
|
|
95
|
-
new Dec(triggerBoostRatio).mul(1e16).toString(),
|
|
96
|
-
new Dec(targetBoostRatio).mul(1e16).toString(),
|
|
97
|
-
new Dec(targetRepayRatio).mul(1e16).toString(),
|
|
98
|
-
boostEnabled,
|
|
99
|
-
];
|
|
100
|
-
},
|
|
101
84
|
leverageManagementWithoutSubProxy(
|
|
102
85
|
vaultId: number,
|
|
103
86
|
triggerRatio: number,
|
|
@@ -179,21 +162,6 @@ export const liquityEncode = {
|
|
|
179
162
|
|
|
180
163
|
return [strategyId, isBundle, triggerData, subData];
|
|
181
164
|
},
|
|
182
|
-
leverageManagement(
|
|
183
|
-
triggerRepayRatio:string,
|
|
184
|
-
triggerBoostRatio:string,
|
|
185
|
-
targetBoostRatio:string,
|
|
186
|
-
targetRepayRatio:string,
|
|
187
|
-
boostEnabled:boolean,
|
|
188
|
-
) {
|
|
189
|
-
return [
|
|
190
|
-
new Dec(triggerRepayRatio).mul(1e16).toString(),
|
|
191
|
-
new Dec(triggerBoostRatio).mul(1e16).toString(),
|
|
192
|
-
new Dec(targetBoostRatio).mul(1e16).toString(),
|
|
193
|
-
new Dec(targetRepayRatio).mul(1e16).toString(),
|
|
194
|
-
boostEnabled,
|
|
195
|
-
];
|
|
196
|
-
},
|
|
197
165
|
leverageManagementWithoutSubProxy(
|
|
198
166
|
strategyOrBundleId: number,
|
|
199
167
|
user: EthereumAddress,
|
|
@@ -262,15 +230,6 @@ export const chickenBondsEncode = {
|
|
|
262
230
|
};
|
|
263
231
|
|
|
264
232
|
export const aaveV2Encode = {
|
|
265
|
-
leverageManagement(
|
|
266
|
-
triggerRepayRatio: number,
|
|
267
|
-
triggerBoostRatio: number,
|
|
268
|
-
targetBoostRatio: number,
|
|
269
|
-
targetRepayRatio: number,
|
|
270
|
-
boostEnabled: boolean,
|
|
271
|
-
) {
|
|
272
|
-
return subDataService.aaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
273
|
-
},
|
|
274
233
|
leverageManagementWithoutSubProxy(
|
|
275
234
|
strategyOrBundleId: number,
|
|
276
235
|
market: EthereumAddress,
|
|
@@ -289,27 +248,6 @@ export const aaveV2Encode = {
|
|
|
289
248
|
};
|
|
290
249
|
|
|
291
250
|
export const aaveV3Encode = {
|
|
292
|
-
leverageManagement(
|
|
293
|
-
triggerRepayRatio: number,
|
|
294
|
-
triggerBoostRatio: number,
|
|
295
|
-
targetBoostRatio: number,
|
|
296
|
-
targetRepayRatio: number,
|
|
297
|
-
boostEnabled: boolean,
|
|
298
|
-
) {
|
|
299
|
-
let subInput = '0x';
|
|
300
|
-
|
|
301
|
-
subInput = subInput.concat(new Dec(triggerRepayRatio).mul(1e16).toHex().slice(2)
|
|
302
|
-
.padStart(32, '0'));
|
|
303
|
-
subInput = subInput.concat(new Dec(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
304
|
-
.padStart(32, '0'));
|
|
305
|
-
subInput = subInput.concat(new Dec(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
306
|
-
.padStart(32, '0'));
|
|
307
|
-
subInput = subInput.concat(new Dec(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
308
|
-
.padStart(32, '0'));
|
|
309
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
310
|
-
|
|
311
|
-
return subInput;
|
|
312
|
-
},
|
|
313
251
|
closeToAsset(
|
|
314
252
|
strategyOrBundleId: number,
|
|
315
253
|
isBundle: boolean = true,
|
|
@@ -470,15 +408,6 @@ export const aaveV3Encode = {
|
|
|
470
408
|
};
|
|
471
409
|
|
|
472
410
|
export const compoundV2Encode = {
|
|
473
|
-
leverageManagement(
|
|
474
|
-
triggerRepayRatio: number,
|
|
475
|
-
triggerBoostRatio: number,
|
|
476
|
-
targetBoostRatio: number,
|
|
477
|
-
targetRepayRatio: number,
|
|
478
|
-
boostEnabled: boolean,
|
|
479
|
-
) {
|
|
480
|
-
return subDataService.compoundV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
481
|
-
},
|
|
482
411
|
leverageManagementWithoutSubProxy(
|
|
483
412
|
strategyOrBundleId: number,
|
|
484
413
|
user: EthereumAddress,
|
|
@@ -496,18 +425,6 @@ export const compoundV2Encode = {
|
|
|
496
425
|
};
|
|
497
426
|
|
|
498
427
|
export const compoundV3Encode = {
|
|
499
|
-
leverageManagement(
|
|
500
|
-
market: EthereumAddress,
|
|
501
|
-
baseToken: EthereumAddress,
|
|
502
|
-
triggerRepayRatio: number,
|
|
503
|
-
triggerBoostRatio: number,
|
|
504
|
-
targetBoostRatio: number,
|
|
505
|
-
targetRepayRatio: number,
|
|
506
|
-
boostEnabled: boolean,
|
|
507
|
-
isEOA: boolean,
|
|
508
|
-
) {
|
|
509
|
-
return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA);
|
|
510
|
-
},
|
|
511
428
|
leverageManagementWithoutSubProxy(
|
|
512
429
|
strategyOrBundleId: number,
|
|
513
430
|
market: EthereumAddress,
|
|
@@ -591,16 +508,6 @@ export const exchangeEncode = {
|
|
|
591
508
|
|
|
592
509
|
return [strategyId, false, triggerData, subData];
|
|
593
510
|
},
|
|
594
|
-
limitOrder(
|
|
595
|
-
fromToken: EthereumAddress,
|
|
596
|
-
toToken: EthereumAddress,
|
|
597
|
-
amount: string,
|
|
598
|
-
targetPrice: string,
|
|
599
|
-
goodUntil: string | number,
|
|
600
|
-
orderType: OrderType,
|
|
601
|
-
) {
|
|
602
|
-
return subDataService.exchangeLimitOrderSubData.encode(fromToken, toToken, amount, targetPrice, goodUntil, orderType);
|
|
603
|
-
},
|
|
604
511
|
limitOrderWithoutSubProxy(
|
|
605
512
|
fromToken: EthereumAddress,
|
|
606
513
|
toToken: EthereumAddress,
|
|
@@ -623,27 +530,6 @@ export const exchangeEncode = {
|
|
|
623
530
|
};
|
|
624
531
|
|
|
625
532
|
export const sparkEncode = {
|
|
626
|
-
leverageManagement(
|
|
627
|
-
triggerRepayRatio: number,
|
|
628
|
-
triggerBoostRatio: number,
|
|
629
|
-
targetBoostRatio: number,
|
|
630
|
-
targetRepayRatio: number,
|
|
631
|
-
boostEnabled: boolean,
|
|
632
|
-
) {
|
|
633
|
-
let subInput = '0x';
|
|
634
|
-
|
|
635
|
-
subInput = subInput.concat(new Dec(triggerRepayRatio).mul(1e16).toHex().slice(2)
|
|
636
|
-
.padStart(32, '0'));
|
|
637
|
-
subInput = subInput.concat(new Dec(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
638
|
-
.padStart(32, '0'));
|
|
639
|
-
subInput = subInput.concat(new Dec(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
640
|
-
.padStart(32, '0'));
|
|
641
|
-
subInput = subInput.concat(new Dec(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
642
|
-
.padStart(32, '0'));
|
|
643
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
644
|
-
|
|
645
|
-
return subInput;
|
|
646
|
-
},
|
|
647
533
|
leverageManagementOnPrice(
|
|
648
534
|
strategyOrBundleId: number,
|
|
649
535
|
isBundle: boolean = true,
|