@defisaver/automation-sdk 2.1.0 → 2.1.1

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.
package/README.md CHANGED
@@ -18,6 +18,9 @@ const subscriptions = await ethereumStrategies.getSubscriptionsFor(
18
18
  {
19
19
  fromBlock: 0,
20
20
  toBlock: 'latest',
21
+ mergeWithSameId: true, // Used for merging subscriptions with same strategy ID (e.g. boost and repay)
22
+ enabledOnly: true,
23
+ unexpiredOnly: true, // Referring to exchange subscriptions
21
24
  }
22
25
  );
23
26
 
@@ -166,18 +166,6 @@ exports.liquityRatioTrigger = {
166
166
  },
167
167
  };
168
168
  exports.liquityDebtInFrontTrigger = {
169
- encode(owner, debtInFrontMin) {
170
- return [web3_eth_abi_1.default.encodeParameters(['address', 'uint256'], [owner, debtInFrontMin])];
171
- },
172
- decode(triggerData) {
173
- const decodedData = web3_eth_abi_1.default.decodeParameters(['address', 'uint256'], triggerData[0]);
174
- return {
175
- owner: decodedData[0],
176
- debtInFrontMin: decodedData[1],
177
- };
178
- },
179
- };
180
- exports.liquityDebtInFrontWithLimitTrigger = {
181
169
  encode(owner, debtInFrontMin) {
182
170
  const debtInFrontMinWei = web3Utils.toWei(new decimal_js_1.default(debtInFrontMin).toString(), 'ether');
183
171
  return [web3_eth_abi_1.default.encodeParameters(['address', 'uint256'], [owner, debtInFrontMinWei])];
@@ -190,6 +178,7 @@ exports.liquityDebtInFrontWithLimitTrigger = {
190
178
  };
191
179
  },
192
180
  };
181
+ exports.liquityDebtInFrontWithLimitTrigger = exports.liquityDebtInFrontTrigger;
193
182
  exports.aaveV2RatioTrigger = {
194
183
  encode(owner, market, ratioPercentage, ratioState) {
195
184
  const ratioWei = (0, utils_1.ratioPercentageToWei)(ratioPercentage);
@@ -363,17 +363,34 @@ describe('Feature: triggerService.ts', () => {
363
363
  describe('encode()', () => {
364
364
  const examples = [
365
365
  [
366
- ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000000007ee'],
366
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000006e0be8c4995af80000'],
367
367
  [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '2030']
368
368
  ],
369
369
  [
370
- ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c0000000000000000000000000000000000000000000000000000000000051639'],
370
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000004697f83e6356dd440000'],
371
371
  [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '333369']
372
372
  ],
373
+ [
374
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000084595161401484a000000'],
375
+ [web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '10000000']
376
+ ],
377
+ [
378
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf0000000000000000000000000000000000000000000000000000000000989680'],
379
+ [web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '0.00000000001']
380
+ ],
381
+ [
382
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
383
+ [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '500000000']
384
+ ],
385
+ [
386
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
387
+ [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '2000000']
388
+ ],
373
389
  ];
374
390
  examples.forEach(([expected, actual]) => {
375
391
  it(`Given ${actual} should return expected value: ${expected}`, () => {
376
392
  (0, chai_1.expect)(triggerService_1.liquityDebtInFrontTrigger.encode(...actual)).to.eql(expected);
393
+ (0, chai_1.expect)(triggerService_1.liquityDebtInFrontWithLimitTrigger.encode(...actual)).to.eql(expected);
377
394
  });
378
395
  });
379
396
  });
@@ -384,19 +401,48 @@ describe('Feature: triggerService.ts', () => {
384
401
  owner: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
385
402
  debtInFrontMin: '2030',
386
403
  },
387
- ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000000007ee'],
404
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000006e0be8c4995af80000'],
388
405
  ],
389
406
  [
390
407
  {
391
408
  owner: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
392
409
  debtInFrontMin: '333369',
393
410
  },
394
- ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c0000000000000000000000000000000000000000000000000000000000051639'],
411
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000004697f83e6356dd440000'],
412
+ ],
413
+ [
414
+ {
415
+ owner: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
416
+ debtInFrontMin: '10000000',
417
+ },
418
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000084595161401484a000000'],
419
+ ],
420
+ [
421
+ {
422
+ owner: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
423
+ debtInFrontMin: '0.00000000001',
424
+ },
425
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf0000000000000000000000000000000000000000000000000000000000989680'],
426
+ ],
427
+ [
428
+ {
429
+ owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
430
+ debtInFrontMin: '500000000',
431
+ },
432
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
433
+ ],
434
+ [
435
+ {
436
+ owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
437
+ debtInFrontMin: '2000000',
438
+ },
439
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
395
440
  ],
396
441
  ];
397
442
  examples.forEach(([expected, actual]) => {
398
443
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
399
444
  (0, chai_1.expect)(triggerService_1.liquityDebtInFrontTrigger.decode(actual)).to.eql(expected);
445
+ (0, chai_1.expect)(triggerService_1.liquityDebtInFrontWithLimitTrigger.decode(actual)).to.eql(expected);
400
446
  });
401
447
  });
402
448
  });
@@ -776,46 +822,4 @@ describe('Feature: triggerService.ts', () => {
776
822
  });
777
823
  });
778
824
  });
779
- describe('When testing triggerService.liquityDebtInFrontWithLimitTrigger', () => {
780
- describe('encode()', () => {
781
- const examples = [
782
- [
783
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
784
- [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '500000000']
785
- ],
786
- [
787
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
788
- [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '2000000']
789
- ],
790
- ];
791
- examples.forEach(([expected, actual]) => {
792
- it(`Given ${actual} should return expected value: ${expected}`, () => {
793
- (0, chai_1.expect)(triggerService_1.liquityDebtInFrontWithLimitTrigger.encode(...actual)).to.eql(expected);
794
- });
795
- });
796
- });
797
- describe('decode()', () => {
798
- const examples = [
799
- [
800
- {
801
- owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
802
- debtInFrontMin: '500000000',
803
- },
804
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
805
- ],
806
- [
807
- {
808
- owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
809
- debtInFrontMin: '2000000',
810
- },
811
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
812
- ],
813
- ];
814
- examples.forEach(([expected, actual]) => {
815
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
816
- (0, chai_1.expect)(triggerService_1.liquityDebtInFrontWithLimitTrigger.decode(actual)).to.eql(expected);
817
- });
818
- });
819
- });
820
- });
821
825
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/automation-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "",
5
5
  "main": "./umd/index.js",
6
6
  "module": "./esm/index.js",
@@ -395,18 +395,35 @@ describe('Feature: triggerService.ts', () => {
395
395
  describe('encode()', () => {
396
396
  const examples: Array<[[string], [owner: EthereumAddress, debtInFrontMin: string]]> = [
397
397
  [
398
- ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000000007ee'],
398
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000006e0be8c4995af80000'],
399
399
  [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '2030']
400
400
  ],
401
401
  [
402
- ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c0000000000000000000000000000000000000000000000000000000000051639'],
402
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000004697f83e6356dd440000'],
403
403
  [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '333369']
404
404
  ],
405
+ [
406
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000084595161401484a000000'],
407
+ [web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '10000000']
408
+ ],
409
+ [
410
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf0000000000000000000000000000000000000000000000000000000000989680'],
411
+ [web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '0.00000000001']
412
+ ],
413
+ [
414
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
415
+ [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '500000000']
416
+ ],
417
+ [
418
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
419
+ [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '2000000']
420
+ ],
405
421
  ];
406
422
 
407
423
  examples.forEach(([expected, actual]) => {
408
424
  it(`Given ${actual} should return expected value: ${expected}`, () => {
409
425
  expect(liquityDebtInFrontTrigger.encode(...actual)).to.eql(expected);
426
+ expect(liquityDebtInFrontWithLimitTrigger.encode(...actual)).to.eql(expected);
410
427
  });
411
428
  });
412
429
  });
@@ -418,20 +435,49 @@ describe('Feature: triggerService.ts', () => {
418
435
  owner: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
419
436
  debtInFrontMin: '2030',
420
437
  },
421
- ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000000000000000007ee'],
438
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000006e0be8c4995af80000'],
422
439
  ],
423
440
  [
424
441
  {
425
442
  owner: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
426
443
  debtInFrontMin: '333369',
427
444
  },
428
- ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c0000000000000000000000000000000000000000000000000000000000051639'],
445
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000004697f83e6356dd440000'],
446
+ ],
447
+ [
448
+ {
449
+ owner: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
450
+ debtInFrontMin: '10000000',
451
+ },
452
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000084595161401484a000000'],
453
+ ],
454
+ [
455
+ {
456
+ owner: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
457
+ debtInFrontMin: '0.00000000001',
458
+ },
459
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf0000000000000000000000000000000000000000000000000000000000989680'],
460
+ ],
461
+ [
462
+ {
463
+ owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
464
+ debtInFrontMin: '500000000',
465
+ },
466
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
467
+ ],
468
+ [
469
+ {
470
+ owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
471
+ debtInFrontMin: '2000000',
472
+ },
473
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
429
474
  ],
430
475
  ];
431
476
 
432
477
  examples.forEach(([expected, actual]) => {
433
478
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
434
479
  expect(liquityDebtInFrontTrigger.decode(actual)).to.eql(expected);
480
+ expect(liquityDebtInFrontWithLimitTrigger.decode(actual)).to.eql(expected);
435
481
  });
436
482
  });
437
483
  });
@@ -848,50 +894,4 @@ describe('Feature: triggerService.ts', () => {
848
894
  });
849
895
  });
850
896
 
851
- describe('When testing triggerService.liquityDebtInFrontWithLimitTrigger', () => {
852
- describe('encode()', () => {
853
- const examples: Array<[[string], [owner: EthereumAddress, debtInFrontMin: string]]> = [
854
- [
855
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
856
- [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '500000000']
857
- ],
858
- [
859
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
860
- [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '2000000']
861
- ],
862
- ];
863
-
864
- examples.forEach(([expected, actual]) => {
865
- it(`Given ${actual} should return expected value: ${expected}`, () => {
866
- expect(liquityDebtInFrontWithLimitTrigger.encode(...actual)).to.eql(expected);
867
- });
868
- });
869
- });
870
-
871
- describe('decode()', () => {
872
- const examples: Array<[{ owner: EthereumAddress, debtInFrontMin: string }, TriggerData]> = [
873
- [
874
- {
875
- owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
876
- debtInFrontMin: '500000000',
877
- },
878
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
879
- ],
880
- [
881
- {
882
- owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
883
- debtInFrontMin: '2000000',
884
- },
885
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
886
- ],
887
- ];
888
-
889
- examples.forEach(([expected, actual]) => {
890
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
891
- expect(liquityDebtInFrontWithLimitTrigger.decode(actual)).to.eql(expected);
892
- });
893
- });
894
- });
895
- });
896
-
897
- });
897
+ });
@@ -172,19 +172,6 @@ export const liquityRatioTrigger = {
172
172
  };
173
173
 
174
174
  export const liquityDebtInFrontTrigger = {
175
- encode(owner: EthereumAddress, debtInFrontMin: string) {
176
- return [AbiCoder.encodeParameters(['address', 'uint256'], [owner, debtInFrontMin])];
177
- },
178
- decode(triggerData: TriggerData): { owner: EthereumAddress, debtInFrontMin: string } {
179
- const decodedData = AbiCoder.decodeParameters(['address', 'uint256'], triggerData[0]);
180
- return {
181
- owner: decodedData[0] as EthereumAddress,
182
- debtInFrontMin: decodedData[1] as string,
183
- };
184
- },
185
- };
186
-
187
- export const liquityDebtInFrontWithLimitTrigger = {
188
175
  encode(owner: EthereumAddress, debtInFrontMin: string) {
189
176
  const debtInFrontMinWei = web3Utils.toWei(new Dec(debtInFrontMin).toString(), 'ether');
190
177
  return [AbiCoder.encodeParameters(['address', 'uint256'], [owner, debtInFrontMinWei])];
@@ -198,6 +185,8 @@ export const liquityDebtInFrontWithLimitTrigger = {
198
185
  },
199
186
  };
200
187
 
188
+ export const liquityDebtInFrontWithLimitTrigger = liquityDebtInFrontTrigger;
189
+
201
190
  export const aaveV2RatioTrigger = {
202
191
  encode(owner: EthereumAddress, market: EthereumAddress, ratioPercentage: number, ratioState: RatioState) {
203
192
  const ratioWei = ratioPercentageToWei(ratioPercentage);
package/umd/index.js CHANGED
@@ -32961,18 +32961,6 @@ var liquityRatioTrigger = {
32961
32961
  }
32962
32962
  };
32963
32963
  var liquityDebtInFrontTrigger = {
32964
- encode(owner, debtInFrontMin) {
32965
- return [web3_eth_abi__WEBPACK_IMPORTED_MODULE_2___default().encodeParameters(['address', 'uint256'], [owner, debtInFrontMin])];
32966
- },
32967
- decode(triggerData) {
32968
- var decodedData = web3_eth_abi__WEBPACK_IMPORTED_MODULE_2___default().decodeParameters(['address', 'uint256'], triggerData[0]);
32969
- return {
32970
- owner: decodedData[0],
32971
- debtInFrontMin: decodedData[1]
32972
- };
32973
- }
32974
- };
32975
- var liquityDebtInFrontWithLimitTrigger = {
32976
32964
  encode(owner, debtInFrontMin) {
32977
32965
  var debtInFrontMinWei = web3_utils__WEBPACK_IMPORTED_MODULE_3__.toWei(new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(debtInFrontMin).toString(), 'ether');
32978
32966
  return [web3_eth_abi__WEBPACK_IMPORTED_MODULE_2___default().encodeParameters(['address', 'uint256'], [owner, debtInFrontMinWei])];
@@ -32985,6 +32973,7 @@ var liquityDebtInFrontWithLimitTrigger = {
32985
32973
  };
32986
32974
  }
32987
32975
  };
32976
+ var liquityDebtInFrontWithLimitTrigger = liquityDebtInFrontTrigger;
32988
32977
  var aaveV2RatioTrigger = {
32989
32978
  encode(owner, market, ratioPercentage, ratioState) {
32990
32979
  var ratioWei = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.ratioPercentageToWei)(ratioPercentage);
package/.env DELETED
@@ -1,4 +0,0 @@
1
- RPC_1=https://mainnet.infura.io/v3/a3503e4501d040cd9ea2c913c68983a1
2
- RPC_10=https://opt-mainnet.g.alchemy.com/v2/Pwh-hdbsP7Bf0CP_UMw4_Pw-NfHhSpIA
3
- RPC_8453=https://base-mainnet.g.alchemy.com/v2/TERsAaPNcA7sgCVHHAMBvd95UtT4wCEf
4
- RPC_42161=https://arb-mainnet.g.alchemy.com/v2/Pwh-hdbsP7Bf0CP_UMw4_Pw-NfHhSpIA