@defisaver/automation-sdk 3.3.15-liq-prot-2-dev → 3.3.15-liq-prot-3-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.
@@ -85,7 +85,7 @@ export const makerEncode = {
85
85
 
86
86
  return [strategyOrBundleId, isBundle, triggerData, subData];
87
87
  },
88
- leverageManagementWithoutSubProxy(
88
+ leverageManagement(
89
89
  vaultId: number,
90
90
  triggerRatio: number,
91
91
  targetRatio: number,
@@ -97,7 +97,7 @@ export const makerEncode = {
97
97
 
98
98
  const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
99
99
 
100
- const subData = subDataService.makerLeverageManagementWithoutSubProxy.encode(vaultId, targetRatio, daiAddr);
100
+ const subData = subDataService.makerLeverageManagementSubData.encode(vaultId, targetRatio, daiAddr);
101
101
 
102
102
  return [
103
103
  bundleId,
@@ -186,7 +186,7 @@ export const liquityEncode = {
186
186
 
187
187
  return [strategyId, isBundle, triggerData, subData];
188
188
  },
189
- leverageManagementWithoutSubProxy(
189
+ leverageManagement(
190
190
  strategyOrBundleId: number,
191
191
  user: EthereumAddress,
192
192
  ratioState: RatioState,
@@ -195,7 +195,7 @@ export const liquityEncode = {
195
195
  ) {
196
196
  const isBundle = true;
197
197
 
198
- const subData = subDataService.liquityLeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
198
+ const subData = subDataService.liquityLeverageManagementSubData.encode(targetRatio, ratioState);
199
199
  const triggerData = triggerService.liquityRatioTrigger.encode(user, triggerRatio, ratioState);
200
200
 
201
201
  return [strategyOrBundleId, isBundle, triggerData, subData];
@@ -247,14 +247,8 @@ export const liquityEncode = {
247
247
  },
248
248
  };
249
249
 
250
- export const chickenBondsEncode = {
251
- rebond(bondId: number) {
252
- return subDataService.cBondsRebondSubData.encode(bondId);
253
- },
254
- };
255
-
256
250
  export const aaveV2Encode = {
257
- leverageManagementWithoutSubProxy(
251
+ leverageManagement(
258
252
  strategyOrBundleId: number,
259
253
  market: EthereumAddress,
260
254
  user: EthereumAddress,
@@ -264,7 +258,7 @@ export const aaveV2Encode = {
264
258
  ) {
265
259
  const isBundle = true;
266
260
 
267
- const subData = subDataService.aaveV2LeverageManagementSubDataWithoutSubProxy.encode(market, targetRatio, ratioState);
261
+ const subData = subDataService.aaveV2LeverageManagementSubData.encode(market, targetRatio, ratioState);
268
262
  const triggerData = triggerService.aaveV2RatioTrigger.encode(user, market, triggerRatio, ratioState);
269
263
 
270
264
  return [strategyOrBundleId, isBundle, triggerData, subData];
@@ -338,7 +332,7 @@ export const aaveV3Encode = {
338
332
 
339
333
  return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
340
334
  },
341
- leverageManagementWithoutSubProxy(
335
+ leverageManagement(
342
336
  strategyOrBundleId: number,
343
337
  market: EthereumAddress,
344
338
  user: EthereumAddress,
@@ -349,7 +343,7 @@ export const aaveV3Encode = {
349
343
  ) {
350
344
  const isBundle = true;
351
345
 
352
- const subData = subDataService.aaveV3LeverageManagementSubDataWithoutSubProxy.encode(
346
+ const subData = subDataService.aaveV3LeverageManagementSubData.encode(
353
347
  targetRatio,
354
348
  ratioState,
355
349
  market,
@@ -376,6 +370,7 @@ export const aaveV3Encode = {
376
370
  ratioState,
377
371
  market,
378
372
  user,
373
+ true, // isGeneric
379
374
  );
380
375
  const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
381
376
 
@@ -453,7 +448,7 @@ export const aaveV3Encode = {
453
448
  };
454
449
 
455
450
  export const compoundV2Encode = {
456
- leverageManagementWithoutSubProxy(
451
+ leverageManagement(
457
452
  strategyOrBundleId: number,
458
453
  user: EthereumAddress,
459
454
  ratioState: RatioState,
@@ -462,7 +457,7 @@ export const compoundV2Encode = {
462
457
  ) {
463
458
  const isBundle = true;
464
459
 
465
- const subData = subDataService.compoundV2LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
460
+ const subData = subDataService.compoundV2LeverageManagementSubData.encode(targetRatio, ratioState);
466
461
  const triggerData = triggerService.compoundV2RatioTrigger.encode(user, triggerRatio, ratioState);
467
462
 
468
463
  return [strategyOrBundleId, isBundle, triggerData, subData];
@@ -470,7 +465,7 @@ export const compoundV2Encode = {
470
465
  };
471
466
 
472
467
  export const compoundV3Encode = {
473
- leverageManagementWithoutSubProxy(
468
+ leverageManagement(
474
469
  strategyOrBundleId: number,
475
470
  market: EthereumAddress,
476
471
  baseToken: EthereumAddress,
@@ -481,13 +476,13 @@ export const compoundV3Encode = {
481
476
  ) {
482
477
  const isBundle = true;
483
478
 
484
- const subData = subDataService.compoundV3LeverageManagementSubDataWithoutSubProxy.encode(market, baseToken, targetRatio, ratioState);
479
+ const subData = subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, targetRatio, ratioState);
485
480
  const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
486
481
 
487
482
  return [strategyOrBundleId, isBundle, triggerData, subData];
488
483
  },
489
484
 
490
- liquidationProtectionWithoutSubProxy(
485
+ liquidationProtection(
491
486
  strategyOrBundleId: number,
492
487
  market: EthereumAddress,
493
488
  baseToken: EthereumAddress,
@@ -498,7 +493,7 @@ export const compoundV3Encode = {
498
493
  ) {
499
494
  const isBundle = true;
500
495
 
501
- const subData = subDataService.compoundV3LiquidationProtectionSubDataWithoutSubProxy.encode(market, baseToken, targetRatio, ratioState);
496
+ const subData = subDataService.compoundV3LiquidationProtectionSubData.encode(market, baseToken, targetRatio, ratioState);
502
497
  const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
503
498
 
504
499
  return [strategyOrBundleId, isBundle, triggerData, subData];
@@ -542,18 +537,6 @@ export const compoundV3Encode = {
542
537
  },
543
538
  };
544
539
 
545
- export const morphoAaveV2Encode = {
546
- leverageManagement(
547
- triggerRepayRatio: number,
548
- triggerBoostRatio: number,
549
- targetBoostRatio: number,
550
- targetRepayRatio: number,
551
- boostEnabled: boolean,
552
- ) {
553
- return subDataService.morphoAaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
554
- },
555
- };
556
-
557
540
  export const exchangeEncode = {
558
541
  dca(
559
542
  fromToken: EthereumAddress,
@@ -571,7 +554,7 @@ export const exchangeEncode = {
571
554
 
572
555
  return [strategyId, false, triggerData, subData];
573
556
  },
574
- limitOrderWithoutSubProxy(
557
+ limitOrder(
575
558
  fromToken: EthereumAddress,
576
559
  toToken: EthereumAddress,
577
560
  amount: string,
@@ -583,7 +566,7 @@ export const exchangeEncode = {
583
566
  network: ChainId,
584
567
  ) {
585
568
  requireAddresses([fromToken, toToken]);
586
- const subData = subDataService.exchangeLimitOrderSubDataWithoutSubProxy.encode(fromToken, toToken, amount);
569
+ const subData = subDataService.exchangeLimitOrderSubData.encode(fromToken, toToken, amount);
587
570
  const triggerData = triggerService.exchangeOffchainPriceTrigger.encode(targetPrice, Number(goodUntil), orderType, fromTokenDecimals, toTokenDecimals);
588
571
 
589
572
  const strategyId = STRATEGY_IDS[network].EXCHANGE_LIMIT_ORDER;
@@ -636,7 +619,7 @@ export const sparkEncode = {
636
619
 
637
620
  return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
638
621
  },
639
- leverageManagementWithoutSubProxy(
622
+ leverageManagement(
640
623
  strategyOrBundleId: number,
641
624
  market: EthereumAddress,
642
625
  user: EthereumAddress,
@@ -646,7 +629,7 @@ export const sparkEncode = {
646
629
  ) {
647
630
  const isBundle = true;
648
631
 
649
- const subData = subDataService.sparkLeverageManagementSubDataWithoutSubProxy.encode(
632
+ const subData = subDataService.sparkLeverageManagementSubData.encode(
650
633
  targetRatio,
651
634
  ratioState,
652
635
  );
@@ -1,10 +1,9 @@
1
- import Dec from 'decimal.js';
2
1
  import { expect } from 'chai';
3
2
  import { getAssetInfo } from '@defisaver/tokens';
4
3
  import * as web3Utils from 'web3-utils';
5
4
  import { MAXUINT } from '@defisaver/tokens';
6
5
 
7
- import { ChainId, CloseStrategyType, OrderType, RatioState } from '../types/enums';
6
+ import { ChainId, CloseStrategyType, RatioState } from '../types/enums';
8
7
  import type { EthereumAddress, SubData } from '../types';
9
8
 
10
9
  import '../configuration';
@@ -133,7 +132,7 @@ describe('Feature: subDataService.ts', () => {
133
132
  });
134
133
  });
135
134
 
136
- describe('When testing subDataService.makerLeverageManagementSubData', () => {
135
+ describe('When testing subDataService.legacyMakerLeverageManagementSubData', () => {
137
136
  describe('decode()', () => {
138
137
  const examples: Array<[{ vaultId: number, targetRatio: number }, SubData]> = [
139
138
  [
@@ -147,13 +146,13 @@ describe('Feature: subDataService.ts', () => {
147
146
 
148
147
  examples.forEach(([expected, actual]) => {
149
148
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
150
- expect(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
149
+ expect(subDataService.legacyMakerLeverageManagementSubData.decode(actual)).to.eql(expected);
151
150
  });
152
151
  });
153
152
  });
154
153
  });
155
154
 
156
- describe('When testing subDataService.makerLeverageManagementWithoutSubProxy', () => {
155
+ describe('When testing subDataService.makerLeverageManagementSubData', () => {
157
156
  describe('encode()', () => {
158
157
  const examples: Array<[SubData, [vaultId: number, targetRatio: number, daiAddr?: EthereumAddress]]> = [
159
158
  [
@@ -174,7 +173,7 @@ describe('Feature: subDataService.ts', () => {
174
173
 
175
174
  examples.forEach(([expected, actual]) => {
176
175
  it(`Given ${actual} should return expected value: ${expected}`, () => {
177
- expect(subDataService.makerLeverageManagementWithoutSubProxy.encode(...actual)).to.eql(expected);
176
+ expect(subDataService.makerLeverageManagementSubData.encode(...actual)).to.eql(expected);
178
177
  });
179
178
  });
180
179
  });
@@ -207,13 +206,13 @@ describe('Feature: subDataService.ts', () => {
207
206
 
208
207
  examples.forEach(([expected, actual]) => {
209
208
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
210
- expect(subDataService.makerLeverageManagementWithoutSubProxy.decode(actual)).to.eql(expected);
209
+ expect(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
211
210
  });
212
211
  });
213
212
  });
214
213
  });
215
214
 
216
- describe('When testing subDataService.liquityLeverageManagementSubData', () => {
215
+ describe('When testing subDataService.legacyLiquityLeverageManagementSubData', () => {
217
216
  describe('decode()', () => {
218
217
  const examples: Array<[{ targetRatio: number }, SubData]> = [
219
218
  [
@@ -227,7 +226,7 @@ describe('Feature: subDataService.ts', () => {
227
226
 
228
227
  examples.forEach(([expected, actual]) => {
229
228
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
230
- expect(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
229
+ expect(subDataService.legacyLiquityLeverageManagementSubData.decode(actual)).to.eql(expected);
231
230
  });
232
231
  });
233
232
  });
@@ -287,26 +286,7 @@ describe('Feature: subDataService.ts', () => {
287
286
  });
288
287
  });
289
288
 
290
- describe('When testing subDataService.aaveV2LeverageManagementSubData', () => {
291
- describe('encode()', () => {
292
- const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
293
- [
294
- [new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
295
- [160, 220, 180, 190, true]
296
- ],
297
- [
298
- [new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
299
- [160, 200, 180, 190, false]
300
- ],
301
- ];
302
-
303
- examples.forEach(([expected, actual]) => {
304
- it(`Given ${actual} should return expected value: ${expected}`, () => {
305
- expect(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
306
- });
307
- });
308
- });
309
-
289
+ describe('When testing subDataService.legacyAaveV2LeverageManagementSubData', () => {
310
290
  describe('decode()', () => {
311
291
  const examples: Array<[{ targetRatio: number }, SubData]> = [
312
292
  [
@@ -321,13 +301,13 @@ describe('Feature: subDataService.ts', () => {
321
301
 
322
302
  examples.forEach(([expected, actual]) => {
323
303
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
324
- expect(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
304
+ expect(subDataService.legacyAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
325
305
  });
326
306
  });
327
307
  });
328
308
  });
329
309
 
330
- describe('When testing subDataService.aaveV3LeverageManagementSubData', () => {
310
+ describe('When testing subDataService.legacyAaveV3LeverageManagementSubData', () => {
331
311
  describe('decode()', () => {
332
312
  const examples: Array<[{ targetRatio: number }, SubData]> = [
333
313
  [
@@ -342,7 +322,7 @@ describe('Feature: subDataService.ts', () => {
342
322
 
343
323
  examples.forEach(([expected, actual]) => {
344
324
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
345
- expect(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
325
+ expect(subDataService.legacyAaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
346
326
  });
347
327
  });
348
328
  });
@@ -694,26 +674,7 @@ describe('Feature: subDataService.ts', () => {
694
674
  });
695
675
  });
696
676
 
697
- describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
698
- describe('encode()', () => {
699
- const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
700
- [
701
- [new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
702
- [160, 220, 180, 190, true]
703
- ],
704
- [
705
- [new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
706
- [160, 200, 180, 190, false]
707
- ],
708
- ];
709
-
710
- examples.forEach(([expected, actual]) => {
711
- it(`Given ${actual} should return expected value: ${expected}`, () => {
712
- expect(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
713
- });
714
- });
715
- });
716
-
677
+ describe('When testing subDataService.legacyCompoundV2LeverageManagementSubData', () => {
717
678
  describe('decode()', () => {
718
679
  const examples: Array<[{ targetRatio: number }, SubData]> = [
719
680
  [
@@ -728,32 +689,13 @@ describe('Feature: subDataService.ts', () => {
728
689
 
729
690
  examples.forEach(([expected, actual]) => {
730
691
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
731
- expect(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
692
+ expect(subDataService.legacyCompoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
732
693
  });
733
694
  });
734
695
  });
735
696
  });
736
697
 
737
698
  describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
738
- describe('encode()', () => {
739
- const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
740
- [
741
- [new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
742
- [160, 220, 180, 190, true]
743
- ],
744
- [
745
- [new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
746
- [160, 200, 180, 190, false]
747
- ],
748
- ];
749
-
750
- examples.forEach(([expected, actual]) => {
751
- it(`Given ${actual} should return expected value: ${expected}`, () => {
752
- expect(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
753
- });
754
- });
755
- });
756
-
757
699
  describe('decode()', () => {
758
700
  const examples: Array<[{ targetRatio: number }, SubData]> = [
759
701
  [
@@ -775,25 +717,6 @@ describe('Feature: subDataService.ts', () => {
775
717
  });
776
718
 
777
719
  describe('When testing subDataService.cBondsRebondSubData', () => {
778
- describe('encode()', () => {
779
- const examples: Array<[SubData, [bondId: number | string]]> = [
780
- [
781
- ['0x00000000000000000000000000000000000000000000000000000000000000c8'],
782
- [200]
783
- ],
784
- [
785
- ['0x000000000000000000000000000000000000000000000000000000000000a119'],
786
- [41241]
787
- ],
788
- ];
789
-
790
- examples.forEach(([expected, actual]) => {
791
- it(`Given ${actual} should return expected value: ${expected}`, () => {
792
- expect(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
793
- });
794
- });
795
- });
796
-
797
720
  describe('decode()', () => {
798
721
  const examples: Array<[{ bondId: string }, SubData]> = [
799
722
  [
@@ -944,54 +867,7 @@ describe('Feature: subDataService.ts', () => {
944
867
  });
945
868
  });
946
869
 
947
- describe('When testing subDataService.exchangeLimitOrderSubData', () => {
948
- describe('encode()', () => {
949
- const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string], [fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType]]> = [
950
- [
951
- [
952
- web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
953
- web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
954
- '2131',
955
- '0.53123',
956
- '1696590921159',
957
- `${OrderType.STOP_LOSS}`
958
- ],
959
- [
960
- web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
961
- web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
962
- '2131',
963
- '0.53123',
964
- 1696590921159,
965
- OrderType.STOP_LOSS
966
- ]
967
- ],
968
- [
969
- [
970
- web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
971
- web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
972
- '2131',
973
- '0.43123',
974
- '1646590921159',
975
- `${OrderType.TAKE_PROFIT}`
976
- ],
977
- [
978
- web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
979
- web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
980
- '2131',
981
- '0.43123',
982
- 1646590921159,
983
- OrderType.TAKE_PROFIT
984
- ]
985
- ],
986
- ];
987
-
988
- examples.forEach(([expected, actual]) => {
989
- it(`Given ${actual} should return expected value: ${expected}`, () => {
990
- expect(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
991
- });
992
- });
993
- });
994
-
870
+ describe('When testing subDataService.legacyExchangeLimitOrderSubData', () => {
995
871
  describe('decode()', () => {
996
872
  const examples: Array<[{ fromToken: EthereumAddress, toToken: EthereumAddress, amount: string }, [SubData, ChainId]]> = [
997
873
  [
@@ -1026,13 +902,13 @@ describe('Feature: subDataService.ts', () => {
1026
902
 
1027
903
  examples.forEach(([expected, actual]) => {
1028
904
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1029
- expect(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
905
+ expect(subDataService.legacyExchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
1030
906
  });
1031
907
  });
1032
908
  });
1033
909
  });
1034
910
 
1035
- describe('When testing subDataService.sparkLeverageManagementSubData', () => {
911
+ describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
1036
912
  describe('decode()', () => {
1037
913
  const examples: Array<[{ targetRatio: number }, SubData]> = [
1038
914
  [
@@ -1047,7 +923,7 @@ describe('Feature: subDataService.ts', () => {
1047
923
 
1048
924
  examples.forEach(([expected, actual]) => {
1049
925
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1050
- expect(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
926
+ expect(subDataService.legacySparkLeverageManagementSubData.decode(actual)).to.eql(expected);
1051
927
  });
1052
928
  });
1053
929
  });