@defisaver/automation-sdk 3.3.7 → 3.3.8
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 +15 -0
- package/cjs/services/ethereumService.test.js +1 -0
- package/cjs/services/strategiesService.js +30 -0
- package/cjs/services/strategiesService.test.js +1 -0
- package/cjs/services/strategySubService.d.ts +1 -0
- package/cjs/services/strategySubService.js +7 -0
- package/cjs/services/strategySubService.test.js +40 -2
- package/cjs/services/subDataService.d.ts +12 -0
- package/cjs/services/subDataService.js +31 -1
- package/cjs/services/subDataService.test.js +62 -10
- package/cjs/services/triggerService.d.ts +10 -0
- package/cjs/services/triggerService.js +21 -1
- package/cjs/services/triggerService.test.js +48 -0
- package/cjs/types/enums.d.ts +6 -3
- package/cjs/types/enums.js +3 -0
- package/esm/constants/index.js +15 -0
- package/esm/services/ethereumService.test.js +1 -0
- package/esm/services/strategiesService.js +30 -0
- package/esm/services/strategiesService.test.js +1 -0
- package/esm/services/strategySubService.d.ts +1 -0
- package/esm/services/strategySubService.js +7 -0
- package/esm/services/strategySubService.test.js +40 -2
- package/esm/services/subDataService.d.ts +12 -0
- package/esm/services/subDataService.js +30 -0
- package/esm/services/subDataService.test.js +62 -10
- package/esm/services/triggerService.d.ts +10 -0
- package/esm/services/triggerService.js +20 -0
- package/esm/services/triggerService.test.js +49 -1
- package/esm/types/enums.d.ts +6 -3
- package/esm/types/enums.js +3 -0
- package/package.json +2 -2
- package/src/constants/index.ts +15 -0
- package/src/services/ethereumService.test.ts +1 -0
- package/src/services/strategiesService.test.ts +1 -0
- package/src/services/strategiesService.ts +43 -0
- package/src/services/strategySubService.test.ts +57 -2
- package/src/services/strategySubService.ts +21 -0
- package/src/services/subDataService.test.ts +73 -14
- package/src/services/subDataService.ts +40 -0
- package/src/services/triggerService.test.ts +53 -0
- package/src/services/triggerService.ts +32 -0
- package/src/types/enums.ts +3 -0
package/cjs/constants/index.js
CHANGED
|
@@ -468,6 +468,11 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
468
468
|
strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
|
|
469
469
|
protocol: exports.PROTOCOLS.Spark,
|
|
470
470
|
},
|
|
471
|
+
[enums_1.Bundles.MainnetIds.MORPHO_BLUE_CLOSE]: {
|
|
472
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
473
|
+
strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
|
|
474
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
475
|
+
},
|
|
471
476
|
};
|
|
472
477
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
473
478
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -657,6 +662,11 @@ exports.BASE_BUNDLES_INFO = {
|
|
|
657
662
|
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
658
663
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
659
664
|
},
|
|
665
|
+
[enums_1.Bundles.BaseIds.MORPHO_BLUE_CLOSE]: {
|
|
666
|
+
strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_CLOSE,
|
|
667
|
+
strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
|
|
668
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
669
|
+
},
|
|
660
670
|
};
|
|
661
671
|
exports.ARBITRUM_BUNDLES_INFO = {
|
|
662
672
|
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -799,6 +809,11 @@ exports.ARBITRUM_BUNDLES_INFO = {
|
|
|
799
809
|
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
800
810
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
801
811
|
},
|
|
812
|
+
[enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_CLOSE]: {
|
|
813
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_CLOSE,
|
|
814
|
+
strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
|
|
815
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
816
|
+
},
|
|
802
817
|
};
|
|
803
818
|
exports.BUNDLES_INFO = {
|
|
804
819
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
|
|
@@ -101,6 +101,7 @@ describe('Feature: ethereumService.ts', () => {
|
|
|
101
101
|
'address': '0x5f98805A4E8be255a32880FDeC7F6728C6568bA0',
|
|
102
102
|
'blockHash': '0xb92cab2569456dbfbdb853d2c67d72c9a7580543dbcb55d483a77322b40755a4',
|
|
103
103
|
'blockNumber': 15166163,
|
|
104
|
+
'blockTimestamp': '0x62d53ad8',
|
|
104
105
|
'event': 'Transfer',
|
|
105
106
|
'id': 'log_e2258e3a',
|
|
106
107
|
'logIndex': 385,
|
|
@@ -770,6 +770,35 @@ function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
|
770
770
|
};
|
|
771
771
|
return _position;
|
|
772
772
|
}
|
|
773
|
+
function parseMorphoBlueCloseOnPrice(position, parseData) {
|
|
774
|
+
const _position = (0, lodash_1.cloneDeep)(position);
|
|
775
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
776
|
+
const triggerData = triggerService.morphoBluePriceRangeTrigger.decode(subStruct.triggerData);
|
|
777
|
+
const subData = subDataService.morphoBlueCloseOnPriceSubData.decode(subStruct.subData);
|
|
778
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
779
|
+
_position.strategyData.decoded.subData = subData;
|
|
780
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, Math.random());
|
|
781
|
+
const marketIdEncodedData = web3.eth.abi.encodeParameters(['address', 'address', 'address', 'address', 'uint256'], [
|
|
782
|
+
subData.loanToken,
|
|
783
|
+
subData.collToken,
|
|
784
|
+
subData.oracle,
|
|
785
|
+
subData.irm,
|
|
786
|
+
subData.lltv,
|
|
787
|
+
]);
|
|
788
|
+
const marketId = web3.utils.keccak256(marketIdEncodedData);
|
|
789
|
+
const { takeProfitType, stopLossType } = (0, utils_1.getStopLossAndTakeProfitTypeByCloseStrategyType)(+subData.closeType);
|
|
790
|
+
_position.specific = {
|
|
791
|
+
subHash: _position.subHash,
|
|
792
|
+
marketId,
|
|
793
|
+
collAsset: subData.collToken,
|
|
794
|
+
debtAsset: subData.loanToken,
|
|
795
|
+
stopLossPrice: triggerData.lowerPrice,
|
|
796
|
+
takeProfitPrice: triggerData.upperPrice,
|
|
797
|
+
stopLossType,
|
|
798
|
+
takeProfitType,
|
|
799
|
+
};
|
|
800
|
+
return _position;
|
|
801
|
+
}
|
|
773
802
|
function parseLiquityV2CloseOnPrice(position, parseData) {
|
|
774
803
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
775
804
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -957,6 +986,7 @@ const parsingMethodsMapping = {
|
|
|
957
986
|
[enums_1.Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
958
987
|
[enums_1.Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
959
988
|
[enums_1.Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
989
|
+
[enums_1.Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
960
990
|
},
|
|
961
991
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
962
992
|
[enums_1.Strategies.Identifiers.Repay]: parseFluidT1LeverageManagement,
|
|
@@ -94,6 +94,7 @@ export declare const crvUSDEncode: {
|
|
|
94
94
|
export declare const morphoBlueEncode: {
|
|
95
95
|
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)[];
|
|
96
96
|
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[])[];
|
|
97
|
+
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[])[];
|
|
97
98
|
};
|
|
98
99
|
export declare const liquityV2Encode: {
|
|
99
100
|
leverageManagement(market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
@@ -309,6 +309,13 @@ exports.morphoBlueEncode = {
|
|
|
309
309
|
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
310
310
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
311
311
|
},
|
|
312
|
+
closeOnPrice(strategyOrBundleId, loanToken, collToken, oracle, irm, lltv, user, stopLossPrice = 0, stopLossType = enums_1.CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = enums_1.CloseToAssetType.COLLATERAL) {
|
|
313
|
+
const isBundle = true;
|
|
314
|
+
const closeType = (0, utils_1.getCloseStrategyType)(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
315
|
+
const subDataEncoded = subDataService.morphoBlueCloseOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, user, closeType);
|
|
316
|
+
const triggerDataEncoded = triggerService.morphoBluePriceRangeTrigger.encode(oracle, collToken, loanToken, stopLossPrice, takeProfitPrice);
|
|
317
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
318
|
+
},
|
|
312
319
|
};
|
|
313
320
|
exports.liquityV2Encode = {
|
|
314
321
|
leverageManagement(market, troveId, collToken, boldToken, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
@@ -500,7 +500,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
500
500
|
[
|
|
501
501
|
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
502
502
|
true,
|
|
503
|
-
['
|
|
503
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000001'],
|
|
504
504
|
[
|
|
505
505
|
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
506
506
|
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
@@ -528,7 +528,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
528
528
|
[
|
|
529
529
|
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
530
530
|
true,
|
|
531
|
-
['
|
|
531
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000002faf0800000000000000000000000000000000000000000000000000000000000000000'],
|
|
532
532
|
[
|
|
533
533
|
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
534
534
|
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
@@ -1364,6 +1364,44 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1364
1364
|
});
|
|
1365
1365
|
});
|
|
1366
1366
|
});
|
|
1367
|
+
describe('closeOnPrice()', () => {
|
|
1368
|
+
const examples = [
|
|
1369
|
+
[
|
|
1370
|
+
[
|
|
1371
|
+
enums_1.Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
1372
|
+
true,
|
|
1373
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1374
|
+
[
|
|
1375
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1376
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1377
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1378
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1379
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1380
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1381
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1382
|
+
],
|
|
1383
|
+
],
|
|
1384
|
+
[
|
|
1385
|
+
enums_1.Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
1386
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1387
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1388
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1389
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1390
|
+
'945000000000000000',
|
|
1391
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1392
|
+
1500,
|
|
1393
|
+
enums_1.CloseToAssetType.DEBT,
|
|
1394
|
+
4000,
|
|
1395
|
+
enums_1.CloseToAssetType.COLLATERAL
|
|
1396
|
+
]
|
|
1397
|
+
],
|
|
1398
|
+
];
|
|
1399
|
+
examples.forEach(([expected, actual]) => {
|
|
1400
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1401
|
+
(0, chai_1.expect)(strategySubService_1.morphoBlueEncode.closeOnPrice(...actual)).to.eql(expected);
|
|
1402
|
+
});
|
|
1403
|
+
});
|
|
1404
|
+
});
|
|
1367
1405
|
});
|
|
1368
1406
|
describe('When testing strategySubService.compoundV3L2Encode', () => {
|
|
1369
1407
|
describe('leverageManagement()', () => {
|
|
@@ -318,3 +318,15 @@ export declare const sparkCloseGenericSubData: {
|
|
|
318
318
|
owner: EthereumAddress;
|
|
319
319
|
};
|
|
320
320
|
};
|
|
321
|
+
export declare const morphoBlueCloseOnPriceSubData: {
|
|
322
|
+
encode(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, closeType: CloseStrategyType): string[];
|
|
323
|
+
decode(subData: string[]): {
|
|
324
|
+
loanToken: string;
|
|
325
|
+
collToken: string;
|
|
326
|
+
oracle: string;
|
|
327
|
+
irm: string;
|
|
328
|
+
lltv: string;
|
|
329
|
+
user: string;
|
|
330
|
+
closeType: CloseStrategyType;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sparkCloseGenericSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.fluidLeverageManagementSubData = exports.liquityV2PaybackSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
6
|
+
exports.morphoBlueCloseOnPriceSubData = exports.sparkCloseGenericSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.fluidLeverageManagementSubData = exports.liquityV2PaybackSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
9
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -858,3 +858,33 @@ exports.sparkCloseGenericSubData = {
|
|
|
858
858
|
};
|
|
859
859
|
},
|
|
860
860
|
};
|
|
861
|
+
exports.morphoBlueCloseOnPriceSubData = {
|
|
862
|
+
encode(loanToken, collToken, oracle, irm, lltv, user, closeType) {
|
|
863
|
+
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
864
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
865
|
+
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
866
|
+
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
867
|
+
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
868
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
869
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
870
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, userEncoded, closeTypeEncoded];
|
|
871
|
+
},
|
|
872
|
+
decode(subData) {
|
|
873
|
+
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
874
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
875
|
+
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
876
|
+
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
877
|
+
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
878
|
+
const user = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
879
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
880
|
+
return {
|
|
881
|
+
loanToken,
|
|
882
|
+
collToken,
|
|
883
|
+
oracle,
|
|
884
|
+
irm,
|
|
885
|
+
lltv,
|
|
886
|
+
user,
|
|
887
|
+
closeType,
|
|
888
|
+
};
|
|
889
|
+
},
|
|
890
|
+
};
|
|
@@ -1292,6 +1292,58 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1292
1292
|
});
|
|
1293
1293
|
});
|
|
1294
1294
|
});
|
|
1295
|
+
describe('When testing subDataService.morphoBlueCloseOnPriceSubData', () => {
|
|
1296
|
+
describe('encode()', () => {
|
|
1297
|
+
const examples = [
|
|
1298
|
+
[
|
|
1299
|
+
[
|
|
1300
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1301
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1302
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1303
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1304
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1305
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1306
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1307
|
+
],
|
|
1308
|
+
[web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'), '945000000000000000', web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT]
|
|
1309
|
+
],
|
|
1310
|
+
];
|
|
1311
|
+
examples.forEach(([expected, actual]) => {
|
|
1312
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1313
|
+
(0, chai_1.expect)(subDataService.morphoBlueCloseOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1314
|
+
});
|
|
1315
|
+
});
|
|
1316
|
+
});
|
|
1317
|
+
describe('decode()', () => {
|
|
1318
|
+
const examples = [
|
|
1319
|
+
[
|
|
1320
|
+
{
|
|
1321
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1322
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1323
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1324
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1325
|
+
lltv: '945000000000000000',
|
|
1326
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1327
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1328
|
+
},
|
|
1329
|
+
[
|
|
1330
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1331
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1332
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1333
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1334
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1335
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1336
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1337
|
+
],
|
|
1338
|
+
],
|
|
1339
|
+
];
|
|
1340
|
+
examples.forEach(([expected, actual]) => {
|
|
1341
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1342
|
+
(0, chai_1.expect)(subDataService.morphoBlueCloseOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1343
|
+
});
|
|
1344
|
+
});
|
|
1345
|
+
});
|
|
1346
|
+
});
|
|
1295
1347
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1296
1348
|
describe('encode()', () => {
|
|
1297
1349
|
const examples = [
|
|
@@ -1585,7 +1637,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1585
1637
|
debtAssetId: 1,
|
|
1586
1638
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1587
1639
|
targetRatio: 200,
|
|
1588
|
-
|
|
1640
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1589
1641
|
},
|
|
1590
1642
|
[
|
|
1591
1643
|
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -1605,7 +1657,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1605
1657
|
debtAssetId: 1,
|
|
1606
1658
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1607
1659
|
targetRatio: 200,
|
|
1608
|
-
|
|
1660
|
+
owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1609
1661
|
},
|
|
1610
1662
|
[
|
|
1611
1663
|
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
@@ -1814,7 +1866,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1814
1866
|
debtAssetId: 1,
|
|
1815
1867
|
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1816
1868
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1817
|
-
|
|
1869
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1818
1870
|
},
|
|
1819
1871
|
[
|
|
1820
1872
|
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -1835,7 +1887,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1835
1887
|
debtAssetId: 1,
|
|
1836
1888
|
closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
1837
1889
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1838
|
-
|
|
1890
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1839
1891
|
},
|
|
1840
1892
|
[
|
|
1841
1893
|
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -1856,7 +1908,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1856
1908
|
debtAssetId: 1,
|
|
1857
1909
|
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT,
|
|
1858
1910
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1859
|
-
|
|
1911
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1860
1912
|
},
|
|
1861
1913
|
[
|
|
1862
1914
|
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -1877,7 +1929,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1877
1929
|
debtAssetId: 1,
|
|
1878
1930
|
closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT,
|
|
1879
1931
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1880
|
-
|
|
1932
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1881
1933
|
},
|
|
1882
1934
|
[
|
|
1883
1935
|
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -1898,7 +1950,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1898
1950
|
debtAssetId: 1,
|
|
1899
1951
|
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
1900
1952
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1901
|
-
|
|
1953
|
+
owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1902
1954
|
},
|
|
1903
1955
|
[
|
|
1904
1956
|
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -1919,7 +1971,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1919
1971
|
debtAssetId: 1,
|
|
1920
1972
|
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
1921
1973
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1922
|
-
|
|
1974
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1923
1975
|
},
|
|
1924
1976
|
[
|
|
1925
1977
|
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
@@ -1940,7 +1992,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1940
1992
|
debtAssetId: 1,
|
|
1941
1993
|
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1942
1994
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1943
|
-
|
|
1995
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1944
1996
|
},
|
|
1945
1997
|
[
|
|
1946
1998
|
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
@@ -1961,7 +2013,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1961
2013
|
debtAssetId: 1,
|
|
1962
2014
|
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
1963
2015
|
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1964
|
-
|
|
2016
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1965
2017
|
},
|
|
1966
2018
|
[
|
|
1967
2019
|
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
@@ -275,3 +275,13 @@ export declare const sparkQuotePriceRangeTrigger: {
|
|
|
275
275
|
upperPrice: string;
|
|
276
276
|
};
|
|
277
277
|
};
|
|
278
|
+
export declare const morphoBluePriceRangeTrigger: {
|
|
279
|
+
encode(oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, lowerPrice: number, upperPrice: number): string[];
|
|
280
|
+
decode(triggerData: string[]): {
|
|
281
|
+
oracle: string;
|
|
282
|
+
collateralToken: string;
|
|
283
|
+
loanToken: string;
|
|
284
|
+
lowerPrice: string;
|
|
285
|
+
upperPrice: string;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.sparkQuotePriceRangeTrigger = exports.aaveV3QuotePriceRangeTrigger = exports.compoundV3PriceRangeTrigger = exports.compoundV3PriceTrigger = exports.fluidRatioTrigger = exports.morphoBluePriceTrigger = exports.closePriceTrigger = exports.liquityV2QuotePriceTrigger = exports.liquityV2RatioTrigger = exports.morphoBlueRatioTrigger = exports.crvUsdHealthRatioTrigger = exports.crvUSDRatioTrigger = exports.curveUsdSoftLiquidationTrigger = exports.curveUsdBorrowRateTrigger = exports.sparkRatioTrigger = exports.exchangeOffchainPriceTrigger = exports.exchangeTimestampTrigger = exports.compoundV3RatioTrigger = exports.cBondsRebondTrigger = exports.aaveV2RatioTrigger = exports.liquityV2AdjustTimeTrigger = exports.liquityV2DebtInFrontTrigger = exports.liquityDebtInFrontWithLimitTrigger = exports.liquityDebtInFrontTrigger = exports.liquityRatioTrigger = exports.compoundV2RatioTrigger = exports.aaveV3QuotePriceWithMaximumGasPriceTrigger = exports.aaveV3QuotePriceTrigger = exports.morphoAaveV2RatioTrigger = exports.aaveV3RatioTrigger = exports.makerRatioTrigger = exports.trailingStopTrigger = exports.chainlinkPriceTrigger = void 0;
|
|
29
|
+
exports.morphoBluePriceRangeTrigger = exports.sparkQuotePriceRangeTrigger = exports.aaveV3QuotePriceRangeTrigger = exports.compoundV3PriceRangeTrigger = exports.compoundV3PriceTrigger = exports.fluidRatioTrigger = exports.morphoBluePriceTrigger = exports.closePriceTrigger = exports.liquityV2QuotePriceTrigger = exports.liquityV2RatioTrigger = exports.morphoBlueRatioTrigger = exports.crvUsdHealthRatioTrigger = exports.crvUSDRatioTrigger = exports.curveUsdSoftLiquidationTrigger = exports.curveUsdBorrowRateTrigger = exports.sparkRatioTrigger = exports.exchangeOffchainPriceTrigger = exports.exchangeTimestampTrigger = exports.compoundV3RatioTrigger = exports.cBondsRebondTrigger = exports.aaveV2RatioTrigger = exports.liquityV2AdjustTimeTrigger = exports.liquityV2DebtInFrontTrigger = exports.liquityDebtInFrontWithLimitTrigger = exports.liquityDebtInFrontTrigger = exports.liquityRatioTrigger = exports.compoundV2RatioTrigger = exports.aaveV3QuotePriceWithMaximumGasPriceTrigger = exports.aaveV3QuotePriceTrigger = exports.morphoAaveV2RatioTrigger = exports.aaveV3RatioTrigger = exports.makerRatioTrigger = exports.trailingStopTrigger = exports.chainlinkPriceTrigger = void 0;
|
|
30
30
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
31
|
const tokens_1 = require("@defisaver/tokens");
|
|
32
32
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
@@ -527,3 +527,23 @@ exports.sparkQuotePriceRangeTrigger = {
|
|
|
527
527
|
};
|
|
528
528
|
},
|
|
529
529
|
};
|
|
530
|
+
exports.morphoBluePriceRangeTrigger = {
|
|
531
|
+
encode(oracle, collateralToken, loanToken, lowerPrice, upperPrice) {
|
|
532
|
+
// Price is scaled to 1e8
|
|
533
|
+
const lowerPriceFormatted = new decimal_js_1.default(lowerPrice).mul(1e8).floor().toString();
|
|
534
|
+
const upperPriceFormatted = new decimal_js_1.default(upperPrice).mul(1e8).floor().toString();
|
|
535
|
+
return [
|
|
536
|
+
web3_eth_abi_1.default.encodeParameters(['address', 'address', 'address', 'uint256', 'uint256'], [oracle, collateralToken, loanToken, lowerPriceFormatted, upperPriceFormatted]),
|
|
537
|
+
];
|
|
538
|
+
},
|
|
539
|
+
decode(triggerData) {
|
|
540
|
+
const decodedData = web3_eth_abi_1.default.decodeParameters(['address', 'address', 'address', 'uint256', 'uint256'], triggerData[0]);
|
|
541
|
+
return {
|
|
542
|
+
oracle: decodedData[0],
|
|
543
|
+
collateralToken: decodedData[1],
|
|
544
|
+
loanToken: decodedData[2],
|
|
545
|
+
lowerPrice: new decimal_js_1.default(decodedData[3]).div(1e8).toString(),
|
|
546
|
+
upperPrice: new decimal_js_1.default(decodedData[4]).div(1e8).toString(),
|
|
547
|
+
};
|
|
548
|
+
},
|
|
549
|
+
};
|
|
@@ -1136,4 +1136,52 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1136
1136
|
});
|
|
1137
1137
|
});
|
|
1138
1138
|
});
|
|
1139
|
+
describe('When testing triggerService.morphoBluePriceRangeTrigger', () => {
|
|
1140
|
+
describe('encode()', () => {
|
|
1141
|
+
const examples = [
|
|
1142
|
+
[
|
|
1143
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1144
|
+
[web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
|
|
1145
|
+
],
|
|
1146
|
+
[
|
|
1147
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1148
|
+
[web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
|
|
1149
|
+
],
|
|
1150
|
+
];
|
|
1151
|
+
examples.forEach(([expected, actual]) => {
|
|
1152
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1153
|
+
(0, chai_1.expect)(triggerService_1.morphoBluePriceRangeTrigger.encode(...actual)).to.eql(expected);
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
});
|
|
1157
|
+
describe('decode()', () => {
|
|
1158
|
+
const examples = [
|
|
1159
|
+
[
|
|
1160
|
+
{
|
|
1161
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1162
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1163
|
+
loanToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1164
|
+
lowerPrice: '1500',
|
|
1165
|
+
upperPrice: '4000',
|
|
1166
|
+
},
|
|
1167
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1168
|
+
],
|
|
1169
|
+
[
|
|
1170
|
+
{
|
|
1171
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1172
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1173
|
+
loanToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1174
|
+
lowerPrice: '0',
|
|
1175
|
+
upperPrice: '5000',
|
|
1176
|
+
},
|
|
1177
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8dA6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
1178
|
+
],
|
|
1179
|
+
];
|
|
1180
|
+
examples.forEach(([expected, actual]) => {
|
|
1181
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1182
|
+
(0, chai_1.expect)(triggerService_1.morphoBluePriceRangeTrigger.decode(actual)).to.eql(expected);
|
|
1183
|
+
});
|
|
1184
|
+
});
|
|
1185
|
+
});
|
|
1186
|
+
});
|
|
1139
1187
|
});
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -206,7 +206,8 @@ export declare namespace Bundles {
|
|
|
206
206
|
AAVE_V3_EOA_REPAY_ON_PRICE = 54,
|
|
207
207
|
AAVE_V3_EOA_BOOST_ON_PRICE = 55,
|
|
208
208
|
AAVE_V3_EOA_CLOSE = 56,
|
|
209
|
-
SPARK_CLOSE = 57
|
|
209
|
+
SPARK_CLOSE = 57,
|
|
210
|
+
MORPHO_BLUE_CLOSE = 58
|
|
210
211
|
}
|
|
211
212
|
enum OptimismIds {
|
|
212
213
|
AAVE_V3_REPAY = 0,
|
|
@@ -247,7 +248,8 @@ export declare namespace Bundles {
|
|
|
247
248
|
AAVE_V3_EOA_BOOST = 24,
|
|
248
249
|
AAVE_V3_EOA_REPAY_ON_PRICE = 25,
|
|
249
250
|
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
250
|
-
AAVE_V3_EOA_CLOSE = 27
|
|
251
|
+
AAVE_V3_EOA_CLOSE = 27,
|
|
252
|
+
MORPHO_BLUE_CLOSE = 28
|
|
251
253
|
}
|
|
252
254
|
enum ArbitrumIds {
|
|
253
255
|
AAVE_V3_REPAY = 0,
|
|
@@ -277,6 +279,7 @@ export declare namespace Bundles {
|
|
|
277
279
|
MORPHO_BLUE_BOOST = 24,
|
|
278
280
|
MORPHO_BLUE_BOOST_ON_PRICE = 25,
|
|
279
281
|
MORPHO_BLUE_EOA_REPAY = 26,
|
|
280
|
-
MORPHO_BLUE_EOA_BOOST = 27
|
|
282
|
+
MORPHO_BLUE_EOA_BOOST = 27,
|
|
283
|
+
MORPHO_BLUE_CLOSE = 28
|
|
281
284
|
}
|
|
282
285
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -230,6 +230,7 @@ var Bundles;
|
|
|
230
230
|
MainnetIds[MainnetIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 55] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
231
231
|
MainnetIds[MainnetIds["AAVE_V3_EOA_CLOSE"] = 56] = "AAVE_V3_EOA_CLOSE";
|
|
232
232
|
MainnetIds[MainnetIds["SPARK_CLOSE"] = 57] = "SPARK_CLOSE";
|
|
233
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_CLOSE"] = 58] = "MORPHO_BLUE_CLOSE";
|
|
233
234
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
234
235
|
let OptimismIds;
|
|
235
236
|
(function (OptimismIds) {
|
|
@@ -273,6 +274,7 @@ var Bundles;
|
|
|
273
274
|
BaseIds[BaseIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 25] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
274
275
|
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
275
276
|
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
277
|
+
BaseIds[BaseIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
276
278
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
277
279
|
let ArbitrumIds;
|
|
278
280
|
(function (ArbitrumIds) {
|
|
@@ -304,5 +306,6 @@ var Bundles;
|
|
|
304
306
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_BOOST_ON_PRICE"] = 25] = "MORPHO_BLUE_BOOST_ON_PRICE";
|
|
305
307
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY"] = 26] = "MORPHO_BLUE_EOA_REPAY";
|
|
306
308
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST"] = 27] = "MORPHO_BLUE_EOA_BOOST";
|
|
309
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
307
310
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
308
311
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|
package/esm/constants/index.js
CHANGED
|
@@ -462,6 +462,11 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
462
462
|
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
463
463
|
protocol: PROTOCOLS.Spark,
|
|
464
464
|
},
|
|
465
|
+
[Bundles.MainnetIds.MORPHO_BLUE_CLOSE]: {
|
|
466
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
467
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
468
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
469
|
+
},
|
|
465
470
|
};
|
|
466
471
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
467
472
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -651,6 +656,11 @@ export const BASE_BUNDLES_INFO = {
|
|
|
651
656
|
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
652
657
|
protocol: PROTOCOLS.AaveV3,
|
|
653
658
|
},
|
|
659
|
+
[Bundles.BaseIds.MORPHO_BLUE_CLOSE]: {
|
|
660
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_CLOSE,
|
|
661
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
662
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
663
|
+
},
|
|
654
664
|
};
|
|
655
665
|
export const ARBITRUM_BUNDLES_INFO = {
|
|
656
666
|
[Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -793,6 +803,11 @@ export const ARBITRUM_BUNDLES_INFO = {
|
|
|
793
803
|
strategyId: Strategies.Identifiers.EoaBoost,
|
|
794
804
|
protocol: PROTOCOLS.MorphoBlue,
|
|
795
805
|
},
|
|
806
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_CLOSE]: {
|
|
807
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_CLOSE,
|
|
808
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
809
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
810
|
+
},
|
|
796
811
|
};
|
|
797
812
|
export const BUNDLES_INFO = {
|
|
798
813
|
[ChainId.Ethereum]: MAINNET_BUNDLES_INFO,
|
|
@@ -96,6 +96,7 @@ describe('Feature: ethereumService.ts', () => {
|
|
|
96
96
|
'address': '0x5f98805A4E8be255a32880FDeC7F6728C6568bA0',
|
|
97
97
|
'blockHash': '0xb92cab2569456dbfbdb853d2c67d72c9a7580543dbcb55d483a77322b40755a4',
|
|
98
98
|
'blockNumber': 15166163,
|
|
99
|
+
'blockTimestamp': '0x62d53ad8',
|
|
99
100
|
'event': 'Transfer',
|
|
100
101
|
'id': 'log_e2258e3a',
|
|
101
102
|
'logIndex': 385,
|