@defisaver/automation-sdk 3.0.1 → 3.0.2-dev2
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/esm/automation/private/LegacyAutomation.js +2 -2
- package/esm/automation/private/StrategiesAutomation.js +9 -1
- package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -1
- package/esm/automation/private/StrategiesAutomation.test.js +500 -499
- package/esm/constants/index.d.ts +4 -25
- package/esm/constants/index.js +77 -1
- package/esm/services/ethereumService.test.d.ts +1 -1
- package/esm/services/ethereumService.test.js +1 -0
- package/esm/services/strategiesService.js +63 -3
- package/esm/services/strategiesService.test.d.ts +1 -1
- package/esm/services/strategiesService.test.js +1 -0
- package/esm/services/strategySubService.d.ts +17 -0
- package/esm/services/strategySubService.js +30 -1
- package/esm/services/strategySubService.test.d.ts +1 -1
- package/esm/services/strategySubService.test.js +152 -0
- package/esm/services/subDataService.d.ts +32 -0
- package/esm/services/subDataService.js +96 -1
- package/esm/services/subDataService.test.d.ts +1 -1
- package/esm/services/subDataService.test.js +193 -0
- package/esm/services/triggerService.d.ts +17 -0
- package/esm/services/triggerService.js +31 -1
- package/esm/services/triggerService.test.d.ts +1 -1
- package/esm/services/triggerService.test.js +65 -0
- package/esm/services/utils.test.d.ts +1 -1
- package/esm/services/utils.test.js +1 -0
- package/esm/types/enums.d.ts +27 -8
- package/esm/types/enums.js +19 -0
- package/package.json +3 -3
- package/scripts/generateContractTypes.js +1 -1
- package/src/automation/private/LegacyAutomation.ts +2 -2
- package/src/automation/private/StrategiesAutomation.test.ts +503 -501
- package/src/automation/private/StrategiesAutomation.ts +9 -0
- package/src/constants/index.ts +80 -3
- package/src/services/ethereumService.test.ts +1 -0
- package/src/services/ethereumService.ts +1 -1
- package/src/services/strategiesService.test.ts +1 -0
- package/src/services/strategiesService.ts +81 -3
- package/src/services/strategySubService.test.ts +187 -1
- package/src/services/strategySubService.ts +68 -0
- package/src/services/subDataService.test.ts +212 -1
- package/src/services/subDataService.ts +134 -1
- package/src/services/triggerService.test.ts +70 -0
- package/src/services/triggerService.ts +44 -1
- package/src/services/utils.test.ts +1 -0
- package/src/types/enums.ts +19 -0
- package/umd/index.js +397 -58
- package/.env +0 -4
- package/.yarn/releases/yarn-1.22.1.cjs +0 -147386
- package/.yarnrc.yml +0 -3
package/esm/constants/index.d.ts
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
|
-
import type { ArbitrumBundleInfo, BundlesInfo, EthereumAddress, Interfaces, MainnetBundleInfo, MainnetStrategiesInfo, OptimismBundleInfo, StrategiesInfo } from '../types';
|
|
1
|
+
import type { ArbitrumBundleInfo, ArbitrumStrategiesInfo, BundlesInfo, EthereumAddress, Interfaces, MainnetBundleInfo, MainnetStrategiesInfo, OptimismBundleInfo, OptimismStrategiesInfo, StrategiesInfo } from '../types';
|
|
2
2
|
import { ProtocolIdentifiers, Strategies, Bundles } from '../types/enums';
|
|
3
3
|
export declare const ZERO_ADDRESS: EthereumAddress;
|
|
4
|
+
export declare const AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
4
5
|
export declare const PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.StrategiesAutomation, Interfaces.Protocol>;
|
|
5
6
|
export declare const LEGACY_PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.LegacyAutomation, Interfaces.LegacyProtocol>;
|
|
6
7
|
export declare const MAINNET_STRATEGIES_INFO: MainnetStrategiesInfo;
|
|
7
|
-
export declare const OPTIMISM_STRATEGIES_INFO:
|
|
8
|
-
|
|
9
|
-
strategyOrBundleId: Strategies.OptimismIds;
|
|
10
|
-
strategyId: Strategies.Identifiers;
|
|
11
|
-
protocol: Interfaces.Protocol;
|
|
12
|
-
};
|
|
13
|
-
9: {
|
|
14
|
-
strategyOrBundleId: Strategies.OptimismIds;
|
|
15
|
-
strategyId: Strategies.Identifiers;
|
|
16
|
-
protocol: Interfaces.Protocol;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export declare const ARBITRUM_STRATEGIES_INFO: {
|
|
20
|
-
8: {
|
|
21
|
-
strategyOrBundleId: Strategies.ArbitrumIds;
|
|
22
|
-
strategyId: Strategies.Identifiers;
|
|
23
|
-
protocol: Interfaces.Protocol;
|
|
24
|
-
};
|
|
25
|
-
9: {
|
|
26
|
-
strategyOrBundleId: Strategies.ArbitrumIds;
|
|
27
|
-
strategyId: Strategies.Identifiers;
|
|
28
|
-
protocol: Interfaces.Protocol;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
8
|
+
export declare const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo;
|
|
9
|
+
export declare const ARBITRUM_STRATEGIES_INFO: ArbitrumStrategiesInfo;
|
|
31
10
|
export declare const STRATEGIES_INFO: StrategiesInfo;
|
|
32
11
|
export declare const STRATEGY_IDS: {
|
|
33
12
|
1: typeof Strategies.MainnetIds;
|
package/esm/constants/index.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.BUNDLE_IDS = exports.BUNDLES_INFO = exports.ARBITRUM_BUNDLES_INFO = exports.OPTIMISM_BUNDLES_INFO = exports.MAINNET_BUNDLES_INFO = exports.STRATEGY_IDS = exports.STRATEGIES_INFO = exports.ARBITRUM_STRATEGIES_INFO = exports.OPTIMISM_STRATEGIES_INFO = exports.MAINNET_STRATEGIES_INFO = exports.LEGACY_PROTOCOLS = exports.PROTOCOLS = exports.ZERO_ADDRESS = void 0;
|
|
6
|
+
exports.BUNDLE_IDS = exports.BUNDLES_INFO = exports.ARBITRUM_BUNDLES_INFO = exports.OPTIMISM_BUNDLES_INFO = exports.MAINNET_BUNDLES_INFO = exports.STRATEGY_IDS = exports.STRATEGIES_INFO = exports.ARBITRUM_STRATEGIES_INFO = exports.OPTIMISM_STRATEGIES_INFO = exports.MAINNET_STRATEGIES_INFO = exports.LEGACY_PROTOCOLS = exports.PROTOCOLS = exports.AAVE_V3_VARIABLE_BORROW_RATE = exports.ZERO_ADDRESS = void 0;
|
|
7
7
|
const enums_1 = require("../types/enums");
|
|
8
8
|
const Protocol_1 = __importDefault(require("../automation/private/Protocol"));
|
|
9
9
|
const LegacyProtocol_1 = __importDefault(require("../automation/private/LegacyProtocol"));
|
|
10
10
|
// General
|
|
11
11
|
exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
12
|
+
exports.AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
12
13
|
exports.PROTOCOLS = (() => {
|
|
13
14
|
const protocolsMapping = {};
|
|
14
15
|
Object.entries(enums_1.ProtocolIdentifiers.StrategiesAutomation).forEach(([id, value]) => {
|
|
@@ -90,6 +91,16 @@ exports.MAINNET_STRATEGIES_INFO = {
|
|
|
90
91
|
strategyId: enums_1.Strategies.Identifiers.DebtInFrontRepay,
|
|
91
92
|
protocol: exports.PROTOCOLS.Liquity,
|
|
92
93
|
},
|
|
94
|
+
[enums_1.Strategies.MainnetIds.CURVEUSD_PAYBACK]: {
|
|
95
|
+
strategyOrBundleId: enums_1.Strategies.MainnetIds.CURVEUSD_PAYBACK,
|
|
96
|
+
strategyId: enums_1.Strategies.Identifiers.Payback,
|
|
97
|
+
protocol: exports.PROTOCOLS.CrvUSD,
|
|
98
|
+
},
|
|
99
|
+
[enums_1.Strategies.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
100
|
+
strategyOrBundleId: enums_1.Strategies.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
101
|
+
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromDebt,
|
|
102
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
103
|
+
},
|
|
93
104
|
};
|
|
94
105
|
exports.OPTIMISM_STRATEGIES_INFO = {
|
|
95
106
|
[enums_1.Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -102,6 +113,11 @@ exports.OPTIMISM_STRATEGIES_INFO = {
|
|
|
102
113
|
strategyId: enums_1.Strategies.Identifiers.LimitOrder,
|
|
103
114
|
protocol: exports.PROTOCOLS.Exchange,
|
|
104
115
|
},
|
|
116
|
+
[enums_1.Strategies.OptimismIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
117
|
+
strategyOrBundleId: enums_1.Strategies.OptimismIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
118
|
+
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromDebt,
|
|
119
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
120
|
+
},
|
|
105
121
|
};
|
|
106
122
|
exports.ARBITRUM_STRATEGIES_INFO = {
|
|
107
123
|
[enums_1.Strategies.ArbitrumIds.EXCHANGE_DCA]: {
|
|
@@ -114,6 +130,11 @@ exports.ARBITRUM_STRATEGIES_INFO = {
|
|
|
114
130
|
strategyId: enums_1.Strategies.Identifiers.LimitOrder,
|
|
115
131
|
protocol: exports.PROTOCOLS.Exchange,
|
|
116
132
|
},
|
|
133
|
+
[enums_1.Strategies.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
134
|
+
strategyOrBundleId: enums_1.Strategies.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
135
|
+
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromDebt,
|
|
136
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
137
|
+
},
|
|
117
138
|
};
|
|
118
139
|
exports.STRATEGIES_INFO = {
|
|
119
140
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_STRATEGIES_INFO,
|
|
@@ -168,6 +189,26 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
168
189
|
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
169
190
|
protocol: exports.PROTOCOLS.CompoundV3,
|
|
170
191
|
},
|
|
192
|
+
[enums_1.Bundles.MainnetIds.COMP_V3_SW_REPAY_V2_BUNDLE]: {
|
|
193
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.COMP_V3_SW_REPAY_V2_BUNDLE,
|
|
194
|
+
strategyId: enums_1.Strategies.Identifiers.Repay,
|
|
195
|
+
protocol: exports.PROTOCOLS.CompoundV3,
|
|
196
|
+
},
|
|
197
|
+
[enums_1.Bundles.MainnetIds.COMP_V3_SW_BOOST_V2_BUNDLE]: {
|
|
198
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.COMP_V3_SW_BOOST_V2_BUNDLE,
|
|
199
|
+
strategyId: enums_1.Strategies.Identifiers.Boost,
|
|
200
|
+
protocol: exports.PROTOCOLS.CompoundV3,
|
|
201
|
+
},
|
|
202
|
+
[enums_1.Bundles.MainnetIds.COMP_V3_EOA_REPAY_V2_BUNDLE]: {
|
|
203
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.COMP_V3_EOA_REPAY_V2_BUNDLE,
|
|
204
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepay,
|
|
205
|
+
protocol: exports.PROTOCOLS.CompoundV3,
|
|
206
|
+
},
|
|
207
|
+
[enums_1.Bundles.MainnetIds.COMP_V3_EOA_BOOST_V2_BUNDLE]: {
|
|
208
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.COMP_V3_EOA_BOOST_V2_BUNDLE,
|
|
209
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
210
|
+
protocol: exports.PROTOCOLS.CompoundV3,
|
|
211
|
+
},
|
|
171
212
|
[enums_1.Bundles.MainnetIds.LIQUITY_PAYBACK_USING_CHICKEN_BOND]: {
|
|
172
213
|
strategyOrBundleId: enums_1.Bundles.MainnetIds.LIQUITY_PAYBACK_USING_CHICKEN_BOND,
|
|
173
214
|
strategyId: enums_1.Strategies.Identifiers.BondProtection,
|
|
@@ -283,6 +324,31 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
283
324
|
strategyId: enums_1.Strategies.Identifiers.Boost,
|
|
284
325
|
protocol: exports.PROTOCOLS.CrvUSD,
|
|
285
326
|
},
|
|
327
|
+
[enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY]: {
|
|
328
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY,
|
|
329
|
+
strategyId: enums_1.Strategies.Identifiers.Repay,
|
|
330
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
331
|
+
},
|
|
332
|
+
[enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST]: {
|
|
333
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST,
|
|
334
|
+
strategyId: enums_1.Strategies.Identifiers.Boost,
|
|
335
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
336
|
+
},
|
|
337
|
+
[enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY]: {
|
|
338
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY,
|
|
339
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepay,
|
|
340
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
341
|
+
},
|
|
342
|
+
[enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST]: {
|
|
343
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST,
|
|
344
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
345
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
346
|
+
},
|
|
347
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL]: {
|
|
348
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL,
|
|
349
|
+
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromCollateral,
|
|
350
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
351
|
+
},
|
|
286
352
|
};
|
|
287
353
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
288
354
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -305,6 +371,11 @@ exports.OPTIMISM_BUNDLES_INFO = {
|
|
|
305
371
|
strategyId: enums_1.Strategies.Identifiers.CloseToCollateral,
|
|
306
372
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
307
373
|
},
|
|
374
|
+
[enums_1.Bundles.OptimismIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL]: {
|
|
375
|
+
strategyOrBundleId: enums_1.Bundles.OptimismIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL,
|
|
376
|
+
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromCollateral,
|
|
377
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
378
|
+
},
|
|
308
379
|
};
|
|
309
380
|
exports.ARBITRUM_BUNDLES_INFO = {
|
|
310
381
|
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -337,6 +408,11 @@ exports.ARBITRUM_BUNDLES_INFO = {
|
|
|
337
408
|
strategyId: enums_1.Strategies.Identifiers.Repay,
|
|
338
409
|
protocol: exports.PROTOCOLS.CompoundV3,
|
|
339
410
|
},
|
|
411
|
+
[enums_1.Bundles.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL]: {
|
|
412
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL,
|
|
413
|
+
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromCollateral,
|
|
414
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
415
|
+
},
|
|
340
416
|
};
|
|
341
417
|
exports.BUNDLES_INFO = {
|
|
342
418
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import '../configuration';
|
|
@@ -16,6 +16,7 @@ const web3_1 = __importDefault(require("web3"));
|
|
|
16
16
|
const chai_1 = require("chai");
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const enums_1 = require("../types/enums");
|
|
19
|
+
require("../configuration");
|
|
19
20
|
const ethereumService_1 = require("./ethereumService");
|
|
20
21
|
const contractService_1 = require("./contractService");
|
|
21
22
|
require('dotenv').config({ path: '.env' });
|
|
@@ -333,8 +333,7 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
333
333
|
const subData = subDataDecoder.decode(subStruct.subData);
|
|
334
334
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
335
335
|
_position.strategyData.decoded.subData = subData;
|
|
336
|
-
_position.
|
|
337
|
-
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
336
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.market);
|
|
338
337
|
const isRepay = [enums_1.Strategies.Identifiers.Repay, enums_1.Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId);
|
|
339
338
|
if (isRepay) {
|
|
340
339
|
_position.specific = {
|
|
@@ -520,6 +519,7 @@ function parseCrvUSDLeverageManagement(position, parseData) {
|
|
|
520
519
|
const subData = subDataService.crvUSDLeverageManagementSubData.decode(subStruct.subData);
|
|
521
520
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
522
521
|
_position.strategyData.decoded.subData = subData;
|
|
522
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller);
|
|
523
523
|
const isRepay = _position.strategy.strategyId === enums_1.Strategies.Identifiers.Repay;
|
|
524
524
|
if (isRepay) {
|
|
525
525
|
_position.specific = {
|
|
@@ -541,10 +541,62 @@ function parseCrvUSDLeverageManagement(position, parseData) {
|
|
|
541
541
|
mergeId: enums_1.Strategies.Identifiers.Boost,
|
|
542
542
|
};
|
|
543
543
|
}
|
|
544
|
-
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller);
|
|
545
544
|
_position.strategy.strategyId = enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
546
545
|
return _position;
|
|
547
546
|
}
|
|
547
|
+
function parseCrvUSDPayback(position, parseData) {
|
|
548
|
+
const _position = (0, lodash_1.cloneDeep)(position);
|
|
549
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
550
|
+
const triggerData = triggerService.crvUsdHealthRatioTrigger.decode(subStruct.triggerData);
|
|
551
|
+
const subData = subDataService.crvUSDPaybackSubData.decode(subStruct.subData);
|
|
552
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
553
|
+
_position.strategyData.decoded.subData = subData;
|
|
554
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller, Math.random());
|
|
555
|
+
_position.strategy.strategyId = enums_1.Strategies.Identifiers.Payback;
|
|
556
|
+
return _position;
|
|
557
|
+
}
|
|
558
|
+
function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
559
|
+
const _position = (0, lodash_1.cloneDeep)(position);
|
|
560
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
561
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
562
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.decode(subStruct.triggerData);
|
|
563
|
+
const subData = subDataService.morphoBlueLeverageManagementSubData.decode(subStruct.subData);
|
|
564
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
565
|
+
_position.strategyData.decoded.subData = subData;
|
|
566
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.marketId);
|
|
567
|
+
const isRepay = [enums_1.Strategies.Identifiers.Repay, enums_1.Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId);
|
|
568
|
+
if (isRepay) {
|
|
569
|
+
_position.specific = {
|
|
570
|
+
triggerRepayRatio: triggerData.ratio,
|
|
571
|
+
targetRepayRatio: subData.targetRatio,
|
|
572
|
+
repayEnabled: isEnabled,
|
|
573
|
+
subId1: Number(subId),
|
|
574
|
+
subHashRepay: subHash,
|
|
575
|
+
mergeWithId: enums_1.Strategies.Identifiers.Boost,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
_position.specific = {
|
|
580
|
+
triggerBoostRatio: triggerData.ratio,
|
|
581
|
+
targetBoostRatio: subData.targetRatio,
|
|
582
|
+
boostEnabled: isEnabled,
|
|
583
|
+
subId2: Number(subId),
|
|
584
|
+
subHashBoost: subHash,
|
|
585
|
+
mergeId: enums_1.Strategies.Identifiers.Boost,
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
589
|
+
_position.strategy.strategyId = isEOA ? enums_1.Strategies.IdOverrides.EoaLeverageManagement : enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
590
|
+
return _position;
|
|
591
|
+
}
|
|
592
|
+
function parseAaveV3OpenOrderFromCollateral(position, parseData) {
|
|
593
|
+
const _position = (0, lodash_1.cloneDeep)(position);
|
|
594
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
595
|
+
_position.strategyData.decoded.triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
596
|
+
_position.strategyData.decoded.subData = subDataService.aaveV3OpenOrderSubData.decode(subStruct.subData);
|
|
597
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, Math.random());
|
|
598
|
+
return _position;
|
|
599
|
+
}
|
|
548
600
|
const parsingMethodsMapping = {
|
|
549
601
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
550
602
|
[enums_1.Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -576,6 +628,7 @@ const parsingMethodsMapping = {
|
|
|
576
628
|
[enums_1.Strategies.Identifiers.CloseToDebtWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
577
629
|
[enums_1.Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
578
630
|
[enums_1.Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
631
|
+
[enums_1.Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3OpenOrderFromCollateral,
|
|
579
632
|
},
|
|
580
633
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
581
634
|
[enums_1.Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -607,6 +660,13 @@ const parsingMethodsMapping = {
|
|
|
607
660
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CrvUSD]: {
|
|
608
661
|
[enums_1.Strategies.Identifiers.Repay]: parseCrvUSDLeverageManagement,
|
|
609
662
|
[enums_1.Strategies.Identifiers.Boost]: parseCrvUSDLeverageManagement,
|
|
663
|
+
[enums_1.Strategies.Identifiers.Payback]: parseCrvUSDPayback,
|
|
664
|
+
},
|
|
665
|
+
[enums_1.ProtocolIdentifiers.StrategiesAutomation.MorphoBlue]: {
|
|
666
|
+
[enums_1.Strategies.Identifiers.Repay]: parseMorphoBlueLeverageManagement,
|
|
667
|
+
[enums_1.Strategies.Identifiers.Boost]: parseMorphoBlueLeverageManagement,
|
|
668
|
+
[enums_1.Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
669
|
+
[enums_1.Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
610
670
|
},
|
|
611
671
|
};
|
|
612
672
|
function getParsingMethod(id, strategy) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import '../configuration';
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const chai_1 = require("chai");
|
|
13
13
|
const enums_1 = require("../types/enums");
|
|
14
|
+
require("../configuration");
|
|
14
15
|
const strategiesService_1 = require("./strategiesService");
|
|
15
16
|
describe('Feature: strategiesService.ts', () => {
|
|
16
17
|
describe('When testing strategiesService.parseStrategiesAutomatedPosition', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -47,6 +47,19 @@ export declare const aaveV3Encode: {
|
|
|
47
47
|
debtAsset: EthereumAddress;
|
|
48
48
|
debtAssetId: number;
|
|
49
49
|
}): (number | boolean | string[])[];
|
|
50
|
+
openOrder(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
51
|
+
baseTokenAddress: EthereumAddress;
|
|
52
|
+
quoteTokenAddress: EthereumAddress;
|
|
53
|
+
price: number;
|
|
54
|
+
state: RatioState.UNDER;
|
|
55
|
+
}, subData: {
|
|
56
|
+
collAsset: EthereumAddress;
|
|
57
|
+
collAssetId: number;
|
|
58
|
+
debtAsset: EthereumAddress;
|
|
59
|
+
debtAssetId: number;
|
|
60
|
+
marketAddr: EthereumAddress;
|
|
61
|
+
targetRatio: number;
|
|
62
|
+
}): (number | boolean | string[])[];
|
|
50
63
|
};
|
|
51
64
|
export declare const compoundV2Encode: {
|
|
52
65
|
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
@@ -80,4 +93,8 @@ export declare const sparkEncode: {
|
|
|
80
93
|
};
|
|
81
94
|
export declare const crvUSDEncode: {
|
|
82
95
|
leverageManagement(owner: EthereumAddress, controllerAddr: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, collTokenAddr: EthereumAddress, crvUSDAddr: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
96
|
+
payback(proxyAddress: EthereumAddress, addressToPullTokensFrom: EthereumAddress, positionOwner: EthereumAddress, paybackAmount: string, crvUSDAddr: EthereumAddress, controllerAddr: EthereumAddress, minHealthRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
97
|
+
};
|
|
98
|
+
export declare const morphoBlueEncode: {
|
|
99
|
+
leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean): (boolean | string[] | Bundles.MainnetIds)[];
|
|
83
100
|
};
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.morphoAaveV2Encode = exports.compoundV3L2Encode = exports.compoundV3Encode = exports.compoundV2Encode = exports.aaveV3Encode = exports.aaveV2Encode = exports.chickenBondsEncode = exports.liquityEncode = exports.makerEncode = void 0;
|
|
29
|
+
exports.morphoBlueEncode = exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.morphoAaveV2Encode = exports.compoundV3L2Encode = exports.compoundV3Encode = exports.compoundV2Encode = exports.aaveV3Encode = exports.aaveV2Encode = exports.chickenBondsEncode = exports.liquityEncode = exports.makerEncode = void 0;
|
|
30
30
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
31
|
const tokens_1 = require("@defisaver/tokens");
|
|
32
32
|
const enums_1 = require("../types/enums");
|
|
@@ -168,6 +168,13 @@ exports.aaveV3Encode = {
|
|
|
168
168
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceWithMaximumGasPriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, ratioState, maximumGasPrice);
|
|
169
169
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
170
170
|
},
|
|
171
|
+
openOrder(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
172
|
+
const { collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, } = subData;
|
|
173
|
+
const subDataEncoded = subDataService.aaveV3OpenOrderSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
174
|
+
const { baseTokenAddress, quoteTokenAddress, price, state, } = triggerData;
|
|
175
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
176
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
177
|
+
},
|
|
171
178
|
};
|
|
172
179
|
exports.compoundV2Encode = {
|
|
173
180
|
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
@@ -232,4 +239,26 @@ exports.crvUSDEncode = {
|
|
|
232
239
|
const isBundle = true;
|
|
233
240
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
234
241
|
},
|
|
242
|
+
payback(proxyAddress, addressToPullTokensFrom, positionOwner, paybackAmount, crvUSDAddr, controllerAddr, minHealthRatio) {
|
|
243
|
+
const subData = subDataService.crvUSDPaybackSubData.encode(controllerAddr, addressToPullTokensFrom, positionOwner, paybackAmount, crvUSDAddr);
|
|
244
|
+
const triggerData = triggerService.crvUsdHealthRatioTrigger.encode(proxyAddress, controllerAddr, minHealthRatio);
|
|
245
|
+
const strategyId = enums_1.Strategies.MainnetIds.CURVEUSD_PAYBACK;
|
|
246
|
+
const isBundle = false;
|
|
247
|
+
return [strategyId, isBundle, triggerData, subData];
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
exports.morphoBlueEncode = {
|
|
251
|
+
leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA) {
|
|
252
|
+
const subData = subDataService.morphoBlueLeverageManagementSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
253
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
254
|
+
// over is boost, under is repay
|
|
255
|
+
const isBoost = ratioState === enums_1.RatioState.OVER;
|
|
256
|
+
let strategyOrBundleId;
|
|
257
|
+
if (isBoost)
|
|
258
|
+
strategyOrBundleId = isEOA ? enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST : enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST;
|
|
259
|
+
else
|
|
260
|
+
strategyOrBundleId = isEOA ? enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY : enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY;
|
|
261
|
+
const isBundle = true;
|
|
262
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
263
|
+
},
|
|
235
264
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import '../configuration';
|
|
@@ -32,6 +32,7 @@ const sdk_1 = require("@defisaver/sdk");
|
|
|
32
32
|
const tokens_1 = require("@defisaver/tokens");
|
|
33
33
|
const web3Utils = __importStar(require("web3-utils"));
|
|
34
34
|
const enums_1 = require("../types/enums");
|
|
35
|
+
require("../configuration");
|
|
35
36
|
const strategySubService_1 = require("./strategySubService");
|
|
36
37
|
describe('Feature: strategySubService.ts', () => {
|
|
37
38
|
describe('When testing strategySubService.makerEncode', () => {
|
|
@@ -453,6 +454,46 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
453
454
|
});
|
|
454
455
|
});
|
|
455
456
|
});
|
|
457
|
+
describe('openOrder()', () => {
|
|
458
|
+
const examples = [
|
|
459
|
+
[
|
|
460
|
+
[
|
|
461
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL,
|
|
462
|
+
true,
|
|
463
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000007acead34980000000000000000000000000000000000000000000000000000000000000001'],
|
|
464
|
+
[
|
|
465
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
466
|
+
'0x000000000000000000000000000000000000000000000000000000000000000a',
|
|
467
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
468
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
469
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
470
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
471
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
472
|
+
],
|
|
473
|
+
],
|
|
474
|
+
[
|
|
475
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_COLLATERAL,
|
|
476
|
+
true,
|
|
477
|
+
{
|
|
478
|
+
baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 5274.534678, state: enums_1.RatioState.UNDER
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
collAsset: (0, tokens_1.getAssetInfo)('WETH').address,
|
|
482
|
+
collAssetId: 10,
|
|
483
|
+
debtAsset: (0, tokens_1.getAssetInfo)('DAI').address,
|
|
484
|
+
debtAssetId: 4,
|
|
485
|
+
marketAddr: '0x2f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
486
|
+
targetRatio: 200,
|
|
487
|
+
},
|
|
488
|
+
]
|
|
489
|
+
],
|
|
490
|
+
];
|
|
491
|
+
examples.forEach(([expected, actual]) => {
|
|
492
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
493
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.openOrder(...actual)).to.eql(expected);
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
});
|
|
456
497
|
});
|
|
457
498
|
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
458
499
|
describe('leverageManagement()', () => {
|
|
@@ -749,6 +790,117 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
749
790
|
});
|
|
750
791
|
});
|
|
751
792
|
});
|
|
793
|
+
describe('payback()', () => {
|
|
794
|
+
const examples = [
|
|
795
|
+
[
|
|
796
|
+
[
|
|
797
|
+
enums_1.Strategies.MainnetIds.CURVEUSD_PAYBACK,
|
|
798
|
+
false,
|
|
799
|
+
[
|
|
800
|
+
'0x0000000000000000000000007a2af22ba3276108cd331c8985ef9528e10a871a000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d421963500000000000000000000000000000000000000000000000002c68af0bb140000',
|
|
801
|
+
],
|
|
802
|
+
[
|
|
803
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
804
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
805
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
806
|
+
'0x00000000000000000000000000000000000000000000043c33c1937564800000',
|
|
807
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e'
|
|
808
|
+
],
|
|
809
|
+
],
|
|
810
|
+
[
|
|
811
|
+
web3Utils.toChecksumAddress('0x7a2af22ba3276108cd331c8985ef9528e10a871a'),
|
|
812
|
+
web3Utils.toChecksumAddress('0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280'),
|
|
813
|
+
web3Utils.toChecksumAddress('0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280'),
|
|
814
|
+
'20000',
|
|
815
|
+
'0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
|
|
816
|
+
web3Utils.toChecksumAddress('0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635'),
|
|
817
|
+
20,
|
|
818
|
+
]
|
|
819
|
+
]
|
|
820
|
+
];
|
|
821
|
+
examples.forEach(([expected, actual]) => {
|
|
822
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
823
|
+
(0, chai_1.expect)(strategySubService_1.crvUSDEncode.payback(...actual)).to.eql(expected);
|
|
824
|
+
});
|
|
825
|
+
});
|
|
826
|
+
});
|
|
827
|
+
});
|
|
828
|
+
describe('When testing strategySubService.morphoBlueEncode', () => {
|
|
829
|
+
describe('leverageManagement()', () => {
|
|
830
|
+
const examples = [
|
|
831
|
+
[
|
|
832
|
+
[
|
|
833
|
+
enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY,
|
|
834
|
+
true,
|
|
835
|
+
[
|
|
836
|
+
'0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec410000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001',
|
|
837
|
+
],
|
|
838
|
+
[
|
|
839
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
840
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
841
|
+
'0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
|
|
842
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
843
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
844
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
845
|
+
'0x000000000000000000000000000000000000000000000000136dcc951d8c0000',
|
|
846
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
847
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
848
|
+
],
|
|
849
|
+
],
|
|
850
|
+
[
|
|
851
|
+
'0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41',
|
|
852
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
853
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
854
|
+
web3Utils.toChecksumAddress('0x2a01eb9496094da03c4e364def50f5ad1280ad72'),
|
|
855
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
856
|
+
'945000000000000000',
|
|
857
|
+
enums_1.RatioState.UNDER,
|
|
858
|
+
140,
|
|
859
|
+
120,
|
|
860
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
861
|
+
false,
|
|
862
|
+
]
|
|
863
|
+
],
|
|
864
|
+
[
|
|
865
|
+
[
|
|
866
|
+
enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST,
|
|
867
|
+
true,
|
|
868
|
+
[
|
|
869
|
+
'0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec410000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'
|
|
870
|
+
],
|
|
871
|
+
[
|
|
872
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
873
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
874
|
+
'0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
|
|
875
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
876
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
877
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
878
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
879
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
880
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
881
|
+
],
|
|
882
|
+
],
|
|
883
|
+
[
|
|
884
|
+
'0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41',
|
|
885
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
886
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
887
|
+
web3Utils.toChecksumAddress('0x2a01eb9496094da03c4e364def50f5ad1280ad72'),
|
|
888
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
889
|
+
'945000000000000000',
|
|
890
|
+
enums_1.RatioState.OVER,
|
|
891
|
+
160,
|
|
892
|
+
200,
|
|
893
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
894
|
+
false,
|
|
895
|
+
]
|
|
896
|
+
],
|
|
897
|
+
];
|
|
898
|
+
examples.forEach(([expected, actual]) => {
|
|
899
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
900
|
+
(0, chai_1.expect)(strategySubService_1.morphoBlueEncode.leverageManagement(...actual)).to.eql(expected);
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
});
|
|
752
904
|
});
|
|
753
905
|
describe('When testing strategySubService.compoundV3L2Encode', () => {
|
|
754
906
|
describe('leverageManagement()', () => {
|
|
@@ -158,3 +158,35 @@ export declare const crvUSDLeverageManagementSubData: {
|
|
|
158
158
|
targetRatio: number;
|
|
159
159
|
};
|
|
160
160
|
};
|
|
161
|
+
export declare const crvUSDPaybackSubData: {
|
|
162
|
+
encode: (controllerAddr: EthereumAddress, addressToPullTokensFrom: EthereumAddress, positionOwner: EthereumAddress, paybackAmount: string, crvUSDAddr: EthereumAddress) => string[];
|
|
163
|
+
decode: (subData: string[]) => {
|
|
164
|
+
controller: string;
|
|
165
|
+
addressToPullTokensFrom: string;
|
|
166
|
+
positionOwner: string;
|
|
167
|
+
paybackAmount: string;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
export declare const morphoBlueLeverageManagementSubData: {
|
|
171
|
+
encode: (loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, user: EthereumAddress, isEOA: boolean) => string[];
|
|
172
|
+
decode: (subData: string[]) => {
|
|
173
|
+
loanToken: string;
|
|
174
|
+
collToken: string;
|
|
175
|
+
oracle: string;
|
|
176
|
+
irm: string;
|
|
177
|
+
lltv: string;
|
|
178
|
+
user: string;
|
|
179
|
+
targetRatio: number;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
export declare const aaveV3OpenOrderSubData: {
|
|
183
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number): string[];
|
|
184
|
+
decode(subData: string[]): {
|
|
185
|
+
collAsset: EthereumAddress;
|
|
186
|
+
collAssetId: number;
|
|
187
|
+
debtAsset: EthereumAddress;
|
|
188
|
+
debtAssetId: number;
|
|
189
|
+
marketAddr: EthereumAddress;
|
|
190
|
+
targetRatio: number;
|
|
191
|
+
};
|
|
192
|
+
};
|