@defisaver/automation-sdk 3.3.6 → 3.3.7-dev.0

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 (39) hide show
  1. package/cjs/constants/index.js +5 -10
  2. package/cjs/services/strategiesService.js +11 -14
  3. package/cjs/services/strategySubService.d.ts +1 -11
  4. package/cjs/services/strategySubService.js +5 -5
  5. package/cjs/services/strategySubService.test.js +0 -72
  6. package/cjs/services/subDataService.d.ts +12 -9
  7. package/cjs/services/subDataService.js +33 -20
  8. package/cjs/services/subDataService.test.js +0 -72
  9. package/cjs/services/triggerService.d.ts +9 -9
  10. package/cjs/services/triggerService.js +20 -19
  11. package/cjs/services/triggerService.test.js +0 -46
  12. package/cjs/services/utils.test.js +0 -77
  13. package/cjs/types/enums.d.ts +2 -3
  14. package/cjs/types/enums.js +1 -2
  15. package/esm/constants/index.js +5 -10
  16. package/esm/services/strategiesService.js +11 -14
  17. package/esm/services/strategySubService.d.ts +1 -11
  18. package/esm/services/strategySubService.js +5 -5
  19. package/esm/services/strategySubService.test.js +1 -73
  20. package/esm/services/subDataService.d.ts +12 -9
  21. package/esm/services/subDataService.js +32 -19
  22. package/esm/services/subDataService.test.js +0 -72
  23. package/esm/services/triggerService.d.ts +9 -9
  24. package/esm/services/triggerService.js +19 -18
  25. package/esm/services/triggerService.test.js +1 -47
  26. package/esm/services/utils.test.js +1 -52
  27. package/esm/types/enums.d.ts +2 -3
  28. package/esm/types/enums.js +1 -2
  29. package/package.json +1 -1
  30. package/src/constants/index.ts +5 -12
  31. package/src/services/strategiesService.ts +12 -22
  32. package/src/services/strategySubService.test.ts +4 -94
  33. package/src/services/strategySubService.ts +15 -16
  34. package/src/services/subDataService.test.ts +1 -78
  35. package/src/services/subDataService.ts +52 -31
  36. package/src/services/triggerService.test.ts +0 -51
  37. package/src/services/triggerService.ts +29 -26
  38. package/src/services/utils.test.ts +0 -59
  39. package/src/types/enums.ts +1 -2
@@ -1,19 +1,14 @@
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
 
6
4
  import type { EthereumAddress } from '../types';
7
5
  import { ChainId, ProtocolIdentifiers, RatioState } from '../types/enums';
8
6
 
9
- import { sparkEncode } from './strategySubService';
10
-
11
7
  import '../configuration';
12
8
  import {
13
9
  addToArrayIf,
14
10
  addToObjectIf,
15
11
  compareAddresses,
16
- compareSubHashes,
17
12
  encodeSubId,
18
13
  ethToWeth,
19
14
  getRatioStateInfoForAaveCloseStrategy,
@@ -199,60 +194,6 @@ describe('Feature: utils.ts', () => {
199
194
  });
200
195
  });
201
196
 
202
- describe('When testing utils.compareSubHashes()', () => {
203
-
204
- const subDataToEncodeOne = [
205
- 12,
206
- false,
207
- {
208
- baseTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
209
- quoteTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
210
- price: 100,
211
- ratioState: 1,
212
- },
213
- {
214
- collAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
215
- collAssetId: 2,
216
- debtAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
217
- debtAssetId: 3,
218
- },
219
- ]
220
-
221
- const subDataToEncodeTwo = [
222
- 13,
223
- true,
224
- {
225
- baseTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
226
- quoteTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
227
- price: 100,
228
- ratioState: 2,
229
- },
230
- {
231
- collAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
232
- collAssetId: 2,
233
- debtAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
234
- debtAssetId: 3,
235
- },
236
- ]
237
-
238
- // @ts-ignore
239
- const encodedSubDataOne = sparkEncode.closeToAsset(...subDataToEncodeOne);
240
- // @ts-ignore
241
- const encodedSubDataTwo = sparkEncode.closeToAsset(...subDataToEncodeTwo);
242
- const encodedParams = web3Utils.keccak256(AbiCoder.encodeParameter('(uint64,bool,bytes[],bytes32[])', encodedSubDataOne));
243
-
244
- const examples: Array<[boolean, [string, any[]]]> = [
245
- [true, [encodedParams, encodedSubDataOne]],
246
- [false, [encodedParams, encodedSubDataTwo]],
247
- ];
248
-
249
- examples.forEach(([expected, actual]) => {
250
- it(`Given ${actual} should return expected value: ${expected}`, () => {
251
- expect(compareSubHashes(...actual)).to.equal(expected);
252
- });
253
- });
254
- });
255
-
256
197
  describe('When testing utils.encodeSubId()', () => {
257
198
  const examples: Array<[string, string]> = [
258
199
  ['00000001', '1'],
@@ -186,8 +186,6 @@ export namespace Bundles {
186
186
  LIQUITY_BOOST = 17,
187
187
  SPARK_REPAY = 18,
188
188
  SPARK_BOOST = 19,
189
- SPARK_CLOSE_TO_DEBT = -21231230, // @dev This was never deployed
190
- SPARK_CLOSE_TO_COLLATERAL = -21231231, // @dev This was never deployed
191
189
  AAVE_V2_REPAY = 22,
192
190
  AAVE_V2_BOOST = 23,
193
191
  COMP_V2_REPAY = 20,
@@ -223,6 +221,7 @@ export namespace Bundles {
223
221
  AAVE_V3_EOA_REPAY_ON_PRICE = 54,
224
222
  AAVE_V3_EOA_BOOST_ON_PRICE = 55,
225
223
  AAVE_V3_EOA_CLOSE = 56,
224
+ SPARK_CLOSE = 57,
226
225
  }
227
226
 
228
227
  export enum OptimismIds {