@defisaver/automation-sdk 3.1.10 → 3.1.14-spark-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 (72) hide show
  1. package/cjs/automation/private/StrategiesAutomation.d.ts +5 -3
  2. package/cjs/automation/private/StrategiesAutomation.js +27 -10
  3. package/cjs/automation/private/StrategiesAutomation.test.js +25 -0
  4. package/cjs/constants/index.d.ts +1 -0
  5. package/cjs/constants/index.js +352 -11
  6. package/cjs/index.d.ts +2 -1
  7. package/cjs/index.js +1 -1
  8. package/cjs/services/ethereumService.js +21 -14
  9. package/cjs/services/ethereumService.test.js +3 -0
  10. package/cjs/services/strategiesService.js +329 -54
  11. package/cjs/services/strategiesService.test.js +1 -0
  12. package/cjs/services/strategySubService.d.ts +24 -5
  13. package/cjs/services/strategySubService.js +116 -10
  14. package/cjs/services/strategySubService.test.js +1049 -173
  15. package/cjs/services/subDataService.d.ts +361 -88
  16. package/cjs/services/subDataService.js +799 -249
  17. package/cjs/services/subDataService.test.js +1287 -142
  18. package/cjs/services/triggerService.d.ts +100 -9
  19. package/cjs/services/triggerService.js +188 -19
  20. package/cjs/services/triggerService.test.js +437 -46
  21. package/cjs/services/utils.d.ts +1 -1
  22. package/cjs/services/utils.js +10 -2
  23. package/cjs/services/utils.test.js +0 -77
  24. package/cjs/types/enums.d.ts +88 -12
  25. package/cjs/types/enums.js +78 -2
  26. package/cjs/types/index.d.ts +59 -1
  27. package/esm/automation/private/StrategiesAutomation.d.ts +5 -3
  28. package/esm/automation/private/StrategiesAutomation.js +27 -10
  29. package/esm/automation/private/StrategiesAutomation.test.js +25 -0
  30. package/esm/constants/index.d.ts +1 -0
  31. package/esm/constants/index.js +351 -10
  32. package/esm/index.d.ts +2 -1
  33. package/esm/index.js +2 -2
  34. package/esm/services/ethereumService.js +21 -14
  35. package/esm/services/ethereumService.test.js +3 -0
  36. package/esm/services/strategiesService.js +330 -55
  37. package/esm/services/strategiesService.test.js +1 -0
  38. package/esm/services/strategySubService.d.ts +24 -5
  39. package/esm/services/strategySubService.js +115 -9
  40. package/esm/services/strategySubService.test.js +1052 -176
  41. package/esm/services/subDataService.d.ts +361 -88
  42. package/esm/services/subDataService.js +799 -249
  43. package/esm/services/subDataService.test.js +1288 -143
  44. package/esm/services/triggerService.d.ts +100 -9
  45. package/esm/services/triggerService.js +187 -18
  46. package/esm/services/triggerService.test.js +438 -47
  47. package/esm/services/utils.d.ts +1 -1
  48. package/esm/services/utils.js +10 -2
  49. package/esm/services/utils.test.js +1 -52
  50. package/esm/types/enums.d.ts +88 -12
  51. package/esm/types/enums.js +78 -2
  52. package/esm/types/index.d.ts +59 -1
  53. package/package.json +4 -5
  54. package/src/automation/private/StrategiesAutomation.test.ts +40 -0
  55. package/src/automation/private/StrategiesAutomation.ts +38 -15
  56. package/src/constants/index.ts +353 -11
  57. package/src/index.ts +4 -2
  58. package/src/services/ethereumService.test.ts +3 -0
  59. package/src/services/ethereumService.ts +23 -16
  60. package/src/services/strategiesService.test.ts +1 -0
  61. package/src/services/strategiesService.ts +387 -72
  62. package/src/services/strategySubService.test.ts +1330 -316
  63. package/src/services/strategySubService.ts +365 -12
  64. package/src/services/subDataService.test.ts +1413 -170
  65. package/src/services/subDataService.ts +1148 -431
  66. package/src/services/triggerService.test.ts +482 -52
  67. package/src/services/triggerService.ts +272 -27
  68. package/src/services/utils.test.ts +0 -59
  69. package/src/services/utils.ts +15 -4
  70. package/src/types/enums.ts +78 -2
  71. package/src/types/index.ts +74 -1
  72. package/umd/index.js +0 -34219
@@ -3,7 +3,7 @@ import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
3
3
  import * as web3Utils from 'web3-utils';
4
4
  import { ChainId, OrderType, RatioState } from '../types/enums';
5
5
  import '../configuration';
6
- import { aaveV2RatioTrigger, aaveV3QuotePriceTrigger, aaveV3QuotePriceWithMaximumGasPriceTrigger, aaveV3RatioTrigger, cBondsRebondTrigger, chainlinkPriceTrigger, compoundV2RatioTrigger, compoundV3RatioTrigger, curveUsdBorrowRateTrigger, curveUsdSoftLiquidationTrigger, exchangeOffchainPriceTrigger, exchangeTimestampTrigger, liquityDebtInFrontTrigger, makerRatioTrigger, morphoAaveV2RatioTrigger, sparkQuotePriceTrigger, sparkRatioTrigger, trailingStopTrigger, liquityDebtInFrontWithLimitTrigger, crvUSDRatioTrigger, morphoBlueRatioTrigger, crvUsdHealthRatioTrigger, } from './triggerService';
6
+ import { aaveV2RatioTrigger, aaveV3QuotePriceTrigger, aaveV3QuotePriceWithMaximumGasPriceTrigger, aaveV3RatioTrigger, cBondsRebondTrigger, chainlinkPriceTrigger, compoundV2RatioTrigger, compoundV3RatioTrigger, compoundV3PriceTrigger, curveUsdBorrowRateTrigger, curveUsdSoftLiquidationTrigger, exchangeOffchainPriceTrigger, exchangeTimestampTrigger, liquityDebtInFrontTrigger, makerRatioTrigger, morphoAaveV2RatioTrigger, sparkRatioTrigger, trailingStopTrigger, liquityDebtInFrontWithLimitTrigger, crvUSDRatioTrigger, morphoBlueRatioTrigger, crvUsdHealthRatioTrigger, liquityV2DebtInFrontTrigger, liquityV2AdjustTimeTrigger, compoundV3PriceRangeTrigger, aaveV3QuotePriceRangeTrigger, morphoBluePriceRangeTrigger, sparkQuotePriceTrigger, aaveV4RatioTrigger, aaveV4QuotePriceTrigger, aaveV4QuotePriceRangeTrigger, } from './triggerService';
7
7
  describe('Feature: triggerService.ts', () => {
8
8
  describe('When testing triggerService.chainlinkPriceTrigger', () => {
9
9
  describe('encode()', () => {
@@ -423,6 +423,125 @@ describe('Feature: triggerService.ts', () => {
423
423
  });
424
424
  });
425
425
  });
426
+ describe('When testing triggerService.liquityV2DebtInFrontTrigger', () => {
427
+ describe('encode()', () => {
428
+ const examples = [
429
+ [
430
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd1500000000000000000000000000000000000000000000006e0be8c4995af80000'],
431
+ [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '123456789', '2030']
432
+ ],
433
+ [
434
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1000000000000000000000000000000000000000000004697f83e6356dd440000'],
435
+ [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '987654321', '333369']
436
+ ],
437
+ [
438
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf00000000000000000000000000000000000000000000000000000000075bd924000000000000000000000000000000000000000000084595161401484a000000'],
439
+ [web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '123459876', '10000000']
440
+ ],
441
+ [
442
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000000000000000002060d4950000000000000000000000000000000000000000000000000000000000989680'],
443
+ [web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '543216789', '0.00000000001']
444
+ ],
445
+ [
446
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a000000000000000000000000000000000000000000000000000000003ade5ca20000000000000000000000000000000000000000019d971e4fe8401e74000000'],
447
+ [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '987651234', '500000000']
448
+ ],
449
+ ];
450
+ examples.forEach(([expected, actual]) => {
451
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
452
+ expect(liquityV2DebtInFrontTrigger.encode(...actual)).to.eql(expected);
453
+ });
454
+ });
455
+ });
456
+ describe('decode()', () => {
457
+ const examples = [
458
+ [
459
+ {
460
+ market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
461
+ troveId: '123456789',
462
+ debtInFrontMin: '2030',
463
+ },
464
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd1500000000000000000000000000000000000000000000006e0be8c4995af80000'],
465
+ ],
466
+ [
467
+ {
468
+ market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
469
+ troveId: '987654321',
470
+ debtInFrontMin: '333369',
471
+ },
472
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1000000000000000000000000000000000000000000004697f83e6356dd440000'],
473
+ ], [
474
+ {
475
+ market: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
476
+ troveId: '123459876',
477
+ debtInFrontMin: '10000000',
478
+ },
479
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf00000000000000000000000000000000000000000000000000000000075bd924000000000000000000000000000000000000000000084595161401484a000000'],
480
+ ], [
481
+ {
482
+ market: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
483
+ troveId: '543216789',
484
+ debtInFrontMin: '0.00000000001',
485
+ },
486
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000000000000000002060d4950000000000000000000000000000000000000000000000000000000000989680'],
487
+ ], [
488
+ {
489
+ market: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
490
+ troveId: '987651234',
491
+ debtInFrontMin: '500000000',
492
+ },
493
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a000000000000000000000000000000000000000000000000000000003ade5ca20000000000000000000000000000000000000000019d971e4fe8401e74000000'],
494
+ ]
495
+ ];
496
+ examples.forEach(([expected, actual]) => {
497
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
498
+ expect(liquityV2DebtInFrontTrigger.decode(actual)).to.eql(expected);
499
+ });
500
+ });
501
+ });
502
+ });
503
+ describe('When testing triggerService.liquityV2AdjustTimeTrigger', () => {
504
+ describe('encode()', () => {
505
+ const examples = [
506
+ [
507
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd15'],
508
+ [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '123456789']
509
+ ],
510
+ [
511
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1'],
512
+ [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '987654321']
513
+ ],
514
+ ];
515
+ examples.forEach(([expected, actual]) => {
516
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
517
+ expect(liquityV2AdjustTimeTrigger.encode(...actual)).to.eql(expected);
518
+ });
519
+ });
520
+ });
521
+ describe('decode()', () => {
522
+ const examples = [
523
+ [
524
+ {
525
+ market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
526
+ troveId: '123456789',
527
+ },
528
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000075bcd15'],
529
+ ],
530
+ [
531
+ {
532
+ market: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
533
+ troveId: '987654321',
534
+ },
535
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000000000000000003ade68b1'],
536
+ ]
537
+ ];
538
+ examples.forEach(([expected, actual]) => {
539
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
540
+ expect(liquityV2AdjustTimeTrigger.decode(actual)).to.eql(expected);
541
+ });
542
+ });
543
+ });
544
+ });
426
545
  describe('When testing triggerService.aaveV2RatioTrigger', () => {
427
546
  describe('encode()', () => {
428
547
  const examples = [
@@ -662,52 +781,6 @@ describe('Feature: triggerService.ts', () => {
662
781
  });
663
782
  });
664
783
  });
665
- describe('When testing triggerService.sparkQuotePriceTrigger', () => {
666
- describe('encode()', () => {
667
- const examples = [
668
- [
669
- ['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000000000000000000000000000000000000000a8ca0000000000000000000000000000000000000000000000000000000000000001'],
670
- [getAssetInfo('DAI', ChainId.Ethereum).address, getAssetInfo('wstETH', ChainId.Ethereum).address, 0.0004321, RatioState.UNDER]
671
- ],
672
- [
673
- ['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000186b70000000000000000000000000000000000000000000000000000000000000000'],
674
- [getAssetInfo('WBTC', ChainId.Arbitrum).address, getAssetInfo('USDC', ChainId.Arbitrum).address, 0.00100023, RatioState.OVER]
675
- ],
676
- ];
677
- examples.forEach(([expected, actual]) => {
678
- it(`Given ${actual} should return expected value: ${expected}`, () => {
679
- expect(sparkQuotePriceTrigger.encode(...actual)).to.eql(expected);
680
- });
681
- });
682
- });
683
- describe('decode()', () => {
684
- const examples = [
685
- [
686
- {
687
- baseTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
688
- quoteTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Ethereum).address),
689
- price: '0.0004321',
690
- ratioState: RatioState.UNDER,
691
- },
692
- ['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000000000000000000000000000000000000000a8ca0000000000000000000000000000000000000000000000000000000000000001'],
693
- ],
694
- [
695
- {
696
- baseTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Arbitrum).address),
697
- quoteTokenAddress: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
698
- price: '0.00100023',
699
- ratioState: RatioState.OVER,
700
- },
701
- ['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000186b70000000000000000000000000000000000000000000000000000000000000000'],
702
- ]
703
- ];
704
- examples.forEach(([expected, actual]) => {
705
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
706
- expect(sparkQuotePriceTrigger.decode(actual)).to.eql(expected);
707
- });
708
- });
709
- });
710
- });
711
784
  describe('When testing triggerService.curveUsdBorrowRateTrigger', () => {
712
785
  describe('encode()', () => {
713
786
  const examples = [
@@ -898,4 +971,322 @@ describe('Feature: triggerService.ts', () => {
898
971
  });
899
972
  });
900
973
  });
974
+ describe('When testing triggerService.compoundV3PriceTrigger', () => {
975
+ describe('encode()', () => {
976
+ const examples = [
977
+ [
978
+ ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009a959b9ee2847a66a5a3d43fd1ec38a4f07775030000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
979
+ [web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), web3Utils.toChecksumAddress('0x9a959B9ee2847a66A5A3d43Fd1Ec38a4f0777503'), 2000, RatioState.UNDER]
980
+ ],
981
+ [
982
+ ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009a959b9ee2847a66a5a3d43fd1ec38a4f077750300000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
983
+ [web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), web3Utils.toChecksumAddress('0x9a959B9ee2847a66A5A3d43Fd1Ec38a4f0777503'), 3000, RatioState.OVER]
984
+ ],
985
+ ];
986
+ examples.forEach(([expected, actual]) => {
987
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
988
+ expect(compoundV3PriceTrigger.encode(...actual)).to.eql(expected);
989
+ });
990
+ });
991
+ });
992
+ describe('decode()', () => {
993
+ const examples = [
994
+ [
995
+ {
996
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
997
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
998
+ user: web3Utils.toChecksumAddress('0x9a959B9ee2847a66A5A3d43Fd1Ec38a4f0777503'),
999
+ price: '2000',
1000
+ priceState: RatioState.UNDER,
1001
+ },
1002
+ ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009a959b9ee2847a66a5a3d43fd1ec38a4f07775030000000000000000000000000000000000000000000000000000002e90edd0000000000000000000000000000000000000000000000000000000000000000001'],
1003
+ ],
1004
+ [
1005
+ {
1006
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1007
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1008
+ user: web3Utils.toChecksumAddress('0x9a959B9ee2847a66A5A3d43Fd1Ec38a4f0777503'),
1009
+ price: '3000',
1010
+ priceState: RatioState.OVER,
1011
+ },
1012
+ ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000009a959b9ee2847a66a5a3d43fd1ec38a4f077750300000000000000000000000000000000000000000000000000000045d964b8000000000000000000000000000000000000000000000000000000000000000000'],
1013
+ ],
1014
+ ];
1015
+ examples.forEach(([expected, actual]) => {
1016
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1017
+ expect(compoundV3PriceTrigger.decode(actual)).to.eql(expected);
1018
+ });
1019
+ });
1020
+ });
1021
+ });
1022
+ describe('When testing triggerService.compoundV3PriceRangeTrigger', () => {
1023
+ describe('encode()', () => {
1024
+ const examples = [
1025
+ [
1026
+ ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1027
+ [web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
1028
+ ],
1029
+ [
1030
+ ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
1031
+ [web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
1032
+ ],
1033
+ ];
1034
+ examples.forEach(([expected, actual]) => {
1035
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1036
+ expect(compoundV3PriceRangeTrigger.encode(...actual)).to.eql(expected);
1037
+ });
1038
+ });
1039
+ });
1040
+ describe('decode()', () => {
1041
+ const examples = [
1042
+ [
1043
+ {
1044
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1045
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1046
+ lowerPrice: '1500',
1047
+ upperPrice: '4000',
1048
+ },
1049
+ ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1050
+ ],
1051
+ [
1052
+ {
1053
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1054
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1055
+ lowerPrice: '0',
1056
+ upperPrice: '5000',
1057
+ },
1058
+ ['0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
1059
+ ],
1060
+ ];
1061
+ examples.forEach(([expected, actual]) => {
1062
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1063
+ expect(compoundV3PriceRangeTrigger.decode(actual)).to.eql(expected);
1064
+ });
1065
+ });
1066
+ });
1067
+ });
1068
+ describe('When testing triggerService.aaveV3PriceRangeTrigger', () => {
1069
+ describe('encode()', () => {
1070
+ const examples = [
1071
+ [
1072
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1073
+ [web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 1500, 4000]
1074
+ ],
1075
+ [
1076
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
1077
+ [web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 0, 5000]
1078
+ ],
1079
+ ];
1080
+ examples.forEach(([expected, actual]) => {
1081
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1082
+ expect(aaveV3QuotePriceRangeTrigger.encode(...actual)).to.eql(expected);
1083
+ });
1084
+ });
1085
+ });
1086
+ describe('decode()', () => {
1087
+ const examples = [
1088
+ [
1089
+ {
1090
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1091
+ debtToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1092
+ lowerPrice: '1500',
1093
+ upperPrice: '4000',
1094
+ },
1095
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1096
+ ],
1097
+ [
1098
+ {
1099
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1100
+ debtToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1101
+ lowerPrice: '0',
1102
+ upperPrice: '5000',
1103
+ },
1104
+ ['000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
1105
+ ],
1106
+ ];
1107
+ examples.forEach(([expected, actual]) => {
1108
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1109
+ expect(aaveV3QuotePriceRangeTrigger.decode(actual)).to.eql(expected);
1110
+ });
1111
+ });
1112
+ });
1113
+ });
1114
+ describe('When testing triggerService.morphoBluePriceRangeTrigger', () => {
1115
+ describe('encode()', () => {
1116
+ const examples = [
1117
+ [
1118
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1119
+ [web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 1500, 4000]
1120
+ ],
1121
+ [
1122
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
1123
+ [web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 0, 5000]
1124
+ ],
1125
+ ];
1126
+ examples.forEach(([expected, actual]) => {
1127
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1128
+ expect(morphoBluePriceRangeTrigger.encode(...actual)).to.eql(expected);
1129
+ });
1130
+ });
1131
+ });
1132
+ describe('decode()', () => {
1133
+ const examples = [
1134
+ [
1135
+ {
1136
+ oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1137
+ collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1138
+ loanToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1139
+ lowerPrice: '1500',
1140
+ upperPrice: '4000',
1141
+ },
1142
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
1143
+ ],
1144
+ [
1145
+ {
1146
+ oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
1147
+ collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
1148
+ loanToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1149
+ lowerPrice: '0',
1150
+ upperPrice: '5000',
1151
+ },
1152
+ ['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8dA6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
1153
+ ],
1154
+ ];
1155
+ examples.forEach(([expected, actual]) => {
1156
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1157
+ expect(morphoBluePriceRangeTrigger.decode(actual)).to.eql(expected);
1158
+ });
1159
+ });
1160
+ });
1161
+ });
1162
+ describe('When testing triggerService.aaveV4RatioTrigger', () => {
1163
+ describe('encode()', () => {
1164
+ const examples = [
1165
+ [
1166
+ ['0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
1167
+ [web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), 120, RatioState.UNDER]
1168
+ ],
1169
+ ];
1170
+ examples.forEach(([expected, actual]) => {
1171
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1172
+ expect(aaveV4RatioTrigger.encode(...actual)).to.eql(expected);
1173
+ });
1174
+ });
1175
+ });
1176
+ describe('decode()', () => {
1177
+ const examples = [
1178
+ [
1179
+ { owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), ratio: 120, ratioState: RatioState.UNDER },
1180
+ ['0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
1181
+ ],
1182
+ ];
1183
+ examples.forEach(([expected, actual]) => {
1184
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1185
+ expect(aaveV4RatioTrigger.decode(actual)).to.eql(expected);
1186
+ });
1187
+ });
1188
+ });
1189
+ });
1190
+ describe('When testing triggerService.aaveV4QuotePriceTrigger', () => {
1191
+ describe('encode()', () => {
1192
+ const examples = [
1193
+ [
1194
+ ['0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000005150ae84a8cdf000000000000000000000000000000000000000000000000000000000000000000000'],
1195
+ [web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), 10, 20, '1500', RatioState.OVER]
1196
+ ],
1197
+ ];
1198
+ examples.forEach(([expected, actual]) => {
1199
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1200
+ expect(aaveV4QuotePriceTrigger.encode(...actual)).to.eql(expected);
1201
+ });
1202
+ });
1203
+ });
1204
+ describe('decode()', () => {
1205
+ const examples = [
1206
+ [
1207
+ { spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), baseTokenId: 10, quoteTokenId: 20, price: '1500', ratioState: RatioState.OVER },
1208
+ ['0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000005150ae84a8cdf000000000000000000000000000000000000000000000000000000000000000000000'],
1209
+ ],
1210
+ ];
1211
+ examples.forEach(([expected, actual]) => {
1212
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1213
+ expect(aaveV4QuotePriceTrigger.decode(actual)).to.eql(expected);
1214
+ });
1215
+ });
1216
+ });
1217
+ });
1218
+ describe('When testing triggerService.aaveV4QuotePriceRangeTrigger', () => {
1219
+ describe('encode()', () => {
1220
+ const examples = [
1221
+ [
1222
+ ['0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000004be4e7267b6ae00000000000000000000000000000000000000000000000000056bc75e2d631000000'],
1223
+ [web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), 10, 20, '1400', '1600']
1224
+ ],
1225
+ ];
1226
+ examples.forEach(([expected, actual]) => {
1227
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1228
+ expect(aaveV4QuotePriceRangeTrigger.encode(...actual)).to.eql(expected);
1229
+ });
1230
+ });
1231
+ });
1232
+ describe('decode()', () => {
1233
+ const examples = [
1234
+ [
1235
+ { spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), baseTokenId: 10, quoteTokenId: 20, lowerPrice: '1400', upperPrice: '1600' },
1236
+ ['0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000004be4e7267b6ae00000000000000000000000000000000000000000000000000056bc75e2d631000000'],
1237
+ ],
1238
+ ];
1239
+ examples.forEach(([expected, actual]) => {
1240
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1241
+ expect(aaveV4QuotePriceRangeTrigger.decode(actual)).to.eql(expected);
1242
+ });
1243
+ });
1244
+ });
1245
+ });
1246
+ describe('When testing triggerService.sparkQuotePriceTrigger', () => {
1247
+ describe('encode()', () => {
1248
+ const examples = [
1249
+ [
1250
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1251
+ [web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address), web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address), 2500, RatioState.UNDER]
1252
+ ],
1253
+ [
1254
+ ['0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000000c1c0000000000000000000000000000000000000000000000000000000000000000'],
1255
+ [web3Utils.toChecksumAddress(getAssetInfo('USDT', ChainId.Ethereum).address), web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address), 0.000031, RatioState.OVER]
1256
+ ],
1257
+ ];
1258
+ examples.forEach(([expected, actual]) => {
1259
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1260
+ expect(sparkQuotePriceTrigger.encode(...actual)).to.eql(expected);
1261
+ });
1262
+ });
1263
+ });
1264
+ describe('decode()', () => {
1265
+ const examples = [
1266
+ [
1267
+ {
1268
+ baseTokenAddr: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
1269
+ quoteTokenAddr: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
1270
+ price: '2500',
1271
+ ratioState: RatioState.UNDER
1272
+ },
1273
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001']
1274
+ ],
1275
+ [
1276
+ {
1277
+ baseTokenAddr: web3Utils.toChecksumAddress(getAssetInfo('USDT', ChainId.Ethereum).address),
1278
+ quoteTokenAddr: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
1279
+ price: '0.000031',
1280
+ ratioState: RatioState.OVER
1281
+ },
1282
+ ['0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000000c1c0000000000000000000000000000000000000000000000000000000000000000']
1283
+ ]
1284
+ ];
1285
+ examples.forEach(([expected, actual]) => {
1286
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1287
+ expect(sparkQuotePriceTrigger.decode(actual)).to.eql(expected);
1288
+ });
1289
+ });
1290
+ });
1291
+ });
901
1292
  });
@@ -23,7 +23,7 @@ export declare function getRatioStateInfoForAaveCloseStrategy(currentRatioState:
23
23
  ratioState: RatioState;
24
24
  };
25
25
  export declare function getPositionId(...args: (number | string)[]): string;
26
- export declare function getCloseStrategyType(stopLossPrice: number, stopLossType: CloseToAssetType, takeProfitPrice: number, takeProfitType: CloseToAssetType): CloseStrategyType;
26
+ export declare function getCloseStrategyType(stopLossPrice: number | string, stopLossType: CloseToAssetType, takeProfitPrice: number | string, takeProfitType: CloseToAssetType): CloseStrategyType;
27
27
  export declare function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStrategyType: CloseStrategyType): {
28
28
  stopLossType: CloseToAssetType | undefined;
29
29
  takeProfitType: CloseToAssetType | undefined;
@@ -81,8 +81,16 @@ export function getPositionId(...args) {
81
81
  return args.map(arg => arg.toString().toLowerCase().split(' ').join('_')).join('-');
82
82
  }
83
83
  export function getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType) {
84
- const isStopLoss = stopLossPrice > 0;
85
- const isTakeProfit = takeProfitPrice > 0;
84
+ const stopLossPriceDec = new Dec(stopLossPrice);
85
+ const takeProfitPriceDec = new Dec(takeProfitPrice);
86
+ if (!stopLossPriceDec.isFinite() || stopLossPriceDec.isNegative()) {
87
+ throw new Error('CloseOnPrice: stopLossPrice must be a finite non-negative number');
88
+ }
89
+ if (!takeProfitPriceDec.isFinite() || takeProfitPriceDec.isNegative()) {
90
+ throw new Error('CloseOnPrice: takeProfitPrice must be a finite non-negative number');
91
+ }
92
+ const isStopLoss = stopLossPriceDec.gt(0);
93
+ const isTakeProfit = takeProfitPriceDec.gt(0);
86
94
  if (!isStopLoss && !isTakeProfit) {
87
95
  throw new Error('CloseOnPrice: At least one price must be defined');
88
96
  }
@@ -1,11 +1,8 @@
1
1
  import { expect } from 'chai';
2
- import * as web3Utils from 'web3-utils';
3
- import AbiCoder from 'web3-eth-abi';
4
2
  import { getAssetInfo } from '@defisaver/tokens';
5
3
  import { ChainId, ProtocolIdentifiers, RatioState } from '../types/enums';
6
- import { sparkEncode } from './strategySubService';
7
4
  import '../configuration';
8
- import { addToArrayIf, addToObjectIf, compareAddresses, compareSubHashes, encodeSubId, ethToWeth, getRatioStateInfoForAaveCloseStrategy, isAddress, isDefined, isEmptyBytes, isRatioStateOver, isRatioStateUnder, isUndefined, ratioPercentageToWei, requireAddress, requireAddresses, weiToRatioPercentage, wethToEth, wethToEthByAddress, getPositionId, } from './utils';
5
+ import { addToArrayIf, addToObjectIf, compareAddresses, encodeSubId, ethToWeth, getRatioStateInfoForAaveCloseStrategy, isAddress, isDefined, isEmptyBytes, isRatioStateOver, isRatioStateUnder, isUndefined, ratioPercentageToWei, requireAddress, requireAddresses, weiToRatioPercentage, wethToEth, wethToEthByAddress, getPositionId, } from './utils';
9
6
  describe('Feature: utils.ts', () => {
10
7
  describe('When testing utils.isDefined()', () => {
11
8
  const examples = [
@@ -139,54 +136,6 @@ describe('Feature: utils.ts', () => {
139
136
  });
140
137
  });
141
138
  });
142
- describe('When testing utils.compareSubHashes()', () => {
143
- const subDataToEncodeOne = [
144
- 12,
145
- false,
146
- {
147
- baseTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
148
- quoteTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
149
- price: 100,
150
- ratioState: 1,
151
- },
152
- {
153
- collAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
154
- collAssetId: 2,
155
- debtAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
156
- debtAssetId: 3,
157
- },
158
- ];
159
- const subDataToEncodeTwo = [
160
- 13,
161
- true,
162
- {
163
- baseTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
164
- quoteTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
165
- price: 100,
166
- ratioState: 2,
167
- },
168
- {
169
- collAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
170
- collAssetId: 2,
171
- debtAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
172
- debtAssetId: 3,
173
- },
174
- ];
175
- // @ts-ignore
176
- const encodedSubDataOne = sparkEncode.closeToAsset(...subDataToEncodeOne);
177
- // @ts-ignore
178
- const encodedSubDataTwo = sparkEncode.closeToAsset(...subDataToEncodeTwo);
179
- const encodedParams = web3Utils.keccak256(AbiCoder.encodeParameter('(uint64,bool,bytes[],bytes32[])', encodedSubDataOne));
180
- const examples = [
181
- [true, [encodedParams, encodedSubDataOne]],
182
- [false, [encodedParams, encodedSubDataTwo]],
183
- ];
184
- examples.forEach(([expected, actual]) => {
185
- it(`Given ${actual} should return expected value: ${expected}`, () => {
186
- expect(compareSubHashes(...actual)).to.equal(expected);
187
- });
188
- });
189
- });
190
139
  describe('When testing utils.encodeSubId()', () => {
191
140
  const examples = [
192
141
  ['00000001', '1'],