@defisaver/automation-sdk 3.3.10 → 3.3.11-aave-v4-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 (49) hide show
  1. package/cjs/constants/index.d.ts +1 -0
  2. package/cjs/constants/index.js +72 -1
  3. package/cjs/services/ethereumService.test.js +2 -0
  4. package/cjs/services/strategiesService.js +129 -0
  5. package/cjs/services/strategySubService.d.ts +19 -0
  6. package/cjs/services/strategySubService.js +37 -1
  7. package/cjs/services/strategySubService.test.js +229 -0
  8. package/cjs/services/subDataService.d.ts +298 -129
  9. package/cjs/services/subDataService.js +639 -369
  10. package/cjs/services/subDataService.test.js +214 -0
  11. package/cjs/services/triggerService.d.ts +38 -0
  12. package/cjs/services/triggerService.js +68 -1
  13. package/cjs/services/triggerService.test.js +130 -0
  14. package/cjs/services/utils.d.ts +1 -1
  15. package/cjs/services/utils.js +10 -2
  16. package/cjs/types/enums.d.ts +19 -3
  17. package/cjs/types/enums.js +16 -0
  18. package/cjs/types/index.d.ts +33 -1
  19. package/esm/constants/index.d.ts +1 -0
  20. package/esm/constants/index.js +71 -0
  21. package/esm/services/ethereumService.test.js +2 -0
  22. package/esm/services/strategiesService.js +130 -1
  23. package/esm/services/strategySubService.d.ts +19 -0
  24. package/esm/services/strategySubService.js +36 -0
  25. package/esm/services/strategySubService.test.js +230 -1
  26. package/esm/services/subDataService.d.ts +298 -129
  27. package/esm/services/subDataService.js +639 -369
  28. package/esm/services/subDataService.test.js +214 -0
  29. package/esm/services/triggerService.d.ts +38 -0
  30. package/esm/services/triggerService.js +67 -0
  31. package/esm/services/triggerService.test.js +131 -1
  32. package/esm/services/utils.d.ts +1 -1
  33. package/esm/services/utils.js +10 -2
  34. package/esm/types/enums.d.ts +19 -3
  35. package/esm/types/enums.js +16 -0
  36. package/esm/types/index.d.ts +33 -1
  37. package/package.json +2 -2
  38. package/src/constants/index.ts +72 -0
  39. package/src/services/ethereumService.test.ts +2 -0
  40. package/src/services/strategiesService.ts +150 -2
  41. package/src/services/strategySubService.test.ts +286 -0
  42. package/src/services/strategySubService.ts +140 -0
  43. package/src/services/subDataService.test.ts +239 -0
  44. package/src/services/subDataService.ts +1072 -784
  45. package/src/services/triggerService.test.ts +148 -0
  46. package/src/services/triggerService.ts +97 -1
  47. package/src/services/utils.ts +15 -4
  48. package/src/types/enums.ts +16 -0
  49. package/src/types/index.ts +40 -1
@@ -581,6 +581,28 @@ export const sparkEncode = {
581
581
 
582
582
  return subInput;
583
583
  },
584
+ leverageManagementOnPrice(
585
+ strategyOrBundleId: number,
586
+ isBundle: boolean = true,
587
+ triggerData: {
588
+ baseTokenAddr: EthereumAddress, quoteTokenAddr: EthereumAddress, price: number, ratioState: RatioState
589
+ },
590
+ subData: {
591
+ collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number,
592
+ },
593
+ ) {
594
+ const {
595
+ collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
596
+ } = subData;
597
+ const subDataEncoded = subDataService.sparkLeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
598
+
599
+ const {
600
+ baseTokenAddr, quoteTokenAddr, price, ratioState,
601
+ } = triggerData;
602
+ const triggerDataEncoded = triggerService.sparkQuotePriceTrigger.encode(baseTokenAddr, quoteTokenAddr, price, ratioState);
603
+
604
+ return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
605
+ },
584
606
  closeOnPriceGeneric(
585
607
  strategyOrBundleId: number,
586
608
  collAsset: EthereumAddress,
@@ -824,3 +846,121 @@ export const fluidEncode = {
824
846
  return [strategyOrBundleId, isBundle, triggerData, subData];
825
847
  },
826
848
  };
849
+
850
+ export const aaveV4Encode = {
851
+ leverageManagement(
852
+ strategyOrBundleId: number,
853
+ owner: EthereumAddress,
854
+ spoke: EthereumAddress,
855
+ ratioState: RatioState,
856
+ targetRatio: number,
857
+ triggerRatio: number,
858
+ ) {
859
+ const isBundle = true;
860
+ const subData = subDataService.aaveV4LeverageManagementSubData.encode(spoke, owner, ratioState, targetRatio);
861
+ const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
862
+
863
+ return [strategyOrBundleId, isBundle, triggerData, subData];
864
+ },
865
+ leverageManagementOnPrice(
866
+ strategyOrBundleId: number,
867
+ owner: EthereumAddress,
868
+ spoke: EthereumAddress,
869
+ collAsset: EthereumAddress,
870
+ collAssetId: number,
871
+ debtAsset: EthereumAddress,
872
+ debtAssetId: number,
873
+ targetRatio: number,
874
+ price: string,
875
+ priceState: RatioState,
876
+ ratioState: RatioState, // UNDER for repay, OVER for boost
877
+ ) {
878
+ const isBundle = true;
879
+ const subData = subDataService.aaveV4LeverageManagementOnPriceSubData.encode(
880
+ spoke,
881
+ owner,
882
+ collAsset,
883
+ collAssetId,
884
+ debtAsset,
885
+ debtAssetId,
886
+ ratioState,
887
+ targetRatio,
888
+ );
889
+ const triggerData = triggerService.aaveV4QuotePriceTrigger.encode(
890
+ spoke,
891
+ collAssetId,
892
+ debtAssetId,
893
+ price,
894
+ priceState,
895
+ );
896
+
897
+ return [strategyOrBundleId, isBundle, triggerData, subData];
898
+ },
899
+ closeOnPrice(
900
+ strategyOrBundleId: number,
901
+ owner: EthereumAddress,
902
+ spoke: EthereumAddress,
903
+ collAsset: EthereumAddress,
904
+ collAssetId: number,
905
+ debtAsset: EthereumAddress,
906
+ debtAssetId: number,
907
+ stopLossPrice: string = '0',
908
+ stopLossType: CloseToAssetType = CloseToAssetType.DEBT,
909
+ takeProfitPrice: string = '0',
910
+ takeProfitType: CloseToAssetType = CloseToAssetType.COLLATERAL,
911
+ ) {
912
+ const isBundle = true;
913
+ const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
914
+
915
+ const subData = subDataService.aaveV4CloseSubData.encode(
916
+ spoke,
917
+ owner,
918
+ collAsset,
919
+ collAssetId,
920
+ debtAsset,
921
+ debtAssetId,
922
+ closeType,
923
+ );
924
+ const triggerData = triggerService.aaveV4QuotePriceRangeTrigger.encode(
925
+ spoke,
926
+ collAssetId,
927
+ debtAssetId,
928
+ stopLossPrice,
929
+ takeProfitPrice,
930
+ );
931
+
932
+ return [strategyOrBundleId, isBundle, triggerData, subData];
933
+ },
934
+ collateralSwitch(
935
+ strategyOrBundleId: number,
936
+ owner: EthereumAddress,
937
+ spoke: EthereumAddress,
938
+ fromAsset: EthereumAddress,
939
+ fromAssetId: number,
940
+ toAsset: EthereumAddress,
941
+ toAssetId: number,
942
+ amountToSwitch: string,
943
+ price: string,
944
+ ratioState: RatioState,
945
+ ) {
946
+ const isBundle = false;
947
+ const subData = subDataService.aaveV4CollateralSwitchSubData.encode(
948
+ spoke,
949
+ owner,
950
+ fromAsset,
951
+ fromAssetId,
952
+ toAsset,
953
+ toAssetId,
954
+ amountToSwitch,
955
+ );
956
+ const triggerData = triggerService.aaveV4QuotePriceTrigger.encode(
957
+ spoke,
958
+ fromAssetId, // baseTokenId
959
+ toAssetId, // quoteTokenId
960
+ price,
961
+ ratioState,
962
+ );
963
+
964
+ return [strategyOrBundleId, isBundle, triggerData, subData];
965
+ },
966
+ };
@@ -2263,4 +2263,243 @@ describe('Feature: subDataService.ts', () => {
2263
2263
  });
2264
2264
  });
2265
2265
  });
2266
+ describe('When testing subDataService.sparkLeverageManagementOnPriceSubData', () => {
2267
+ describe('encode()', () => {
2268
+ const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]] > =
2269
+ [
2270
+ [
2271
+ [
2272
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2273
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2274
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2275
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2276
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2277
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
2278
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2279
+ ],
2280
+ [
2281
+ web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
2282
+ 0,
2283
+ web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
2284
+ 1,
2285
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2286
+ 200,
2287
+ ]
2288
+ ]
2289
+ ];
2290
+
2291
+ examples.forEach(([expected, actual]) => {
2292
+ it(`Given ${JSON.stringify(
2293
+ actual
2294
+ )} should return expected value: ${JSON.stringify(expected)}`, () => {
2295
+ expect(subDataService.sparkLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
2296
+ });
2297
+ });
2298
+ });
2299
+
2300
+ describe('decode()', () => {
2301
+ const examples: Array<[{ collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number}, SubData]> =
2302
+ [
2303
+ [
2304
+ {
2305
+ collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
2306
+ collAssetId: 2,
2307
+ debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
2308
+ debtAssetId: 4,
2309
+ marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2310
+ targetRatio: 175
2311
+ }
2312
+ ,
2313
+ [
2314
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2315
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2316
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
2317
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
2318
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2319
+ '0x00000000000000000000000000000000000000000000000018493fba64ef0000'
2320
+ ]
2321
+ ]
2322
+ ];
2323
+
2324
+ examples.forEach(([expected, actual]) => {
2325
+ it(`Given ${JSON.stringify(
2326
+ actual
2327
+ )} should return expected value: ${JSON.stringify(expected)}`, () => {
2328
+ expect(subDataService.sparkLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
2329
+ });
2330
+ });
2331
+ });
2332
+ });
2333
+ describe('When testing subDataService.aaveV4LeverageManagementSubData', () => {
2334
+ describe('encode()', () => {
2335
+ const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, ratioState: RatioState, targetRatio: number]]> = [
2336
+ [
2337
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
2338
+ [web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), RatioState.UNDER, 150]
2339
+ ],
2340
+ ];
2341
+
2342
+ examples.forEach(([expected, actual]) => {
2343
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
2344
+ expect(subDataService.aaveV4LeverageManagementSubData.encode(...actual)).to.eql(expected);
2345
+ });
2346
+ });
2347
+ });
2348
+
2349
+ describe('decode()', () => {
2350
+ const examples: Array<[{ spoke: EthereumAddress, owner: EthereumAddress, ratioState: RatioState, targetRatio: number }, SubData]> = [
2351
+ [
2352
+ {
2353
+ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
2354
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2355
+ ratioState: RatioState.UNDER,
2356
+ targetRatio: 150,
2357
+ },
2358
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x0000000000000000000000000000000000000000000000000000000000000001","0x00000000000000000000000000000000000000000000000014d1120d7b160000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
2359
+ ],
2360
+ ];
2361
+
2362
+ examples.forEach(([expected, actual]) => {
2363
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
2364
+ expect(subDataService.aaveV4LeverageManagementSubData.decode(actual)).to.eql(expected);
2365
+ });
2366
+ });
2367
+ });
2368
+ });
2369
+
2370
+ describe('When testing subDataService.aaveV4LeverageManagementOnPriceSubData', () => {
2371
+ describe('encode()', () => {
2372
+ const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, ratioState: RatioState, targetRatio: number]]> = [
2373
+ [
2374
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
2375
+ [
2376
+ web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2377
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
2378
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
2379
+ RatioState.OVER, 160
2380
+ ]
2381
+ ],
2382
+ ];
2383
+
2384
+ examples.forEach(([expected, actual]) => {
2385
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
2386
+ expect(subDataService.aaveV4LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
2387
+ });
2388
+ });
2389
+ });
2390
+
2391
+ describe('decode()', () => {
2392
+ const examples: Array<[{ spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, ratioState: RatioState, targetRatio: number }, SubData]> = [
2393
+ [
2394
+ {
2395
+ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
2396
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2397
+ collAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
2398
+ collAssetId: 10,
2399
+ debtAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
2400
+ debtAssetId: 20,
2401
+ ratioState: RatioState.OVER,
2402
+ targetRatio: 160,
2403
+ },
2404
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000016345785d8a00000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
2405
+ ],
2406
+ ];
2407
+
2408
+ examples.forEach(([expected, actual]) => {
2409
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
2410
+ expect(subDataService.aaveV4LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
2411
+ });
2412
+ });
2413
+ });
2414
+ });
2415
+
2416
+ describe('When testing subDataService.aaveV4CloseSubData', () => {
2417
+ describe('encode()', () => {
2418
+ const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType]]> = [
2419
+ [
2420
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
2421
+ [
2422
+ web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2423
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
2424
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
2425
+ CloseStrategyType.STOP_LOSS_IN_COLLATERAL
2426
+ ]
2427
+ ],
2428
+ ];
2429
+
2430
+ examples.forEach(([expected, actual]) => {
2431
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
2432
+ expect(subDataService.aaveV4CloseSubData.encode(...actual)).to.eql(expected);
2433
+ });
2434
+ });
2435
+ });
2436
+
2437
+ describe('decode()', () => {
2438
+ const examples: Array<[{ spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType }, SubData]> = [
2439
+ [
2440
+ {
2441
+ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
2442
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2443
+ collAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
2444
+ collAssetId: 10,
2445
+ debtAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
2446
+ debtAssetId: 20,
2447
+ closeType: CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
2448
+ },
2449
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000000000000000001","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
2450
+ ],
2451
+ ];
2452
+
2453
+ examples.forEach(([expected, actual]) => {
2454
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
2455
+ expect(subDataService.aaveV4CloseSubData.decode(actual)).to.eql(expected);
2456
+ });
2457
+ });
2458
+ });
2459
+ });
2460
+
2461
+ describe('When testing subDataService.aaveV4CollateralSwitchSubData', () => {
2462
+ describe('encode()', () => {
2463
+ const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, amountToSwitch: string]]> = [
2464
+ [
2465
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
2466
+ [
2467
+ web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2468
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
2469
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
2470
+ '1000000000000000000'
2471
+ ]
2472
+ ],
2473
+ ];
2474
+
2475
+ examples.forEach(([expected, actual]) => {
2476
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
2477
+ expect(subDataService.aaveV4CollateralSwitchSubData.encode(...actual)).to.eql(expected);
2478
+ });
2479
+ });
2480
+ });
2481
+
2482
+ describe('decode()', () => {
2483
+ const examples: Array<[{ spoke: EthereumAddress, owner: EthereumAddress, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, amountToSwitch: string }, SubData]> = [
2484
+ [
2485
+ {
2486
+ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
2487
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2488
+ fromAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
2489
+ fromAssetId: 10,
2490
+ toAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
2491
+ toAssetId: 20,
2492
+ amountToSwitch: '1000000000000000000'
2493
+ },
2494
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e","0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c","0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x000000000000000000000000000000000000000000000000000000000000000a","0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","0x0000000000000000000000000000000000000000000000000000000000000014","0x0000000000000000000000000000000000000000000000000de0b6b3a7640000","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000000"],
2495
+ ],
2496
+ ];
2497
+
2498
+ examples.forEach(([expected, actual]) => {
2499
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
2500
+ expect(subDataService.aaveV4CollateralSwitchSubData.decode(actual)).to.eql(expected);
2501
+ });
2502
+ });
2503
+ });
2504
+ });
2266
2505
  });