@defisaver/automation-sdk 3.3.15-liq-prot-2-dev → 3.3.16

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.
Files changed (44) hide show
  1. package/cjs/constants/index.js +9 -124
  2. package/cjs/index.d.ts +3 -4
  3. package/cjs/index.js +2 -6
  4. package/cjs/services/strategiesService.js +1 -148
  5. package/cjs/services/strategySubService.d.ts +2 -9
  6. package/cjs/services/strategySubService.js +1 -52
  7. package/cjs/services/strategySubService.test.js +67 -0
  8. package/cjs/services/subDataService.d.ts +3 -58
  9. package/cjs/services/subDataService.js +18 -164
  10. package/cjs/services/subDataService.test.js +168 -0
  11. package/cjs/services/triggerService.test.js +60 -0
  12. package/cjs/services/utils.d.ts +1 -3
  13. package/cjs/services/utils.js +1 -34
  14. package/cjs/services/utils.test.js +0 -25
  15. package/cjs/types/enums.d.ts +6 -33
  16. package/cjs/types/enums.js +3 -30
  17. package/esm/constants/index.js +9 -124
  18. package/esm/index.d.ts +3 -4
  19. package/esm/index.js +3 -7
  20. package/esm/services/strategiesService.js +1 -148
  21. package/esm/services/strategySubService.d.ts +2 -9
  22. package/esm/services/strategySubService.js +2 -53
  23. package/esm/services/strategySubService.test.js +67 -0
  24. package/esm/services/subDataService.d.ts +3 -58
  25. package/esm/services/subDataService.js +16 -162
  26. package/esm/services/subDataService.test.js +168 -0
  27. package/esm/services/triggerService.test.js +61 -1
  28. package/esm/services/utils.d.ts +1 -3
  29. package/esm/services/utils.js +1 -32
  30. package/esm/services/utils.test.js +2 -27
  31. package/esm/types/enums.d.ts +6 -33
  32. package/esm/types/enums.js +3 -30
  33. package/package.json +1 -1
  34. package/src/constants/index.ts +10 -126
  35. package/src/index.ts +6 -24
  36. package/src/services/strategiesService.ts +1 -212
  37. package/src/services/strategySubService.test.ts +84 -0
  38. package/src/services/strategySubService.ts +5 -149
  39. package/src/services/subDataService.test.ts +182 -0
  40. package/src/services/subDataService.ts +22 -229
  41. package/src/services/triggerService.test.ts +69 -0
  42. package/src/services/utils.test.ts +1 -32
  43. package/src/services/utils.ts +1 -32
  44. package/src/types/enums.ts +5 -30
@@ -1417,6 +1417,90 @@ describe('Feature: strategySubService.ts', () => {
1417
1417
  });
1418
1418
  });
1419
1419
 
1420
+ describe('leverageManagementOnPrice()', () => {
1421
+ const examples: Array<[
1422
+ [StrategyOrBundleIds, boolean, TriggerData, SubData],
1423
+ [
1424
+ strategyOrBundleId: number,
1425
+ isBundle: boolean,
1426
+ loanToken: EthereumAddress,
1427
+ collToken: EthereumAddress,
1428
+ oracle: EthereumAddress,
1429
+ irm: EthereumAddress,
1430
+ lltv: string,
1431
+ user: EthereumAddress,
1432
+ targetRatio: number,
1433
+ price: number,
1434
+ priceState: RatioState,
1435
+ ]
1436
+ ]> = [
1437
+ [
1438
+ [
1439
+ Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
1440
+ true,
1441
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1442
+ [
1443
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1444
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1445
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1446
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1447
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1448
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1449
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1450
+ ],
1451
+ ],
1452
+ [
1453
+ Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
1454
+ true,
1455
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1456
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1457
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1458
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1459
+ '945000000000000000',
1460
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1461
+ 200,
1462
+ 2500,
1463
+ RatioState.UNDER,
1464
+ ],
1465
+ ],
1466
+ [
1467
+ [
1468
+ Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
1469
+ true,
1470
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1471
+ [
1472
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1473
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1474
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1475
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1476
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1477
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1478
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1479
+ ],
1480
+ ],
1481
+ [
1482
+ Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
1483
+ true,
1484
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1485
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1486
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1487
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1488
+ '945000000000000000',
1489
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1490
+ 160,
1491
+ 4000,
1492
+ RatioState.OVER,
1493
+ ],
1494
+ ],
1495
+ ];
1496
+
1497
+ examples.forEach(([expected, actual]) => {
1498
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1499
+ expect(morphoBlueEncode.leverageManagementOnPrice(...actual)).to.eql(expected);
1500
+ });
1501
+ });
1502
+ });
1503
+
1420
1504
  describe('closeOnPrice()', () => {
1421
1505
  const examples: Array<[
1422
1506
  [StrategyOrBundleIds, boolean, TriggerData, SubData],
@@ -1,26 +1,22 @@
1
- import { getAssetInfo } from '@defisaver/tokens';
2
1
  import Dec from 'decimal.js';
2
+ import { getAssetInfo } from '@defisaver/tokens';
3
3
 
4
- import { STRATEGY_IDS } from '../constants';
4
+ import type { OrderType } from '../types/enums';
5
5
  import {
6
+ CloseToAssetType,
6
7
  Bundles,
7
8
  ChainId,
8
- CloseToAssetType,
9
9
  RatioState,
10
10
  Strategies,
11
11
  } from '../types/enums';
12
12
  import type { EthereumAddress, StrategyOrBundleIds } from '../types';
13
13
 
14
- import type { OrderType } from '../types/enums';
14
+ import { STRATEGY_IDS } from '../constants';
15
15
 
16
16
  import * as subDataService from './subDataService';
17
17
  import * as triggerService from './triggerService';
18
18
  import {
19
- compareAddresses,
20
- getBundleIdsByNetwork,
21
- getCloseStrategyType,
22
- requireAddress,
23
- requireAddresses,
19
+ compareAddresses, getCloseStrategyType, requireAddress, requireAddresses,
24
20
  } from './utils';
25
21
 
26
22
  export const makerEncode = {
@@ -106,26 +102,6 @@ export const makerEncode = {
106
102
  subData,
107
103
  ];
108
104
  },
109
-
110
- liquidationProtection(
111
- vaultId: number,
112
- triggerRatio: number,
113
- targetRatio: number,
114
- ratioState: RatioState,
115
- daiAddr?: EthereumAddress,
116
- ) {
117
- const bundleId = Bundles.MainnetIds.MAKER_SW_LIQUIDATION_PROTECTION;
118
-
119
- const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
120
- const subData = subDataService.makerLiquidationProtectionSubData.encode(vaultId, targetRatio, daiAddr);
121
-
122
- return [
123
- bundleId,
124
- true,
125
- triggerData,
126
- subData,
127
- ];
128
- },
129
105
  };
130
106
 
131
107
  export const liquityEncode = {
@@ -361,27 +337,6 @@ export const aaveV3Encode = {
361
337
  return [strategyOrBundleId, isBundle, triggerData, subData];
362
338
  },
363
339
 
364
- liquidationProtection(
365
- strategyOrBundleId: number,
366
- market: EthereumAddress,
367
- user: EthereumAddress,
368
- ratioState: RatioState,
369
- targetRatio: number,
370
- triggerRatio: number,
371
- ) {
372
- const isBundle = true;
373
-
374
- const subData = subDataService.aaveV3LiquidationProtectionSubData.encode(
375
- targetRatio,
376
- ratioState,
377
- market,
378
- user,
379
- );
380
- const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
381
-
382
- return [strategyOrBundleId, isBundle, triggerData, subData];
383
- },
384
-
385
340
  leverageManagementOnPriceGeneric(
386
341
  strategyOrBundleId: number,
387
342
  price: number,
@@ -486,24 +441,6 @@ export const compoundV3Encode = {
486
441
 
487
442
  return [strategyOrBundleId, isBundle, triggerData, subData];
488
443
  },
489
-
490
- liquidationProtectionWithoutSubProxy(
491
- strategyOrBundleId: number,
492
- market: EthereumAddress,
493
- baseToken: EthereumAddress,
494
- user: EthereumAddress,
495
- ratioState: RatioState,
496
- targetRatio: number,
497
- triggerRatio: number,
498
- ) {
499
- const isBundle = true;
500
-
501
- const subData = subDataService.compoundV3LiquidationProtectionSubDataWithoutSubProxy.encode(market, baseToken, targetRatio, ratioState);
502
- const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
503
-
504
- return [strategyOrBundleId, isBundle, triggerData, subData];
505
- },
506
-
507
444
  leverageManagementOnPrice(
508
445
  strategyOrBundleId: number,
509
446
  market: EthereumAddress,
@@ -654,26 +591,6 @@ export const sparkEncode = {
654
591
 
655
592
  return [strategyOrBundleId, isBundle, triggerData, subData];
656
593
  },
657
-
658
- liquidationProtection(
659
- strategyOrBundleId: number,
660
- market: EthereumAddress,
661
- user: EthereumAddress,
662
- ratioState: RatioState,
663
- targetRatio: number,
664
- triggerRatio: number,
665
- ) {
666
- const isBundle = true;
667
-
668
- const subData = subDataService.sparkLiquidationProtectionSubData.encode(
669
- targetRatio,
670
- ratioState,
671
- );
672
- const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
673
-
674
- return [strategyOrBundleId, isBundle, triggerData, subData];
675
- },
676
-
677
594
  collateralSwitch(
678
595
  strategyOrBundleId: number,
679
596
  fromAsset: EthereumAddress,
@@ -770,35 +687,6 @@ export const morphoBlueEncode = {
770
687
 
771
688
  return [strategyOrBundleId, isBundle, triggerData, subData];
772
689
  },
773
-
774
- liquidationProtection(
775
- marketId: string,
776
- loanToken: EthereumAddress,
777
- collToken: EthereumAddress,
778
- oracle: EthereumAddress,
779
- irm: EthereumAddress,
780
- lltv: string,
781
- ratioState: RatioState,
782
- targetRatio: number,
783
- triggerRatio: number,
784
- user: EthereumAddress,
785
- isEOA: boolean,
786
- network: ChainId,
787
- ) {
788
- const subData = subDataService.morphoBlueLiquidationProtectionSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
789
-
790
- const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
791
-
792
-
793
- // Type casting because there is no MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION for Base chain.
794
- // That is fine because we will just always send isEOA == false for Base chain.
795
- const bundleNetwork = getBundleIdsByNetwork(network) as typeof Bundles.MainnetIds;
796
- const bundleId = isEOA ? bundleNetwork.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION : bundleNetwork.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION;
797
- const isBundle = true;
798
-
799
- return [bundleId, isBundle, triggerData, subData];
800
- },
801
-
802
690
  leverageManagementOnPrice(
803
691
  strategyOrBundleId: number,
804
692
  isBundle: boolean = true,
@@ -927,22 +815,6 @@ export const fluidEncode = {
927
815
 
928
816
  return [strategyOrBundleId, isBundle, triggerData, subData];
929
817
  },
930
-
931
- liquidationProtection(
932
- nftId: string,
933
- vault: EthereumAddress,
934
- ratioState: RatioState,
935
- targetRatio: number,
936
- triggerRatio: number,
937
- strategyOrBundleId: number,
938
- ) {
939
- const isBundle = true;
940
- const subData = subDataService.fluidLiquidationProtectionSubData.encode(nftId, vault, ratioState, targetRatio);
941
- const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
942
-
943
- return [strategyOrBundleId, isBundle, triggerData, subData];
944
- },
945
-
946
818
  };
947
819
 
948
820
  export const aaveV4Encode = {
@@ -960,22 +832,6 @@ export const aaveV4Encode = {
960
832
 
961
833
  return [strategyOrBundleId, isBundle, triggerData, subData];
962
834
  },
963
-
964
- liquidationProtection(
965
- strategyOrBundleId: number,
966
- owner: EthereumAddress,
967
- spoke: EthereumAddress,
968
- ratioState: RatioState,
969
- targetRatio: number,
970
- triggerRatio: number,
971
- ) {
972
- const isBundle = true;
973
- const subData = subDataService.aaveV4LiquidationProtectionSubData.encode(spoke, owner, ratioState, targetRatio);
974
- const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
975
-
976
- return [strategyOrBundleId, isBundle, triggerData, subData];
977
- },
978
-
979
835
  leverageManagementOnPrice(
980
836
  strategyOrBundleId: number,
981
837
  owner: EthereumAddress,
@@ -734,6 +734,78 @@ describe('Feature: subDataService.ts', () => {
734
734
  });
735
735
  });
736
736
 
737
+ describe('When testing subDataService.compoundV3LeverageManagementSubData', () => {
738
+ describe('encode()', () => {
739
+ const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string, boolean, boolean], [market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean]]> = [
740
+ [
741
+ [
742
+ web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
743
+ web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
744
+ new Dec(160).mul(1e16).toString(),
745
+ new Dec(220).mul(1e16).toString(),
746
+ new Dec(180).mul(1e16).toString(),
747
+ new Dec(190).mul(1e16).toString(),
748
+ true, false,
749
+ ],
750
+ [
751
+ web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
752
+ web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
753
+ 160, 220, 180, 190,
754
+ true, false,
755
+ ]
756
+ ],
757
+ [
758
+ [
759
+ web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
760
+ web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
761
+ new Dec(160).mul(1e16).toString(),
762
+ new Dec(210).mul(1e16).toString(),
763
+ new Dec(180).mul(1e16).toString(),
764
+ new Dec(190).mul(1e16).toString(),
765
+ false, true,
766
+ ],
767
+ [
768
+ web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
769
+ web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
770
+ 160, 210, 180, 190,
771
+ false, true,
772
+ ]
773
+ ],
774
+ ];
775
+
776
+ examples.forEach(([expected, actual]) => {
777
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
778
+ expect(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
779
+ });
780
+ });
781
+ });
782
+
783
+ describe('decode()', () => {
784
+ const examples: Array<[{ targetRatio: number }, SubData]> = [
785
+ [
786
+ { targetRatio: 123 },
787
+ [
788
+ '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
789
+ '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
790
+ ],
791
+ ],
792
+ [
793
+ { targetRatio: 200 },
794
+ [
795
+ '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
796
+ '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
797
+ ],
798
+ ],
799
+ ];
800
+
801
+ examples.forEach(([expected, actual]) => {
802
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
803
+ expect(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
804
+ });
805
+ });
806
+ });
807
+ });
808
+
737
809
  describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
738
810
  describe('encode()', () => {
739
811
  const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
@@ -1492,6 +1564,116 @@ describe('Feature: subDataService.ts', () => {
1492
1564
  });
1493
1565
  });
1494
1566
 
1567
+ describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
1568
+ describe('encode()', () => {
1569
+ const examples: Array<[
1570
+ SubData,
1571
+ [loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress],
1572
+ ]> = [
1573
+ [
1574
+ [
1575
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1576
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1577
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1578
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1579
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1580
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1581
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1582
+ ],
1583
+ [
1584
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1585
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1586
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1587
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1588
+ '945000000000000000',
1589
+ 200,
1590
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1591
+ ],
1592
+ ],
1593
+ [
1594
+ [
1595
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1596
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1597
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1598
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1599
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1600
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1601
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1602
+ ],
1603
+ [
1604
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1605
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1606
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1607
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1608
+ '945000000000000000',
1609
+ 160,
1610
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1611
+ ],
1612
+ ],
1613
+ ];
1614
+
1615
+ examples.forEach(([expected, actual]) => {
1616
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1617
+ expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1618
+ });
1619
+ });
1620
+ });
1621
+
1622
+ describe('decode()', () => {
1623
+ const examples: Array<[
1624
+ { loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress },
1625
+ SubData,
1626
+ ]> = [
1627
+ [
1628
+ {
1629
+ loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1630
+ collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
1631
+ oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
1632
+ irm: '0x0000000000000000000000000000000000000000',
1633
+ lltv: '945000000000000000',
1634
+ targetRatio: 200,
1635
+ user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
1636
+ },
1637
+ [
1638
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1639
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1640
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1641
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1642
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1643
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1644
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1645
+ ],
1646
+ ],
1647
+ [
1648
+ {
1649
+ loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1650
+ collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
1651
+ oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
1652
+ irm: '0x0000000000000000000000000000000000000000',
1653
+ lltv: '945000000000000000',
1654
+ targetRatio: 160,
1655
+ user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
1656
+ },
1657
+ [
1658
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1659
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1660
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1661
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1662
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1663
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1664
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1665
+ ],
1666
+ ],
1667
+ ];
1668
+
1669
+ examples.forEach(([expected, actual]) => {
1670
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1671
+ expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1672
+ });
1673
+ });
1674
+ });
1675
+ });
1676
+
1495
1677
  describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
1496
1678
  describe('encode()', () => {
1497
1679
  const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]]> = [