@defisaver/automation-sdk 3.3.15 → 3.3.16-liq-prot-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.
Files changed (42) hide show
  1. package/cjs/constants/index.js +145 -0
  2. package/cjs/index.d.ts +2 -2
  3. package/cjs/index.js +5 -2
  4. package/cjs/services/strategiesService.js +158 -9
  5. package/cjs/services/strategySubService.d.ts +17 -16
  6. package/cjs/services/strategySubService.js +69 -28
  7. package/cjs/services/strategySubService.test.js +69 -40
  8. package/cjs/services/subDataService.d.ts +70 -20
  9. package/cjs/services/subDataService.js +23 -79
  10. package/cjs/services/subDataService.test.js +117 -202
  11. package/cjs/services/triggerService.test.js +60 -0
  12. package/cjs/services/utils.d.ts +2 -1
  13. package/cjs/services/utils.js +14 -1
  14. package/cjs/types/enums.d.ts +39 -6
  15. package/cjs/types/enums.js +33 -0
  16. package/esm/constants/index.js +145 -0
  17. package/esm/index.d.ts +2 -2
  18. package/esm/index.js +5 -2
  19. package/esm/services/strategiesService.js +158 -9
  20. package/esm/services/strategySubService.d.ts +17 -16
  21. package/esm/services/strategySubService.js +69 -28
  22. package/esm/services/strategySubService.test.js +70 -38
  23. package/esm/services/subDataService.d.ts +70 -20
  24. package/esm/services/subDataService.js +21 -77
  25. package/esm/services/subDataService.test.js +118 -200
  26. package/esm/services/triggerService.test.js +61 -1
  27. package/esm/services/utils.d.ts +2 -1
  28. package/esm/services/utils.js +13 -1
  29. package/esm/types/enums.d.ts +39 -6
  30. package/esm/types/enums.js +33 -0
  31. package/package.json +1 -1
  32. package/src/constants/index.ts +147 -1
  33. package/src/index.ts +22 -6
  34. package/src/services/strategiesService.ts +222 -9
  35. package/src/services/strategySubService.test.ts +86 -46
  36. package/src/services/strategySubService.ts +166 -39
  37. package/src/services/subDataService.test.ts +128 -214
  38. package/src/services/subDataService.ts +42 -106
  39. package/src/services/triggerService.test.ts +69 -0
  40. package/src/services/utils.test.ts +1 -1
  41. package/src/services/utils.ts +15 -1
  42. package/src/types/enums.ts +33 -2
@@ -22,11 +22,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const decimal_js_1 = __importDefault(require("decimal.js"));
30
26
  const chai_1 = require("chai");
31
27
  const tokens_1 = require("@defisaver/tokens");
32
28
  const web3Utils = __importStar(require("web3-utils"));
@@ -146,7 +142,7 @@ describe('Feature: subDataService.ts', () => {
146
142
  });
147
143
  });
148
144
  });
149
- describe('When testing subDataService.makerLeverageManagementSubData', () => {
145
+ describe('When testing subDataService.legacyMakerLeverageManagementSubData', () => {
150
146
  describe('decode()', () => {
151
147
  const examples = [
152
148
  [
@@ -159,12 +155,12 @@ describe('Feature: subDataService.ts', () => {
159
155
  ];
160
156
  examples.forEach(([expected, actual]) => {
161
157
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
162
- (0, chai_1.expect)(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
158
+ (0, chai_1.expect)(subDataService.legacyMakerLeverageManagementSubData.decode(actual)).to.eql(expected);
163
159
  });
164
160
  });
165
161
  });
166
162
  });
167
- describe('When testing subDataService.makerLeverageManagementWithoutSubProxy', () => {
163
+ describe('When testing subDataService.makerLeverageManagementSubData', () => {
168
164
  describe('encode()', () => {
169
165
  const examples = [
170
166
  [
@@ -184,7 +180,7 @@ describe('Feature: subDataService.ts', () => {
184
180
  ];
185
181
  examples.forEach(([expected, actual]) => {
186
182
  it(`Given ${actual} should return expected value: ${expected}`, () => {
187
- (0, chai_1.expect)(subDataService.makerLeverageManagementWithoutSubProxy.encode(...actual)).to.eql(expected);
183
+ (0, chai_1.expect)(subDataService.makerLeverageManagementSubData.encode(...actual)).to.eql(expected);
188
184
  });
189
185
  });
190
186
  });
@@ -215,12 +211,12 @@ describe('Feature: subDataService.ts', () => {
215
211
  ];
216
212
  examples.forEach(([expected, actual]) => {
217
213
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
218
- (0, chai_1.expect)(subDataService.makerLeverageManagementWithoutSubProxy.decode(actual)).to.eql(expected);
214
+ (0, chai_1.expect)(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
219
215
  });
220
216
  });
221
217
  });
222
218
  });
223
- describe('When testing subDataService.liquityLeverageManagementSubData', () => {
219
+ describe('When testing subDataService.legacyLiquityLeverageManagementSubData', () => {
224
220
  describe('decode()', () => {
225
221
  const examples = [
226
222
  [
@@ -233,7 +229,7 @@ describe('Feature: subDataService.ts', () => {
233
229
  ];
234
230
  examples.forEach(([expected, actual]) => {
235
231
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
236
- (0, chai_1.expect)(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
232
+ (0, chai_1.expect)(subDataService.legacyLiquityLeverageManagementSubData.decode(actual)).to.eql(expected);
237
233
  });
238
234
  });
239
235
  });
@@ -288,24 +284,7 @@ describe('Feature: subDataService.ts', () => {
288
284
  });
289
285
  });
290
286
  });
291
- describe('When testing subDataService.aaveV2LeverageManagementSubData', () => {
292
- describe('encode()', () => {
293
- const examples = [
294
- [
295
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
296
- [160, 220, 180, 190, true]
297
- ],
298
- [
299
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
300
- [160, 200, 180, 190, false]
301
- ],
302
- ];
303
- examples.forEach(([expected, actual]) => {
304
- it(`Given ${actual} should return expected value: ${expected}`, () => {
305
- (0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
306
- });
307
- });
308
- });
287
+ describe('When testing subDataService.legacyAaveV2LeverageManagementSubData', () => {
309
288
  describe('decode()', () => {
310
289
  const examples = [
311
290
  [
@@ -319,12 +298,12 @@ describe('Feature: subDataService.ts', () => {
319
298
  ];
320
299
  examples.forEach(([expected, actual]) => {
321
300
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
322
- (0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
301
+ (0, chai_1.expect)(subDataService.legacyAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
323
302
  });
324
303
  });
325
304
  });
326
305
  });
327
- describe('When testing subDataService.aaveV3LeverageManagementSubData', () => {
306
+ describe('When testing subDataService.legacyAaveV3LeverageManagementSubData', () => {
328
307
  describe('decode()', () => {
329
308
  const examples = [
330
309
  [
@@ -338,7 +317,7 @@ describe('Feature: subDataService.ts', () => {
338
317
  ];
339
318
  examples.forEach(([expected, actual]) => {
340
319
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
341
- (0, chai_1.expect)(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
320
+ (0, chai_1.expect)(subDataService.legacyAaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
342
321
  });
343
322
  });
344
323
  });
@@ -677,24 +656,7 @@ describe('Feature: subDataService.ts', () => {
677
656
  });
678
657
  });
679
658
  });
680
- describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
681
- describe('encode()', () => {
682
- const examples = [
683
- [
684
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
685
- [160, 220, 180, 190, true]
686
- ],
687
- [
688
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
689
- [160, 200, 180, 190, false]
690
- ],
691
- ];
692
- examples.forEach(([expected, actual]) => {
693
- it(`Given ${actual} should return expected value: ${expected}`, () => {
694
- (0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
695
- });
696
- });
697
- });
659
+ describe('When testing subDataService.legacyCompoundV2LeverageManagementSubData', () => {
698
660
  describe('decode()', () => {
699
661
  const examples = [
700
662
  [
@@ -708,97 +670,12 @@ describe('Feature: subDataService.ts', () => {
708
670
  ];
709
671
  examples.forEach(([expected, actual]) => {
710
672
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
711
- (0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
712
- });
713
- });
714
- });
715
- });
716
- describe('When testing subDataService.compoundV3LeverageManagementSubData', () => {
717
- describe('encode()', () => {
718
- const examples = [
719
- [
720
- [
721
- web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
722
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
723
- new decimal_js_1.default(160).mul(1e16).toString(),
724
- new decimal_js_1.default(220).mul(1e16).toString(),
725
- new decimal_js_1.default(180).mul(1e16).toString(),
726
- new decimal_js_1.default(190).mul(1e16).toString(),
727
- true, false,
728
- ],
729
- [
730
- web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
731
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
732
- 160, 220, 180, 190,
733
- true, false,
734
- ]
735
- ],
736
- [
737
- [
738
- web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
739
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
740
- new decimal_js_1.default(160).mul(1e16).toString(),
741
- new decimal_js_1.default(210).mul(1e16).toString(),
742
- new decimal_js_1.default(180).mul(1e16).toString(),
743
- new decimal_js_1.default(190).mul(1e16).toString(),
744
- false, true,
745
- ],
746
- [
747
- web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
748
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
749
- 160, 210, 180, 190,
750
- false, true,
751
- ]
752
- ],
753
- ];
754
- examples.forEach(([expected, actual]) => {
755
- it(`Given ${actual} should return expected value: ${expected}`, () => {
756
- (0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
757
- });
758
- });
759
- });
760
- describe('decode()', () => {
761
- const examples = [
762
- [
763
- { targetRatio: 123 },
764
- [
765
- '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
766
- '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
767
- ],
768
- ],
769
- [
770
- { targetRatio: 200 },
771
- [
772
- '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
773
- '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
774
- ],
775
- ],
776
- ];
777
- examples.forEach(([expected, actual]) => {
778
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
779
- (0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
673
+ (0, chai_1.expect)(subDataService.legacyCompoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
780
674
  });
781
675
  });
782
676
  });
783
677
  });
784
678
  describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
785
- describe('encode()', () => {
786
- const examples = [
787
- [
788
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
789
- [160, 220, 180, 190, true]
790
- ],
791
- [
792
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
793
- [160, 200, 180, 190, false]
794
- ],
795
- ];
796
- examples.forEach(([expected, actual]) => {
797
- it(`Given ${actual} should return expected value: ${expected}`, () => {
798
- (0, chai_1.expect)(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
799
- });
800
- });
801
- });
802
679
  describe('decode()', () => {
803
680
  const examples = [
804
681
  [
@@ -818,23 +695,6 @@ describe('Feature: subDataService.ts', () => {
818
695
  });
819
696
  });
820
697
  describe('When testing subDataService.cBondsRebondSubData', () => {
821
- describe('encode()', () => {
822
- const examples = [
823
- [
824
- ['0x00000000000000000000000000000000000000000000000000000000000000c8'],
825
- [200]
826
- ],
827
- [
828
- ['0x000000000000000000000000000000000000000000000000000000000000a119'],
829
- [41241]
830
- ],
831
- ];
832
- examples.forEach(([expected, actual]) => {
833
- it(`Given ${actual} should return expected value: ${expected}`, () => {
834
- (0, chai_1.expect)(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
835
- });
836
- });
837
- });
838
698
  describe('decode()', () => {
839
699
  const examples = [
840
700
  [
@@ -975,52 +835,7 @@ describe('Feature: subDataService.ts', () => {
975
835
  });
976
836
  });
977
837
  });
978
- describe('When testing subDataService.exchangeLimitOrderSubData', () => {
979
- describe('encode()', () => {
980
- const examples = [
981
- [
982
- [
983
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
984
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
985
- '2131',
986
- '0.53123',
987
- '1696590921159',
988
- `${enums_1.OrderType.STOP_LOSS}`
989
- ],
990
- [
991
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
992
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
993
- '2131',
994
- '0.53123',
995
- 1696590921159,
996
- enums_1.OrderType.STOP_LOSS
997
- ]
998
- ],
999
- [
1000
- [
1001
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
1002
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
1003
- '2131',
1004
- '0.43123',
1005
- '1646590921159',
1006
- `${enums_1.OrderType.TAKE_PROFIT}`
1007
- ],
1008
- [
1009
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
1010
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
1011
- '2131',
1012
- '0.43123',
1013
- 1646590921159,
1014
- enums_1.OrderType.TAKE_PROFIT
1015
- ]
1016
- ],
1017
- ];
1018
- examples.forEach(([expected, actual]) => {
1019
- it(`Given ${actual} should return expected value: ${expected}`, () => {
1020
- (0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
1021
- });
1022
- });
1023
- });
838
+ describe('When testing subDataService.legacyExchangeLimitOrderSubData', () => {
1024
839
  describe('decode()', () => {
1025
840
  const examples = [
1026
841
  [
@@ -1054,12 +869,12 @@ describe('Feature: subDataService.ts', () => {
1054
869
  ];
1055
870
  examples.forEach(([expected, actual]) => {
1056
871
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1057
- (0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
872
+ (0, chai_1.expect)(subDataService.legacyExchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
1058
873
  });
1059
874
  });
1060
875
  });
1061
876
  });
1062
- describe('When testing subDataService.sparkLeverageManagementSubData', () => {
877
+ describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
1063
878
  describe('decode()', () => {
1064
879
  const examples = [
1065
880
  [
@@ -1073,7 +888,7 @@ describe('Feature: subDataService.ts', () => {
1073
888
  ];
1074
889
  examples.forEach(([expected, actual]) => {
1075
890
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1076
- (0, chai_1.expect)(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
891
+ (0, chai_1.expect)(subDataService.legacySparkLeverageManagementSubData.decode(actual)).to.eql(expected);
1077
892
  });
1078
893
  });
1079
894
  });
@@ -1479,6 +1294,106 @@ describe('Feature: subDataService.ts', () => {
1479
1294
  });
1480
1295
  });
1481
1296
  });
1297
+ describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
1298
+ describe('encode()', () => {
1299
+ const examples = [
1300
+ [
1301
+ [
1302
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1303
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1304
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1305
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1306
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1307
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1308
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1309
+ ],
1310
+ [
1311
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1312
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1313
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1314
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1315
+ '945000000000000000',
1316
+ 200,
1317
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1318
+ ],
1319
+ ],
1320
+ [
1321
+ [
1322
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1323
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1324
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1325
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1326
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1327
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1328
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1329
+ ],
1330
+ [
1331
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1332
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1333
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1334
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1335
+ '945000000000000000',
1336
+ 160,
1337
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
1338
+ ],
1339
+ ],
1340
+ ];
1341
+ examples.forEach(([expected, actual]) => {
1342
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1343
+ (0, chai_1.expect)(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1344
+ });
1345
+ });
1346
+ });
1347
+ describe('decode()', () => {
1348
+ const examples = [
1349
+ [
1350
+ {
1351
+ loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1352
+ collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
1353
+ oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
1354
+ irm: '0x0000000000000000000000000000000000000000',
1355
+ lltv: '945000000000000000',
1356
+ targetRatio: 200,
1357
+ user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
1358
+ },
1359
+ [
1360
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1361
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1362
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1363
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1364
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1365
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1366
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1367
+ ],
1368
+ ],
1369
+ [
1370
+ {
1371
+ loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1372
+ collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
1373
+ oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
1374
+ irm: '0x0000000000000000000000000000000000000000',
1375
+ lltv: '945000000000000000',
1376
+ targetRatio: 160,
1377
+ user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
1378
+ },
1379
+ [
1380
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1381
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1382
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1383
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1384
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1385
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1386
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1387
+ ],
1388
+ ],
1389
+ ];
1390
+ examples.forEach(([expected, actual]) => {
1391
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1392
+ (0, chai_1.expect)(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1393
+ });
1394
+ });
1395
+ });
1396
+ });
1482
1397
  describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
1483
1398
  describe('encode()', () => {
1484
1399
  const examples = [
@@ -1184,6 +1184,66 @@ describe('Feature: triggerService.ts', () => {
1184
1184
  });
1185
1185
  });
1186
1186
  });
1187
+ describe('When testing triggerService.morphoBluePriceTrigger', () => {
1188
+ describe('encode()', () => {
1189
+ const examples = [
1190
+ [
1191
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1192
+ [
1193
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1194
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1195
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1196
+ 2500,
1197
+ enums_1.RatioState.UNDER,
1198
+ ],
1199
+ ],
1200
+ [
1201
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1202
+ [
1203
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1204
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1205
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1206
+ 4000,
1207
+ enums_1.RatioState.OVER,
1208
+ ],
1209
+ ],
1210
+ ];
1211
+ examples.forEach(([expected, actual]) => {
1212
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1213
+ (0, chai_1.expect)(triggerService_1.morphoBluePriceTrigger.encode(...actual)).to.eql(expected);
1214
+ });
1215
+ });
1216
+ });
1217
+ describe('decode()', () => {
1218
+ const examples = [
1219
+ [
1220
+ {
1221
+ oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1222
+ collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1223
+ loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1224
+ price: '2500',
1225
+ priceState: enums_1.RatioState.UNDER,
1226
+ },
1227
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1228
+ ],
1229
+ [
1230
+ {
1231
+ oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1232
+ collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1233
+ loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
1234
+ price: '4000',
1235
+ priceState: enums_1.RatioState.OVER,
1236
+ },
1237
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
1238
+ ],
1239
+ ];
1240
+ examples.forEach(([expected, actual]) => {
1241
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1242
+ (0, chai_1.expect)(triggerService_1.morphoBluePriceTrigger.decode(actual)).to.eql(expected);
1243
+ });
1244
+ });
1245
+ });
1246
+ });
1187
1247
  describe('When testing triggerService.aaveV4RatioTrigger', () => {
1188
1248
  describe('encode()', () => {
1189
1249
  const examples = [
@@ -1,5 +1,5 @@
1
1
  import type { EthereumAddress } from '../types';
2
- import { ChainId, CloseStrategyType, CloseToAssetType, RatioState } from '../types/enums';
2
+ import { Bundles, ChainId, CloseStrategyType, CloseToAssetType, RatioState } from '../types/enums';
3
3
  export declare function isDefined<T>(value: T): value is NonNullable<T>;
4
4
  export declare function isUndefined(value: unknown): boolean;
5
5
  export declare function compareAddresses(firstAddress: EthereumAddress, secondAddress: EthereumAddress): boolean;
@@ -28,3 +28,4 @@ export declare function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStr
28
28
  stopLossType: CloseToAssetType | undefined;
29
29
  takeProfitType: CloseToAssetType | undefined;
30
30
  };
31
+ export declare function getBundleIdsByNetwork(network: ChainId): typeof Bundles.MainnetIds | typeof Bundles.ArbitrumIds | typeof Bundles.BaseIds;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getStopLossAndTakeProfitTypeByCloseStrategyType = exports.getCloseStrategyType = exports.getPositionId = exports.getRatioStateInfoForAaveCloseStrategy = exports.requireAddresses = exports.requireAddress = exports.isEmptyBytes = exports.isRatioStateUnder = exports.isRatioStateOver = exports.weiToRatioPercentage = exports.ratioPercentageToWei = exports.encodeSubId = exports.compareSubHashes = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.addToArrayIf = exports.isAddress = exports.compareAddresses = exports.isUndefined = exports.isDefined = void 0;
29
+ exports.getBundleIdsByNetwork = exports.getStopLossAndTakeProfitTypeByCloseStrategyType = exports.getCloseStrategyType = exports.getPositionId = exports.getRatioStateInfoForAaveCloseStrategy = exports.requireAddresses = exports.requireAddress = exports.isEmptyBytes = exports.isRatioStateUnder = exports.isRatioStateOver = exports.weiToRatioPercentage = exports.ratioPercentageToWei = exports.encodeSubId = exports.compareSubHashes = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.addToArrayIf = exports.isAddress = exports.compareAddresses = exports.isUndefined = exports.isDefined = void 0;
30
30
  const decimal_js_1 = __importDefault(require("decimal.js"));
31
31
  const web3Utils = __importStar(require("web3-utils"));
32
32
  const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
@@ -188,3 +188,16 @@ function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStrategyType) {
188
188
  }
189
189
  }
190
190
  exports.getStopLossAndTakeProfitTypeByCloseStrategyType = getStopLossAndTakeProfitTypeByCloseStrategyType;
191
+ function getBundleIdsByNetwork(network) {
192
+ switch (Number(network)) {
193
+ case enums_1.ChainId.Ethereum:
194
+ return enums_1.Bundles.MainnetIds;
195
+ case enums_1.ChainId.Arbitrum:
196
+ return enums_1.Bundles.ArbitrumIds;
197
+ case enums_1.ChainId.Base:
198
+ return enums_1.Bundles.BaseIds;
199
+ default:
200
+ throw new Error(`Unsupported network ${network}`);
201
+ }
202
+ }
203
+ exports.getBundleIdsByNetwork = getBundleIdsByNetwork;
@@ -138,7 +138,9 @@ export declare namespace Strategies {
138
138
  EoaBoostOnPrice = "eoa-boost-on-price",
139
139
  EoaRepayOnPrice = "eoa-repay-on-price",
140
140
  CollateralSwitch = "collateral-switch",
141
- EoaCollateralSwitch = "eoa-collateral-switch"
141
+ EoaCollateralSwitch = "eoa-collateral-switch",
142
+ LiquidationProtection = "liquidation-protection",
143
+ EoaLiquidationProtection = "liquidation-protection-eoa"
142
144
  }
143
145
  enum IdOverrides {
144
146
  TakeProfit = "take-profit",
@@ -149,7 +151,9 @@ export declare namespace Strategies {
149
151
  LeverageManagement = "leverage-management",
150
152
  EoaLeverageManagement = "leverage-management-eoa",
151
153
  LeverageManagementOnPrice = "leverage-management-on-price",
152
- EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa"
154
+ EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa",
155
+ LiquidationProtection = "liquidation-protection",
156
+ EoaLiquidationProtection = "liquidation-protection-eoa"
153
157
  }
154
158
  }
155
159
  export declare namespace Bundles {
@@ -224,7 +228,19 @@ export declare namespace Bundles {
224
228
  AAVE_V4_EOA_BOOST = 67,
225
229
  AAVE_V4_EOA_REPAY_ON_PRICE = 68,
226
230
  AAVE_V4_EOA_BOOST_ON_PRICE = 69,
227
- AAVE_V4_EOA_CLOSE = 70
231
+ AAVE_V4_EOA_CLOSE = 70,
232
+ AAVE_V3_SW_LIQUIDATION_PROTECTION = 71,
233
+ SPARK_SW_LIQUIDATION_PROTECTION = 72,
234
+ MAKER_SW_LIQUIDATION_PROTECTION = 75,
235
+ FLUID_T1_SW_LIQUIDATION_PROTECTION = 76,
236
+ AAVE_V4_SW_LIQUIDATION_PROTECTION = 77,
237
+ MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 78,
238
+ AAVE_V3_EOA_LIQUIDATION_PROTECTION = 79,
239
+ AAVE_V4_EOA_LIQUIDATION_PROTECTION = 80,
240
+ MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 81,
241
+ COMP_V3_SW_LIQUIDATION_PROTECTION = 82,
242
+ COMP_V3_EOA_LIQUIDATION_PROTECTION = 83,
243
+ MORPHO_BLUE_REPAY_ON_PRICE = 84
228
244
  }
229
245
  enum OptimismIds {
230
246
  AAVE_V3_REPAY = 0,
@@ -237,7 +253,9 @@ export declare namespace Bundles {
237
253
  AAVE_V3_EOA_BOOST = 7,
238
254
  AAVE_V3_EOA_REPAY_ON_PRICE = 8,
239
255
  AAVE_V3_EOA_BOOST_ON_PRICE = 9,
240
- AAVE_V3_EOA_CLOSE = 10
256
+ AAVE_V3_EOA_CLOSE = 10,
257
+ AAVE_V3_SW_LIQUIDATION_PROTECTION = 11,
258
+ AAVE_V3_EOA_LIQUIDATION_PROTECTION = 12
241
259
  }
242
260
  enum BaseIds {
243
261
  AAVE_V3_REPAY = 0,
@@ -266,7 +284,14 @@ export declare namespace Bundles {
266
284
  AAVE_V3_EOA_REPAY_ON_PRICE = 25,
267
285
  AAVE_V3_EOA_BOOST_ON_PRICE = 26,
268
286
  AAVE_V3_EOA_CLOSE = 27,
269
- MORPHO_BLUE_CLOSE = 28
287
+ MORPHO_BLUE_CLOSE = 28,
288
+ AAVE_V3_SW_LIQUIDATION_PROTECTION = 29,
289
+ FLUID_T1_SW_LIQUIDATION_PROTECTION = 30,
290
+ COMP_V3_SW_LIQUIDATION_PROTECTION = 32,
291
+ COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
292
+ AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
293
+ MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 35,
294
+ MORPHO_BLUE_REPAY_ON_PRICE = 36
270
295
  }
271
296
  enum ArbitrumIds {
272
297
  AAVE_V3_REPAY = 0,
@@ -297,6 +322,14 @@ export declare namespace Bundles {
297
322
  MORPHO_BLUE_BOOST_ON_PRICE = 25,
298
323
  MORPHO_BLUE_EOA_REPAY = 26,
299
324
  MORPHO_BLUE_EOA_BOOST = 27,
300
- MORPHO_BLUE_CLOSE = 28
325
+ MORPHO_BLUE_CLOSE = 28,
326
+ AAVE_V3_SW_LIQUIDATION_PROTECTION = 29,
327
+ FLUID_T1_SW_LIQUIDATION_PROTECTION = 30,
328
+ MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 31,
329
+ COMP_V3_SW_LIQUIDATION_PROTECTION = 32,
330
+ COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
331
+ AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
332
+ MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 35,
333
+ MORPHO_BLUE_REPAY_ON_PRICE = 36
301
334
  }
302
335
  }