@defisaver/automation-sdk 3.1.2 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/index.js +20 -15
- package/cjs/services/strategiesService.js +4 -3
- package/cjs/services/strategySubService.d.ts +1 -1
- package/cjs/services/strategySubService.js +2 -2
- package/cjs/services/strategySubService.test.js +2 -2
- package/cjs/services/subDataService.d.ts +1 -1
- package/cjs/services/subDataService.js +2 -2
- package/cjs/services/subDataService.test.js +3 -3
- package/cjs/types/enums.d.ts +13 -11
- package/cjs/types/enums.js +5 -3
- package/esm/constants/index.js +20 -15
- package/esm/services/strategiesService.js +4 -3
- package/esm/services/strategySubService.d.ts +1 -1
- package/esm/services/strategySubService.js +2 -2
- package/esm/services/strategySubService.test.js +2 -2
- package/esm/services/subDataService.d.ts +1 -1
- package/esm/services/subDataService.js +1 -1
- package/esm/services/subDataService.test.js +4 -4
- package/esm/types/enums.d.ts +13 -11
- package/esm/types/enums.js +5 -3
- package/package.json +3 -3
- package/src/constants/index.ts +32 -16
- package/src/services/strategiesService.ts +4 -3
- package/src/services/strategySubService.test.ts +2 -2
- package/src/services/strategySubService.ts +2 -2
- package/src/services/subDataService.test.ts +4 -4
- package/src/services/subDataService.ts +2 -2
- package/src/types/enums.ts +5 -3
package/cjs/constants/index.js
CHANGED
|
@@ -96,11 +96,6 @@ exports.MAINNET_STRATEGIES_INFO = {
|
|
|
96
96
|
strategyId: enums_1.Strategies.Identifiers.Payback,
|
|
97
97
|
protocol: exports.PROTOCOLS.CrvUSD,
|
|
98
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
|
-
},
|
|
104
99
|
};
|
|
105
100
|
exports.OPTIMISM_STRATEGIES_INFO = {
|
|
106
101
|
[enums_1.Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -113,11 +108,6 @@ exports.OPTIMISM_STRATEGIES_INFO = {
|
|
|
113
108
|
strategyId: enums_1.Strategies.Identifiers.LimitOrder,
|
|
114
109
|
protocol: exports.PROTOCOLS.Exchange,
|
|
115
110
|
},
|
|
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
|
-
},
|
|
121
111
|
};
|
|
122
112
|
exports.BASE_STRATEGIES_INFO = {
|
|
123
113
|
[enums_1.Strategies.BaseIds.EXCHANGE_DCA]: {
|
|
@@ -142,11 +132,6 @@ exports.ARBITRUM_STRATEGIES_INFO = {
|
|
|
142
132
|
strategyId: enums_1.Strategies.Identifiers.LimitOrder,
|
|
143
133
|
protocol: exports.PROTOCOLS.Exchange,
|
|
144
134
|
},
|
|
145
|
-
[enums_1.Strategies.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
146
|
-
strategyOrBundleId: enums_1.Strategies.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
147
|
-
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromDebt,
|
|
148
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
149
|
-
},
|
|
150
135
|
};
|
|
151
136
|
exports.STRATEGIES_INFO = {
|
|
152
137
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_STRATEGIES_INFO,
|
|
@@ -363,6 +348,11 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
363
348
|
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromCollateral,
|
|
364
349
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
365
350
|
},
|
|
351
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
352
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_REPAY_ON_PRICE,
|
|
353
|
+
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
354
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
355
|
+
},
|
|
366
356
|
};
|
|
367
357
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
368
358
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -390,6 +380,11 @@ exports.OPTIMISM_BUNDLES_INFO = {
|
|
|
390
380
|
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromCollateral,
|
|
391
381
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
392
382
|
},
|
|
383
|
+
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
384
|
+
strategyOrBundleId: enums_1.Bundles.OptimismIds.AAVE_V3_REPAY_ON_PRICE,
|
|
385
|
+
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
386
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
387
|
+
},
|
|
393
388
|
};
|
|
394
389
|
exports.BASE_BUNDLES_INFO = {
|
|
395
390
|
[enums_1.Bundles.BaseIds.AAVE_V3_REPAY]: {
|
|
@@ -437,6 +432,11 @@ exports.BASE_BUNDLES_INFO = {
|
|
|
437
432
|
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromCollateral,
|
|
438
433
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
439
434
|
},
|
|
435
|
+
[enums_1.Bundles.BaseIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
436
|
+
strategyOrBundleId: enums_1.Bundles.BaseIds.AAVE_V3_REPAY_ON_PRICE,
|
|
437
|
+
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
438
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
439
|
+
},
|
|
440
440
|
};
|
|
441
441
|
exports.ARBITRUM_BUNDLES_INFO = {
|
|
442
442
|
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -474,6 +474,11 @@ exports.ARBITRUM_BUNDLES_INFO = {
|
|
|
474
474
|
strategyId: enums_1.Strategies.Identifiers.OpenOrderFromCollateral,
|
|
475
475
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
476
476
|
},
|
|
477
|
+
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
478
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY_ON_PRICE,
|
|
479
|
+
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
480
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
481
|
+
},
|
|
477
482
|
};
|
|
478
483
|
exports.BUNDLES_INFO = {
|
|
479
484
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
|
|
@@ -590,11 +590,11 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
590
590
|
_position.strategy.strategyId = isEOA ? enums_1.Strategies.IdOverrides.EoaLeverageManagement : enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
591
591
|
return _position;
|
|
592
592
|
}
|
|
593
|
-
function
|
|
593
|
+
function parseAaveV3LeverageManagementOnPrice(position, parseData) {
|
|
594
594
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
595
595
|
const { subStruct } = parseData.subscriptionEventData;
|
|
596
596
|
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
597
|
-
const subData = subDataService.
|
|
597
|
+
const subData = subDataService.aaveV3LeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
598
598
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
599
599
|
_position.strategyData.decoded.subData = subData;
|
|
600
600
|
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, Math.random());
|
|
@@ -642,7 +642,8 @@ const parsingMethodsMapping = {
|
|
|
642
642
|
[enums_1.Strategies.Identifiers.CloseToDebtWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
643
643
|
[enums_1.Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
644
644
|
[enums_1.Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
645
|
-
[enums_1.Strategies.Identifiers.OpenOrderFromCollateral]:
|
|
645
|
+
[enums_1.Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3LeverageManagementOnPrice,
|
|
646
|
+
[enums_1.Strategies.Identifiers.RepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
646
647
|
},
|
|
647
648
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
648
649
|
[enums_1.Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -47,7 +47,7 @@ export declare const aaveV3Encode: {
|
|
|
47
47
|
debtAsset: EthereumAddress;
|
|
48
48
|
debtAssetId: number;
|
|
49
49
|
}): (number | boolean | string[])[];
|
|
50
|
-
|
|
50
|
+
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
51
51
|
baseTokenAddress: EthereumAddress;
|
|
52
52
|
quoteTokenAddress: EthereumAddress;
|
|
53
53
|
price: number;
|
|
@@ -168,9 +168,9 @@ exports.aaveV3Encode = {
|
|
|
168
168
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceWithMaximumGasPriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, ratioState, maximumGasPrice);
|
|
169
169
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
170
170
|
},
|
|
171
|
-
|
|
171
|
+
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
172
172
|
const { collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, } = subData;
|
|
173
|
-
const subDataEncoded = subDataService.
|
|
173
|
+
const subDataEncoded = subDataService.aaveV3LeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
174
174
|
const { baseTokenAddress, quoteTokenAddress, price, state, } = triggerData;
|
|
175
175
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
176
176
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
@@ -454,7 +454,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
454
454
|
});
|
|
455
455
|
});
|
|
456
456
|
});
|
|
457
|
-
describe('
|
|
457
|
+
describe('leverageManagementOnPrice()', () => {
|
|
458
458
|
const examples = [
|
|
459
459
|
[
|
|
460
460
|
[
|
|
@@ -490,7 +490,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
490
490
|
];
|
|
491
491
|
examples.forEach(([expected, actual]) => {
|
|
492
492
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
493
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.
|
|
493
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
494
494
|
});
|
|
495
495
|
});
|
|
496
496
|
});
|
|
@@ -179,7 +179,7 @@ export declare const morphoBlueLeverageManagementSubData: {
|
|
|
179
179
|
targetRatio: number;
|
|
180
180
|
};
|
|
181
181
|
};
|
|
182
|
-
export declare const
|
|
182
|
+
export declare const aaveV3LeverageManagementOnPriceSubData: {
|
|
183
183
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number): string[];
|
|
184
184
|
decode(subData: string[]): {
|
|
185
185
|
collAsset: EthereumAddress;
|
|
@@ -3,7 +3,7 @@ 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.
|
|
6
|
+
exports.aaveV3LeverageManagementOnPriceSubData = 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
9
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -441,7 +441,7 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
441
441
|
};
|
|
442
442
|
},
|
|
443
443
|
};
|
|
444
|
-
exports.
|
|
444
|
+
exports.aaveV3LeverageManagementOnPriceSubData = {
|
|
445
445
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
446
446
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
447
447
|
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
@@ -1222,7 +1222,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1222
1222
|
});
|
|
1223
1223
|
});
|
|
1224
1224
|
});
|
|
1225
|
-
describe('When testing subDataService.
|
|
1225
|
+
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1226
1226
|
describe('encode()', () => {
|
|
1227
1227
|
const examples = [
|
|
1228
1228
|
[
|
|
@@ -1247,7 +1247,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1247
1247
|
];
|
|
1248
1248
|
examples.forEach(([expected, actual]) => {
|
|
1249
1249
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1250
|
-
(0, chai_1.expect)(subDataService_1.
|
|
1250
|
+
(0, chai_1.expect)(subDataService_1.aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1251
1251
|
});
|
|
1252
1252
|
});
|
|
1253
1253
|
});
|
|
@@ -1274,7 +1274,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1274
1274
|
];
|
|
1275
1275
|
examples.forEach(([expected, actual]) => {
|
|
1276
1276
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1277
|
-
(0, chai_1.expect)(subDataService_1.
|
|
1277
|
+
(0, chai_1.expect)(subDataService_1.aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1278
1278
|
});
|
|
1279
1279
|
});
|
|
1280
1280
|
});
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -60,13 +60,11 @@ export declare namespace Strategies {
|
|
|
60
60
|
LIQUITY_DSR_PAYBACK = 69,
|
|
61
61
|
LIQUITY_DSR_SUPPLY = 70,
|
|
62
62
|
LIQUITY_DEBT_IN_FRONT_REPAY = 75,
|
|
63
|
-
CURVEUSD_PAYBACK = 92
|
|
64
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 96
|
|
63
|
+
CURVEUSD_PAYBACK = 92
|
|
65
64
|
}
|
|
66
65
|
enum OptimismIds {
|
|
67
66
|
EXCHANGE_DCA = 8,
|
|
68
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
69
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 12
|
|
67
|
+
EXCHANGE_LIMIT_ORDER = 9
|
|
70
68
|
}
|
|
71
69
|
enum BaseIds {
|
|
72
70
|
EXCHANGE_DCA = 8,
|
|
@@ -74,8 +72,7 @@ export declare namespace Strategies {
|
|
|
74
72
|
}
|
|
75
73
|
enum ArbitrumIds {
|
|
76
74
|
EXCHANGE_DCA = 8,
|
|
77
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
78
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 16
|
|
75
|
+
EXCHANGE_LIMIT_ORDER = 9
|
|
79
76
|
}
|
|
80
77
|
enum Identifiers {
|
|
81
78
|
SavingsLiqProtection = "smart-savings-liquidation-protection",
|
|
@@ -100,7 +97,8 @@ export declare namespace Strategies {
|
|
|
100
97
|
LimitOrder = "limit-order",
|
|
101
98
|
DebtInFrontRepay = "debt-in-front-repay",
|
|
102
99
|
OpenOrderFromCollateral = "open-order-from-collateral",
|
|
103
|
-
OpenOrderFromDebt = "open-order-from-debt"
|
|
100
|
+
OpenOrderFromDebt = "open-order-from-debt",
|
|
101
|
+
RepayOnPrice = "repay-on-price"
|
|
104
102
|
}
|
|
105
103
|
enum IdOverrides {
|
|
106
104
|
TakeProfit = "take-profit",
|
|
@@ -152,14 +150,16 @@ export declare namespace Bundles {
|
|
|
152
150
|
MORPHO_BLUE_BOOST = 33,
|
|
153
151
|
MORPHO_BLUE_EOA_REPAY = 34,
|
|
154
152
|
MORPHO_BLUE_EOA_BOOST = 35,
|
|
155
|
-
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 36
|
|
153
|
+
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 36,
|
|
154
|
+
AAVE_V3_REPAY_ON_PRICE = 37
|
|
156
155
|
}
|
|
157
156
|
enum OptimismIds {
|
|
158
157
|
AAVE_V3_REPAY = 0,
|
|
159
158
|
AAVE_V3_BOOST = 1,
|
|
160
159
|
AAVE_V3_CLOSE_TO_DEBT = 2,
|
|
161
160
|
AAVE_V3_CLOSE_TO_COLLATERAL = 3,
|
|
162
|
-
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 4
|
|
161
|
+
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 4,
|
|
162
|
+
AAVE_V3_REPAY_ON_PRICE = 5
|
|
163
163
|
}
|
|
164
164
|
enum BaseIds {
|
|
165
165
|
AAVE_V3_REPAY = 0,
|
|
@@ -170,7 +170,8 @@ export declare namespace Bundles {
|
|
|
170
170
|
COMP_V3_SW_BOOST_BUNDLE = 5,
|
|
171
171
|
MORPHO_BLUE_REPAY = 8,
|
|
172
172
|
MORPHO_BLUE_BOOST = 9,
|
|
173
|
-
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10
|
|
173
|
+
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10,
|
|
174
|
+
AAVE_V3_REPAY_ON_PRICE = 11
|
|
174
175
|
}
|
|
175
176
|
enum ArbitrumIds {
|
|
176
177
|
AAVE_V3_REPAY = 0,
|
|
@@ -179,6 +180,7 @@ export declare namespace Bundles {
|
|
|
179
180
|
AAVE_V3_CLOSE_TO_COLLATERAL = 3,
|
|
180
181
|
COMP_V3_SW_REPAY_BUNDLE = 4,
|
|
181
182
|
COMP_V3_SW_BOOST_BUNDLE = 5,
|
|
182
|
-
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 6
|
|
183
|
+
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 6,
|
|
184
|
+
AAVE_V3_REPAY_ON_PRICE = 7
|
|
183
185
|
}
|
|
184
186
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -73,13 +73,11 @@ var Strategies;
|
|
|
73
73
|
MainnetIds[MainnetIds["LIQUITY_DSR_SUPPLY"] = 70] = "LIQUITY_DSR_SUPPLY";
|
|
74
74
|
MainnetIds[MainnetIds["LIQUITY_DEBT_IN_FRONT_REPAY"] = 75] = "LIQUITY_DEBT_IN_FRONT_REPAY";
|
|
75
75
|
MainnetIds[MainnetIds["CURVEUSD_PAYBACK"] = 92] = "CURVEUSD_PAYBACK";
|
|
76
|
-
MainnetIds[MainnetIds["AAVE_V3_OPEN_ORDER_FROM_DEBT"] = 96] = "AAVE_V3_OPEN_ORDER_FROM_DEBT";
|
|
77
76
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
78
77
|
let OptimismIds;
|
|
79
78
|
(function (OptimismIds) {
|
|
80
79
|
OptimismIds[OptimismIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
81
80
|
OptimismIds[OptimismIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
82
|
-
OptimismIds[OptimismIds["AAVE_V3_OPEN_ORDER_FROM_DEBT"] = 12] = "AAVE_V3_OPEN_ORDER_FROM_DEBT";
|
|
83
81
|
})(OptimismIds = Strategies.OptimismIds || (Strategies.OptimismIds = {}));
|
|
84
82
|
let BaseIds;
|
|
85
83
|
(function (BaseIds) {
|
|
@@ -90,7 +88,6 @@ var Strategies;
|
|
|
90
88
|
(function (ArbitrumIds) {
|
|
91
89
|
ArbitrumIds[ArbitrumIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
92
90
|
ArbitrumIds[ArbitrumIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
93
|
-
ArbitrumIds[ArbitrumIds["AAVE_V3_OPEN_ORDER_FROM_DEBT"] = 16] = "AAVE_V3_OPEN_ORDER_FROM_DEBT";
|
|
94
91
|
})(ArbitrumIds = Strategies.ArbitrumIds || (Strategies.ArbitrumIds = {}));
|
|
95
92
|
let Identifiers;
|
|
96
93
|
(function (Identifiers) {
|
|
@@ -117,6 +114,7 @@ var Strategies;
|
|
|
117
114
|
Identifiers["DebtInFrontRepay"] = "debt-in-front-repay";
|
|
118
115
|
Identifiers["OpenOrderFromCollateral"] = "open-order-from-collateral";
|
|
119
116
|
Identifiers["OpenOrderFromDebt"] = "open-order-from-debt";
|
|
117
|
+
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
120
118
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
121
119
|
let IdOverrides;
|
|
122
120
|
(function (IdOverrides) {
|
|
@@ -172,6 +170,7 @@ var Bundles;
|
|
|
172
170
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_REPAY"] = 34] = "MORPHO_BLUE_EOA_REPAY";
|
|
173
171
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_BOOST"] = 35] = "MORPHO_BLUE_EOA_BOOST";
|
|
174
172
|
MainnetIds[MainnetIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 36] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
173
|
+
MainnetIds[MainnetIds["AAVE_V3_REPAY_ON_PRICE"] = 37] = "AAVE_V3_REPAY_ON_PRICE";
|
|
175
174
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
176
175
|
let OptimismIds;
|
|
177
176
|
(function (OptimismIds) {
|
|
@@ -180,6 +179,7 @@ var Bundles;
|
|
|
180
179
|
OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_DEBT"] = 2] = "AAVE_V3_CLOSE_TO_DEBT";
|
|
181
180
|
OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
|
|
182
181
|
OptimismIds[OptimismIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 4] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
182
|
+
OptimismIds[OptimismIds["AAVE_V3_REPAY_ON_PRICE"] = 5] = "AAVE_V3_REPAY_ON_PRICE";
|
|
183
183
|
})(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
|
|
184
184
|
let BaseIds;
|
|
185
185
|
(function (BaseIds) {
|
|
@@ -192,6 +192,7 @@ var Bundles;
|
|
|
192
192
|
BaseIds[BaseIds["MORPHO_BLUE_REPAY"] = 8] = "MORPHO_BLUE_REPAY";
|
|
193
193
|
BaseIds[BaseIds["MORPHO_BLUE_BOOST"] = 9] = "MORPHO_BLUE_BOOST";
|
|
194
194
|
BaseIds[BaseIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 10] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
195
|
+
BaseIds[BaseIds["AAVE_V3_REPAY_ON_PRICE"] = 11] = "AAVE_V3_REPAY_ON_PRICE";
|
|
195
196
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
196
197
|
let ArbitrumIds;
|
|
197
198
|
(function (ArbitrumIds) {
|
|
@@ -202,5 +203,6 @@ var Bundles;
|
|
|
202
203
|
ArbitrumIds[ArbitrumIds["COMP_V3_SW_REPAY_BUNDLE"] = 4] = "COMP_V3_SW_REPAY_BUNDLE";
|
|
203
204
|
ArbitrumIds[ArbitrumIds["COMP_V3_SW_BOOST_BUNDLE"] = 5] = "COMP_V3_SW_BOOST_BUNDLE";
|
|
204
205
|
ArbitrumIds[ArbitrumIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 6] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
206
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_REPAY_ON_PRICE"] = 7] = "AAVE_V3_REPAY_ON_PRICE";
|
|
205
207
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
206
208
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|
package/esm/constants/index.js
CHANGED
|
@@ -90,11 +90,6 @@ export const MAINNET_STRATEGIES_INFO = {
|
|
|
90
90
|
strategyId: Strategies.Identifiers.Payback,
|
|
91
91
|
protocol: PROTOCOLS.CrvUSD,
|
|
92
92
|
},
|
|
93
|
-
[Strategies.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
94
|
-
strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
95
|
-
strategyId: Strategies.Identifiers.OpenOrderFromDebt,
|
|
96
|
-
protocol: PROTOCOLS.AaveV3,
|
|
97
|
-
},
|
|
98
93
|
};
|
|
99
94
|
export const OPTIMISM_STRATEGIES_INFO = {
|
|
100
95
|
[Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -107,11 +102,6 @@ export const OPTIMISM_STRATEGIES_INFO = {
|
|
|
107
102
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
108
103
|
protocol: PROTOCOLS.Exchange,
|
|
109
104
|
},
|
|
110
|
-
[Strategies.OptimismIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
111
|
-
strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
112
|
-
strategyId: Strategies.Identifiers.OpenOrderFromDebt,
|
|
113
|
-
protocol: PROTOCOLS.AaveV3,
|
|
114
|
-
},
|
|
115
105
|
};
|
|
116
106
|
export const BASE_STRATEGIES_INFO = {
|
|
117
107
|
[Strategies.BaseIds.EXCHANGE_DCA]: {
|
|
@@ -136,11 +126,6 @@ export const ARBITRUM_STRATEGIES_INFO = {
|
|
|
136
126
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
137
127
|
protocol: PROTOCOLS.Exchange,
|
|
138
128
|
},
|
|
139
|
-
[Strategies.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
140
|
-
strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
141
|
-
strategyId: Strategies.Identifiers.OpenOrderFromDebt,
|
|
142
|
-
protocol: PROTOCOLS.AaveV3,
|
|
143
|
-
},
|
|
144
129
|
};
|
|
145
130
|
export const STRATEGIES_INFO = {
|
|
146
131
|
[ChainId.Ethereum]: MAINNET_STRATEGIES_INFO,
|
|
@@ -357,6 +342,11 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
357
342
|
strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
|
|
358
343
|
protocol: PROTOCOLS.AaveV3,
|
|
359
344
|
},
|
|
345
|
+
[Bundles.MainnetIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
346
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_REPAY_ON_PRICE,
|
|
347
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
348
|
+
protocol: PROTOCOLS.AaveV3,
|
|
349
|
+
},
|
|
360
350
|
};
|
|
361
351
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
362
352
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -384,6 +374,11 @@ export const OPTIMISM_BUNDLES_INFO = {
|
|
|
384
374
|
strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
|
|
385
375
|
protocol: PROTOCOLS.AaveV3,
|
|
386
376
|
},
|
|
377
|
+
[Bundles.OptimismIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
378
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_REPAY_ON_PRICE,
|
|
379
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
380
|
+
protocol: PROTOCOLS.AaveV3,
|
|
381
|
+
},
|
|
387
382
|
};
|
|
388
383
|
export const BASE_BUNDLES_INFO = {
|
|
389
384
|
[Bundles.BaseIds.AAVE_V3_REPAY]: {
|
|
@@ -431,6 +426,11 @@ export const BASE_BUNDLES_INFO = {
|
|
|
431
426
|
strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
|
|
432
427
|
protocol: PROTOCOLS.AaveV3,
|
|
433
428
|
},
|
|
429
|
+
[Bundles.BaseIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
430
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_REPAY_ON_PRICE,
|
|
431
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
432
|
+
protocol: PROTOCOLS.AaveV3,
|
|
433
|
+
},
|
|
434
434
|
};
|
|
435
435
|
export const ARBITRUM_BUNDLES_INFO = {
|
|
436
436
|
[Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -468,6 +468,11 @@ export const ARBITRUM_BUNDLES_INFO = {
|
|
|
468
468
|
strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
|
|
469
469
|
protocol: PROTOCOLS.AaveV3,
|
|
470
470
|
},
|
|
471
|
+
[Bundles.ArbitrumIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
472
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_REPAY_ON_PRICE,
|
|
473
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
474
|
+
protocol: PROTOCOLS.AaveV3,
|
|
475
|
+
},
|
|
471
476
|
};
|
|
472
477
|
export const BUNDLES_INFO = {
|
|
473
478
|
[ChainId.Ethereum]: MAINNET_BUNDLES_INFO,
|
|
@@ -564,11 +564,11 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
564
564
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
565
565
|
return _position;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function parseAaveV3LeverageManagementOnPrice(position, parseData) {
|
|
568
568
|
const _position = cloneDeep(position);
|
|
569
569
|
const { subStruct } = parseData.subscriptionEventData;
|
|
570
570
|
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
571
|
-
const subData = subDataService.
|
|
571
|
+
const subData = subDataService.aaveV3LeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
572
572
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
573
573
|
_position.strategyData.decoded.subData = subData;
|
|
574
574
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, Math.random());
|
|
@@ -616,7 +616,8 @@ const parsingMethodsMapping = {
|
|
|
616
616
|
[Strategies.Identifiers.CloseToDebtWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
617
617
|
[Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
618
618
|
[Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
619
|
-
[Strategies.Identifiers.OpenOrderFromCollateral]:
|
|
619
|
+
[Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3LeverageManagementOnPrice,
|
|
620
|
+
[Strategies.Identifiers.RepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
620
621
|
},
|
|
621
622
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
622
623
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -47,7 +47,7 @@ export declare const aaveV3Encode: {
|
|
|
47
47
|
debtAsset: EthereumAddress;
|
|
48
48
|
debtAssetId: number;
|
|
49
49
|
}): (number | boolean | string[])[];
|
|
50
|
-
|
|
50
|
+
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
51
51
|
baseTokenAddress: EthereumAddress;
|
|
52
52
|
quoteTokenAddress: EthereumAddress;
|
|
53
53
|
price: number;
|
|
@@ -139,9 +139,9 @@ export const aaveV3Encode = {
|
|
|
139
139
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceWithMaximumGasPriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, ratioState, maximumGasPrice);
|
|
140
140
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
141
141
|
},
|
|
142
|
-
|
|
142
|
+
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
143
143
|
const { collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, } = subData;
|
|
144
|
-
const subDataEncoded = subDataService.
|
|
144
|
+
const subDataEncoded = subDataService.aaveV3LeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
145
145
|
const { baseTokenAddress, quoteTokenAddress, price, state, } = triggerData;
|
|
146
146
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
147
147
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
@@ -426,7 +426,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
426
426
|
});
|
|
427
427
|
});
|
|
428
428
|
});
|
|
429
|
-
describe('
|
|
429
|
+
describe('leverageManagementOnPrice()', () => {
|
|
430
430
|
const examples = [
|
|
431
431
|
[
|
|
432
432
|
[
|
|
@@ -462,7 +462,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
462
462
|
];
|
|
463
463
|
examples.forEach(([expected, actual]) => {
|
|
464
464
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
465
|
-
expect(aaveV3Encode.
|
|
465
|
+
expect(aaveV3Encode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
466
466
|
});
|
|
467
467
|
});
|
|
468
468
|
});
|
|
@@ -179,7 +179,7 @@ export declare const morphoBlueLeverageManagementSubData: {
|
|
|
179
179
|
targetRatio: number;
|
|
180
180
|
};
|
|
181
181
|
};
|
|
182
|
-
export declare const
|
|
182
|
+
export declare const aaveV3LeverageManagementOnPriceSubData: {
|
|
183
183
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number): string[];
|
|
184
184
|
decode(subData: string[]): {
|
|
185
185
|
collAsset: EthereumAddress;
|
|
@@ -435,7 +435,7 @@ export const morphoBlueLeverageManagementSubData = {
|
|
|
435
435
|
};
|
|
436
436
|
},
|
|
437
437
|
};
|
|
438
|
-
export const
|
|
438
|
+
export const aaveV3LeverageManagementOnPriceSubData = {
|
|
439
439
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
440
440
|
const encodedColl = AbiCoder.encodeParameter('address', collAsset);
|
|
441
441
|
const encodedCollId = AbiCoder.encodeParameter('uint8', collAssetId);
|
|
@@ -4,7 +4,7 @@ import { getAssetInfo } from '@defisaver/tokens';
|
|
|
4
4
|
import * as web3Utils from 'web3-utils';
|
|
5
5
|
import { ChainId, OrderType, RatioState } from '../types/enums';
|
|
6
6
|
import '../configuration';
|
|
7
|
-
import { aaveV2LeverageManagementSubData, aaveV3LeverageManagementSubData, aaveV3QuotePriceSubData, cBondsRebondSubData, compoundV2LeverageManagementSubData, compoundV3LeverageManagementSubData, exchangeDcaSubData, exchangeLimitOrderSubData, liquityCloseSubData, liquityDebtInFrontRepaySubData, liquityDsrPaybackSubData, liquityDsrSupplySubData, liquityLeverageManagementSubData, liquityPaybackUsingChickenBondSubData, liquityRepayFromSavingsSubData, makerCloseSubData, makerLeverageManagementSubData, makerRepayFromSavingsSubData, morphoAaveV2LeverageManagementSubData, sparkLeverageManagementSubData, sparkQuotePriceSubData, crvUSDLeverageManagementSubData, compoundV3L2LeverageManagementSubData, morphoBlueLeverageManagementSubData, crvUSDPaybackSubData,
|
|
7
|
+
import { aaveV2LeverageManagementSubData, aaveV3LeverageManagementSubData, aaveV3QuotePriceSubData, cBondsRebondSubData, compoundV2LeverageManagementSubData, compoundV3LeverageManagementSubData, exchangeDcaSubData, exchangeLimitOrderSubData, liquityCloseSubData, liquityDebtInFrontRepaySubData, liquityDsrPaybackSubData, liquityDsrSupplySubData, liquityLeverageManagementSubData, liquityPaybackUsingChickenBondSubData, liquityRepayFromSavingsSubData, makerCloseSubData, makerLeverageManagementSubData, makerRepayFromSavingsSubData, morphoAaveV2LeverageManagementSubData, sparkLeverageManagementSubData, sparkQuotePriceSubData, crvUSDLeverageManagementSubData, compoundV3L2LeverageManagementSubData, morphoBlueLeverageManagementSubData, crvUSDPaybackSubData, aaveV3LeverageManagementOnPriceSubData, } from './subDataService';
|
|
8
8
|
describe('Feature: subDataService.ts', () => {
|
|
9
9
|
describe('When testing subDataService.makerRepayFromSavingsSubData', () => {
|
|
10
10
|
describe('encode()', () => {
|
|
@@ -1194,7 +1194,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1194
1194
|
});
|
|
1195
1195
|
});
|
|
1196
1196
|
});
|
|
1197
|
-
describe('When testing subDataService.
|
|
1197
|
+
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1198
1198
|
describe('encode()', () => {
|
|
1199
1199
|
const examples = [
|
|
1200
1200
|
[
|
|
@@ -1219,7 +1219,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1219
1219
|
];
|
|
1220
1220
|
examples.forEach(([expected, actual]) => {
|
|
1221
1221
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1222
|
-
expect(
|
|
1222
|
+
expect(aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1223
1223
|
});
|
|
1224
1224
|
});
|
|
1225
1225
|
});
|
|
@@ -1246,7 +1246,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1246
1246
|
];
|
|
1247
1247
|
examples.forEach(([expected, actual]) => {
|
|
1248
1248
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1249
|
-
expect(
|
|
1249
|
+
expect(aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1250
1250
|
});
|
|
1251
1251
|
});
|
|
1252
1252
|
});
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -60,13 +60,11 @@ export declare namespace Strategies {
|
|
|
60
60
|
LIQUITY_DSR_PAYBACK = 69,
|
|
61
61
|
LIQUITY_DSR_SUPPLY = 70,
|
|
62
62
|
LIQUITY_DEBT_IN_FRONT_REPAY = 75,
|
|
63
|
-
CURVEUSD_PAYBACK = 92
|
|
64
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 96
|
|
63
|
+
CURVEUSD_PAYBACK = 92
|
|
65
64
|
}
|
|
66
65
|
enum OptimismIds {
|
|
67
66
|
EXCHANGE_DCA = 8,
|
|
68
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
69
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 12
|
|
67
|
+
EXCHANGE_LIMIT_ORDER = 9
|
|
70
68
|
}
|
|
71
69
|
enum BaseIds {
|
|
72
70
|
EXCHANGE_DCA = 8,
|
|
@@ -74,8 +72,7 @@ export declare namespace Strategies {
|
|
|
74
72
|
}
|
|
75
73
|
enum ArbitrumIds {
|
|
76
74
|
EXCHANGE_DCA = 8,
|
|
77
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
78
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 16
|
|
75
|
+
EXCHANGE_LIMIT_ORDER = 9
|
|
79
76
|
}
|
|
80
77
|
enum Identifiers {
|
|
81
78
|
SavingsLiqProtection = "smart-savings-liquidation-protection",
|
|
@@ -100,7 +97,8 @@ export declare namespace Strategies {
|
|
|
100
97
|
LimitOrder = "limit-order",
|
|
101
98
|
DebtInFrontRepay = "debt-in-front-repay",
|
|
102
99
|
OpenOrderFromCollateral = "open-order-from-collateral",
|
|
103
|
-
OpenOrderFromDebt = "open-order-from-debt"
|
|
100
|
+
OpenOrderFromDebt = "open-order-from-debt",
|
|
101
|
+
RepayOnPrice = "repay-on-price"
|
|
104
102
|
}
|
|
105
103
|
enum IdOverrides {
|
|
106
104
|
TakeProfit = "take-profit",
|
|
@@ -152,14 +150,16 @@ export declare namespace Bundles {
|
|
|
152
150
|
MORPHO_BLUE_BOOST = 33,
|
|
153
151
|
MORPHO_BLUE_EOA_REPAY = 34,
|
|
154
152
|
MORPHO_BLUE_EOA_BOOST = 35,
|
|
155
|
-
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 36
|
|
153
|
+
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 36,
|
|
154
|
+
AAVE_V3_REPAY_ON_PRICE = 37
|
|
156
155
|
}
|
|
157
156
|
enum OptimismIds {
|
|
158
157
|
AAVE_V3_REPAY = 0,
|
|
159
158
|
AAVE_V3_BOOST = 1,
|
|
160
159
|
AAVE_V3_CLOSE_TO_DEBT = 2,
|
|
161
160
|
AAVE_V3_CLOSE_TO_COLLATERAL = 3,
|
|
162
|
-
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 4
|
|
161
|
+
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 4,
|
|
162
|
+
AAVE_V3_REPAY_ON_PRICE = 5
|
|
163
163
|
}
|
|
164
164
|
enum BaseIds {
|
|
165
165
|
AAVE_V3_REPAY = 0,
|
|
@@ -170,7 +170,8 @@ export declare namespace Bundles {
|
|
|
170
170
|
COMP_V3_SW_BOOST_BUNDLE = 5,
|
|
171
171
|
MORPHO_BLUE_REPAY = 8,
|
|
172
172
|
MORPHO_BLUE_BOOST = 9,
|
|
173
|
-
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10
|
|
173
|
+
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10,
|
|
174
|
+
AAVE_V3_REPAY_ON_PRICE = 11
|
|
174
175
|
}
|
|
175
176
|
enum ArbitrumIds {
|
|
176
177
|
AAVE_V3_REPAY = 0,
|
|
@@ -179,6 +180,7 @@ export declare namespace Bundles {
|
|
|
179
180
|
AAVE_V3_CLOSE_TO_COLLATERAL = 3,
|
|
180
181
|
COMP_V3_SW_REPAY_BUNDLE = 4,
|
|
181
182
|
COMP_V3_SW_BOOST_BUNDLE = 5,
|
|
182
|
-
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 6
|
|
183
|
+
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 6,
|
|
184
|
+
AAVE_V3_REPAY_ON_PRICE = 7
|
|
183
185
|
}
|
|
184
186
|
}
|
package/esm/types/enums.js
CHANGED
|
@@ -70,13 +70,11 @@ export var Strategies;
|
|
|
70
70
|
MainnetIds[MainnetIds["LIQUITY_DSR_SUPPLY"] = 70] = "LIQUITY_DSR_SUPPLY";
|
|
71
71
|
MainnetIds[MainnetIds["LIQUITY_DEBT_IN_FRONT_REPAY"] = 75] = "LIQUITY_DEBT_IN_FRONT_REPAY";
|
|
72
72
|
MainnetIds[MainnetIds["CURVEUSD_PAYBACK"] = 92] = "CURVEUSD_PAYBACK";
|
|
73
|
-
MainnetIds[MainnetIds["AAVE_V3_OPEN_ORDER_FROM_DEBT"] = 96] = "AAVE_V3_OPEN_ORDER_FROM_DEBT";
|
|
74
73
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
75
74
|
let OptimismIds;
|
|
76
75
|
(function (OptimismIds) {
|
|
77
76
|
OptimismIds[OptimismIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
78
77
|
OptimismIds[OptimismIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
79
|
-
OptimismIds[OptimismIds["AAVE_V3_OPEN_ORDER_FROM_DEBT"] = 12] = "AAVE_V3_OPEN_ORDER_FROM_DEBT";
|
|
80
78
|
})(OptimismIds = Strategies.OptimismIds || (Strategies.OptimismIds = {}));
|
|
81
79
|
let BaseIds;
|
|
82
80
|
(function (BaseIds) {
|
|
@@ -87,7 +85,6 @@ export var Strategies;
|
|
|
87
85
|
(function (ArbitrumIds) {
|
|
88
86
|
ArbitrumIds[ArbitrumIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
89
87
|
ArbitrumIds[ArbitrumIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
90
|
-
ArbitrumIds[ArbitrumIds["AAVE_V3_OPEN_ORDER_FROM_DEBT"] = 16] = "AAVE_V3_OPEN_ORDER_FROM_DEBT";
|
|
91
88
|
})(ArbitrumIds = Strategies.ArbitrumIds || (Strategies.ArbitrumIds = {}));
|
|
92
89
|
let Identifiers;
|
|
93
90
|
(function (Identifiers) {
|
|
@@ -114,6 +111,7 @@ export var Strategies;
|
|
|
114
111
|
Identifiers["DebtInFrontRepay"] = "debt-in-front-repay";
|
|
115
112
|
Identifiers["OpenOrderFromCollateral"] = "open-order-from-collateral";
|
|
116
113
|
Identifiers["OpenOrderFromDebt"] = "open-order-from-debt";
|
|
114
|
+
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
117
115
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
118
116
|
let IdOverrides;
|
|
119
117
|
(function (IdOverrides) {
|
|
@@ -169,6 +167,7 @@ export var Bundles;
|
|
|
169
167
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_REPAY"] = 34] = "MORPHO_BLUE_EOA_REPAY";
|
|
170
168
|
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_BOOST"] = 35] = "MORPHO_BLUE_EOA_BOOST";
|
|
171
169
|
MainnetIds[MainnetIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 36] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
170
|
+
MainnetIds[MainnetIds["AAVE_V3_REPAY_ON_PRICE"] = 37] = "AAVE_V3_REPAY_ON_PRICE";
|
|
172
171
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
173
172
|
let OptimismIds;
|
|
174
173
|
(function (OptimismIds) {
|
|
@@ -177,6 +176,7 @@ export var Bundles;
|
|
|
177
176
|
OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_DEBT"] = 2] = "AAVE_V3_CLOSE_TO_DEBT";
|
|
178
177
|
OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
|
|
179
178
|
OptimismIds[OptimismIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 4] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
179
|
+
OptimismIds[OptimismIds["AAVE_V3_REPAY_ON_PRICE"] = 5] = "AAVE_V3_REPAY_ON_PRICE";
|
|
180
180
|
})(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
|
|
181
181
|
let BaseIds;
|
|
182
182
|
(function (BaseIds) {
|
|
@@ -189,6 +189,7 @@ export var Bundles;
|
|
|
189
189
|
BaseIds[BaseIds["MORPHO_BLUE_REPAY"] = 8] = "MORPHO_BLUE_REPAY";
|
|
190
190
|
BaseIds[BaseIds["MORPHO_BLUE_BOOST"] = 9] = "MORPHO_BLUE_BOOST";
|
|
191
191
|
BaseIds[BaseIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 10] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
192
|
+
BaseIds[BaseIds["AAVE_V3_REPAY_ON_PRICE"] = 11] = "AAVE_V3_REPAY_ON_PRICE";
|
|
192
193
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
193
194
|
let ArbitrumIds;
|
|
194
195
|
(function (ArbitrumIds) {
|
|
@@ -199,5 +200,6 @@ export var Bundles;
|
|
|
199
200
|
ArbitrumIds[ArbitrumIds["COMP_V3_SW_REPAY_BUNDLE"] = 4] = "COMP_V3_SW_REPAY_BUNDLE";
|
|
200
201
|
ArbitrumIds[ArbitrumIds["COMP_V3_SW_BOOST_BUNDLE"] = 5] = "COMP_V3_SW_BOOST_BUNDLE";
|
|
201
202
|
ArbitrumIds[ArbitrumIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 6] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
203
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_REPAY_ON_PRICE"] = 7] = "AAVE_V3_REPAY_ON_PRICE";
|
|
202
204
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
203
205
|
})(Bundles || (Bundles = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/automation-sdk",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@defisaver/eslint-config": "^1.0.1",
|
|
27
27
|
"@defisaver/sdk": "^1.0.61",
|
|
28
|
-
"@defisaver/tokens": "^1.5.
|
|
28
|
+
"@defisaver/tokens": "^1.5.50",
|
|
29
29
|
"@ethersproject/address": "^5.0.10",
|
|
30
30
|
"@ethersproject/solidity": "^5.0.9",
|
|
31
31
|
"decimal.js": "^10.4.3",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@defisaver/eslint-config": "^1.0.1",
|
|
38
|
-
"typechain-target-web3-v1-3mihai3": "^6.0.1",
|
|
39
38
|
"@types/chai": "^4.3.6",
|
|
40
39
|
"@types/lodash": "^4.14.191",
|
|
41
40
|
"@types/mocha": "^10.0.1",
|
|
@@ -50,6 +49,7 @@
|
|
|
50
49
|
"react": "^18.2.0",
|
|
51
50
|
"ts-node": "^10.9.1",
|
|
52
51
|
"typechain": "^8.1.0",
|
|
52
|
+
"typechain-target-web3-v1-3mihai3": "^6.0.1",
|
|
53
53
|
"typedoc": "^0.23.20",
|
|
54
54
|
"typedoc-plugin-markdown": "^3.13.6",
|
|
55
55
|
"typescript": "^4.8.4"
|
package/src/constants/index.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
ArbitrumBundleInfo,
|
|
2
|
+
ArbitrumBundleInfo,
|
|
3
|
+
ArbitrumStrategiesInfo,
|
|
4
|
+
BundlesInfo,
|
|
5
|
+
EthereumAddress,
|
|
6
|
+
Interfaces,
|
|
7
|
+
MainnetBundleInfo,
|
|
8
|
+
MainnetStrategiesInfo,
|
|
9
|
+
OptimismBundleInfo,
|
|
10
|
+
OptimismStrategiesInfo,
|
|
11
|
+
BaseBundleInfo,
|
|
12
|
+
BaseStrategiesInfo,
|
|
13
|
+
StrategiesInfo,
|
|
3
14
|
} from '../types';
|
|
4
15
|
|
|
5
16
|
import {
|
|
@@ -102,11 +113,6 @@ export const MAINNET_STRATEGIES_INFO: MainnetStrategiesInfo = {
|
|
|
102
113
|
strategyId: Strategies.Identifiers.Payback,
|
|
103
114
|
protocol: PROTOCOLS.CrvUSD,
|
|
104
115
|
},
|
|
105
|
-
[Strategies.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
106
|
-
strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
107
|
-
strategyId: Strategies.Identifiers.OpenOrderFromDebt,
|
|
108
|
-
protocol: PROTOCOLS.AaveV3,
|
|
109
|
-
},
|
|
110
116
|
};
|
|
111
117
|
|
|
112
118
|
export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
@@ -120,11 +126,6 @@ export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
|
120
126
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
121
127
|
protocol: PROTOCOLS.Exchange,
|
|
122
128
|
},
|
|
123
|
-
[Strategies.OptimismIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
124
|
-
strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
125
|
-
strategyId: Strategies.Identifiers.OpenOrderFromDebt,
|
|
126
|
-
protocol: PROTOCOLS.AaveV3,
|
|
127
|
-
},
|
|
128
129
|
};
|
|
129
130
|
|
|
130
131
|
export const BASE_STRATEGIES_INFO: BaseStrategiesInfo = {
|
|
@@ -151,11 +152,6 @@ export const ARBITRUM_STRATEGIES_INFO: ArbitrumStrategiesInfo = {
|
|
|
151
152
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
152
153
|
protocol: PROTOCOLS.Exchange,
|
|
153
154
|
},
|
|
154
|
-
[Strategies.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_DEBT]: {
|
|
155
|
-
strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_OPEN_ORDER_FROM_DEBT,
|
|
156
|
-
strategyId: Strategies.Identifiers.OpenOrderFromDebt,
|
|
157
|
-
protocol: PROTOCOLS.AaveV3,
|
|
158
|
-
},
|
|
159
155
|
};
|
|
160
156
|
|
|
161
157
|
export const STRATEGIES_INFO: StrategiesInfo = {
|
|
@@ -375,6 +371,11 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
375
371
|
strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
|
|
376
372
|
protocol: PROTOCOLS.AaveV3,
|
|
377
373
|
},
|
|
374
|
+
[Bundles.MainnetIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
375
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_REPAY_ON_PRICE,
|
|
376
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
377
|
+
protocol: PROTOCOLS.AaveV3,
|
|
378
|
+
},
|
|
378
379
|
};
|
|
379
380
|
|
|
380
381
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -403,6 +404,11 @@ export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
|
403
404
|
strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
|
|
404
405
|
protocol: PROTOCOLS.AaveV3,
|
|
405
406
|
},
|
|
407
|
+
[Bundles.OptimismIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
408
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_REPAY_ON_PRICE,
|
|
409
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
410
|
+
protocol: PROTOCOLS.AaveV3,
|
|
411
|
+
},
|
|
406
412
|
};
|
|
407
413
|
|
|
408
414
|
export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
@@ -451,6 +457,11 @@ export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
|
451
457
|
strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
|
|
452
458
|
protocol: PROTOCOLS.AaveV3,
|
|
453
459
|
},
|
|
460
|
+
[Bundles.BaseIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
461
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_REPAY_ON_PRICE,
|
|
462
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
463
|
+
protocol: PROTOCOLS.AaveV3,
|
|
464
|
+
},
|
|
454
465
|
};
|
|
455
466
|
|
|
456
467
|
export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
@@ -489,6 +500,11 @@ export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
|
489
500
|
strategyId: Strategies.Identifiers.OpenOrderFromCollateral,
|
|
490
501
|
protocol: PROTOCOLS.AaveV3,
|
|
491
502
|
},
|
|
503
|
+
[Bundles.ArbitrumIds.AAVE_V3_REPAY_ON_PRICE]: {
|
|
504
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_REPAY_ON_PRICE,
|
|
505
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
506
|
+
protocol: PROTOCOLS.AaveV3,
|
|
507
|
+
},
|
|
492
508
|
};
|
|
493
509
|
|
|
494
510
|
export const BUNDLES_INFO: BundlesInfo = {
|
|
@@ -779,13 +779,13 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
779
779
|
return _position;
|
|
780
780
|
}
|
|
781
781
|
|
|
782
|
-
function
|
|
782
|
+
function parseAaveV3LeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
783
783
|
const _position = cloneDeep(position);
|
|
784
784
|
|
|
785
785
|
const { subStruct } = parseData.subscriptionEventData;
|
|
786
786
|
|
|
787
787
|
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
788
|
-
const subData = subDataService.
|
|
788
|
+
const subData = subDataService.aaveV3LeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
789
789
|
|
|
790
790
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
791
791
|
_position.strategyData.decoded.subData = subData;
|
|
@@ -837,7 +837,8 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
837
837
|
[Strategies.Identifiers.CloseToDebtWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
838
838
|
[Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
839
839
|
[Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
840
|
-
[Strategies.Identifiers.OpenOrderFromCollateral]:
|
|
840
|
+
[Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3LeverageManagementOnPrice,
|
|
841
|
+
[Strategies.Identifiers.RepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
841
842
|
},
|
|
842
843
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
843
844
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -565,7 +565,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
565
565
|
});
|
|
566
566
|
});
|
|
567
567
|
|
|
568
|
-
describe('
|
|
568
|
+
describe('leverageManagementOnPrice()', () => {
|
|
569
569
|
const examples: Array<[
|
|
570
570
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
571
571
|
[
|
|
@@ -614,7 +614,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
614
614
|
|
|
615
615
|
examples.forEach(([expected, actual]) => {
|
|
616
616
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
617
|
-
expect(aaveV3Encode.
|
|
617
|
+
expect(aaveV3Encode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
618
618
|
});
|
|
619
619
|
});
|
|
620
620
|
});
|
|
@@ -298,7 +298,7 @@ export const aaveV3Encode = {
|
|
|
298
298
|
|
|
299
299
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
300
300
|
},
|
|
301
|
-
|
|
301
|
+
leverageManagementOnPrice(
|
|
302
302
|
strategyOrBundleId: number,
|
|
303
303
|
isBundle: boolean = true,
|
|
304
304
|
triggerData: {
|
|
@@ -311,7 +311,7 @@ export const aaveV3Encode = {
|
|
|
311
311
|
const {
|
|
312
312
|
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
313
313
|
} = subData;
|
|
314
|
-
const subDataEncoded = subDataService.
|
|
314
|
+
const subDataEncoded = subDataService.aaveV3LeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
315
315
|
|
|
316
316
|
const {
|
|
317
317
|
baseTokenAddress, quoteTokenAddress, price, state,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
sparkQuotePriceSubData,
|
|
32
32
|
crvUSDLeverageManagementSubData,
|
|
33
33
|
compoundV3L2LeverageManagementSubData, morphoBlueLeverageManagementSubData, crvUSDPaybackSubData,
|
|
34
|
-
|
|
34
|
+
aaveV3LeverageManagementOnPriceSubData,
|
|
35
35
|
} from './subDataService';
|
|
36
36
|
import { AAVE_V3_VARIABLE_BORROW_RATE } from '../constants';
|
|
37
37
|
|
|
@@ -1324,7 +1324,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1324
1324
|
});
|
|
1325
1325
|
});
|
|
1326
1326
|
|
|
1327
|
-
describe('When testing subDataService.
|
|
1327
|
+
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1328
1328
|
describe('encode()', () => {
|
|
1329
1329
|
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]]> = [
|
|
1330
1330
|
[
|
|
@@ -1350,7 +1350,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1350
1350
|
|
|
1351
1351
|
examples.forEach(([expected, actual]) => {
|
|
1352
1352
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1353
|
-
expect(
|
|
1353
|
+
expect(aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1354
1354
|
});
|
|
1355
1355
|
});
|
|
1356
1356
|
});
|
|
@@ -1379,7 +1379,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1379
1379
|
|
|
1380
1380
|
examples.forEach(([expected, actual]) => {
|
|
1381
1381
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1382
|
-
expect(
|
|
1382
|
+
expect(aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1383
1383
|
});
|
|
1384
1384
|
});
|
|
1385
1385
|
});
|
|
@@ -594,7 +594,7 @@ export const morphoBlueLeverageManagementSubData = {
|
|
|
594
594
|
},
|
|
595
595
|
};
|
|
596
596
|
|
|
597
|
-
export const
|
|
597
|
+
export const aaveV3LeverageManagementOnPriceSubData = {
|
|
598
598
|
encode(
|
|
599
599
|
collAsset: EthereumAddress,
|
|
600
600
|
collAssetId: number,
|
|
@@ -642,4 +642,4 @@ export const aaveV3OpenOrderSubData = {
|
|
|
642
642
|
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
643
643
|
};
|
|
644
644
|
},
|
|
645
|
-
};
|
|
645
|
+
};
|
package/src/types/enums.ts
CHANGED
|
@@ -67,13 +67,11 @@ export namespace Strategies {
|
|
|
67
67
|
LIQUITY_DSR_SUPPLY = 70,
|
|
68
68
|
LIQUITY_DEBT_IN_FRONT_REPAY = 75,
|
|
69
69
|
CURVEUSD_PAYBACK = 92,
|
|
70
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 96,
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
export enum OptimismIds {
|
|
74
73
|
EXCHANGE_DCA = 8,
|
|
75
74
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
76
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 12,
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
export enum BaseIds {
|
|
@@ -84,7 +82,6 @@ export namespace Strategies {
|
|
|
84
82
|
export enum ArbitrumIds {
|
|
85
83
|
EXCHANGE_DCA = 8,
|
|
86
84
|
EXCHANGE_LIMIT_ORDER = 9,
|
|
87
|
-
AAVE_V3_OPEN_ORDER_FROM_DEBT = 16,
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
export enum Identifiers {
|
|
@@ -111,6 +108,7 @@ export namespace Strategies {
|
|
|
111
108
|
DebtInFrontRepay = 'debt-in-front-repay',
|
|
112
109
|
OpenOrderFromCollateral = 'open-order-from-collateral',
|
|
113
110
|
OpenOrderFromDebt = 'open-order-from-debt',
|
|
111
|
+
RepayOnPrice = 'repay-on-price',
|
|
114
112
|
}
|
|
115
113
|
export enum IdOverrides {
|
|
116
114
|
TakeProfit = 'take-profit',
|
|
@@ -164,6 +162,7 @@ export namespace Bundles {
|
|
|
164
162
|
MORPHO_BLUE_EOA_REPAY = 34,
|
|
165
163
|
MORPHO_BLUE_EOA_BOOST = 35,
|
|
166
164
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 36,
|
|
165
|
+
AAVE_V3_REPAY_ON_PRICE = 37,
|
|
167
166
|
}
|
|
168
167
|
|
|
169
168
|
export enum OptimismIds {
|
|
@@ -172,6 +171,7 @@ export namespace Bundles {
|
|
|
172
171
|
AAVE_V3_CLOSE_TO_DEBT = 2,
|
|
173
172
|
AAVE_V3_CLOSE_TO_COLLATERAL = 3,
|
|
174
173
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 4,
|
|
174
|
+
AAVE_V3_REPAY_ON_PRICE = 5,
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
export enum BaseIds {
|
|
@@ -184,6 +184,7 @@ export namespace Bundles {
|
|
|
184
184
|
MORPHO_BLUE_REPAY = 8,
|
|
185
185
|
MORPHO_BLUE_BOOST = 9,
|
|
186
186
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 10,
|
|
187
|
+
AAVE_V3_REPAY_ON_PRICE = 11,
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
export enum ArbitrumIds {
|
|
@@ -194,6 +195,7 @@ export namespace Bundles {
|
|
|
194
195
|
COMP_V3_SW_REPAY_BUNDLE = 4,
|
|
195
196
|
COMP_V3_SW_BOOST_BUNDLE = 5,
|
|
196
197
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 6,
|
|
198
|
+
AAVE_V3_REPAY_ON_PRICE = 7,
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
201
|
|