@defisaver/automation-sdk 3.3.15 → 3.3.16-dev-13082-morpho-eoa-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.
@@ -549,6 +549,26 @@ exports.MAINNET_BUNDLES_INFO = {
549
549
  strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
550
550
  protocol: exports.PROTOCOLS.AaveV4,
551
551
  },
552
+ [enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
553
+ strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
554
+ strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
555
+ protocol: exports.PROTOCOLS.MorphoBlue,
556
+ },
557
+ [enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
558
+ strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
559
+ strategyId: enums_1.Strategies.Identifiers.EoaBoostOnPrice,
560
+ protocol: exports.PROTOCOLS.MorphoBlue,
561
+ },
562
+ [enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
563
+ strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
564
+ strategyId: enums_1.Strategies.Identifiers.EoaRepayOnPrice,
565
+ protocol: exports.PROTOCOLS.MorphoBlue,
566
+ },
567
+ [enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_CLOSE]: {
568
+ strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_EOA_CLOSE,
569
+ strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
570
+ protocol: exports.PROTOCOLS.MorphoBlue,
571
+ },
552
572
  };
553
573
  exports.OPTIMISM_BUNDLES_INFO = {
554
574
  [enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
@@ -743,6 +763,36 @@ exports.BASE_BUNDLES_INFO = {
743
763
  strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
744
764
  protocol: exports.PROTOCOLS.MorphoBlue,
745
765
  },
766
+ [enums_1.Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
767
+ strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE,
768
+ strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
769
+ protocol: exports.PROTOCOLS.MorphoBlue,
770
+ },
771
+ [enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY]: {
772
+ strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY,
773
+ strategyId: enums_1.Strategies.Identifiers.EoaRepay,
774
+ protocol: exports.PROTOCOLS.MorphoBlue,
775
+ },
776
+ [enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST]: {
777
+ strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST,
778
+ strategyId: enums_1.Strategies.Identifiers.EoaBoost,
779
+ protocol: exports.PROTOCOLS.MorphoBlue,
780
+ },
781
+ [enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
782
+ strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
783
+ strategyId: enums_1.Strategies.Identifiers.EoaBoostOnPrice,
784
+ protocol: exports.PROTOCOLS.MorphoBlue,
785
+ },
786
+ [enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
787
+ strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
788
+ strategyId: enums_1.Strategies.Identifiers.EoaRepayOnPrice,
789
+ protocol: exports.PROTOCOLS.MorphoBlue,
790
+ },
791
+ [enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_CLOSE]: {
792
+ strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_EOA_CLOSE,
793
+ strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
794
+ protocol: exports.PROTOCOLS.MorphoBlue,
795
+ },
746
796
  };
747
797
  exports.ARBITRUM_BUNDLES_INFO = {
748
798
  [enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
@@ -890,6 +940,26 @@ exports.ARBITRUM_BUNDLES_INFO = {
890
940
  strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
891
941
  protocol: exports.PROTOCOLS.MorphoBlue,
892
942
  },
943
+ [enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
944
+ strategyOrBundleId: enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE,
945
+ strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
946
+ protocol: exports.PROTOCOLS.MorphoBlue,
947
+ },
948
+ [enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
949
+ strategyOrBundleId: enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
950
+ strategyId: enums_1.Strategies.Identifiers.EoaBoostOnPrice,
951
+ protocol: exports.PROTOCOLS.MorphoBlue,
952
+ },
953
+ [enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
954
+ strategyOrBundleId: enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
955
+ strategyId: enums_1.Strategies.Identifiers.EoaRepayOnPrice,
956
+ protocol: exports.PROTOCOLS.MorphoBlue,
957
+ },
958
+ [enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_EOA_CLOSE]: {
959
+ strategyOrBundleId: enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_EOA_CLOSE,
960
+ strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
961
+ protocol: exports.PROTOCOLS.MorphoBlue,
962
+ },
893
963
  };
894
964
  exports.BUNDLES_INFO = {
895
965
  [enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
@@ -1139,7 +1139,11 @@ const parsingMethodsMapping = {
1139
1139
  [enums_1.Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
1140
1140
  [enums_1.Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
1141
1141
  [enums_1.Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
1142
+ [enums_1.Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
1143
+ [enums_1.Strategies.Identifiers.EoaBoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
1144
+ [enums_1.Strategies.Identifiers.EoaRepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
1142
1145
  [enums_1.Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
1146
+ [enums_1.Strategies.Identifiers.EoaCloseOnPrice]: parseMorphoBlueCloseOnPrice,
1143
1147
  },
1144
1148
  [enums_1.ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
1145
1149
  [enums_1.Strategies.Identifiers.Repay]: parseFluidT1LeverageManagement,
@@ -101,10 +101,14 @@ export declare const crvUSDEncode: {
101
101
  leverageManagement(owner: EthereumAddress, controllerAddr: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, collTokenAddr: EthereumAddress, crvUSDAddr: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
102
102
  payback(proxyAddress: EthereumAddress, addressToPullTokensFrom: EthereumAddress, positionOwner: EthereumAddress, paybackAmount: string, crvUSDAddr: EthereumAddress, controllerAddr: EthereumAddress, minHealthRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
103
103
  };
104
+ export type MorphoBlueBundleStrategy = 'repay' | 'boost' | 'repayOnPrice' | 'boostOnPrice' | 'close';
105
+ export declare function getMorphoBlueBundleId(network: ChainId, strategy: MorphoBlueBundleStrategy, isEOA: boolean): number;
104
106
  export declare const morphoBlueEncode: {
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): (boolean | string[] | Bundles.BaseIds)[] | (boolean | string[] | Bundles.MainnetIds | Bundles.ArbitrumIds)[];
107
+ 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
108
  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[])[];
109
+ 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[])[];
107
110
  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[])[];
111
+ 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[])[];
108
112
  };
109
113
  export declare const liquityV2Encode: {
110
114
  leverageManagement(market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.aaveV4Encode = exports.fluidEncode = exports.liquityV2Encode = exports.morphoBlueEncode = exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.morphoAaveV2Encode = exports.compoundV3Encode = exports.compoundV2Encode = exports.aaveV3Encode = exports.aaveV2Encode = exports.chickenBondsEncode = exports.liquityEncode = exports.makerEncode = void 0;
26
+ exports.aaveV4Encode = exports.fluidEncode = exports.liquityV2Encode = exports.morphoBlueEncode = exports.getMorphoBlueBundleId = exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.morphoAaveV2Encode = exports.compoundV3Encode = exports.compoundV2Encode = exports.aaveV3Encode = exports.aaveV2Encode = exports.chickenBondsEncode = exports.liquityEncode = exports.makerEncode = void 0;
27
27
  const tokens_1 = require("@defisaver/tokens");
28
28
  const enums_1 = require("../types/enums");
29
29
  const constants_1 = require("../constants");
@@ -281,29 +281,58 @@ exports.crvUSDEncode = {
281
281
  return [strategyId, isBundle, triggerData, subData];
282
282
  },
283
283
  };
284
+ function getMorphoBlueBundlesIds(network) {
285
+ switch (network) {
286
+ case enums_1.ChainId.Ethereum:
287
+ return enums_1.Bundles.MainnetIds;
288
+ case enums_1.ChainId.Base:
289
+ return enums_1.Bundles.BaseIds;
290
+ case enums_1.ChainId.Arbitrum:
291
+ return enums_1.Bundles.ArbitrumIds;
292
+ default:
293
+ throw new Error(`Morpho Blue strategies are not supported on chain ${network}`);
294
+ }
295
+ }
296
+ function getMorphoBlueBundleId(network, strategy, isEOA) {
297
+ const bundlesIds = getMorphoBlueBundlesIds(network);
298
+ switch (strategy) {
299
+ case 'repay':
300
+ return isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY : bundlesIds.MORPHO_BLUE_REPAY;
301
+ case 'boost':
302
+ return isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST : bundlesIds.MORPHO_BLUE_BOOST;
303
+ case 'repayOnPrice':
304
+ return isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE : bundlesIds.MORPHO_BLUE_REPAY_ON_PRICE;
305
+ case 'boostOnPrice':
306
+ return isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE : bundlesIds.MORPHO_BLUE_BOOST_ON_PRICE;
307
+ case 'close':
308
+ return isEOA ? bundlesIds.MORPHO_BLUE_EOA_CLOSE : bundlesIds.MORPHO_BLUE_CLOSE;
309
+ default:
310
+ throw new Error(`Unknown Morpho Blue strategy: ${strategy}`);
311
+ }
312
+ }
313
+ exports.getMorphoBlueBundleId = getMorphoBlueBundleId;
284
314
  exports.morphoBlueEncode = {
285
315
  leverageManagement(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
286
316
  const subData = subDataService.morphoBlueLeverageManagementSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
287
317
  const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
288
318
  // over is boost, under is repay
289
319
  const isBoost = ratioState === enums_1.RatioState.OVER;
290
- let strategyOrBundleId;
291
- if (network === enums_1.ChainId.Base) {
292
- return [isBoost ? enums_1.Bundles.BaseIds.MORPHO_BLUE_BOOST : enums_1.Bundles.BaseIds.MORPHO_BLUE_REPAY, true, triggerData, subData];
293
- }
294
- const bundlesIds = network === enums_1.ChainId.Arbitrum ? enums_1.Bundles.ArbitrumIds : enums_1.Bundles.MainnetIds;
295
- if (isBoost)
296
- strategyOrBundleId = isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST : bundlesIds.MORPHO_BLUE_BOOST;
297
- else
298
- strategyOrBundleId = isEOA ? bundlesIds.MORPHO_BLUE_EOA_REPAY : bundlesIds.MORPHO_BLUE_REPAY;
320
+ const bundleId = getMorphoBlueBundleId(network, isBoost ? 'boost' : 'repay', isEOA);
299
321
  const isBundle = true;
300
- return [strategyOrBundleId, isBundle, triggerData, subData];
322
+ return [bundleId, isBundle, triggerData, subData];
301
323
  },
302
324
  leverageManagementOnPrice(strategyOrBundleId, isBundle = true, loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState) {
303
325
  const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
304
326
  const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
305
327
  return [strategyOrBundleId, isBundle, triggerData, subData];
306
328
  },
329
+ leverageManagementOnPriceGeneric(loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState, isBoost, isEOA, network) {
330
+ const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
331
+ const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
332
+ const bundleId = getMorphoBlueBundleId(network, isBoost ? 'boostOnPrice' : 'repayOnPrice', isEOA);
333
+ const isBundle = true;
334
+ return [bundleId, isBundle, triggerData, subData];
335
+ },
307
336
  closeOnPrice(strategyOrBundleId, loanToken, collToken, oracle, irm, lltv, user, stopLossPrice = 0, stopLossType = enums_1.CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = enums_1.CloseToAssetType.COLLATERAL) {
308
337
  const isBundle = true;
309
338
  const closeType = (0, utils_1.getCloseStrategyType)(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
@@ -311,6 +340,14 @@ exports.morphoBlueEncode = {
311
340
  const triggerDataEncoded = triggerService.morphoBluePriceRangeTrigger.encode(oracle, collToken, loanToken, stopLossPrice, takeProfitPrice);
312
341
  return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
313
342
  },
343
+ closeOnPriceGeneric(loanToken, collToken, oracle, irm, lltv, user, stopLossPrice = 0, stopLossType = enums_1.CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = enums_1.CloseToAssetType.COLLATERAL, isEOA, network) {
344
+ const isBundle = true;
345
+ const closeType = (0, utils_1.getCloseStrategyType)(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
346
+ const subDataEncoded = subDataService.morphoBlueCloseOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, user, closeType);
347
+ const triggerDataEncoded = triggerService.morphoBluePriceRangeTrigger.encode(oracle, collToken, loanToken, stopLossPrice, takeProfitPrice);
348
+ const bundleId = getMorphoBlueBundleId(network, 'close', isEOA);
349
+ return [bundleId, isBundle, triggerDataEncoded, subDataEncoded];
350
+ },
314
351
  };
315
352
  exports.liquityV2Encode = {
316
353
  leverageManagement(market, troveId, collToken, boldToken, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
@@ -1225,6 +1225,142 @@ describe('Feature: strategySubService.ts', () => {
1225
1225
  });
1226
1226
  });
1227
1227
  });
1228
+ describe('leverageManagementOnPrice()', () => {
1229
+ const examples = [
1230
+ [
1231
+ [
1232
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
1233
+ true,
1234
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1235
+ [
1236
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1237
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1238
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1239
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1240
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1241
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1242
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1243
+ ],
1244
+ ],
1245
+ [
1246
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
1247
+ true,
1248
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1249
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1250
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1251
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1252
+ '945000000000000000',
1253
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1254
+ 200,
1255
+ 2500,
1256
+ enums_1.RatioState.UNDER,
1257
+ ],
1258
+ ],
1259
+ [
1260
+ [
1261
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
1262
+ true,
1263
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1264
+ [
1265
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1266
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1267
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1268
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1269
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1270
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1271
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1272
+ ],
1273
+ ],
1274
+ [
1275
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
1276
+ true,
1277
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1278
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1279
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1280
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1281
+ '945000000000000000',
1282
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1283
+ 160,
1284
+ 4000,
1285
+ enums_1.RatioState.OVER,
1286
+ ],
1287
+ ],
1288
+ ];
1289
+ examples.forEach(([expected, actual]) => {
1290
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1291
+ (0, chai_1.expect)(strategySubService_1.morphoBlueEncode.leverageManagementOnPrice(...actual)).to.eql(expected);
1292
+ });
1293
+ });
1294
+ });
1295
+ describe('leverageManagementOnPriceGeneric()', () => {
1296
+ const examples = [
1297
+ [
1298
+ [
1299
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
1300
+ true,
1301
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1302
+ [
1303
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1304
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1305
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1306
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1307
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1308
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1309
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1310
+ ],
1311
+ ],
1312
+ [
1313
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1314
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1315
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1316
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1317
+ '945000000000000000',
1318
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1319
+ 200,
1320
+ 2500,
1321
+ enums_1.RatioState.UNDER,
1322
+ false,
1323
+ false,
1324
+ enums_1.ChainId.Ethereum,
1325
+ ],
1326
+ ],
1327
+ [
1328
+ [
1329
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
1330
+ true,
1331
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1332
+ [
1333
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1334
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1335
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1336
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1337
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1338
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1339
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1340
+ ],
1341
+ ],
1342
+ [
1343
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1344
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1345
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1346
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1347
+ '945000000000000000',
1348
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1349
+ 160,
1350
+ 4000,
1351
+ enums_1.RatioState.OVER,
1352
+ true,
1353
+ false,
1354
+ enums_1.ChainId.Ethereum,
1355
+ ],
1356
+ ],
1357
+ ];
1358
+ examples.forEach(([expected, actual]) => {
1359
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1360
+ (0, chai_1.expect)(strategySubService_1.morphoBlueEncode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
1361
+ });
1362
+ });
1363
+ });
1228
1364
  describe('closeOnPrice()', () => {
1229
1365
  const examples = [
1230
1366
  [
@@ -1253,7 +1389,7 @@ describe('Feature: strategySubService.ts', () => {
1253
1389
  1500,
1254
1390
  enums_1.CloseToAssetType.DEBT,
1255
1391
  4000,
1256
- enums_1.CloseToAssetType.COLLATERAL
1392
+ enums_1.CloseToAssetType.COLLATERAL,
1257
1393
  ]
1258
1394
  ],
1259
1395
  ];
@@ -1263,6 +1399,45 @@ describe('Feature: strategySubService.ts', () => {
1263
1399
  });
1264
1400
  });
1265
1401
  });
1402
+ describe('closeOnPriceGeneric()', () => {
1403
+ const examples = [
1404
+ [
1405
+ [
1406
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
1407
+ true,
1408
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1409
+ [
1410
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1411
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1412
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1413
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1414
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1415
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1416
+ '0x0000000000000000000000000000000000000000000000000000000000000005',
1417
+ ],
1418
+ ],
1419
+ [
1420
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1421
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1422
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1423
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1424
+ '945000000000000000',
1425
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1426
+ 1500,
1427
+ enums_1.CloseToAssetType.DEBT,
1428
+ 4000,
1429
+ enums_1.CloseToAssetType.COLLATERAL,
1430
+ false,
1431
+ enums_1.ChainId.Ethereum,
1432
+ ]
1433
+ ],
1434
+ ];
1435
+ examples.forEach(([expected, actual]) => {
1436
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1437
+ (0, chai_1.expect)(strategySubService_1.morphoBlueEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
1438
+ });
1439
+ });
1440
+ });
1266
1441
  });
1267
1442
  describe('When testing strategySubService.sparkEncode', () => {
1268
1443
  describe('leverageManagementOnPrice()', () => {
@@ -1479,6 +1479,106 @@ describe('Feature: subDataService.ts', () => {
1479
1479
  });
1480
1480
  });
1481
1481
  });
1482
+ describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
1483
+ describe('encode()', () => {
1484
+ const examples = [
1485
+ [
1486
+ [
1487
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1488
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1489
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1490
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1491
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1492
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1493
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1494
+ ],
1495
+ [
1496
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1497
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1498
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1499
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1500
+ '945000000000000000',
1501
+ 200,
1502
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1503
+ ],
1504
+ ],
1505
+ [
1506
+ [
1507
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1508
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1509
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1510
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1511
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1512
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1513
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1514
+ ],
1515
+ [
1516
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1517
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1518
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1519
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1520
+ '945000000000000000',
1521
+ 160,
1522
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1523
+ ],
1524
+ ],
1525
+ ];
1526
+ examples.forEach(([expected, actual]) => {
1527
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1528
+ (0, chai_1.expect)(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1529
+ });
1530
+ });
1531
+ });
1532
+ describe('decode()', () => {
1533
+ const examples = [
1534
+ [
1535
+ {
1536
+ loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1537
+ collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
1538
+ oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
1539
+ irm: '0x0000000000000000000000000000000000000000',
1540
+ lltv: '945000000000000000',
1541
+ targetRatio: 200,
1542
+ user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
1543
+ },
1544
+ [
1545
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1546
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1547
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1548
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1549
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1550
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1551
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1552
+ ],
1553
+ ],
1554
+ [
1555
+ {
1556
+ loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1557
+ collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
1558
+ oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
1559
+ irm: '0x0000000000000000000000000000000000000000',
1560
+ lltv: '945000000000000000',
1561
+ targetRatio: 160,
1562
+ user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
1563
+ },
1564
+ [
1565
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1566
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1567
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1568
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1569
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1570
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1571
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1572
+ ],
1573
+ ],
1574
+ ];
1575
+ examples.forEach(([expected, actual]) => {
1576
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1577
+ (0, chai_1.expect)(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1578
+ });
1579
+ });
1580
+ });
1581
+ });
1482
1582
  describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
1483
1583
  describe('encode()', () => {
1484
1584
  const examples = [
@@ -1184,6 +1184,66 @@ describe('Feature: triggerService.ts', () => {
1184
1184
  });
1185
1185
  });
1186
1186
  });
1187
+ describe('When testing triggerService.morphoBluePriceTrigger', () => {
1188
+ describe('encode()', () => {
1189
+ const examples = [
1190
+ [
1191
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1192
+ [
1193
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1194
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1195
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1196
+ 2500,
1197
+ enums_1.RatioState.UNDER,
1198
+ ],
1199
+ ],
1200
+ [
1201
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1202
+ [
1203
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1204
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1205
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1206
+ 4000,
1207
+ enums_1.RatioState.OVER,
1208
+ ],
1209
+ ],
1210
+ ];
1211
+ examples.forEach(([expected, actual]) => {
1212
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1213
+ (0, chai_1.expect)(triggerService_1.morphoBluePriceTrigger.encode(...actual)).to.eql(expected);
1214
+ });
1215
+ });
1216
+ });
1217
+ describe('decode()', () => {
1218
+ const examples = [
1219
+ [
1220
+ {
1221
+ oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1222
+ collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1223
+ loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1224
+ price: '2500',
1225
+ priceState: enums_1.RatioState.UNDER,
1226
+ },
1227
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1228
+ ],
1229
+ [
1230
+ {
1231
+ oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1232
+ collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1233
+ loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1234
+ price: '4000',
1235
+ priceState: enums_1.RatioState.OVER,
1236
+ },
1237
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1238
+ ],
1239
+ ];
1240
+ examples.forEach(([expected, actual]) => {
1241
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1242
+ (0, chai_1.expect)(triggerService_1.morphoBluePriceTrigger.decode(actual)).to.eql(expected);
1243
+ });
1244
+ });
1245
+ });
1246
+ });
1187
1247
  describe('When testing triggerService.aaveV4RatioTrigger', () => {
1188
1248
  describe('encode()', () => {
1189
1249
  const examples = [
@@ -224,7 +224,11 @@ export declare namespace Bundles {
224
224
  AAVE_V4_EOA_BOOST = 67,
225
225
  AAVE_V4_EOA_REPAY_ON_PRICE = 68,
226
226
  AAVE_V4_EOA_BOOST_ON_PRICE = 69,
227
- AAVE_V4_EOA_CLOSE = 70
227
+ AAVE_V4_EOA_CLOSE = 70,
228
+ MORPHO_BLUE_REPAY_ON_PRICE = 84,
229
+ MORPHO_BLUE_EOA_BOOST_ON_PRICE = 85,
230
+ MORPHO_BLUE_EOA_REPAY_ON_PRICE = 86,
231
+ MORPHO_BLUE_EOA_CLOSE = 87
228
232
  }
229
233
  enum OptimismIds {
230
234
  AAVE_V3_REPAY = 0,
@@ -266,7 +270,13 @@ export declare namespace Bundles {
266
270
  AAVE_V3_EOA_REPAY_ON_PRICE = 25,
267
271
  AAVE_V3_EOA_BOOST_ON_PRICE = 26,
268
272
  AAVE_V3_EOA_CLOSE = 27,
269
- MORPHO_BLUE_CLOSE = 28
273
+ MORPHO_BLUE_CLOSE = 28,
274
+ MORPHO_BLUE_REPAY_ON_PRICE = 36,
275
+ MORPHO_BLUE_EOA_REPAY = 37,
276
+ MORPHO_BLUE_EOA_BOOST = 38,
277
+ MORPHO_BLUE_EOA_BOOST_ON_PRICE = 39,
278
+ MORPHO_BLUE_EOA_REPAY_ON_PRICE = 40,
279
+ MORPHO_BLUE_EOA_CLOSE = 41
270
280
  }
271
281
  enum ArbitrumIds {
272
282
  AAVE_V3_REPAY = 0,
@@ -297,6 +307,10 @@ export declare namespace Bundles {
297
307
  MORPHO_BLUE_BOOST_ON_PRICE = 25,
298
308
  MORPHO_BLUE_EOA_REPAY = 26,
299
309
  MORPHO_BLUE_EOA_BOOST = 27,
300
- MORPHO_BLUE_CLOSE = 28
310
+ MORPHO_BLUE_CLOSE = 28,
311
+ MORPHO_BLUE_REPAY_ON_PRICE = 36,
312
+ MORPHO_BLUE_EOA_BOOST_ON_PRICE = 37,
313
+ MORPHO_BLUE_EOA_REPAY_ON_PRICE = 38,
314
+ MORPHO_BLUE_EOA_CLOSE = 39
301
315
  }
302
316
  }