@defisaver/automation-sdk 3.3.16-liq-prot-dev → 3.3.17-liq-prot-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/index.js +60 -0
- package/cjs/services/strategiesService.js +12 -3
- package/cjs/services/strategySubService.d.ts +6 -2
- package/cjs/services/strategySubService.js +51 -15
- package/cjs/services/strategySubService.test.js +109 -1
- package/cjs/services/utils.d.ts +1 -2
- package/cjs/services/utils.js +1 -14
- package/cjs/types/enums.d.ts +15 -3
- package/cjs/types/enums.js +12 -0
- package/esm/constants/index.js +60 -0
- package/esm/services/strategiesService.js +12 -3
- package/esm/services/strategySubService.d.ts +6 -2
- package/esm/services/strategySubService.js +50 -15
- package/esm/services/strategySubService.test.js +109 -1
- package/esm/services/utils.d.ts +1 -2
- package/esm/services/utils.js +1 -13
- package/esm/types/enums.d.ts +15 -3
- package/esm/types/enums.js +12 -0
- package/package.json +1 -1
- package/src/constants/index.ts +60 -0
- package/src/services/strategiesService.ts +14 -4
- package/src/services/strategySubService.test.ts +145 -1
- package/src/services/strategySubService.ts +89 -17
- package/src/services/utils.ts +0 -12
- package/src/types/enums.ts +12 -0
|
@@ -918,6 +918,7 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
918
918
|
const _position = cloneDeep(position);
|
|
919
919
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
920
920
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
921
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
921
922
|
const triggerData = triggerService.morphoBlueRatioTrigger.decode(subStruct.triggerData);
|
|
922
923
|
const subData = subDataService.morphoBlueLeverageManagementSubData.decode(subStruct.subData);
|
|
923
924
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -931,7 +932,7 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
931
932
|
repayEnabled: isEnabled,
|
|
932
933
|
subId1: Number(subId),
|
|
933
934
|
subHashRepay: subHash,
|
|
934
|
-
mergeWithId: Strategies.Identifiers.Boost,
|
|
935
|
+
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
935
936
|
};
|
|
936
937
|
}
|
|
937
938
|
else {
|
|
@@ -941,10 +942,9 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
941
942
|
boostEnabled: isEnabled,
|
|
942
943
|
subId2: Number(subId),
|
|
943
944
|
subHashBoost: subHash,
|
|
944
|
-
mergeId: Strategies.Identifiers.Boost,
|
|
945
|
+
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
945
946
|
};
|
|
946
947
|
}
|
|
947
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
948
948
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
949
949
|
return _position;
|
|
950
950
|
}
|
|
@@ -971,6 +971,7 @@ function parseMorphoBlueLiquidationProtection(position, parseData) {
|
|
|
971
971
|
function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
972
972
|
const _position = cloneDeep(position);
|
|
973
973
|
const { subStruct } = parseData.subscriptionEventData;
|
|
974
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
974
975
|
const triggerData = triggerService.morphoBluePriceTrigger.decode(subStruct.triggerData);
|
|
975
976
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
976
977
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -993,11 +994,15 @@ function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
|
993
994
|
ratio: subData.targetRatio,
|
|
994
995
|
ratioState: triggerData.priceState,
|
|
995
996
|
};
|
|
997
|
+
_position.strategy.strategyId = isEOA
|
|
998
|
+
? Strategies.IdOverrides.EoaLeverageManagementOnPrice
|
|
999
|
+
: Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
996
1000
|
return _position;
|
|
997
1001
|
}
|
|
998
1002
|
function parseMorphoBlueCloseOnPrice(position, parseData) {
|
|
999
1003
|
const _position = cloneDeep(position);
|
|
1000
1004
|
const { subStruct } = parseData.subscriptionEventData;
|
|
1005
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
1001
1006
|
const triggerData = triggerService.morphoBluePriceRangeTrigger.decode(subStruct.triggerData);
|
|
1002
1007
|
const subData = subDataService.morphoBlueCloseOnPriceSubData.decode(subStruct.subData);
|
|
1003
1008
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -1012,6 +1017,7 @@ function parseMorphoBlueCloseOnPrice(position, parseData) {
|
|
|
1012
1017
|
]);
|
|
1013
1018
|
const marketId = web3.utils.keccak256(marketIdEncodedData);
|
|
1014
1019
|
const { takeProfitType, stopLossType } = getStopLossAndTakeProfitTypeByCloseStrategyType(+subData.closeType);
|
|
1020
|
+
_position.strategy.strategyId = isEOA ? Strategies.Identifiers.EoaCloseOnPrice : Strategies.Identifiers.CloseOnPrice;
|
|
1015
1021
|
_position.specific = {
|
|
1016
1022
|
subHash: _position.subHash,
|
|
1017
1023
|
marketId,
|
|
@@ -1256,9 +1262,12 @@ const parsingMethodsMapping = {
|
|
|
1256
1262
|
[Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1257
1263
|
[Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1258
1264
|
[Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1265
|
+
[Strategies.Identifiers.EoaBoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1266
|
+
[Strategies.Identifiers.EoaRepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1259
1267
|
[Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1260
1268
|
[Strategies.Identifiers.LiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1261
1269
|
[Strategies.Identifiers.EoaLiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1270
|
+
[Strategies.Identifiers.EoaCloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1262
1271
|
},
|
|
1263
1272
|
[ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
1264
1273
|
[Strategies.Identifiers.Repay]: parseFluidT1LeverageManagement,
|
|
@@ -99,11 +99,15 @@ export declare const crvUSDEncode: {
|
|
|
99
99
|
leverageManagement(owner: EthereumAddress, controllerAddr: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, collTokenAddr: EthereumAddress, crvUSDAddr: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
100
100
|
payback(proxyAddress: EthereumAddress, addressToPullTokensFrom: EthereumAddress, positionOwner: EthereumAddress, paybackAmount: string, crvUSDAddr: EthereumAddress, controllerAddr: EthereumAddress, minHealthRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
101
101
|
};
|
|
102
|
+
export type MorphoBlueBundleStrategy = 'repay' | 'boost' | 'repayOnPrice' | 'boostOnPrice' | 'close' | 'liquidationProtection';
|
|
103
|
+
export declare function getMorphoBlueBundleId(network: ChainId, strategy: MorphoBlueBundleStrategy, isEOA: boolean): number;
|
|
102
104
|
export declare const morphoBlueEncode: {
|
|
103
|
-
leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean, network: ChainId): (
|
|
104
|
-
liquidationProtection(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean, network: ChainId): (boolean | string[]
|
|
105
|
+
leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean, network: ChainId): (number | boolean | string[])[];
|
|
106
|
+
liquidationProtection(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean, network: ChainId): (number | boolean | string[])[];
|
|
105
107
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, targetRatio: number, price: number, priceState: RatioState): (number | boolean | string[])[];
|
|
108
|
+
leverageManagementOnPriceGeneric(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, isBoost: boolean, isEOA: boolean, network: ChainId): (number | boolean | string[])[];
|
|
106
109
|
closeOnPrice(strategyOrBundleId: number, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
110
|
+
closeOnPriceGeneric(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, stopLossPrice: number | undefined, stopLossType: CloseToAssetType | undefined, takeProfitPrice: number | undefined, takeProfitType: CloseToAssetType | undefined, isEOA: boolean, network: ChainId): (number | boolean | string[])[];
|
|
107
111
|
};
|
|
108
112
|
export declare const liquityV2Encode: {
|
|
109
113
|
leverageManagement(market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
@@ -3,7 +3,7 @@ import { STRATEGY_IDS } from '../constants';
|
|
|
3
3
|
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies, } from '../types/enums';
|
|
4
4
|
import * as subDataService from './subDataService';
|
|
5
5
|
import * as triggerService from './triggerService';
|
|
6
|
-
import { compareAddresses,
|
|
6
|
+
import { compareAddresses, getCloseStrategyType, requireAddress, requireAddresses, } from './utils';
|
|
7
7
|
export const makerEncode = {
|
|
8
8
|
repayFromSavings(bundleId, vaultId, triggerRepayRatio, targetRepayRatio, isBundle = true, chainId = ChainId.Ethereum, daiAddr, mcdCdpManagerAddr) {
|
|
9
9
|
const subData = subDataService.makerRepayFromSavingsSubData.encode(vaultId, targetRepayRatio, chainId, daiAddr, mcdCdpManagerAddr);
|
|
@@ -274,31 +274,51 @@ export const crvUSDEncode = {
|
|
|
274
274
|
return [strategyId, isBundle, triggerData, subData];
|
|
275
275
|
},
|
|
276
276
|
};
|
|
277
|
+
function getMorphoBlueBundlesIds(network) {
|
|
278
|
+
switch (network) {
|
|
279
|
+
case ChainId.Ethereum:
|
|
280
|
+
return Bundles.MainnetIds;
|
|
281
|
+
case ChainId.Base:
|
|
282
|
+
return Bundles.BaseIds;
|
|
283
|
+
case ChainId.Arbitrum:
|
|
284
|
+
return Bundles.ArbitrumIds;
|
|
285
|
+
default:
|
|
286
|
+
throw new Error(`Morpho Blue strategies are not supported on chain ${network}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
export function getMorphoBlueBundleId(network, strategy, isEOA) {
|
|
290
|
+
const bundlesIds = getMorphoBlueBundlesIds(network);
|
|
291
|
+
switch (strategy) {
|
|
292
|
+
case 'repay':
|
|
293
|
+
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY : bundlesIds.MORPHO_BLUE_REPAY;
|
|
294
|
+
case 'boost':
|
|
295
|
+
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST : bundlesIds.MORPHO_BLUE_BOOST;
|
|
296
|
+
case 'repayOnPrice':
|
|
297
|
+
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE : bundlesIds.MORPHO_BLUE_REPAY_ON_PRICE;
|
|
298
|
+
case 'boostOnPrice':
|
|
299
|
+
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE : bundlesIds.MORPHO_BLUE_BOOST_ON_PRICE;
|
|
300
|
+
case 'close':
|
|
301
|
+
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_CLOSE : bundlesIds.MORPHO_BLUE_CLOSE;
|
|
302
|
+
case 'liquidationProtection':
|
|
303
|
+
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION : bundlesIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION;
|
|
304
|
+
default:
|
|
305
|
+
throw new Error(`Unknown Morpho Blue strategy: ${strategy}`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
277
308
|
export const morphoBlueEncode = {
|
|
278
309
|
leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
279
310
|
const subData = subDataService.morphoBlueLeverageManagementSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
280
311
|
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
281
312
|
// over is boost, under is repay
|
|
282
313
|
const isBoost = ratioState === RatioState.OVER;
|
|
283
|
-
|
|
284
|
-
if (network === ChainId.Base) {
|
|
285
|
-
return [isBoost ? Bundles.BaseIds.MORPHO_BLUE_BOOST : Bundles.BaseIds.MORPHO_BLUE_REPAY, true, triggerData, subData];
|
|
286
|
-
}
|
|
287
|
-
const bundlesIds = network === ChainId.Arbitrum ? Bundles.ArbitrumIds : Bundles.MainnetIds;
|
|
288
|
-
if (isBoost)
|
|
289
|
-
strategyOrBundleId = isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST : bundlesIds.MORPHO_BLUE_BOOST;
|
|
290
|
-
else
|
|
291
|
-
strategyOrBundleId = isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY : bundlesIds.MORPHO_BLUE_REPAY;
|
|
314
|
+
const bundleId = getMorphoBlueBundleId(network, isBoost ? 'boost' : 'repay', isEOA);
|
|
292
315
|
const isBundle = true;
|
|
293
|
-
return [
|
|
316
|
+
return [bundleId, isBundle, triggerData, subData];
|
|
294
317
|
},
|
|
295
318
|
liquidationProtection(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
296
319
|
const subData = subDataService.morphoBlueLiquidationProtectionSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
297
320
|
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
298
|
-
|
|
299
|
-
// That is fine because we will just always send isEOA == false for Base chain.
|
|
300
|
-
const bundleNetwork = getBundleIdsByNetwork(network);
|
|
301
|
-
const bundleId = isEOA ? bundleNetwork.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION : bundleNetwork.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION;
|
|
321
|
+
const bundleId = getMorphoBlueBundleId(network, 'liquidationProtection', isEOA);
|
|
302
322
|
const isBundle = true;
|
|
303
323
|
return [bundleId, isBundle, triggerData, subData];
|
|
304
324
|
},
|
|
@@ -307,6 +327,13 @@ export const morphoBlueEncode = {
|
|
|
307
327
|
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
308
328
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
309
329
|
},
|
|
330
|
+
leverageManagementOnPriceGeneric(loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState, isBoost, isEOA, network) {
|
|
331
|
+
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
|
|
332
|
+
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
333
|
+
const bundleId = getMorphoBlueBundleId(network, isBoost ? 'boostOnPrice' : 'repayOnPrice', isEOA);
|
|
334
|
+
const isBundle = true;
|
|
335
|
+
return [bundleId, isBundle, triggerData, subData];
|
|
336
|
+
},
|
|
310
337
|
closeOnPrice(strategyOrBundleId, loanToken, collToken, oracle, irm, lltv, user, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL) {
|
|
311
338
|
const isBundle = true;
|
|
312
339
|
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
@@ -314,6 +341,14 @@ export const morphoBlueEncode = {
|
|
|
314
341
|
const triggerDataEncoded = triggerService.morphoBluePriceRangeTrigger.encode(oracle, collToken, loanToken, stopLossPrice, takeProfitPrice);
|
|
315
342
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
316
343
|
},
|
|
344
|
+
closeOnPriceGeneric(loanToken, collToken, oracle, irm, lltv, user, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL, isEOA, network) {
|
|
345
|
+
const isBundle = true;
|
|
346
|
+
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
347
|
+
const subDataEncoded = subDataService.morphoBlueCloseOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, user, closeType);
|
|
348
|
+
const triggerDataEncoded = triggerService.morphoBluePriceRangeTrigger.encode(oracle, collToken, loanToken, stopLossPrice, takeProfitPrice);
|
|
349
|
+
const bundleId = getMorphoBlueBundleId(network, 'close', isEOA);
|
|
350
|
+
return [bundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
351
|
+
},
|
|
317
352
|
};
|
|
318
353
|
export const liquityV2Encode = {
|
|
319
354
|
leverageManagement(market, troveId, collToken, boldToken, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
@@ -1229,6 +1229,75 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1229
1229
|
});
|
|
1230
1230
|
});
|
|
1231
1231
|
});
|
|
1232
|
+
describe('leverageManagementOnPriceGeneric()', () => {
|
|
1233
|
+
const examples = [
|
|
1234
|
+
[
|
|
1235
|
+
[
|
|
1236
|
+
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1237
|
+
true,
|
|
1238
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1239
|
+
[
|
|
1240
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1241
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1242
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1243
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1244
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1245
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1246
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1247
|
+
],
|
|
1248
|
+
],
|
|
1249
|
+
[
|
|
1250
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1251
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1252
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1253
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1254
|
+
'945000000000000000',
|
|
1255
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1256
|
+
200,
|
|
1257
|
+
2500,
|
|
1258
|
+
RatioState.UNDER,
|
|
1259
|
+
false,
|
|
1260
|
+
false,
|
|
1261
|
+
ChainId.Ethereum,
|
|
1262
|
+
],
|
|
1263
|
+
],
|
|
1264
|
+
[
|
|
1265
|
+
[
|
|
1266
|
+
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1267
|
+
true,
|
|
1268
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1269
|
+
[
|
|
1270
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1271
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1272
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1273
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1274
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1275
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1276
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1277
|
+
],
|
|
1278
|
+
],
|
|
1279
|
+
[
|
|
1280
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1281
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1282
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1283
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1284
|
+
'945000000000000000',
|
|
1285
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1286
|
+
160,
|
|
1287
|
+
4000,
|
|
1288
|
+
RatioState.OVER,
|
|
1289
|
+
true,
|
|
1290
|
+
false,
|
|
1291
|
+
ChainId.Ethereum,
|
|
1292
|
+
],
|
|
1293
|
+
],
|
|
1294
|
+
];
|
|
1295
|
+
examples.forEach(([expected, actual]) => {
|
|
1296
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1297
|
+
expect(morphoBlueEncode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
|
|
1298
|
+
});
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1232
1301
|
describe('closeOnPrice()', () => {
|
|
1233
1302
|
const examples = [
|
|
1234
1303
|
[
|
|
@@ -1257,7 +1326,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1257
1326
|
1500,
|
|
1258
1327
|
CloseToAssetType.DEBT,
|
|
1259
1328
|
4000,
|
|
1260
|
-
CloseToAssetType.COLLATERAL
|
|
1329
|
+
CloseToAssetType.COLLATERAL,
|
|
1261
1330
|
]
|
|
1262
1331
|
],
|
|
1263
1332
|
];
|
|
@@ -1267,6 +1336,45 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1267
1336
|
});
|
|
1268
1337
|
});
|
|
1269
1338
|
});
|
|
1339
|
+
describe('closeOnPriceGeneric()', () => {
|
|
1340
|
+
const examples = [
|
|
1341
|
+
[
|
|
1342
|
+
[
|
|
1343
|
+
Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
1344
|
+
true,
|
|
1345
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1346
|
+
[
|
|
1347
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1348
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1349
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1350
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1351
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1352
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1353
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1354
|
+
],
|
|
1355
|
+
],
|
|
1356
|
+
[
|
|
1357
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1358
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1359
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1360
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1361
|
+
'945000000000000000',
|
|
1362
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1363
|
+
1500,
|
|
1364
|
+
CloseToAssetType.DEBT,
|
|
1365
|
+
4000,
|
|
1366
|
+
CloseToAssetType.COLLATERAL,
|
|
1367
|
+
false,
|
|
1368
|
+
ChainId.Ethereum,
|
|
1369
|
+
]
|
|
1370
|
+
],
|
|
1371
|
+
];
|
|
1372
|
+
examples.forEach(([expected, actual]) => {
|
|
1373
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1374
|
+
expect(morphoBlueEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
|
|
1375
|
+
});
|
|
1376
|
+
});
|
|
1377
|
+
});
|
|
1270
1378
|
});
|
|
1271
1379
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1272
1380
|
describe('leverageManagementOnPrice()', () => {
|
package/esm/services/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EthereumAddress } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { ChainId, CloseStrategyType, CloseToAssetType, RatioState } from '../types/enums';
|
|
3
3
|
export declare function isDefined<T>(value: T): value is NonNullable<T>;
|
|
4
4
|
export declare function isUndefined(value: unknown): boolean;
|
|
5
5
|
export declare function compareAddresses(firstAddress: EthereumAddress, secondAddress: EthereumAddress): boolean;
|
|
@@ -28,4 +28,3 @@ export declare function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStr
|
|
|
28
28
|
stopLossType: CloseToAssetType | undefined;
|
|
29
29
|
takeProfitType: CloseToAssetType | undefined;
|
|
30
30
|
};
|
|
31
|
-
export declare function getBundleIdsByNetwork(network: ChainId): typeof Bundles.MainnetIds | typeof Bundles.ArbitrumIds | typeof Bundles.BaseIds;
|
package/esm/services/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import Dec from 'decimal.js';
|
|
|
2
2
|
import * as web3Utils from 'web3-utils';
|
|
3
3
|
import AbiCoder from 'web3-eth-abi';
|
|
4
4
|
import { getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
5
|
-
import {
|
|
5
|
+
import { ChainId, CloseStrategyType, CloseToAssetType, RatioState, } from '../types/enums';
|
|
6
6
|
export function isDefined(value) {
|
|
7
7
|
return value !== undefined && value !== null;
|
|
8
8
|
}
|
|
@@ -137,15 +137,3 @@ export function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStrategyTyp
|
|
|
137
137
|
throw new Error('CloseStrategyType not supported');
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
export function getBundleIdsByNetwork(network) {
|
|
141
|
-
switch (Number(network)) {
|
|
142
|
-
case ChainId.Ethereum:
|
|
143
|
-
return Bundles.MainnetIds;
|
|
144
|
-
case ChainId.Arbitrum:
|
|
145
|
-
return Bundles.ArbitrumIds;
|
|
146
|
-
case ChainId.Base:
|
|
147
|
-
return Bundles.BaseIds;
|
|
148
|
-
default:
|
|
149
|
-
throw new Error(`Unsupported network ${network}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -240,7 +240,10 @@ export declare namespace Bundles {
|
|
|
240
240
|
MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 81,
|
|
241
241
|
COMP_V3_SW_LIQUIDATION_PROTECTION = 82,
|
|
242
242
|
COMP_V3_EOA_LIQUIDATION_PROTECTION = 83,
|
|
243
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 84
|
|
243
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 84,
|
|
244
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 85,
|
|
245
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 86,
|
|
246
|
+
MORPHO_BLUE_EOA_CLOSE = 87
|
|
244
247
|
}
|
|
245
248
|
enum OptimismIds {
|
|
246
249
|
AAVE_V3_REPAY = 0,
|
|
@@ -291,7 +294,13 @@ export declare namespace Bundles {
|
|
|
291
294
|
COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
|
|
292
295
|
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
|
|
293
296
|
MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 35,
|
|
294
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
297
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36,
|
|
298
|
+
MORPHO_BLUE_EOA_REPAY = 37,
|
|
299
|
+
MORPHO_BLUE_EOA_BOOST = 38,
|
|
300
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 39,
|
|
301
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 40,
|
|
302
|
+
MORPHO_BLUE_EOA_CLOSE = 41,
|
|
303
|
+
MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 42
|
|
295
304
|
}
|
|
296
305
|
enum ArbitrumIds {
|
|
297
306
|
AAVE_V3_REPAY = 0,
|
|
@@ -330,6 +339,9 @@ export declare namespace Bundles {
|
|
|
330
339
|
COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
|
|
331
340
|
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
|
|
332
341
|
MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 35,
|
|
333
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
342
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36,
|
|
343
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 37,
|
|
344
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 38,
|
|
345
|
+
MORPHO_BLUE_EOA_CLOSE = 39
|
|
334
346
|
}
|
|
335
347
|
}
|
package/esm/types/enums.js
CHANGED
|
@@ -261,6 +261,9 @@ export var Bundles;
|
|
|
261
261
|
MainnetIds[MainnetIds["COMP_V3_SW_LIQUIDATION_PROTECTION"] = 82] = "COMP_V3_SW_LIQUIDATION_PROTECTION";
|
|
262
262
|
MainnetIds[MainnetIds["COMP_V3_EOA_LIQUIDATION_PROTECTION"] = 83] = "COMP_V3_EOA_LIQUIDATION_PROTECTION";
|
|
263
263
|
MainnetIds[MainnetIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 84] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
264
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 85] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
265
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 86] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
266
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_CLOSE"] = 87] = "MORPHO_BLUE_EOA_CLOSE";
|
|
264
267
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
265
268
|
let OptimismIds;
|
|
266
269
|
(function (OptimismIds) {
|
|
@@ -314,6 +317,12 @@ export var Bundles;
|
|
|
314
317
|
BaseIds[BaseIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 34] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
315
318
|
BaseIds[BaseIds["MORPHO_BLUE_SW_LIQUIDATION_PROTECTION"] = 35] = "MORPHO_BLUE_SW_LIQUIDATION_PROTECTION";
|
|
316
319
|
BaseIds[BaseIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
320
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_REPAY"] = 37] = "MORPHO_BLUE_EOA_REPAY";
|
|
321
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_BOOST"] = 38] = "MORPHO_BLUE_EOA_BOOST";
|
|
322
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 39] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
323
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 40] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
324
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_CLOSE"] = 41] = "MORPHO_BLUE_EOA_CLOSE";
|
|
325
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION"] = 42] = "MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION";
|
|
317
326
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
318
327
|
let ArbitrumIds;
|
|
319
328
|
(function (ArbitrumIds) {
|
|
@@ -354,5 +363,8 @@ export var Bundles;
|
|
|
354
363
|
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 34] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
355
364
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION"] = 35] = "MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION";
|
|
356
365
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
366
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 37] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
367
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 38] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
368
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_CLOSE"] = 39] = "MORPHO_BLUE_EOA_CLOSE";
|
|
357
369
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
358
370
|
})(Bundles || (Bundles = {}));
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -634,6 +634,21 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
634
634
|
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
635
635
|
protocol: PROTOCOLS.MorphoBlue,
|
|
636
636
|
},
|
|
637
|
+
[Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
|
|
638
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
|
|
639
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
640
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
641
|
+
},
|
|
642
|
+
[Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
|
|
643
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
|
|
644
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
645
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
646
|
+
},
|
|
647
|
+
[Bundles.MainnetIds.MORPHO_BLUE_EOA_CLOSE]: {
|
|
648
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_EOA_CLOSE,
|
|
649
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
650
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
651
|
+
},
|
|
637
652
|
};
|
|
638
653
|
|
|
639
654
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -865,6 +880,11 @@ export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
|
865
880
|
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
866
881
|
protocol: PROTOCOLS.MorphoBlue,
|
|
867
882
|
},
|
|
883
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION]: {
|
|
884
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION,
|
|
885
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
886
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
887
|
+
},
|
|
868
888
|
[Bundles.BaseIds.FLUID_T1_SW_LIQUIDATION_PROTECTION]: {
|
|
869
889
|
strategyOrBundleId: Bundles.BaseIds.FLUID_T1_SW_LIQUIDATION_PROTECTION,
|
|
870
890
|
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
@@ -875,6 +895,31 @@ export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
|
875
895
|
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
876
896
|
protocol: PROTOCOLS.AaveV3,
|
|
877
897
|
},
|
|
898
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY]: {
|
|
899
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY,
|
|
900
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
901
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
902
|
+
},
|
|
903
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST]: {
|
|
904
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST,
|
|
905
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
906
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
907
|
+
},
|
|
908
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
|
|
909
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
|
|
910
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
911
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
912
|
+
},
|
|
913
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
|
|
914
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
|
|
915
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
916
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
917
|
+
},
|
|
918
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_CLOSE]: {
|
|
919
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_CLOSE,
|
|
920
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
921
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
922
|
+
},
|
|
878
923
|
};
|
|
879
924
|
|
|
880
925
|
export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
@@ -1064,6 +1109,21 @@ export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
|
1064
1109
|
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
1065
1110
|
protocol: PROTOCOLS.MorphoBlue,
|
|
1066
1111
|
},
|
|
1112
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
|
|
1113
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
|
|
1114
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
1115
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
1116
|
+
},
|
|
1117
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
|
|
1118
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
|
|
1119
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
1120
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
1121
|
+
},
|
|
1122
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_CLOSE]: {
|
|
1123
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_CLOSE,
|
|
1124
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
1125
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
1126
|
+
},
|
|
1067
1127
|
};
|
|
1068
1128
|
|
|
1069
1129
|
export const BUNDLES_INFO: BundlesInfo = {
|
|
@@ -1214,6 +1214,7 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
1214
1214
|
|
|
1215
1215
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
1216
1216
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
1217
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
1217
1218
|
const triggerData = triggerService.morphoBlueRatioTrigger.decode(subStruct.triggerData);
|
|
1218
1219
|
const subData = subDataService.morphoBlueLeverageManagementSubData.decode(subStruct.subData);
|
|
1219
1220
|
|
|
@@ -1231,7 +1232,7 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
1231
1232
|
repayEnabled: isEnabled,
|
|
1232
1233
|
subId1: Number(subId),
|
|
1233
1234
|
subHashRepay: subHash,
|
|
1234
|
-
mergeWithId: Strategies.Identifiers.Boost,
|
|
1235
|
+
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
1235
1236
|
};
|
|
1236
1237
|
} else {
|
|
1237
1238
|
_position.specific = {
|
|
@@ -1240,14 +1241,12 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
1240
1241
|
boostEnabled: isEnabled,
|
|
1241
1242
|
subId2: Number(subId),
|
|
1242
1243
|
subHashBoost: subHash,
|
|
1243
|
-
mergeId: Strategies.Identifiers.Boost,
|
|
1244
|
+
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
1244
1245
|
};
|
|
1245
1246
|
}
|
|
1246
1247
|
|
|
1247
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
1248
1248
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
1249
1249
|
|
|
1250
|
-
|
|
1251
1250
|
return _position;
|
|
1252
1251
|
}
|
|
1253
1252
|
|
|
@@ -1283,6 +1282,7 @@ function parseMorphoBlueLeverageManagementOnPrice(position: Position.Automated,
|
|
|
1283
1282
|
const _position = cloneDeep(position);
|
|
1284
1283
|
|
|
1285
1284
|
const { subStruct } = parseData.subscriptionEventData;
|
|
1285
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
1286
1286
|
const triggerData = triggerService.morphoBluePriceTrigger.decode(subStruct.triggerData);
|
|
1287
1287
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
1288
1288
|
|
|
@@ -1313,6 +1313,10 @@ function parseMorphoBlueLeverageManagementOnPrice(position: Position.Automated,
|
|
|
1313
1313
|
ratioState: triggerData.priceState,
|
|
1314
1314
|
};
|
|
1315
1315
|
|
|
1316
|
+
_position.strategy.strategyId = isEOA
|
|
1317
|
+
? Strategies.IdOverrides.EoaLeverageManagementOnPrice
|
|
1318
|
+
: Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
1319
|
+
|
|
1316
1320
|
return _position;
|
|
1317
1321
|
}
|
|
1318
1322
|
|
|
@@ -1320,6 +1324,7 @@ function parseMorphoBlueCloseOnPrice(position: Position.Automated, parseData: Pa
|
|
|
1320
1324
|
const _position = cloneDeep(position);
|
|
1321
1325
|
|
|
1322
1326
|
const { subStruct } = parseData.subscriptionEventData;
|
|
1327
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
1323
1328
|
|
|
1324
1329
|
const triggerData = triggerService.morphoBluePriceRangeTrigger.decode(subStruct.triggerData);
|
|
1325
1330
|
const subData = subDataService.morphoBlueCloseOnPriceSubData.decode(subStruct.subData);
|
|
@@ -1344,6 +1349,8 @@ function parseMorphoBlueCloseOnPrice(position: Position.Automated, parseData: Pa
|
|
|
1344
1349
|
|
|
1345
1350
|
const { takeProfitType, stopLossType } = getStopLossAndTakeProfitTypeByCloseStrategyType(+subData.closeType);
|
|
1346
1351
|
|
|
1352
|
+
_position.strategy.strategyId = isEOA ? Strategies.Identifiers.EoaCloseOnPrice : Strategies.Identifiers.CloseOnPrice;
|
|
1353
|
+
|
|
1347
1354
|
_position.specific = {
|
|
1348
1355
|
subHash: _position.subHash,
|
|
1349
1356
|
marketId,
|
|
@@ -1633,9 +1640,12 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1633
1640
|
[Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1634
1641
|
[Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1635
1642
|
[Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1643
|
+
[Strategies.Identifiers.EoaBoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1644
|
+
[Strategies.Identifiers.EoaRepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1636
1645
|
[Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1637
1646
|
[Strategies.Identifiers.LiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1638
1647
|
[Strategies.Identifiers.EoaLiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1648
|
+
[Strategies.Identifiers.EoaCloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1639
1649
|
},
|
|
1640
1650
|
[ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
1641
1651
|
[Strategies.Identifiers.Repay]: parseFluidT1LeverageManagement,
|