@defisaver/automation-sdk 3.0.2-dev → 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/StrategiesAutomation.js +3 -1
- package/esm/constants/index.d.ts +4 -25
- package/esm/constants/index.js +67 -1
- package/esm/services/strategiesService.js +29 -6
- package/esm/services/strategySubService.d.ts +15 -1
- package/esm/services/strategySubService.js +22 -3
- package/esm/services/strategySubService.test.js +80 -2
- package/esm/services/subDataService.d.ts +21 -1
- package/esm/services/subDataService.js +66 -3
- package/esm/services/subDataService.test.js +106 -2
- package/esm/services/triggerService.d.ts +8 -0
- package/esm/services/triggerService.js +15 -1
- package/esm/services/triggerService.test.js +28 -0
- package/esm/types/enums.d.ts +23 -7
- package/esm/types/enums.js +16 -0
- package/package.json +2 -2
- package/src/automation/private/StrategiesAutomation.ts +3 -1
- package/src/constants/index.ts +70 -3
- package/src/services/ethereumService.ts +1 -1
- package/src/services/strategiesService.ts +42 -6
- package/src/services/strategySubService.test.ts +99 -2
- package/src/services/strategySubService.ts +45 -2
- package/src/services/subDataService.test.ts +119 -4
- package/src/services/subDataService.ts +92 -2
- package/src/services/triggerService.test.ts +30 -0
- package/src/services/triggerService.ts +21 -1
- package/src/types/enums.ts +16 -0
- package/umd/index.js +283 -67
|
@@ -32,7 +32,9 @@ class StrategiesAutomation extends Automation_1.default {
|
|
|
32
32
|
getEventFromSubStorage(event, options) {
|
|
33
33
|
var _a;
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
|
|
35
|
+
// only used for backfilling, so in case options?.fromBlock in undefined
|
|
36
|
+
// (just like we omit fromBlock when we call from app when not on fork), we still want to fetch events
|
|
37
|
+
if (new decimal_js_1.default(this.subStorageContract.createdBlock.toString()).gt(((_a = options === null || options === void 0 ? void 0 : options.fromBlock) === null || _a === void 0 ? void 0 : _a.toString()) || this.subStorageContract.createdBlock.toString())) {
|
|
36
38
|
return [];
|
|
37
39
|
}
|
|
38
40
|
return (0, ethereumService_1.getEventsFromContract)(this.subStorageContract, this.subStorageContractFork, event, options);
|
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,
|
|
@@ -293,6 +334,21 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
293
334
|
strategyId: enums_1.Strategies.Identifiers.Boost,
|
|
294
335
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
295
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
|
+
},
|
|
296
352
|
};
|
|
297
353
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
298
354
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -315,6 +371,11 @@ exports.OPTIMISM_BUNDLES_INFO = {
|
|
|
315
371
|
strategyId: enums_1.Strategies.Identifiers.CloseToCollateral,
|
|
316
372
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
317
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
|
+
},
|
|
318
379
|
};
|
|
319
380
|
exports.ARBITRUM_BUNDLES_INFO = {
|
|
320
381
|
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -347,6 +408,11 @@ exports.ARBITRUM_BUNDLES_INFO = {
|
|
|
347
408
|
strategyId: enums_1.Strategies.Identifiers.Repay,
|
|
348
409
|
protocol: exports.PROTOCOLS.CompoundV3,
|
|
349
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
|
+
},
|
|
350
416
|
};
|
|
351
417
|
exports.BUNDLES_INFO = {
|
|
352
418
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
|
|
@@ -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,20 @@ 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
|
+
}
|
|
548
558
|
function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
549
559
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
550
560
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
@@ -553,7 +563,8 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
553
563
|
const subData = subDataService.morphoBlueLeverageManagementSubData.decode(subStruct.subData);
|
|
554
564
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
555
565
|
_position.strategyData.decoded.subData = subData;
|
|
556
|
-
|
|
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);
|
|
557
568
|
if (isRepay) {
|
|
558
569
|
_position.specific = {
|
|
559
570
|
triggerRepayRatio: triggerData.ratio,
|
|
@@ -574,8 +585,16 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
574
585
|
mergeId: enums_1.Strategies.Identifiers.Boost,
|
|
575
586
|
};
|
|
576
587
|
}
|
|
577
|
-
|
|
578
|
-
_position.strategy.strategyId = enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
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());
|
|
579
598
|
return _position;
|
|
580
599
|
}
|
|
581
600
|
const parsingMethodsMapping = {
|
|
@@ -609,6 +628,7 @@ const parsingMethodsMapping = {
|
|
|
609
628
|
[enums_1.Strategies.Identifiers.CloseToDebtWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
610
629
|
[enums_1.Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
611
630
|
[enums_1.Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
631
|
+
[enums_1.Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3OpenOrderFromCollateral,
|
|
612
632
|
},
|
|
613
633
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
614
634
|
[enums_1.Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -640,10 +660,13 @@ const parsingMethodsMapping = {
|
|
|
640
660
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CrvUSD]: {
|
|
641
661
|
[enums_1.Strategies.Identifiers.Repay]: parseCrvUSDLeverageManagement,
|
|
642
662
|
[enums_1.Strategies.Identifiers.Boost]: parseCrvUSDLeverageManagement,
|
|
663
|
+
[enums_1.Strategies.Identifiers.Payback]: parseCrvUSDPayback,
|
|
643
664
|
},
|
|
644
665
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.MorphoBlue]: {
|
|
645
666
|
[enums_1.Strategies.Identifiers.Repay]: parseMorphoBlueLeverageManagement,
|
|
646
667
|
[enums_1.Strategies.Identifiers.Boost]: parseMorphoBlueLeverageManagement,
|
|
668
|
+
[enums_1.Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
669
|
+
[enums_1.Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
647
670
|
},
|
|
648
671
|
};
|
|
649
672
|
function getParsingMethod(id, strategy) {
|
|
@@ -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,7 +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)[];
|
|
83
97
|
};
|
|
84
98
|
export declare const morphoBlueEncode: {
|
|
85
|
-
leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
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)[];
|
|
86
100
|
};
|
|
@@ -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,13 +239,25 @@ 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
|
+
},
|
|
235
249
|
};
|
|
236
250
|
exports.morphoBlueEncode = {
|
|
237
|
-
leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user) {
|
|
238
|
-
const subData = subDataService.morphoBlueLeverageManagementSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user);
|
|
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);
|
|
239
253
|
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
240
254
|
// over is boost, under is repay
|
|
241
|
-
const
|
|
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;
|
|
242
261
|
const isBundle = true;
|
|
243
262
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
244
263
|
},
|
|
@@ -454,6 +454,46 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
454
454
|
});
|
|
455
455
|
});
|
|
456
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
|
+
});
|
|
457
497
|
});
|
|
458
498
|
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
459
499
|
describe('leverageManagement()', () => {
|
|
@@ -750,6 +790,40 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
750
790
|
});
|
|
751
791
|
});
|
|
752
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
|
+
});
|
|
753
827
|
});
|
|
754
828
|
describe('When testing strategySubService.morphoBlueEncode', () => {
|
|
755
829
|
describe('leverageManagement()', () => {
|
|
@@ -770,6 +844,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
770
844
|
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
771
845
|
'0x000000000000000000000000000000000000000000000000136dcc951d8c0000',
|
|
772
846
|
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
847
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
773
848
|
],
|
|
774
849
|
],
|
|
775
850
|
[
|
|
@@ -782,7 +857,8 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
782
857
|
enums_1.RatioState.UNDER,
|
|
783
858
|
140,
|
|
784
859
|
120,
|
|
785
|
-
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c')
|
|
860
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
861
|
+
false,
|
|
786
862
|
]
|
|
787
863
|
],
|
|
788
864
|
[
|
|
@@ -801,6 +877,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
801
877
|
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
802
878
|
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
803
879
|
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
880
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
804
881
|
],
|
|
805
882
|
],
|
|
806
883
|
[
|
|
@@ -813,7 +890,8 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
813
890
|
enums_1.RatioState.OVER,
|
|
814
891
|
160,
|
|
815
892
|
200,
|
|
816
|
-
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c')
|
|
893
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
894
|
+
false,
|
|
817
895
|
]
|
|
818
896
|
],
|
|
819
897
|
];
|
|
@@ -158,8 +158,17 @@ 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
|
+
};
|
|
161
170
|
export declare const morphoBlueLeverageManagementSubData: {
|
|
162
|
-
encode: (loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, user: EthereumAddress) => string[];
|
|
171
|
+
encode: (loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, user: EthereumAddress, isEOA: boolean) => string[];
|
|
163
172
|
decode: (subData: string[]) => {
|
|
164
173
|
loanToken: string;
|
|
165
174
|
collToken: string;
|
|
@@ -170,3 +179,14 @@ export declare const morphoBlueLeverageManagementSubData: {
|
|
|
170
179
|
targetRatio: number;
|
|
171
180
|
};
|
|
172
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
|
+
};
|
|
@@ -3,9 +3,10 @@ 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.morphoBlueLeverageManagementSubData = exports.crvUSDLeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkQuotePriceSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
6
|
+
exports.aaveV3OpenOrderSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkQuotePriceSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
|
+
const web3_utils_1 = require("web3-utils");
|
|
9
10
|
const tokens_1 = require("@defisaver/tokens");
|
|
10
11
|
const sdk_1 = require("@defisaver/sdk");
|
|
11
12
|
const enums_1 = require("../types/enums");
|
|
@@ -378,8 +379,37 @@ exports.crvUSDLeverageManagementSubData = {
|
|
|
378
379
|
return { controller, targetRatio };
|
|
379
380
|
},
|
|
380
381
|
};
|
|
382
|
+
exports.crvUSDPaybackSubData = {
|
|
383
|
+
encode: (controllerAddr, addressToPullTokensFrom, positionOwner, paybackAmount, crvUSDAddr) => {
|
|
384
|
+
const controllerAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', controllerAddr);
|
|
385
|
+
const addressToPullTokensFromEncoded = web3_eth_abi_1.default.encodeParameter('address', addressToPullTokensFrom);
|
|
386
|
+
const positionOwnerEncoded = web3_eth_abi_1.default.encodeParameter('address', positionOwner);
|
|
387
|
+
const paybackAmountEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, web3_utils_1.toWei)(paybackAmount, 'ether'));
|
|
388
|
+
const crvUSDAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', crvUSDAddr);
|
|
389
|
+
return [
|
|
390
|
+
controllerAddrEncoded,
|
|
391
|
+
addressToPullTokensFromEncoded,
|
|
392
|
+
positionOwnerEncoded,
|
|
393
|
+
paybackAmountEncoded,
|
|
394
|
+
crvUSDAddrEncoded,
|
|
395
|
+
];
|
|
396
|
+
},
|
|
397
|
+
decode: (subData) => {
|
|
398
|
+
const controller = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
399
|
+
const addressToPullTokensFrom = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
400
|
+
const positionOwner = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
401
|
+
const weiPaybackAmount = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
402
|
+
const paybackAmount = (0, web3_utils_1.fromWei)(weiPaybackAmount, 'ether');
|
|
403
|
+
return {
|
|
404
|
+
controller,
|
|
405
|
+
addressToPullTokensFrom,
|
|
406
|
+
positionOwner,
|
|
407
|
+
paybackAmount,
|
|
408
|
+
};
|
|
409
|
+
},
|
|
410
|
+
};
|
|
381
411
|
exports.morphoBlueLeverageManagementSubData = {
|
|
382
|
-
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user) => {
|
|
412
|
+
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA) => {
|
|
383
413
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
384
414
|
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
385
415
|
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
@@ -388,7 +418,8 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
388
418
|
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
389
419
|
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
390
420
|
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
391
|
-
|
|
421
|
+
const isEOAEncoded = web3_eth_abi_1.default.encodeParameter('bool', isEOA);
|
|
422
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, ratioStateEncoded, targetRatioEncoded, userEncoded, isEOAEncoded];
|
|
392
423
|
},
|
|
393
424
|
decode: (subData) => {
|
|
394
425
|
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
@@ -410,3 +441,35 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
410
441
|
};
|
|
411
442
|
},
|
|
412
443
|
};
|
|
444
|
+
exports.aaveV3OpenOrderSubData = {
|
|
445
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
446
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
447
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
448
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
449
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
450
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
451
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
452
|
+
const useOnBehalfEncoded = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
453
|
+
return [
|
|
454
|
+
encodedColl,
|
|
455
|
+
encodedCollId,
|
|
456
|
+
encodedDebt,
|
|
457
|
+
encodedDebtId,
|
|
458
|
+
encodedMarket,
|
|
459
|
+
encodedTargetRatio,
|
|
460
|
+
useOnBehalfEncoded,
|
|
461
|
+
];
|
|
462
|
+
},
|
|
463
|
+
decode(subData) {
|
|
464
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
465
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
466
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
467
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
468
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
469
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
470
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
471
|
+
return {
|
|
472
|
+
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
473
|
+
};
|
|
474
|
+
},
|
|
475
|
+
};
|