@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
@@ -164,9 +164,6 @@ export const makerLeverageManagementSubData = {
164
164
  return { vaultId, targetRatio };
165
165
  },
166
166
  };
167
-
168
- // ! Any change here will PROBABLY require a change in makerLiquidationProtectionSubData as well, since it is copy paste
169
- // ! Double check before changing
170
167
  export const makerLeverageManagementWithoutSubProxy = {
171
168
  encode(
172
169
  vaultId: number,
@@ -187,28 +184,6 @@ export const makerLeverageManagementWithoutSubProxy = {
187
184
  },
188
185
  };
189
186
 
190
- export const makerLiquidationProtectionSubData = {
191
- encode(
192
- vaultId: number,
193
- targetRatio: number,
194
- daiAddr?: EthereumAddress,
195
- ): SubData {
196
- const encodedVaultId = AbiCoder.encodeParameter('uint256', vaultId);
197
- const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
198
- const encodedDaiAddr = AbiCoder.encodeParameter('address', daiAddr || getAssetInfo('DAI', 1).address);
199
-
200
- return [encodedVaultId, encodedTargetRatio, encodedDaiAddr];
201
- },
202
- decode(subData: SubData): { vaultId: number, targetRatio: number, daiAddr: string } {
203
- const vaultId = +AbiCoder.decodeParameter('uint256', subData[0])!.toString();
204
- const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[1]) as any as string);
205
- const daiAddr = AbiCoder.decodeParameter('address', subData[2])!.toString();
206
-
207
- return { vaultId, targetRatio, daiAddr };
208
- },
209
- };
210
-
211
-
212
187
  /**
213
188
  __ __ ______ __ __ __ .___________.____ ____ ____ ____ __
214
189
  | | | | / __ \ | | | | | | | |\ \ / / \ \ / / /_ |
@@ -603,9 +578,6 @@ export const aaveV3LeverageManagementSubData = {
603
578
  return { targetRatio };
604
579
  },
605
580
  };
606
-
607
- // ! Any change here will PROBABLY require a change in aaveV3LiquidationProtectionSubData as well
608
- // ! Double check before changing. Liquidation protection is using Generic encoding for both - EOA and SW
609
581
  export const aaveV3LeverageManagementSubDataWithoutSubProxy = {
610
582
  encode(
611
583
  targetRatio: number,
@@ -633,30 +605,6 @@ export const aaveV3LeverageManagementSubDataWithoutSubProxy = {
633
605
  return { targetRatio, ratioState };
634
606
  },
635
607
  };
636
-
637
- export const aaveV3LiquidationProtectionSubData = {
638
- encode(
639
- targetRatio: number,
640
- ratioState: RatioState,
641
- market: EthereumAddress,
642
- user: EthereumAddress,
643
- ): SubData {
644
- const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
645
- const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
646
- const encodedMarket = AbiCoder.encodeParameter('address', market);
647
- const encodedUser = AbiCoder.encodeParameter('address', user);
648
-
649
- return [encodedTargetRatio, encodedRatioState, encodedMarket, encodedUser];
650
- },
651
- decode(subData: SubData): { targetRatio: number, ratioState: RatioState } {
652
- const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[0]) as any as string);
653
- const ratioState = AbiCoder.decodeParameter('uint8', subData[1]) as any as RatioState;
654
-
655
- return { targetRatio, ratioState };
656
- },
657
- };
658
-
659
-
660
608
  export const aaveV3LeverageManagementOnPriceGeneric = {
661
609
  encode(
662
610
  collAsset: EthereumAddress,
@@ -903,9 +851,6 @@ export const aaveV3LeverageManagementOnPriceSubData = {
903
851
  / _____ \ / _____ \ \ / | |____ \ / | |
904
852
  /__/ \__\ /__/ \__\ \__/ |_______| \__/ |_|
905
853
  */
906
-
907
- // ! Any change here will PROBABLY require a change in aaveV4LiquidationProtectionSubData as well, since it is copy paste
908
- // ! Double check before changing
909
854
  export const aaveV4LeverageManagementSubData = {
910
855
  encode: (
911
856
  spoke: EthereumAddress,
@@ -937,39 +882,6 @@ export const aaveV4LeverageManagementSubData = {
937
882
  };
938
883
  },
939
884
  };
940
-
941
- export const aaveV4LiquidationProtectionSubData = {
942
- encode: (
943
- spoke: EthereumAddress,
944
- owner: EthereumAddress,
945
- ratioState: RatioState,
946
- targetRatio: number,
947
- ) => {
948
- const spokeEncoded = AbiCoder.encodeParameter('address', spoke);
949
- const ownerEncoded = AbiCoder.encodeParameter('address', owner);
950
- const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
951
- const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
952
- // Add two empty slots for future addons (e.g tsi or slippage settings)
953
- return [
954
- spokeEncoded,
955
- ownerEncoded,
956
- ratioStateEncoded,
957
- targetRatioEncoded,
958
- EMPTY_SLOT,
959
- EMPTY_SLOT,
960
- ];
961
- },
962
- decode: (subData: SubData) => {
963
- const spoke = AbiCoder.decodeParameter('address', subData[0]) as unknown as EthereumAddress;
964
- const owner = AbiCoder.decodeParameter('address', subData[1]) as unknown as EthereumAddress;
965
- const ratioState = Number(AbiCoder.decodeParameter('uint8', subData[2])) as RatioState;
966
- const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[3]) as any as string);
967
- return {
968
- spoke, owner, ratioState, targetRatio,
969
- };
970
- },
971
- };
972
-
973
885
  export const aaveV4LeverageManagementOnPriceSubData = {
974
886
  encode: (
975
887
  spoke: EthereumAddress,
@@ -1169,35 +1081,36 @@ export const compoundV2LeverageManagementSubDataWithoutSubProxy = {
1169
1081
  | `----.| `--' | | | | | | | \ / ___) |
1170
1082
  \______| \______/ |__| |__| | _| \__/ |____/
1171
1083
  */
1172
-
1173
- // ! Any change here will PROBABLY require a change in compoundV3LiquidationProtectionSubDataWithoutSubProxy as well, since it is copy paste
1174
- // ! Double check before changing
1175
- export const compoundV3LeverageManagementSubDataWithoutSubProxy = {
1084
+ export const compoundV3LeverageManagementSubData = {
1176
1085
  encode(
1177
1086
  market: EthereumAddress,
1178
1087
  baseToken: EthereumAddress,
1179
- targetRatio: number,
1180
- ratioState: RatioState,
1088
+ triggerRepayRatio: number,
1089
+ triggerBoostRatio: number,
1090
+ targetBoostRatio: number,
1091
+ targetRepayRatio: number,
1092
+ boostEnabled: boolean,
1093
+ isEOA: boolean,
1181
1094
  ): SubData {
1182
- const encodedMarket = AbiCoder.encodeParameter('address', market);
1183
- const encodedBaseToken = AbiCoder.encodeParameter('address', baseToken);
1184
- const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
1185
- const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
1186
- return [encodedMarket, encodedBaseToken, encodedRatioState, encodedTargetRatio];
1095
+ return [
1096
+ market,
1097
+ baseToken,
1098
+ new Dec(triggerRepayRatio).mul(1e16).toString(),
1099
+ new Dec(triggerBoostRatio).mul(1e16).toString(),
1100
+ new Dec(targetBoostRatio).mul(1e16).toString(),
1101
+ new Dec(targetRepayRatio).mul(1e16).toString(),
1102
+ // @ts-ignore // TODO
1103
+ boostEnabled, isEOA,
1104
+ ];
1187
1105
  },
1188
- decode(subData: SubData): { market: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState } {
1189
- const market = AbiCoder.decodeParameter('address', subData[0]) as any as EthereumAddress;
1190
- const baseToken = AbiCoder.decodeParameter('address', subData[1]) as any as EthereumAddress;
1191
- const ratioState = AbiCoder.decodeParameter('uint8', subData[2]) as any as RatioState;
1192
- const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[3]) as any as string);
1106
+ decode(subData: SubData): { targetRatio: number } {
1107
+ const weiRatio = AbiCoder.decodeParameter('uint256', subData[3]) as any as string;
1108
+ const targetRatio = weiToRatioPercentage(weiRatio);
1193
1109
 
1194
- return {
1195
- market, baseToken, targetRatio, ratioState,
1196
- };
1110
+ return { targetRatio };
1197
1111
  },
1198
1112
  };
1199
-
1200
- export const compoundV3LiquidationProtectionSubDataWithoutSubProxy = {
1113
+ export const compoundV3LeverageManagementSubDataWithoutSubProxy = {
1201
1114
  encode(
1202
1115
  market: EthereumAddress,
1203
1116
  baseToken: EthereumAddress,
@@ -1221,7 +1134,6 @@ export const compoundV3LiquidationProtectionSubDataWithoutSubProxy = {
1221
1134
  };
1222
1135
  },
1223
1136
  };
1224
-
1225
1137
  export const compoundV3LeverageManagementOnPriceSubData = {
1226
1138
  encode(
1227
1139
  market: EthereumAddress,
@@ -1389,9 +1301,6 @@ export const sparkLeverageManagementSubData = {
1389
1301
  return { targetRatio };
1390
1302
  },
1391
1303
  };
1392
-
1393
- // ! Any change here will PROBABLY require a change in sparkLiquidationProtectionSubData as well, since it is copy paste
1394
- // ! Double check before changing
1395
1304
  export const sparkLeverageManagementSubDataWithoutSubProxy = {
1396
1305
  encode(
1397
1306
  targetRatio: number,
@@ -1411,28 +1320,6 @@ export const sparkLeverageManagementSubDataWithoutSubProxy = {
1411
1320
  return { targetRatio, ratioState };
1412
1321
  },
1413
1322
  };
1414
-
1415
- export const sparkLiquidationProtectionSubData = {
1416
- encode(
1417
- targetRatio: number,
1418
- ratioState: RatioState,
1419
- ): SubData {
1420
- const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
1421
- const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
1422
- const encodedUseDefaultMarket = AbiCoder.encodeParameter('bool', true);
1423
- const encodedUseOnBehalf = AbiCoder.encodeParameter('bool', false);
1424
-
1425
- return [encodedTargetRatio, encodedRatioState, encodedUseDefaultMarket, encodedUseOnBehalf];
1426
- },
1427
- decode(subData: SubData): { targetRatio: number, ratioState: RatioState } {
1428
- const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[0]) as any as string);
1429
- const ratioState = AbiCoder.decodeParameter('uint8', subData[1]) as any as RatioState;
1430
-
1431
- return { targetRatio, ratioState };
1432
- },
1433
- };
1434
-
1435
-
1436
1323
  export const sparkCloseGenericSubData = {
1437
1324
  encode(
1438
1325
  collAsset: EthereumAddress,
@@ -1647,9 +1534,6 @@ export const crvUSDPaybackSubData = {
1647
1534
  | | | | | `--' | | |\ \----.| | | | | | | `--' |
1648
1535
  |__| |__| \______/ | _| `._____|| _| |__| |__| \______/
1649
1536
  */
1650
-
1651
- // ! Any change here will PROBABLY require a change in morphoBlueLiquidationProtectionSubData as well, since it is copy paste
1652
- // ! Double check before changing
1653
1537
  export const morphoBlueLeverageManagementSubData = {
1654
1538
  encode: (
1655
1539
  loanToken: EthereumAddress,
@@ -1694,53 +1578,6 @@ export const morphoBlueLeverageManagementSubData = {
1694
1578
  };
1695
1579
  },
1696
1580
  };
1697
-
1698
- export const morphoBlueLiquidationProtectionSubData = {
1699
- encode: (
1700
- loanToken: EthereumAddress,
1701
- collToken: EthereumAddress,
1702
- oracle: EthereumAddress,
1703
- irm: EthereumAddress,
1704
- lltv: string,
1705
- ratioState: RatioState,
1706
- targetRatio: number,
1707
- user: EthereumAddress,
1708
- isEOA: boolean,
1709
- ) => {
1710
- const loanTokenEncoded = AbiCoder.encodeParameter('address', loanToken);
1711
- const collTokenEncoded = AbiCoder.encodeParameter('address', collToken);
1712
- const oracleEncoded = AbiCoder.encodeParameter('address', oracle);
1713
- const irmEncoded = AbiCoder.encodeParameter('address', irm);
1714
- const lltvEncoded = AbiCoder.encodeParameter('uint256', lltv);
1715
- const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
1716
- const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
1717
- const userEncoded = AbiCoder.encodeParameter('address', user);
1718
- const isEOAEncoded = AbiCoder.encodeParameter('bool', isEOA);
1719
- return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, ratioStateEncoded, targetRatioEncoded, userEncoded, isEOAEncoded];
1720
- },
1721
- decode: (subData: SubData) => {
1722
- const loanToken = AbiCoder.decodeParameter('address', subData[0]) as unknown as EthereumAddress;
1723
- const collToken = AbiCoder.decodeParameter('address', subData[1]) as any as EthereumAddress;
1724
- const oracle = AbiCoder.decodeParameter('address', subData[2]) as any as EthereumAddress;
1725
- const irm = AbiCoder.decodeParameter('address', subData[3]) as any as EthereumAddress;
1726
- const lltv = AbiCoder.decodeParameter('uint256', subData[4]) as any as EthereumAddress;
1727
- const weiRatio = AbiCoder.decodeParameter('uint256', subData[6]) as any as EthereumAddress;
1728
- const user = AbiCoder.decodeParameter('address', subData[7]) as any as EthereumAddress;
1729
- const targetRatio = weiToRatioPercentage(weiRatio);
1730
-
1731
- return {
1732
- loanToken,
1733
- collToken,
1734
- oracle,
1735
- irm,
1736
- lltv,
1737
- user,
1738
- targetRatio,
1739
- };
1740
- },
1741
- };
1742
-
1743
-
1744
1581
  export const morphoBlueLeverageManagementOnPriceSubData = {
1745
1582
  encode(
1746
1583
  loanToken: EthereumAddress,
@@ -1829,8 +1666,6 @@ _______ __ __ __ __ _______
1829
1666
  | | | `----.| `--' | | | | '--' |
1830
1667
  |__| |_______| \______/ |__| |_______/
1831
1668
  */
1832
- // ! Any change here will PROBABLY require a change in fluidLeverageManagementSubData as well, since it is copy paste
1833
- // ! Double check before changing
1834
1669
  export const fluidLeverageManagementSubData = {
1835
1670
  encode: (
1836
1671
  nftId: string,
@@ -1873,45 +1708,3 @@ export const fluidLeverageManagementSubData = {
1873
1708
  };
1874
1709
  },
1875
1710
  };
1876
-
1877
- export const fluidLiquidationProtectionSubData = {
1878
- encode: (
1879
- nftId: string,
1880
- vault: EthereumAddress,
1881
- ratioState: RatioState,
1882
- targetRatio: number,
1883
- ) => {
1884
- const nftIdEncoded = AbiCoder.encodeParameter('uint256', nftId);
1885
- const vaultEncoded = AbiCoder.encodeParameter('address', vault);
1886
- const ratioStateEncoded = AbiCoder.encodeParameter('uint8', ratioState);
1887
- const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
1888
- const wrapEthEncoded = AbiCoder.encodeParameter('bool', true);
1889
-
1890
- const collActionType = CollActionType.WITHDRAW;
1891
- const debtActionType = DebtActionType.PAYBACK;
1892
-
1893
- const collActionTypeEncoded = AbiCoder.encodeParameter('uint8', collActionType);
1894
- const debtActionTypeEncoded = AbiCoder.encodeParameter('uint8', debtActionType);
1895
-
1896
- return [
1897
- nftIdEncoded,
1898
- vaultEncoded,
1899
- ratioStateEncoded,
1900
- targetRatioEncoded,
1901
- wrapEthEncoded,
1902
- collActionTypeEncoded,
1903
- debtActionTypeEncoded,
1904
- ];
1905
- },
1906
- decode: (subData: SubData) => {
1907
- const nftId = AbiCoder.decodeParameter('uint256', subData[0]) as any as string;
1908
- const vault = AbiCoder.decodeParameter('address', subData[1]) as unknown as EthereumAddress;
1909
- const ratioState = AbiCoder.decodeParameter('uint8', subData[2]) as any as RatioState;
1910
- const weiRatio = AbiCoder.decodeParameter('uint256', subData[3]) as any as string;
1911
- const targetRatio = weiToRatioPercentage(weiRatio);
1912
-
1913
- return {
1914
- nftId, vault, ratioState, targetRatio,
1915
- };
1916
- },
1917
- };
@@ -32,6 +32,7 @@ import {
32
32
  compoundV3PriceRangeTrigger,
33
33
  aaveV3QuotePriceRangeTrigger,
34
34
  morphoBluePriceRangeTrigger,
35
+ morphoBluePriceTrigger,
35
36
  sparkQuotePriceTrigger,
36
37
  aaveV4RatioTrigger,
37
38
  aaveV4QuotePriceTrigger,
@@ -1287,6 +1288,74 @@ describe('Feature: triggerService.ts', () => {
1287
1288
  });
1288
1289
  });
1289
1290
  });
1291
+
1292
+ describe('When testing triggerService.morphoBluePriceTrigger', () => {
1293
+ describe('encode()', () => {
1294
+ const examples: Array<[[string], [oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, price: number, priceState: RatioState]]> = [
1295
+ [
1296
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1297
+ [
1298
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1299
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1300
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1301
+ 2500,
1302
+ RatioState.UNDER,
1303
+ ],
1304
+ ],
1305
+ [
1306
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1307
+ [
1308
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1309
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1310
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1311
+ 4000,
1312
+ RatioState.OVER,
1313
+ ],
1314
+ ],
1315
+ ];
1316
+
1317
+ examples.forEach(([expected, actual]) => {
1318
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1319
+ expect(morphoBluePriceTrigger.encode(...actual)).to.eql(expected);
1320
+ });
1321
+ });
1322
+ });
1323
+
1324
+ describe('decode()', () => {
1325
+ const examples: Array<[
1326
+ { oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, price: string, priceState: RatioState },
1327
+ TriggerData,
1328
+ ]> = [
1329
+ [
1330
+ {
1331
+ oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1332
+ collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1333
+ loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1334
+ price: '2500',
1335
+ priceState: RatioState.UNDER,
1336
+ },
1337
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1338
+ ],
1339
+ [
1340
+ {
1341
+ oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1342
+ collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1343
+ loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1344
+ price: '4000',
1345
+ priceState: RatioState.OVER,
1346
+ },
1347
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1348
+ ],
1349
+ ];
1350
+
1351
+ examples.forEach(([expected, actual]) => {
1352
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1353
+ expect(morphoBluePriceTrigger.decode(actual)).to.eql(expected);
1354
+ });
1355
+ });
1356
+ });
1357
+ });
1358
+
1290
1359
  describe('When testing triggerService.aaveV4RatioTrigger', () => {
1291
1360
  describe('encode()', () => {
1292
1361
  const examples: Array<[[string], [owner: EthereumAddress, spoke: EthereumAddress, ratioPercentage: number, ratioState: RatioState]]> = [
@@ -2,7 +2,7 @@ import { expect } from 'chai';
2
2
  import { getAssetInfo } from '@defisaver/tokens';
3
3
 
4
4
  import type { EthereumAddress } from '../types';
5
- import { Bundles, ChainId, ProtocolIdentifiers, RatioState } from '../types/enums';
5
+ import { ChainId, ProtocolIdentifiers, RatioState } from '../types/enums';
6
6
 
7
7
  import '../configuration';
8
8
  import {
@@ -11,7 +11,6 @@ import {
11
11
  compareAddresses,
12
12
  encodeSubId,
13
13
  ethToWeth,
14
- getCompoundV3LeverageManagementBundleId,
15
14
  getRatioStateInfoForAaveCloseStrategy,
16
15
  isAddress,
17
16
  isDefined,
@@ -370,34 +369,4 @@ describe('Feature: utils.ts', () => {
370
369
  });
371
370
  });
372
371
  });
373
-
374
- describe('When testing utils.getCompoundV3LeverageManagementBundleId()', () => {
375
- // Mainnet uses the V2 bundle ids; L2s use the original bundle ids.
376
- const examples: Array<[number, [network: ChainId, isEOA: boolean, isBoost: boolean]]> = [
377
- [Bundles.MainnetIds.COMP_V3_SW_REPAY_V2_BUNDLE, [ChainId.Ethereum, false, false]],
378
- [Bundles.MainnetIds.COMP_V3_SW_BOOST_V2_BUNDLE, [ChainId.Ethereum, false, true]],
379
- [Bundles.MainnetIds.COMP_V3_EOA_REPAY_V2_BUNDLE, [ChainId.Ethereum, true, false]],
380
- [Bundles.MainnetIds.COMP_V3_EOA_BOOST_V2_BUNDLE, [ChainId.Ethereum, true, true]],
381
-
382
- [Bundles.BaseIds.COMP_V3_SW_REPAY_BUNDLE, [ChainId.Base, false, false]],
383
- [Bundles.BaseIds.COMP_V3_SW_BOOST_BUNDLE, [ChainId.Base, false, true]],
384
- [Bundles.BaseIds.COMP_V3_EOA_REPAY, [ChainId.Base, true, false]],
385
- [Bundles.BaseIds.COMP_V3_EOA_BOOST, [ChainId.Base, true, true]],
386
-
387
- [Bundles.ArbitrumIds.COMP_V3_SW_REPAY_BUNDLE, [ChainId.Arbitrum, false, false]],
388
- [Bundles.ArbitrumIds.COMP_V3_SW_BOOST_BUNDLE, [ChainId.Arbitrum, false, true]],
389
- [Bundles.ArbitrumIds.COMP_V3_EOA_REPAY, [ChainId.Arbitrum, true, false]],
390
- [Bundles.ArbitrumIds.COMP_V3_EOA_BOOST, [ChainId.Arbitrum, true, true]],
391
- ];
392
-
393
- examples.forEach(([expected, actual]) => {
394
- it(`Given ${actual} should return expected value: ${expected}`, () => {
395
- expect(getCompoundV3LeverageManagementBundleId(...actual)).to.equal(expected);
396
- });
397
- });
398
-
399
- it(`Given ${ChainId.Optimism} (unsupported) should throw an error`, () => {
400
- expect(() => getCompoundV3LeverageManagementBundleId(ChainId.Optimism, false, false)).to.throw(Error);
401
- });
402
- });
403
372
  });
@@ -5,7 +5,6 @@ import { getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
5
5
 
6
6
  import type { EthereumAddress } from '../types';
7
7
  import {
8
- Bundles,
9
8
  ChainId, CloseStrategyType, CloseToAssetType, RatioState,
10
9
  } from '../types/enums';
11
10
 
@@ -172,34 +171,4 @@ export function getStopLossAndTakeProfitTypeByCloseStrategyType(
172
171
  default:
173
172
  throw new Error('CloseStrategyType not supported');
174
173
  }
175
- }
176
-
177
- export function getBundleIdsByNetwork(network: ChainId) {
178
- switch (Number(network)) {
179
- case ChainId.Ethereum:
180
- return Bundles.MainnetIds;
181
- case ChainId.Arbitrum:
182
- return Bundles.ArbitrumIds;
183
- case ChainId.Base:
184
- return Bundles.BaseIds;
185
- default:
186
- throw new Error(`Unsupported network ${network}`);
187
- }
188
- }
189
-
190
- // Mainnet uses the V2 bundle ids; L2s use the original bundle ids.
191
- export function getCompoundV3LeverageManagementBundleId(network: ChainId, isEOA: boolean, isBoost: boolean): number {
192
- switch (Number(network)) {
193
- case ChainId.Ethereum:
194
- if (isEOA) return isBoost ? Bundles.MainnetIds.COMP_V3_EOA_BOOST_V2_BUNDLE : Bundles.MainnetIds.COMP_V3_EOA_REPAY_V2_BUNDLE;
195
- return isBoost ? Bundles.MainnetIds.COMP_V3_SW_BOOST_V2_BUNDLE : Bundles.MainnetIds.COMP_V3_SW_REPAY_V2_BUNDLE;
196
- case ChainId.Base:
197
- if (isEOA) return isBoost ? Bundles.BaseIds.COMP_V3_EOA_BOOST : Bundles.BaseIds.COMP_V3_EOA_REPAY;
198
- return isBoost ? Bundles.BaseIds.COMP_V3_SW_BOOST_BUNDLE : Bundles.BaseIds.COMP_V3_SW_REPAY_BUNDLE;
199
- case ChainId.Arbitrum:
200
- if (isEOA) return isBoost ? Bundles.ArbitrumIds.COMP_V3_EOA_BOOST : Bundles.ArbitrumIds.COMP_V3_EOA_REPAY;
201
- return isBoost ? Bundles.ArbitrumIds.COMP_V3_SW_BOOST_BUNDLE : Bundles.ArbitrumIds.COMP_V3_SW_REPAY_BUNDLE;
202
- default:
203
- throw new Error(`Compound V3 leverage management is not supported on network ${network}`);
204
- }
205
- }
174
+ }
@@ -153,8 +153,6 @@ export namespace Strategies {
153
153
  EoaRepayOnPrice = 'eoa-repay-on-price',
154
154
  CollateralSwitch = 'collateral-switch',
155
155
  EoaCollateralSwitch = 'eoa-collateral-switch',
156
- LiquidationProtection = 'liquidation-protection',
157
- EoaLiquidationProtection = 'liquidation-protection-eoa',
158
156
  }
159
157
  export enum IdOverrides {
160
158
  TakeProfit = 'take-profit',
@@ -166,8 +164,6 @@ export namespace Strategies {
166
164
  EoaLeverageManagement = 'leverage-management-eoa',
167
165
  LeverageManagementOnPrice = 'leverage-management-on-price',
168
166
  EoaLeverageManagementOnPrice = 'leverage-management-on-price-eoa',
169
- LiquidationProtection = 'liquidation-protection',
170
- EoaLiquidationProtection = 'liquidation-protection-eoa',
171
167
  }
172
168
  }
173
169
 
@@ -244,17 +240,7 @@ export namespace Bundles {
244
240
  AAVE_V4_EOA_REPAY_ON_PRICE = 68,
245
241
  AAVE_V4_EOA_BOOST_ON_PRICE = 69,
246
242
  AAVE_V4_EOA_CLOSE = 70,
247
- AAVE_V3_SW_LIQUIDATION_PROTECTION = 71,
248
- SPARK_SW_LIQUIDATION_PROTECTION = 72,
249
- MAKER_SW_LIQUIDATION_PROTECTION = 75,
250
- FLUID_T1_SW_LIQUIDATION_PROTECTION = 76,
251
- AAVE_V4_SW_LIQUIDATION_PROTECTION = 77,
252
- MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 78,
253
- AAVE_V3_EOA_LIQUIDATION_PROTECTION = 79,
254
- AAVE_V4_EOA_LIQUIDATION_PROTECTION = 80,
255
- MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 81,
256
- COMP_V3_SW_LIQUIDATION_PROTECTION = 82,
257
- COMP_V3_EOA_LIQUIDATION_PROTECTION = 83,
243
+ MORPHO_BLUE_REPAY_ON_PRICE = 84,
258
244
  }
259
245
 
260
246
  export enum OptimismIds {
@@ -269,8 +255,6 @@ export namespace Bundles {
269
255
  AAVE_V3_EOA_REPAY_ON_PRICE = 8,
270
256
  AAVE_V3_EOA_BOOST_ON_PRICE = 9,
271
257
  AAVE_V3_EOA_CLOSE = 10,
272
- AAVE_V3_SW_LIQUIDATION_PROTECTION = 11,
273
- AAVE_V3_EOA_LIQUIDATION_PROTECTION = 12,
274
258
  }
275
259
 
276
260
  export enum BaseIds {
@@ -301,12 +285,7 @@ export namespace Bundles {
301
285
  AAVE_V3_EOA_BOOST_ON_PRICE = 26,
302
286
  AAVE_V3_EOA_CLOSE = 27,
303
287
  MORPHO_BLUE_CLOSE = 28,
304
- AAVE_V3_SW_LIQUIDATION_PROTECTION = 29,
305
- FLUID_T1_SW_LIQUIDATION_PROTECTION = 30,
306
- COMP_V3_SW_LIQUIDATION_PROTECTION = 32,
307
- COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
308
- AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
309
- MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 35,
288
+ MORPHO_BLUE_REPAY_ON_PRICE = 36,
310
289
  }
311
290
 
312
291
  export enum ArbitrumIds {
@@ -339,12 +318,8 @@ export namespace Bundles {
339
318
  MORPHO_BLUE_EOA_REPAY = 26,
340
319
  MORPHO_BLUE_EOA_BOOST = 27,
341
320
  MORPHO_BLUE_CLOSE = 28,
342
- AAVE_V3_SW_LIQUIDATION_PROTECTION = 29,
343
- FLUID_T1_SW_LIQUIDATION_PROTECTION = 30,
344
- MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 31,
345
- COMP_V3_SW_LIQUIDATION_PROTECTION = 32,
346
- COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
347
- AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
348
- MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 35,
321
+ MORPHO_BLUE_REPAY_ON_PRICE = 36,
349
322
  }
350
323
  }
324
+
325
+