@defisaver/automation-sdk 3.3.6 → 3.3.7-morpho-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/index.js +20 -10
- package/cjs/services/strategiesService.js +41 -14
- package/cjs/services/strategySubService.d.ts +2 -11
- package/cjs/services/strategySubService.js +12 -5
- package/cjs/services/strategySubService.test.js +38 -72
- package/cjs/services/subDataService.d.ts +24 -9
- package/cjs/services/subDataService.js +63 -20
- package/cjs/services/subDataService.test.js +52 -72
- package/cjs/services/triggerService.d.ts +19 -9
- package/cjs/services/triggerService.js +40 -19
- package/cjs/services/triggerService.test.js +48 -46
- package/cjs/services/utils.test.js +0 -77
- package/cjs/types/enums.d.ts +7 -5
- package/cjs/types/enums.js +4 -2
- package/esm/constants/index.js +20 -10
- package/esm/services/strategiesService.js +41 -14
- package/esm/services/strategySubService.d.ts +2 -11
- package/esm/services/strategySubService.js +12 -5
- package/esm/services/strategySubService.test.js +39 -73
- package/esm/services/subDataService.d.ts +24 -9
- package/esm/services/subDataService.js +62 -19
- package/esm/services/subDataService.test.js +52 -72
- package/esm/services/triggerService.d.ts +19 -9
- package/esm/services/triggerService.js +39 -18
- package/esm/services/triggerService.test.js +49 -47
- package/esm/services/utils.test.js +1 -52
- package/esm/types/enums.d.ts +7 -5
- package/esm/types/enums.js +4 -2
- package/package.json +1 -1
- package/src/constants/index.ts +20 -12
- package/src/services/strategiesService.ts +55 -22
- package/src/services/strategySubService.test.ts +59 -94
- package/src/services/strategySubService.ts +36 -16
- package/src/services/subDataService.test.ts +60 -78
- package/src/services/subDataService.ts +92 -31
- package/src/services/triggerService.test.ts +53 -51
- package/src/services/triggerService.ts +61 -26
- package/src/services/utils.test.ts +0 -59
- package/src/types/enums.ts +4 -2
package/cjs/constants/index.js
CHANGED
|
@@ -308,16 +308,6 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
308
308
|
strategyId: enums_1.Strategies.Identifiers.Boost,
|
|
309
309
|
protocol: exports.PROTOCOLS.Spark,
|
|
310
310
|
},
|
|
311
|
-
[enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT]: {
|
|
312
|
-
strategyOrBundleId: enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
|
|
313
|
-
strategyId: enums_1.Strategies.Identifiers.CloseToDebt,
|
|
314
|
-
protocol: exports.PROTOCOLS.Spark,
|
|
315
|
-
},
|
|
316
|
-
[enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL]: {
|
|
317
|
-
strategyOrBundleId: enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
|
|
318
|
-
strategyId: enums_1.Strategies.Identifiers.CloseToCollateral,
|
|
319
|
-
protocol: exports.PROTOCOLS.Spark,
|
|
320
|
-
},
|
|
321
311
|
[enums_1.Bundles.MainnetIds.AAVE_V2_REPAY]: {
|
|
322
312
|
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V2_REPAY,
|
|
323
313
|
strategyId: enums_1.Strategies.Identifiers.Repay,
|
|
@@ -473,6 +463,16 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
473
463
|
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
474
464
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
475
465
|
},
|
|
466
|
+
[enums_1.Bundles.MainnetIds.SPARK_CLOSE]: {
|
|
467
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.SPARK_CLOSE,
|
|
468
|
+
strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
|
|
469
|
+
protocol: exports.PROTOCOLS.Spark,
|
|
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
|
+
},
|
|
476
476
|
};
|
|
477
477
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
478
478
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -662,6 +662,11 @@ exports.BASE_BUNDLES_INFO = {
|
|
|
662
662
|
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
663
663
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
664
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
|
+
},
|
|
665
670
|
};
|
|
666
671
|
exports.ARBITRUM_BUNDLES_INFO = {
|
|
667
672
|
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -804,6 +809,11 @@ exports.ARBITRUM_BUNDLES_INFO = {
|
|
|
804
809
|
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
805
810
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
806
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
|
+
},
|
|
807
817
|
};
|
|
808
818
|
exports.BUNDLES_INFO = {
|
|
809
819
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
|
|
@@ -36,9 +36,6 @@ const utils_1 = require("./utils");
|
|
|
36
36
|
const subDataService = __importStar(require("./subDataService"));
|
|
37
37
|
const triggerService = __importStar(require("./triggerService"));
|
|
38
38
|
const web3 = new web3_1.default();
|
|
39
|
-
const SPARK_MARKET_ADDRESSES = {
|
|
40
|
-
[enums_1.ChainId.Ethereum]: '0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE',
|
|
41
|
-
};
|
|
42
39
|
const AAVE_V3_MARKET_ADDRESSES = {
|
|
43
40
|
[enums_1.ChainId.Ethereum]: '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e',
|
|
44
41
|
[enums_1.ChainId.Optimism]: '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
|
|
@@ -619,23 +616,24 @@ function parseSparkLeverageManagement(position, parseData) {
|
|
|
619
616
|
function parseSparkCloseOnPrice(position, parseData) {
|
|
620
617
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
621
618
|
const { subStruct } = parseData.subscriptionEventData;
|
|
622
|
-
const triggerData = triggerService.
|
|
623
|
-
const subData = subDataService.
|
|
619
|
+
const triggerData = triggerService.sparkQuotePriceRangeTrigger.decode(subStruct.triggerData);
|
|
620
|
+
const subData = subDataService.sparkCloseGenericSubData.decode(subStruct.subData);
|
|
624
621
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
625
622
|
_position.strategyData.decoded.subData = subData;
|
|
626
|
-
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner,
|
|
623
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
624
|
+
const { takeProfitType, stopLossType } = (0, utils_1.getStopLossAndTakeProfitTypeByCloseStrategyType)(+subData.closeType);
|
|
627
625
|
_position.specific = {
|
|
628
626
|
collAsset: subData.collAsset,
|
|
629
627
|
collAssetId: subData.collAssetId,
|
|
630
628
|
debtAsset: subData.debtAsset,
|
|
631
629
|
debtAssetId: subData.debtAssetId,
|
|
632
|
-
baseToken: triggerData.
|
|
633
|
-
quoteToken: triggerData.
|
|
634
|
-
|
|
635
|
-
|
|
630
|
+
baseToken: triggerData.collToken,
|
|
631
|
+
quoteToken: triggerData.debtToken,
|
|
632
|
+
stopLossPrice: triggerData.lowerPrice,
|
|
633
|
+
takeProfitPrice: triggerData.upperPrice,
|
|
634
|
+
stopLossType,
|
|
635
|
+
takeProfitType,
|
|
636
636
|
};
|
|
637
|
-
const { ratioState } = (0, utils_1.getRatioStateInfoForAaveCloseStrategy)(_position.specific.ratioState, (0, utils_1.wethToEthByAddress)(_position.specific.collAsset, parseData.chainId), (0, utils_1.wethToEthByAddress)(_position.specific.debtAsset, parseData.chainId), parseData.chainId);
|
|
638
|
-
_position.strategy.strategyId = (0, utils_1.isRatioStateOver)(ratioState) ? enums_1.Strategies.IdOverrides.TakeProfit : enums_1.Strategies.IdOverrides.StopLoss;
|
|
639
637
|
return _position;
|
|
640
638
|
}
|
|
641
639
|
function parseLiquitySavingsLiqProtection(position, parseData) {
|
|
@@ -772,6 +770,35 @@ function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
|
772
770
|
};
|
|
773
771
|
return _position;
|
|
774
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
|
+
}
|
|
775
802
|
function parseLiquityV2CloseOnPrice(position, parseData) {
|
|
776
803
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
777
804
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -946,8 +973,7 @@ const parsingMethodsMapping = {
|
|
|
946
973
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.Spark]: {
|
|
947
974
|
[enums_1.Strategies.Identifiers.Repay]: parseSparkLeverageManagement,
|
|
948
975
|
[enums_1.Strategies.Identifiers.Boost]: parseSparkLeverageManagement,
|
|
949
|
-
[enums_1.Strategies.Identifiers.
|
|
950
|
-
[enums_1.Strategies.Identifiers.CloseToCollateral]: parseSparkCloseOnPrice,
|
|
976
|
+
[enums_1.Strategies.Identifiers.CloseOnPrice]: parseSparkCloseOnPrice,
|
|
951
977
|
},
|
|
952
978
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CrvUSD]: {
|
|
953
979
|
[enums_1.Strategies.Identifiers.Repay]: parseCrvUSDLeverageManagement,
|
|
@@ -960,6 +986,7 @@ const parsingMethodsMapping = {
|
|
|
960
986
|
[enums_1.Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
961
987
|
[enums_1.Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
962
988
|
[enums_1.Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
989
|
+
[enums_1.Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
963
990
|
},
|
|
964
991
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
965
992
|
[enums_1.Strategies.Identifiers.Repay]: parseFluidT1LeverageManagement,
|
|
@@ -85,17 +85,7 @@ export declare const exchangeEncode: {
|
|
|
85
85
|
};
|
|
86
86
|
export declare const sparkEncode: {
|
|
87
87
|
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
88
|
-
|
|
89
|
-
baseTokenAddress: EthereumAddress;
|
|
90
|
-
quoteTokenAddress: EthereumAddress;
|
|
91
|
-
price: number;
|
|
92
|
-
ratioState: RatioState;
|
|
93
|
-
}, subData: {
|
|
94
|
-
collAsset: EthereumAddress;
|
|
95
|
-
collAssetId: number;
|
|
96
|
-
debtAsset: EthereumAddress;
|
|
97
|
-
debtAssetId: number;
|
|
98
|
-
}): (number | boolean | string[])[];
|
|
88
|
+
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
99
89
|
};
|
|
100
90
|
export declare const crvUSDEncode: {
|
|
101
91
|
leverageManagement(owner: EthereumAddress, controllerAddr: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, collTokenAddr: EthereumAddress, crvUSDAddr: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
@@ -104,6 +94,7 @@ export declare const crvUSDEncode: {
|
|
|
104
94
|
export declare const morphoBlueEncode: {
|
|
105
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)[];
|
|
106
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[])[];
|
|
107
98
|
};
|
|
108
99
|
export declare const liquityV2Encode: {
|
|
109
100
|
leverageManagement(market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
@@ -261,11 +261,11 @@ exports.sparkEncode = {
|
|
|
261
261
|
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
262
262
|
return subInput;
|
|
263
263
|
},
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
const triggerDataEncoded = triggerService.
|
|
264
|
+
closeOnPriceGeneric(strategyOrBundleId, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, user, stopLossPrice = 0, stopLossType = enums_1.CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = enums_1.CloseToAssetType.COLLATERAL) {
|
|
265
|
+
const isBundle = true;
|
|
266
|
+
const closeType = (0, utils_1.getCloseStrategyType)(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
267
|
+
const subDataEncoded = subDataService.sparkCloseGenericSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user);
|
|
268
|
+
const triggerDataEncoded = triggerService.sparkQuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
269
269
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
270
270
|
},
|
|
271
271
|
};
|
|
@@ -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) {
|
|
@@ -1191,78 +1191,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1191
1191
|
});
|
|
1192
1192
|
});
|
|
1193
1193
|
});
|
|
1194
|
-
describe('When testing strategySubService.sparkEncode', () => {
|
|
1195
|
-
describe('leverageManagement()', () => {
|
|
1196
|
-
const examples = [
|
|
1197
|
-
[
|
|
1198
|
-
'0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
|
|
1199
|
-
[160, 220, 180, 190, true]
|
|
1200
|
-
],
|
|
1201
|
-
[
|
|
1202
|
-
'0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
|
|
1203
|
-
[160, 200, 180, 190, false]
|
|
1204
|
-
],
|
|
1205
|
-
];
|
|
1206
|
-
examples.forEach(([expected, actual]) => {
|
|
1207
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1208
|
-
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1209
|
-
});
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
|
-
describe('closeToAsset()', () => {
|
|
1213
|
-
const examples = [
|
|
1214
|
-
[
|
|
1215
|
-
[
|
|
1216
|
-
enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
|
|
1217
|
-
true,
|
|
1218
|
-
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1219
|
-
[
|
|
1220
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
1221
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
1222
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1223
|
-
],
|
|
1224
|
-
],
|
|
1225
|
-
[
|
|
1226
|
-
enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
|
|
1227
|
-
true,
|
|
1228
|
-
{
|
|
1229
|
-
baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER
|
|
1230
|
-
},
|
|
1231
|
-
{
|
|
1232
|
-
collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
|
|
1233
|
-
},
|
|
1234
|
-
]
|
|
1235
|
-
],
|
|
1236
|
-
[
|
|
1237
|
-
[
|
|
1238
|
-
enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
|
|
1239
|
-
true,
|
|
1240
|
-
['0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1241
|
-
[
|
|
1242
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
|
|
1243
|
-
'0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
1244
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1245
|
-
],
|
|
1246
|
-
],
|
|
1247
|
-
[
|
|
1248
|
-
enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
|
|
1249
|
-
true,
|
|
1250
|
-
{
|
|
1251
|
-
baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER
|
|
1252
|
-
},
|
|
1253
|
-
{
|
|
1254
|
-
collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
|
|
1255
|
-
},
|
|
1256
|
-
]
|
|
1257
|
-
]
|
|
1258
|
-
];
|
|
1259
|
-
examples.forEach(([expected, actual]) => {
|
|
1260
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1261
|
-
(0, chai_1.expect)(strategySubService_1.sparkEncode.closeToAsset(...actual)).to.eql(expected);
|
|
1262
|
-
});
|
|
1263
|
-
});
|
|
1264
|
-
});
|
|
1265
|
-
});
|
|
1266
1194
|
describe('When testing strategySubService.crvUSDEncode', () => {
|
|
1267
1195
|
describe('leverageManagement()', () => {
|
|
1268
1196
|
const examples = [
|
|
@@ -1436,6 +1364,44 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1436
1364
|
});
|
|
1437
1365
|
});
|
|
1438
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
|
+
});
|
|
1439
1405
|
});
|
|
1440
1406
|
describe('When testing strategySubService.compoundV3L2Encode', () => {
|
|
1441
1407
|
describe('leverageManagement()', () => {
|
|
@@ -166,15 +166,6 @@ export declare const sparkLeverageManagementSubData: {
|
|
|
166
166
|
targetRatio: number;
|
|
167
167
|
};
|
|
168
168
|
};
|
|
169
|
-
export declare const sparkQuotePriceSubData: {
|
|
170
|
-
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress): string[];
|
|
171
|
-
decode(subData: string[]): {
|
|
172
|
-
collAsset: EthereumAddress;
|
|
173
|
-
collAssetId: number;
|
|
174
|
-
debtAsset: EthereumAddress;
|
|
175
|
-
debtAssetId: number;
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
169
|
export declare const liquityDsrPaybackSubData: {
|
|
179
170
|
encode: (targetRatio: number) => string[];
|
|
180
171
|
decode: (subData: string[]) => {
|
|
@@ -315,3 +306,27 @@ export declare const compoundV3CloseSubData: {
|
|
|
315
306
|
owner: EthereumAddress;
|
|
316
307
|
};
|
|
317
308
|
};
|
|
309
|
+
export declare const sparkCloseGenericSubData: {
|
|
310
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress): string[];
|
|
311
|
+
decode(subData: string[]): {
|
|
312
|
+
collAsset: EthereumAddress;
|
|
313
|
+
collAssetId: number;
|
|
314
|
+
debtAsset: EthereumAddress;
|
|
315
|
+
debtAssetId: number;
|
|
316
|
+
closeType: CloseStrategyType;
|
|
317
|
+
marketAddr: EthereumAddress;
|
|
318
|
+
owner: EthereumAddress;
|
|
319
|
+
};
|
|
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.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.
|
|
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");
|
|
@@ -417,25 +417,6 @@ exports.sparkLeverageManagementSubData = {
|
|
|
417
417
|
return { targetRatio };
|
|
418
418
|
},
|
|
419
419
|
};
|
|
420
|
-
exports.sparkQuotePriceSubData = {
|
|
421
|
-
encode(collAsset, collAssetId, debtAsset, debtAssetId, nullAddress = constants_1.ZERO_ADDRESS) {
|
|
422
|
-
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
423
|
-
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
424
|
-
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
425
|
-
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
426
|
-
const encodedNullAddress = web3_eth_abi_1.default.encodeParameter('address', nullAddress);
|
|
427
|
-
return [encodedColl, encodedCollId, encodedDebt, encodedDebtId, encodedNullAddress];
|
|
428
|
-
},
|
|
429
|
-
decode(subData) {
|
|
430
|
-
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
431
|
-
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
432
|
-
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
433
|
-
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
434
|
-
return {
|
|
435
|
-
collAsset, collAssetId, debtAsset, debtAssetId,
|
|
436
|
-
};
|
|
437
|
-
},
|
|
438
|
-
};
|
|
439
420
|
exports.liquityDsrPaybackSubData = {
|
|
440
421
|
encode: (targetRatio) => {
|
|
441
422
|
const daiAddress = (0, tokens_1.getAssetInfo)('DAI').address;
|
|
@@ -845,3 +826,65 @@ exports.compoundV3CloseSubData = {
|
|
|
845
826
|
};
|
|
846
827
|
},
|
|
847
828
|
};
|
|
829
|
+
exports.sparkCloseGenericSubData = {
|
|
830
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
831
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
832
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
833
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
834
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
835
|
+
const encodedCloseType = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
836
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
837
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
838
|
+
return [
|
|
839
|
+
encodedColl,
|
|
840
|
+
encodedCollId,
|
|
841
|
+
encodedDebt,
|
|
842
|
+
encodedDebtId,
|
|
843
|
+
encodedCloseType,
|
|
844
|
+
encodedMarket,
|
|
845
|
+
userEncoded,
|
|
846
|
+
];
|
|
847
|
+
},
|
|
848
|
+
decode(subData) {
|
|
849
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
850
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
851
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
852
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
853
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
854
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
855
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
856
|
+
return {
|
|
857
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner,
|
|
858
|
+
};
|
|
859
|
+
},
|
|
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
|
+
};
|
|
@@ -901,78 +901,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
901
901
|
});
|
|
902
902
|
});
|
|
903
903
|
});
|
|
904
|
-
describe('When testing subDataService.sparkQuotePriceSubData', () => {
|
|
905
|
-
describe('encode()', () => {
|
|
906
|
-
const examples = [
|
|
907
|
-
[
|
|
908
|
-
[
|
|
909
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
910
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
911
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
912
|
-
],
|
|
913
|
-
[
|
|
914
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
915
|
-
2,
|
|
916
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
917
|
-
4,
|
|
918
|
-
]
|
|
919
|
-
],
|
|
920
|
-
[
|
|
921
|
-
[
|
|
922
|
-
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
923
|
-
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
924
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
925
|
-
],
|
|
926
|
-
[
|
|
927
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
|
|
928
|
-
6,
|
|
929
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
930
|
-
2,
|
|
931
|
-
]
|
|
932
|
-
],
|
|
933
|
-
];
|
|
934
|
-
examples.forEach(([expected, actual]) => {
|
|
935
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
936
|
-
(0, chai_1.expect)(subDataService.sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
937
|
-
});
|
|
938
|
-
});
|
|
939
|
-
});
|
|
940
|
-
describe('decode()', () => {
|
|
941
|
-
const examples = [
|
|
942
|
-
[
|
|
943
|
-
{
|
|
944
|
-
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
945
|
-
collAssetId: 2,
|
|
946
|
-
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
947
|
-
debtAssetId: 4,
|
|
948
|
-
},
|
|
949
|
-
[
|
|
950
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
951
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
952
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
953
|
-
],
|
|
954
|
-
],
|
|
955
|
-
[
|
|
956
|
-
{
|
|
957
|
-
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
|
|
958
|
-
collAssetId: 6,
|
|
959
|
-
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
960
|
-
debtAssetId: 2,
|
|
961
|
-
},
|
|
962
|
-
[
|
|
963
|
-
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
964
|
-
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
965
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
966
|
-
],
|
|
967
|
-
],
|
|
968
|
-
];
|
|
969
|
-
examples.forEach(([expected, actual]) => {
|
|
970
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
971
|
-
(0, chai_1.expect)(subDataService.sparkQuotePriceSubData.decode(actual)).to.eql(expected);
|
|
972
|
-
});
|
|
973
|
-
});
|
|
974
|
-
});
|
|
975
|
-
});
|
|
976
904
|
describe('When testing subDataService.liquityDsrPaybackSubData', () => {
|
|
977
905
|
describe('encode()', () => {
|
|
978
906
|
const examples = [
|
|
@@ -1364,6 +1292,58 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1364
1292
|
});
|
|
1365
1293
|
});
|
|
1366
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
|
+
});
|
|
1367
1347
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1368
1348
|
describe('encode()', () => {
|
|
1369
1349
|
const examples = [
|