@defisaver/automation-sdk 3.3.16 → 3.3.17
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 +55 -0
- package/cjs/services/strategiesService.js +12 -3
- package/cjs/services/strategySubService.d.ts +5 -1
- package/cjs/services/strategySubService.js +48 -11
- package/cjs/services/strategySubService.test.js +109 -1
- package/cjs/types/enums.d.ts +14 -3
- package/cjs/types/enums.js +11 -0
- package/esm/constants/index.js +55 -0
- package/esm/services/strategiesService.js +12 -3
- package/esm/services/strategySubService.d.ts +5 -1
- package/esm/services/strategySubService.js +46 -10
- package/esm/services/strategySubService.test.js +109 -1
- package/esm/types/enums.d.ts +14 -3
- package/esm/types/enums.js +11 -0
- package/package.json +1 -1
- package/src/constants/index.ts +55 -0
- package/src/services/strategiesService.ts +14 -4
- package/src/services/strategySubService.test.ts +145 -1
- package/src/services/strategySubService.ts +86 -11
- package/src/types/enums.ts +11 -0
package/cjs/constants/index.js
CHANGED
|
@@ -554,6 +554,21 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
554
554
|
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
555
555
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
556
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
|
+
},
|
|
557
572
|
};
|
|
558
573
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
559
574
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -753,6 +768,31 @@ exports.BASE_BUNDLES_INFO = {
|
|
|
753
768
|
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
754
769
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
755
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
|
+
},
|
|
756
796
|
};
|
|
757
797
|
exports.ARBITRUM_BUNDLES_INFO = {
|
|
758
798
|
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -905,6 +945,21 @@ exports.ARBITRUM_BUNDLES_INFO = {
|
|
|
905
945
|
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
906
946
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
907
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
|
+
},
|
|
908
963
|
};
|
|
909
964
|
exports.BUNDLES_INFO = {
|
|
910
965
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
|
|
@@ -849,6 +849,7 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
849
849
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
850
850
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
851
851
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
852
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
852
853
|
const triggerData = triggerService.morphoBlueRatioTrigger.decode(subStruct.triggerData);
|
|
853
854
|
const subData = subDataService.morphoBlueLeverageManagementSubData.decode(subStruct.subData);
|
|
854
855
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -862,7 +863,7 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
862
863
|
repayEnabled: isEnabled,
|
|
863
864
|
subId1: Number(subId),
|
|
864
865
|
subHashRepay: subHash,
|
|
865
|
-
mergeWithId: enums_1.Strategies.Identifiers.Boost,
|
|
866
|
+
mergeWithId: isEOA ? enums_1.Strategies.Identifiers.EoaBoost : enums_1.Strategies.Identifiers.Boost,
|
|
866
867
|
};
|
|
867
868
|
}
|
|
868
869
|
else {
|
|
@@ -872,16 +873,16 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
872
873
|
boostEnabled: isEnabled,
|
|
873
874
|
subId2: Number(subId),
|
|
874
875
|
subHashBoost: subHash,
|
|
875
|
-
mergeId: enums_1.Strategies.Identifiers.Boost,
|
|
876
|
+
mergeId: isEOA ? enums_1.Strategies.Identifiers.EoaBoost : enums_1.Strategies.Identifiers.Boost,
|
|
876
877
|
};
|
|
877
878
|
}
|
|
878
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
879
879
|
_position.strategy.strategyId = isEOA ? enums_1.Strategies.IdOverrides.EoaLeverageManagement : enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
880
880
|
return _position;
|
|
881
881
|
}
|
|
882
882
|
function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
883
883
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
884
884
|
const { subStruct } = parseData.subscriptionEventData;
|
|
885
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
885
886
|
const triggerData = triggerService.morphoBluePriceTrigger.decode(subStruct.triggerData);
|
|
886
887
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
887
888
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -904,11 +905,15 @@ function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
|
904
905
|
ratio: subData.targetRatio,
|
|
905
906
|
ratioState: triggerData.priceState,
|
|
906
907
|
};
|
|
908
|
+
_position.strategy.strategyId = isEOA
|
|
909
|
+
? enums_1.Strategies.IdOverrides.EoaLeverageManagementOnPrice
|
|
910
|
+
: enums_1.Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
907
911
|
return _position;
|
|
908
912
|
}
|
|
909
913
|
function parseMorphoBlueCloseOnPrice(position, parseData) {
|
|
910
914
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
911
915
|
const { subStruct } = parseData.subscriptionEventData;
|
|
916
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
912
917
|
const triggerData = triggerService.morphoBluePriceRangeTrigger.decode(subStruct.triggerData);
|
|
913
918
|
const subData = subDataService.morphoBlueCloseOnPriceSubData.decode(subStruct.subData);
|
|
914
919
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -923,6 +928,7 @@ function parseMorphoBlueCloseOnPrice(position, parseData) {
|
|
|
923
928
|
]);
|
|
924
929
|
const marketId = web3.utils.keccak256(marketIdEncodedData);
|
|
925
930
|
const { takeProfitType, stopLossType } = (0, utils_1.getStopLossAndTakeProfitTypeByCloseStrategyType)(+subData.closeType);
|
|
931
|
+
_position.strategy.strategyId = isEOA ? enums_1.Strategies.Identifiers.EoaCloseOnPrice : enums_1.Strategies.Identifiers.CloseOnPrice;
|
|
926
932
|
_position.specific = {
|
|
927
933
|
subHash: _position.subHash,
|
|
928
934
|
marketId,
|
|
@@ -1140,7 +1146,10 @@ const parsingMethodsMapping = {
|
|
|
1140
1146
|
[enums_1.Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1141
1147
|
[enums_1.Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1142
1148
|
[enums_1.Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1149
|
+
[enums_1.Strategies.Identifiers.EoaBoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1150
|
+
[enums_1.Strategies.Identifiers.EoaRepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1143
1151
|
[enums_1.Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1152
|
+
[enums_1.Strategies.Identifiers.EoaCloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1144
1153
|
},
|
|
1145
1154
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
1146
1155
|
[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): (
|
|
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
|
-
|
|
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 [
|
|
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) {
|
|
@@ -1292,6 +1292,75 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1292
1292
|
});
|
|
1293
1293
|
});
|
|
1294
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
|
+
});
|
|
1295
1364
|
describe('closeOnPrice()', () => {
|
|
1296
1365
|
const examples = [
|
|
1297
1366
|
[
|
|
@@ -1320,7 +1389,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1320
1389
|
1500,
|
|
1321
1390
|
enums_1.CloseToAssetType.DEBT,
|
|
1322
1391
|
4000,
|
|
1323
|
-
enums_1.CloseToAssetType.COLLATERAL
|
|
1392
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
1324
1393
|
]
|
|
1325
1394
|
],
|
|
1326
1395
|
];
|
|
@@ -1330,6 +1399,45 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1330
1399
|
});
|
|
1331
1400
|
});
|
|
1332
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
|
+
});
|
|
1333
1441
|
});
|
|
1334
1442
|
describe('When testing strategySubService.sparkEncode', () => {
|
|
1335
1443
|
describe('leverageManagementOnPrice()', () => {
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -225,7 +225,10 @@ export declare namespace Bundles {
|
|
|
225
225
|
AAVE_V4_EOA_REPAY_ON_PRICE = 68,
|
|
226
226
|
AAVE_V4_EOA_BOOST_ON_PRICE = 69,
|
|
227
227
|
AAVE_V4_EOA_CLOSE = 70,
|
|
228
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 84
|
|
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
|
|
229
232
|
}
|
|
230
233
|
enum OptimismIds {
|
|
231
234
|
AAVE_V3_REPAY = 0,
|
|
@@ -268,7 +271,12 @@ export declare namespace Bundles {
|
|
|
268
271
|
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
269
272
|
AAVE_V3_EOA_CLOSE = 27,
|
|
270
273
|
MORPHO_BLUE_CLOSE = 28,
|
|
271
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
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
|
|
272
280
|
}
|
|
273
281
|
enum ArbitrumIds {
|
|
274
282
|
AAVE_V3_REPAY = 0,
|
|
@@ -300,6 +308,9 @@ export declare namespace Bundles {
|
|
|
300
308
|
MORPHO_BLUE_EOA_REPAY = 26,
|
|
301
309
|
MORPHO_BLUE_EOA_BOOST = 27,
|
|
302
310
|
MORPHO_BLUE_CLOSE = 28,
|
|
303
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
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
|
|
304
315
|
}
|
|
305
316
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -249,6 +249,9 @@ var Bundles;
|
|
|
249
249
|
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST_ON_PRICE"] = 69] = "AAVE_V4_EOA_BOOST_ON_PRICE";
|
|
250
250
|
MainnetIds[MainnetIds["AAVE_V4_EOA_CLOSE"] = 70] = "AAVE_V4_EOA_CLOSE";
|
|
251
251
|
MainnetIds[MainnetIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 84] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
252
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 85] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
253
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 86] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
254
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_CLOSE"] = 87] = "MORPHO_BLUE_EOA_CLOSE";
|
|
252
255
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
253
256
|
let OptimismIds;
|
|
254
257
|
(function (OptimismIds) {
|
|
@@ -294,6 +297,11 @@ var Bundles;
|
|
|
294
297
|
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
295
298
|
BaseIds[BaseIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
296
299
|
BaseIds[BaseIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
300
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_REPAY"] = 37] = "MORPHO_BLUE_EOA_REPAY";
|
|
301
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_BOOST"] = 38] = "MORPHO_BLUE_EOA_BOOST";
|
|
302
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 39] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
303
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 40] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
304
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_CLOSE"] = 41] = "MORPHO_BLUE_EOA_CLOSE";
|
|
297
305
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
298
306
|
let ArbitrumIds;
|
|
299
307
|
(function (ArbitrumIds) {
|
|
@@ -327,5 +335,8 @@ var Bundles;
|
|
|
327
335
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST"] = 27] = "MORPHO_BLUE_EOA_BOOST";
|
|
328
336
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
329
337
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
338
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 37] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
339
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 38] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
340
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_CLOSE"] = 39] = "MORPHO_BLUE_EOA_CLOSE";
|
|
330
341
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
331
342
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|
package/esm/constants/index.js
CHANGED
|
@@ -548,6 +548,21 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
548
548
|
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
549
549
|
protocol: PROTOCOLS.MorphoBlue,
|
|
550
550
|
},
|
|
551
|
+
[Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
|
|
552
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
|
|
553
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
554
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
555
|
+
},
|
|
556
|
+
[Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
|
|
557
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
|
|
558
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
559
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
560
|
+
},
|
|
561
|
+
[Bundles.MainnetIds.MORPHO_BLUE_EOA_CLOSE]: {
|
|
562
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_EOA_CLOSE,
|
|
563
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
564
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
565
|
+
},
|
|
551
566
|
};
|
|
552
567
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
553
568
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -747,6 +762,31 @@ export const BASE_BUNDLES_INFO = {
|
|
|
747
762
|
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
748
763
|
protocol: PROTOCOLS.MorphoBlue,
|
|
749
764
|
},
|
|
765
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY]: {
|
|
766
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY,
|
|
767
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
768
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
769
|
+
},
|
|
770
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST]: {
|
|
771
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST,
|
|
772
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
773
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
774
|
+
},
|
|
775
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
|
|
776
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
|
|
777
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
778
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
779
|
+
},
|
|
780
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
|
|
781
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
|
|
782
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
783
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
784
|
+
},
|
|
785
|
+
[Bundles.BaseIds.MORPHO_BLUE_EOA_CLOSE]: {
|
|
786
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_EOA_CLOSE,
|
|
787
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
788
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
789
|
+
},
|
|
750
790
|
};
|
|
751
791
|
export const ARBITRUM_BUNDLES_INFO = {
|
|
752
792
|
[Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -899,6 +939,21 @@ export const ARBITRUM_BUNDLES_INFO = {
|
|
|
899
939
|
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
900
940
|
protocol: PROTOCOLS.MorphoBlue,
|
|
901
941
|
},
|
|
942
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE]: {
|
|
943
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE,
|
|
944
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
945
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
946
|
+
},
|
|
947
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE]: {
|
|
948
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_REPAY_ON_PRICE,
|
|
949
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
950
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
951
|
+
},
|
|
952
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_CLOSE]: {
|
|
953
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_CLOSE,
|
|
954
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
955
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
956
|
+
},
|
|
902
957
|
};
|
|
903
958
|
export const BUNDLES_INFO = {
|
|
904
959
|
[ChainId.Ethereum]: MAINNET_BUNDLES_INFO,
|
|
@@ -820,6 +820,7 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
820
820
|
const _position = cloneDeep(position);
|
|
821
821
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
822
822
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
823
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
823
824
|
const triggerData = triggerService.morphoBlueRatioTrigger.decode(subStruct.triggerData);
|
|
824
825
|
const subData = subDataService.morphoBlueLeverageManagementSubData.decode(subStruct.subData);
|
|
825
826
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -833,7 +834,7 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
833
834
|
repayEnabled: isEnabled,
|
|
834
835
|
subId1: Number(subId),
|
|
835
836
|
subHashRepay: subHash,
|
|
836
|
-
mergeWithId: Strategies.Identifiers.Boost,
|
|
837
|
+
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
837
838
|
};
|
|
838
839
|
}
|
|
839
840
|
else {
|
|
@@ -843,16 +844,16 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
843
844
|
boostEnabled: isEnabled,
|
|
844
845
|
subId2: Number(subId),
|
|
845
846
|
subHashBoost: subHash,
|
|
846
|
-
mergeId: Strategies.Identifiers.Boost,
|
|
847
|
+
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
847
848
|
};
|
|
848
849
|
}
|
|
849
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
850
850
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
851
851
|
return _position;
|
|
852
852
|
}
|
|
853
853
|
function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
854
854
|
const _position = cloneDeep(position);
|
|
855
855
|
const { subStruct } = parseData.subscriptionEventData;
|
|
856
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
856
857
|
const triggerData = triggerService.morphoBluePriceTrigger.decode(subStruct.triggerData);
|
|
857
858
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
858
859
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -875,11 +876,15 @@ function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
|
875
876
|
ratio: subData.targetRatio,
|
|
876
877
|
ratioState: triggerData.priceState,
|
|
877
878
|
};
|
|
879
|
+
_position.strategy.strategyId = isEOA
|
|
880
|
+
? Strategies.IdOverrides.EoaLeverageManagementOnPrice
|
|
881
|
+
: Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
878
882
|
return _position;
|
|
879
883
|
}
|
|
880
884
|
function parseMorphoBlueCloseOnPrice(position, parseData) {
|
|
881
885
|
const _position = cloneDeep(position);
|
|
882
886
|
const { subStruct } = parseData.subscriptionEventData;
|
|
887
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
883
888
|
const triggerData = triggerService.morphoBluePriceRangeTrigger.decode(subStruct.triggerData);
|
|
884
889
|
const subData = subDataService.morphoBlueCloseOnPriceSubData.decode(subStruct.subData);
|
|
885
890
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -894,6 +899,7 @@ function parseMorphoBlueCloseOnPrice(position, parseData) {
|
|
|
894
899
|
]);
|
|
895
900
|
const marketId = web3.utils.keccak256(marketIdEncodedData);
|
|
896
901
|
const { takeProfitType, stopLossType } = getStopLossAndTakeProfitTypeByCloseStrategyType(+subData.closeType);
|
|
902
|
+
_position.strategy.strategyId = isEOA ? Strategies.Identifiers.EoaCloseOnPrice : Strategies.Identifiers.CloseOnPrice;
|
|
897
903
|
_position.specific = {
|
|
898
904
|
subHash: _position.subHash,
|
|
899
905
|
marketId,
|
|
@@ -1111,7 +1117,10 @@ const parsingMethodsMapping = {
|
|
|
1111
1117
|
[Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1112
1118
|
[Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1113
1119
|
[Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1120
|
+
[Strategies.Identifiers.EoaBoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1121
|
+
[Strategies.Identifiers.EoaRepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1114
1122
|
[Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1123
|
+
[Strategies.Identifiers.EoaCloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1115
1124
|
},
|
|
1116
1125
|
[ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
1117
1126
|
[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): (
|
|
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[])[];
|