@across-protocol/sdk 4.1.9 → 4.1.10-beta.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 (68) hide show
  1. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +2 -6
  2. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +94 -114
  3. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  4. package/dist/cjs/clients/HubPoolClient.d.ts +1 -0
  5. package/dist/cjs/clients/HubPoolClient.js +10 -3
  6. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  7. package/dist/cjs/clients/SpokePoolClient.d.ts +3 -1
  8. package/dist/cjs/clients/SpokePoolClient.js +61 -38
  9. package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
  10. package/dist/cjs/interfaces/HubPool.d.ts +4 -1
  11. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +2 -3
  12. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  13. package/dist/cjs/utils/CachingUtils.js +3 -3
  14. package/dist/cjs/utils/CachingUtils.js.map +1 -1
  15. package/dist/cjs/utils/EventUtils.d.ts +1 -0
  16. package/dist/cjs/utils/EventUtils.js +5 -1
  17. package/dist/cjs/utils/EventUtils.js.map +1 -1
  18. package/dist/cjs/utils/LogUtils.d.ts +1 -0
  19. package/dist/cjs/utils/LogUtils.js +7 -1
  20. package/dist/cjs/utils/LogUtils.js.map +1 -1
  21. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +2 -6
  22. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +89 -110
  23. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  24. package/dist/esm/clients/HubPoolClient.d.ts +1 -0
  25. package/dist/esm/clients/HubPoolClient.js +10 -3
  26. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  27. package/dist/esm/clients/SpokePoolClient.d.ts +5 -3
  28. package/dist/esm/clients/SpokePoolClient.js +71 -44
  29. package/dist/esm/clients/SpokePoolClient.js.map +1 -1
  30. package/dist/esm/interfaces/HubPool.d.ts +4 -1
  31. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +1 -2
  32. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  33. package/dist/esm/utils/CachingUtils.js +1 -1
  34. package/dist/esm/utils/CachingUtils.js.map +1 -1
  35. package/dist/esm/utils/EventUtils.d.ts +1 -0
  36. package/dist/esm/utils/EventUtils.js +3 -0
  37. package/dist/esm/utils/EventUtils.js.map +1 -1
  38. package/dist/esm/utils/LogUtils.d.ts +7 -0
  39. package/dist/esm/utils/LogUtils.js +11 -0
  40. package/dist/esm/utils/LogUtils.js.map +1 -1
  41. package/dist/esm/utils/abi/typechain/Multicall3.d.ts +1 -4
  42. package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
  43. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +2 -6
  44. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  45. package/dist/types/clients/HubPoolClient.d.ts +1 -0
  46. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  47. package/dist/types/clients/SpokePoolClient.d.ts +5 -3
  48. package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
  49. package/dist/types/interfaces/HubPool.d.ts +4 -1
  50. package/dist/types/interfaces/HubPool.d.ts.map +1 -1
  51. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  52. package/dist/types/utils/EventUtils.d.ts +1 -0
  53. package/dist/types/utils/EventUtils.d.ts.map +1 -1
  54. package/dist/types/utils/LogUtils.d.ts +7 -0
  55. package/dist/types/utils/LogUtils.d.ts.map +1 -1
  56. package/dist/types/utils/abi/typechain/Multicall3.d.ts +1 -4
  57. package/dist/types/utils/abi/typechain/Multicall3.d.ts.map +1 -1
  58. package/dist/types/utils/abi/typechain/common.d.ts.map +1 -1
  59. package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/src/clients/BundleDataClient/BundleDataClient.ts +127 -153
  62. package/src/clients/HubPoolClient.ts +17 -11
  63. package/src/clients/SpokePoolClient.ts +44 -10
  64. package/src/interfaces/HubPool.ts +4 -1
  65. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +1 -1
  66. package/src/utils/CachingUtils.ts +1 -1
  67. package/src/utils/EventUtils.ts +4 -0
  68. package/src/utils/LogUtils.ts +12 -0
@@ -2,7 +2,7 @@ import { ProposedRootBundle, SpokePoolClientsByChain, LoadDataReturnValue, Clien
2
2
  import { SpokePoolClient } from "..";
3
3
  import { BigNumber } from "../../utils";
4
4
  import winston from "winston";
5
- import { BundleData, PoolRebalanceRoot } from "./utils";
5
+ import { BundleData } from "./utils";
6
6
  export declare const INFINITE_FILL_DEADLINE: BigNumber;
7
7
  export declare class BundleDataClient {
8
8
  readonly logger: winston.Logger;
@@ -33,16 +33,12 @@ export declare class BundleDataClient {
33
33
  static getArweaveClientKey(blockRangesForChains: number[][]): string;
34
34
  private getArweaveBundleDataClientKey;
35
35
  backfillMessageHashes(data: Pick<BundleData, "bundleDepositsV3" | "bundleFillsV3">): void;
36
+ private getBundleDataFromArweave;
36
37
  private loadPersistedDataFromArweave;
37
38
  getPendingRefundsFromValidBundles(): Promise<CombinedRefunds[]>;
38
39
  getPendingRefundsFromBundle(bundle: ProposedRootBundle): Promise<CombinedRefunds>;
39
40
  getApproximateRefundsForBlockRange(chainIds: number[], blockRanges: number[][]): Promise<CombinedRefunds>;
40
41
  getUpcomingDepositAmount(chainId: number, l2Token: string, latestBlockToSearch: number): BigNumber;
41
- private getLatestProposedBundleData;
42
- getLatestPoolRebalanceRoot(): Promise<{
43
- root: PoolRebalanceRoot;
44
- blockRanges: number[][];
45
- }>;
46
42
  getNextBundleRefunds(): Promise<CombinedRefunds[]>;
47
43
  getExecutedRefunds(spokePoolClient: SpokePoolClient, relayerRefundRoot: string): {
48
44
  [tokenAddress: string]: {
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BundleDataClient = exports.INFINITE_FILL_DEADLINE = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var assert_1 = tslib_1.__importDefault(require("assert"));
6
5
  var lodash_1 = tslib_1.__importDefault(require("lodash"));
7
6
  var interfaces_1 = require("../../interfaces");
8
7
  var utils_1 = require("../../utils");
@@ -30,7 +29,7 @@ function updateBundleDepositsV3(dict, deposit) {
30
29
  }
31
30
  function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentToken, repaymentAddress) {
32
31
  var _a, _b;
33
- (0, assert_1.default)((0, utils_1.chainIsEvm)(repaymentChainId) && (0, utils_1.isValidEvmAddress)(fill.relayer), "validatedBundleV3Fills dictionary should only contain fills with valid repayment information");
32
+ (0, utils_1.assert)((0, utils_1.chainIsEvm)(repaymentChainId) && (0, utils_1.isValidEvmAddress)(fill.relayer), "validatedBundleV3Fills dictionary should only contain fills with valid repayment information");
34
33
  if (!((_a = dict === null || dict === void 0 ? void 0 : dict[repaymentChainId]) === null || _a === void 0 ? void 0 : _a[repaymentToken])) {
35
34
  (0, utils_1.assign)(dict, [repaymentChainId, repaymentToken], {
36
35
  fills: [],
@@ -145,6 +144,22 @@ var BundleDataClient = (function () {
145
144
  });
146
145
  });
147
146
  };
147
+ BundleDataClient.prototype.getBundleDataFromArweave = function (blockRangesForChains) {
148
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
149
+ var persistedData;
150
+ return tslib_1.__generator(this, function (_a) {
151
+ switch (_a.label) {
152
+ case 0: return [4, this.clients.arweaveClient.getByTopic(this.getArweaveBundleDataClientKey(blockRangesForChains), utils_2.BundleDataSS)];
153
+ case 1:
154
+ persistedData = _a.sent();
155
+ if (!(0, utils_1.isDefined)(persistedData) || persistedData.length < 1) {
156
+ return [2, undefined];
157
+ }
158
+ return [2, persistedData];
159
+ }
160
+ });
161
+ });
162
+ };
148
163
  BundleDataClient.prototype.loadPersistedDataFromArweave = function (blockRangesForChains) {
149
164
  var _a;
150
165
  return tslib_1.__awaiter(this, void 0, void 0, function () {
@@ -156,10 +171,10 @@ var BundleDataClient = (function () {
156
171
  return [2, undefined];
157
172
  }
158
173
  start = performance.now();
159
- return [4, this.clients.arweaveClient.getByTopic(this.getArweaveBundleDataClientKey(blockRangesForChains), utils_2.BundleDataSS)];
174
+ return [4, this.getBundleDataFromArweave(blockRangesForChains)];
160
175
  case 1:
161
176
  persistedData = _b.sent();
162
- if (!(0, utils_1.isDefined)(persistedData) || persistedData.length < 1) {
177
+ if (!(0, utils_1.isDefined)(persistedData)) {
163
178
  return [2, undefined];
164
179
  }
165
180
  convertTypedStringRecordIntoNumericRecord = function (data) {
@@ -280,7 +295,7 @@ var BundleDataClient = (function () {
280
295
  switch (_f.label) {
281
296
  case 0:
282
297
  matchingDeposit = this.spokePoolClients[_fill.originChainId].getDeposit(_fill.depositId);
283
- (0, assert_1.default)((0, utils_1.isDefined)(matchingDeposit), "Deposit not found for fill.");
298
+ (0, utils_1.assert)((0, utils_1.isDefined)(matchingDeposit), "Deposit not found for fill.");
284
299
  return [4, (0, utils_2.verifyFillRepayment)(_fill, this.spokePoolClients[_fill.destinationChainId].spokePool.provider, matchingDeposit, this.clients.hubPoolClient)];
285
300
  case 1:
286
301
  fill = _f.sent();
@@ -332,48 +347,6 @@ var BundleDataClient = (function () {
332
347
  return acc.add(deposit.inputAmount);
333
348
  }, (0, utils_1.toBN)(0));
334
349
  };
335
- BundleDataClient.prototype.getLatestProposedBundleData = function () {
336
- return tslib_1.__awaiter(this, void 0, void 0, function () {
337
- var hubPoolClient, bundleBlockRanges;
338
- var _a;
339
- return tslib_1.__generator(this, function (_b) {
340
- switch (_b.label) {
341
- case 0:
342
- hubPoolClient = this.clients.hubPoolClient;
343
- bundleBlockRanges = (0, utils_1.getImpliedBundleBlockRanges)(hubPoolClient, this.clients.configStoreClient, hubPoolClient.hasPendingProposal()
344
- ? hubPoolClient.getLatestProposedRootBundle()
345
- : hubPoolClient.getLatestFullyExecutedRootBundle(hubPoolClient.latestBlockSearched));
346
- _a = {
347
- blockRanges: bundleBlockRanges
348
- };
349
- return [4, this.loadData(bundleBlockRanges, this.spokePoolClients, true)];
350
- case 1: return [2, (_a.bundleData = _b.sent(),
351
- _a)];
352
- }
353
- });
354
- });
355
- };
356
- BundleDataClient.prototype.getLatestPoolRebalanceRoot = function () {
357
- return tslib_1.__awaiter(this, void 0, void 0, function () {
358
- var _a, bundleData, blockRanges, hubPoolClient, root;
359
- return tslib_1.__generator(this, function (_b) {
360
- switch (_b.label) {
361
- case 0: return [4, this.getLatestProposedBundleData()];
362
- case 1:
363
- _a = _b.sent(), bundleData = _a.bundleData, blockRanges = _a.blockRanges;
364
- hubPoolClient = this.clients.hubPoolClient;
365
- root = (0, utils_2._buildPoolRebalanceRoot)(hubPoolClient.latestBlockSearched, blockRanges[0][1], bundleData.bundleDepositsV3, bundleData.bundleFillsV3, bundleData.bundleSlowFillsV3, bundleData.unexecutableSlowFills, bundleData.expiredDepositsToRefundV3, {
366
- hubPoolClient: hubPoolClient,
367
- configStoreClient: hubPoolClient.configStoreClient,
368
- });
369
- return [2, {
370
- root: root,
371
- blockRanges: blockRanges,
372
- }];
373
- }
374
- });
375
- });
376
- };
377
350
  BundleDataClient.prototype.getNextBundleRefunds = function () {
378
351
  return tslib_1.__awaiter(this, void 0, void 0, function () {
379
352
  function getBlockRangeDelta(_pendingBlockRanges) {
@@ -635,6 +608,7 @@ var BundleDataClient = (function () {
635
608
  continue;
636
609
  }
637
610
  originClient.getDepositsForDestinationChainWithDuplicates(destinationChainId).forEach(function (deposit) {
611
+ var _a, _b;
638
612
  if (deposit.blockNumber > originChainBlockRange[1] || (0, utils_1.isZeroValueDeposit)(deposit)) {
639
613
  return;
640
614
  }
@@ -647,17 +621,21 @@ var BundleDataClient = (function () {
647
621
  };
648
622
  }
649
623
  else {
650
- var deposits_1 = v3RelayHashes[relayDataHash].deposits;
651
- (0, assert_1.default)((0, utils_1.isDefined)(deposits_1) && deposits_1.length > 0, "Deposit should exist in relay hash dictionary.");
652
- deposits_1.push(deposit);
624
+ v3RelayHashes[relayDataHash].deposits.push(deposit);
653
625
  }
654
- var deposits = v3RelayHashes[relayDataHash].deposits;
655
- (0, assert_1.default)((0, utils_1.isDefined)(deposits) && deposits.length > 0, "Deposit should exist in relay hash dictionary.");
656
- var newBundleDepositHash = "".concat(relayDataHash, "@").concat(deposits.length - 1);
626
+ var newBundleDepositHash = "".concat(relayDataHash, "@").concat(v3RelayHashes[relayDataHash].deposits.length - 1);
657
627
  var decodedBundleDepositHash = decodeBundleDepositHash(newBundleDepositHash);
658
- (0, assert_1.default)(decodedBundleDepositHash.relayDataHash === relayDataHash &&
659
- decodedBundleDepositHash.index === deposits.length - 1, "Not using correct bundle deposit hash key");
628
+ (0, utils_1.assert)(decodedBundleDepositHash.relayDataHash === relayDataHash &&
629
+ decodedBundleDepositHash.index === v3RelayHashes[relayDataHash].deposits.length - 1, "Not using correct bundle deposit hash key");
660
630
  if (deposit.blockNumber >= originChainBlockRange[0]) {
631
+ if ((_b = (_a = bundleDepositsV3 === null || bundleDepositsV3 === void 0 ? void 0 : bundleDepositsV3[originChainId]) === null || _a === void 0 ? void 0 : _a[deposit.inputToken]) === null || _b === void 0 ? void 0 : _b.find(function (d) { return (0, utils_1.duplicateEvent)(deposit, d); })) {
632
+ _this.logger.debug({
633
+ at: "BundleDataClient#loadData",
634
+ message: "Duplicate deposit detected",
635
+ deposit: deposit,
636
+ });
637
+ throw new Error("Duplicate deposit detected");
638
+ }
661
639
  bundleDepositHashes.push(newBundleDepositHash);
662
640
  updateBundleDepositsV3(bundleDepositsV3, deposit);
663
641
  }
@@ -701,19 +679,25 @@ var BundleDataClient = (function () {
701
679
  return [4, (0, utils_1.forEachAsync)(destinationClient
702
680
  .getFillsForOriginChain(originChainId)
703
681
  .filter(function (fill) { return fill.blockNumber <= destinationChainBlockRange[1] && !(0, utils_1.isZeroValueFillOrSlowFillRequest)(fill); }), function (fill) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
704
- var relayDataHash, deposits, fillToRefund_1, duplicateDeposits, historicalDeposit, matchedDeposit, fillToRefund;
682
+ var relayDataHash, fillToRefund_1, duplicateDeposits, historicalDeposit, matchedDeposit, fillToRefund;
705
683
  return tslib_1.__generator(this, function (_a) {
706
684
  switch (_a.label) {
707
685
  case 0:
708
686
  fillCounter++;
709
687
  relayDataHash = (0, utils_1.getRelayEventKey)(fill);
710
- if (!v3RelayHashes[relayDataHash]) return [3, 5];
711
- if (!!v3RelayHashes[relayDataHash].fill) return [3, 3];
712
- deposits = v3RelayHashes[relayDataHash].deposits;
713
- (0, assert_1.default)((0, utils_1.isDefined)(deposits) && deposits.length > 0, "Deposit should exist in relay hash dictionary.");
688
+ if (!v3RelayHashes[relayDataHash]) return [3, 3];
689
+ if (v3RelayHashes[relayDataHash].fill) {
690
+ this.logger.debug({
691
+ at: "BundleDataClient#loadData",
692
+ message: "Duplicate fill detected",
693
+ fill: fill,
694
+ });
695
+ throw new Error("Duplicate fill detected");
696
+ }
697
+ (0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposits) && v3RelayHashes[relayDataHash].deposits.length > 0, "Deposit should exist in relay hash dictionary.");
714
698
  v3RelayHashes[relayDataHash].fill = fill;
715
699
  if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 2];
716
- return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, deposits[0], this.clients.hubPoolClient)];
700
+ return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, v3RelayHashes[relayDataHash].deposits[0], this.clients.hubPoolClient)];
717
701
  case 1:
718
702
  fillToRefund_1 = _a.sent();
719
703
  if (!(0, utils_1.isDefined)(fillToRefund_1)) {
@@ -721,8 +705,8 @@ var BundleDataClient = (function () {
721
705
  }
722
706
  else {
723
707
  v3RelayHashes[relayDataHash].fill = fillToRefund_1;
724
- validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund_1), { quoteTimestamp: deposits[0].quoteTimestamp }));
725
- duplicateDeposits = deposits.slice(1);
708
+ validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund_1), { quoteTimestamp: v3RelayHashes[relayDataHash].deposits[0].quoteTimestamp }));
709
+ duplicateDeposits = v3RelayHashes[relayDataHash].deposits.slice(1);
726
710
  duplicateDeposits.forEach(function (duplicateDeposit) {
727
711
  if ((0, utils_1.isSlowFill)(fill)) {
728
712
  updateExpiredDepositsV3(expiredDepositsToRefundV3, duplicateDeposit);
@@ -733,31 +717,29 @@ var BundleDataClient = (function () {
733
717
  });
734
718
  }
735
719
  if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
736
- _canCreateSlowFillLeaf(deposits[0])) {
720
+ _canCreateSlowFillLeaf(v3RelayHashes[relayDataHash].deposits[0])) {
737
721
  fastFillsReplacingSlowFills.push(relayDataHash);
738
722
  }
739
723
  _a.label = 2;
740
- case 2: return [3, 4];
741
- case 3: throw new Error("Duplicate fill detected");
742
- case 4: return [2];
743
- case 5:
724
+ case 2: return [2];
725
+ case 3:
744
726
  v3RelayHashes[relayDataHash] = {
745
727
  deposits: undefined,
746
728
  fill: fill,
747
729
  slowFillRequest: undefined,
748
730
  };
749
- if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 9];
731
+ if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 7];
750
732
  if (!exports.INFINITE_FILL_DEADLINE.eq(fill.fillDeadline)) {
751
733
  bundleInvalidFillsV3.push(fill);
752
734
  return [2];
753
735
  }
754
736
  return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, fill)];
755
- case 6:
737
+ case 4:
756
738
  historicalDeposit = _a.sent();
757
- if (!!historicalDeposit.found) return [3, 7];
739
+ if (!!historicalDeposit.found) return [3, 5];
758
740
  bundleInvalidFillsV3.push(fill);
759
- return [3, 9];
760
- case 7:
741
+ return [3, 7];
742
+ case 5:
761
743
  matchedDeposit = historicalDeposit.deposit;
762
744
  if (matchedDeposit.blockNumber > originChainBlockRange[1]) {
763
745
  bundleInvalidFillsV3.push(fill);
@@ -765,13 +747,13 @@ var BundleDataClient = (function () {
765
747
  }
766
748
  v3RelayHashes[relayDataHash].deposits = [matchedDeposit];
767
749
  return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, matchedDeposit, this.clients.hubPoolClient)];
768
- case 8:
750
+ case 6:
769
751
  fillToRefund = _a.sent();
770
752
  if (!(0, utils_1.isDefined)(fillToRefund)) {
771
753
  bundleUnrepayableFillsV3.push(fill);
772
754
  }
773
755
  else {
774
- (0, assert_1.default)((0, utils_1.getRelayEventKey)(matchedDeposit) === relayDataHash, "Relay hashes should match.");
756
+ (0, utils_1.assert)((0, utils_1.getRelayEventKey)(matchedDeposit) === relayDataHash, "Relay hashes should match.");
775
757
  validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund), { quoteTimestamp: matchedDeposit.quoteTimestamp }));
776
758
  v3RelayHashes[relayDataHash].fill = fillToRefund;
777
759
  }
@@ -779,8 +761,8 @@ var BundleDataClient = (function () {
779
761
  _canCreateSlowFillLeaf(matchedDeposit)) {
780
762
  fastFillsReplacingSlowFills.push(relayDataHash);
781
763
  }
782
- _a.label = 9;
783
- case 9: return [2];
764
+ _a.label = 7;
765
+ case 7: return [2];
784
766
  }
785
767
  });
786
768
  }); })];
@@ -791,29 +773,31 @@ var BundleDataClient = (function () {
791
773
  .filter(function (request) {
792
774
  return request.blockNumber <= destinationChainBlockRange[1] && !(0, utils_1.isZeroValueFillOrSlowFillRequest)(request);
793
775
  }), function (slowFillRequest) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
794
- var relayDataHash, _a, deposits, fill, matchedDeposit, historicalDeposit, matchedDeposit;
795
- return tslib_1.__generator(this, function (_b) {
796
- switch (_b.label) {
776
+ var relayDataHash, matchedDeposit, historicalDeposit, matchedDeposit;
777
+ return tslib_1.__generator(this, function (_a) {
778
+ switch (_a.label) {
797
779
  case 0:
798
780
  relayDataHash = (0, utils_1.getRelayEventKey)(slowFillRequest);
799
781
  if (v3RelayHashes[relayDataHash]) {
800
- if (!v3RelayHashes[relayDataHash].slowFillRequest) {
801
- v3RelayHashes[relayDataHash].slowFillRequest = slowFillRequest;
802
- _a = v3RelayHashes[relayDataHash], deposits = _a.deposits, fill = _a.fill;
803
- if (fill) {
804
- return [2];
805
- }
806
- (0, assert_1.default)((0, utils_1.isDefined)(deposits) && deposits.length > 0, "Deposit should exist in relay hash dictionary.");
807
- matchedDeposit = deposits[0];
808
- if (slowFillRequest.blockNumber >= destinationChainBlockRange[0] &&
809
- _canCreateSlowFillLeaf(matchedDeposit) &&
810
- !_depositIsExpired(matchedDeposit)) {
811
- validatedBundleSlowFills.push(matchedDeposit);
812
- }
813
- }
814
- else {
782
+ if (v3RelayHashes[relayDataHash].slowFillRequest) {
783
+ this.logger.debug({
784
+ at: "BundleDataClient#loadData",
785
+ message: "Duplicate slow fill request detected",
786
+ slowFillRequest: slowFillRequest,
787
+ });
815
788
  throw new Error("Duplicate slow fill request detected.");
816
789
  }
790
+ v3RelayHashes[relayDataHash].slowFillRequest = slowFillRequest;
791
+ if (v3RelayHashes[relayDataHash].fill) {
792
+ return [2];
793
+ }
794
+ (0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposits) && v3RelayHashes[relayDataHash].deposits.length > 0, "Deposit should exist in relay hash dictionary.");
795
+ matchedDeposit = v3RelayHashes[relayDataHash].deposits[0];
796
+ if (slowFillRequest.blockNumber >= destinationChainBlockRange[0] &&
797
+ _canCreateSlowFillLeaf(matchedDeposit) &&
798
+ !_depositIsExpired(matchedDeposit)) {
799
+ validatedBundleSlowFills.push(matchedDeposit);
800
+ }
817
801
  return [2];
818
802
  }
819
803
  v3RelayHashes[relayDataHash] = {
@@ -828,7 +812,7 @@ var BundleDataClient = (function () {
828
812
  }
829
813
  return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, slowFillRequest)];
830
814
  case 1:
831
- historicalDeposit = _b.sent();
815
+ historicalDeposit = _a.sent();
832
816
  if (!historicalDeposit.found) {
833
817
  bundleInvalidSlowFillRequests.push(slowFillRequest);
834
818
  return [2];
@@ -838,13 +822,13 @@ var BundleDataClient = (function () {
838
822
  bundleInvalidSlowFillRequests.push(slowFillRequest);
839
823
  return [2];
840
824
  }
841
- (0, assert_1.default)((0, utils_1.getRelayEventKey)(matchedDeposit) === relayDataHash, "Deposit relay hashes should match.");
825
+ (0, utils_1.assert)((0, utils_1.getRelayEventKey)(matchedDeposit) === relayDataHash, "Deposit relay hashes should match.");
842
826
  v3RelayHashes[relayDataHash].deposits = [matchedDeposit];
843
827
  if (!_canCreateSlowFillLeaf(matchedDeposit) || _depositIsExpired(matchedDeposit)) {
844
828
  return [2];
845
829
  }
846
830
  validatedBundleSlowFills.push(matchedDeposit);
847
- _b.label = 2;
831
+ _a.label = 2;
848
832
  case 2: return [2];
849
833
  }
850
834
  });
@@ -869,7 +853,7 @@ var BundleDataClient = (function () {
869
853
  }
870
854
  if (!fill) return [3, 3];
871
855
  if (!(fill.blockNumber < destinationChainBlockRange[0])) return [3, 2];
872
- return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, deposits[0], this.clients.hubPoolClient)];
856
+ return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, v3RelayHashes[relayDataHash].deposits[0], this.clients.hubPoolClient)];
873
857
  case 1:
874
858
  fillToRefund = _c.sent();
875
859
  if (!(0, utils_1.isDefined)(fillToRefund)) {
@@ -903,8 +887,8 @@ var BundleDataClient = (function () {
903
887
  return [4, this.findMatchingFillEvent(deposit, destinationClient)];
904
888
  case 5:
905
889
  prefill = _c.sent();
906
- (0, assert_1.default)((0, utils_1.isDefined)(prefill), "findFillEvent# Cannot find prefill: ".concat(relayDataHash));
907
- (0, assert_1.default)((0, utils_1.getRelayEventKey)(prefill) === relayDataHash, "Relay hashes should match.");
890
+ (0, utils_1.assert)((0, utils_1.isDefined)(prefill), "findFillEvent# Cannot find prefill: ".concat(relayDataHash));
891
+ (0, utils_1.assert)((0, utils_1.getRelayEventKey)(prefill) === relayDataHash, "Relay hashes should match.");
908
892
  return [4, (0, utils_2.verifyFillRepayment)(prefill, destinationClient.spokePool.provider, deposit, this.clients.hubPoolClient)];
909
893
  case 6:
910
894
  verifiedFill = _c.sent();
@@ -937,11 +921,11 @@ var BundleDataClient = (function () {
937
921
  _g.sent();
938
922
  fastFillsReplacingSlowFills.forEach(function (relayDataHash) {
939
923
  var _a = v3RelayHashes[relayDataHash], deposits = _a.deposits, slowFillRequest = _a.slowFillRequest, fill = _a.fill;
940
- (0, assert_1.default)((fill === null || fill === void 0 ? void 0 : fill.relayExecutionInfo.fillType) === interfaces_1.FillType.ReplacedSlowFill, "Fill type should be ReplacedSlowFill.");
924
+ (0, utils_1.assert)((fill === null || fill === void 0 ? void 0 : fill.relayExecutionInfo.fillType) === interfaces_1.FillType.ReplacedSlowFill, "Fill type should be ReplacedSlowFill.");
941
925
  if (!deposits || deposits.length < 1) {
942
926
  throw new Error("Deposit should exist in relay hash dictionary.");
943
927
  }
944
- (0, assert_1.default)(_canCreateSlowFillLeaf(deposits[0]), "fastFillsReplacingSlowFills should contain only deposits that can be slow filled");
928
+ (0, utils_1.assert)(_canCreateSlowFillLeaf(deposits[0]), "fastFillsReplacingSlowFills should contain only deposits that can be slow filled");
945
929
  var destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
946
930
  var originBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, originChainId, chainIds);
947
931
  var matchedDeposit = deposits[0];
@@ -1029,10 +1013,8 @@ var BundleDataClient = (function () {
1029
1013
  promises = [
1030
1014
  validatedBundleV3Fills.length > 0
1031
1015
  ? this.clients.hubPoolClient.batchComputeRealizedLpFeePct(validatedBundleV3Fills.map(function (fill) {
1032
- var deposits = v3RelayHashes[(0, utils_1.getRelayEventKey)(fill)].deposits;
1033
- (0, assert_1.default)((0, utils_1.isDefined)(deposits) && deposits.length > 0, "Deposit should exist in relay hash dictionary.");
1034
- var matchedDeposit = deposits[0];
1035
- (0, assert_1.default)((0, utils_1.isDefined)(matchedDeposit), "Deposit should exist in relay hash dictionary.");
1016
+ var matchedDeposit = v3RelayHashes[(0, utils_1.getRelayEventKey)(fill)].deposits[0];
1017
+ (0, utils_1.assert)((0, utils_1.isDefined)(matchedDeposit), "Deposit should exist in relay hash dictionary.");
1036
1018
  var paymentChainId = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRangesForChains, chainIds, matchedDeposit.fromLiteChain).chainToSendRefundTo;
1037
1019
  return tslib_1.__assign(tslib_1.__assign({}, fill), { paymentChainId: paymentChainId });
1038
1020
  }))
@@ -1058,10 +1040,8 @@ var BundleDataClient = (function () {
1058
1040
  v3FillLpFees.forEach(function (_a, idx) {
1059
1041
  var realizedLpFeePct = _a.realizedLpFeePct;
1060
1042
  var fill = validatedBundleV3Fills[idx];
1061
- var deposits = v3RelayHashes[(0, utils_1.getRelayEventKey)(fill)].deposits;
1062
- (0, assert_1.default)((0, utils_1.isDefined)(deposits) && deposits.length > 0, "Deposit should exist in relay hash dictionary.");
1063
- var associatedDeposit = deposits[0];
1064
- (0, assert_1.default)((0, utils_1.isDefined)(associatedDeposit), "Deposit should exist in relay hash dictionary.");
1043
+ var associatedDeposit = v3RelayHashes[(0, utils_1.getRelayEventKey)(fill)].deposits[0];
1044
+ (0, utils_1.assert)((0, utils_1.isDefined)(associatedDeposit), "Deposit should exist in relay hash dictionary.");
1065
1045
  var _b = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRangesForChains, chainIds, associatedDeposit.fromLiteChain), chainToSendRefundTo = _b.chainToSendRefundTo, repaymentToken = _b.repaymentToken;
1066
1046
  updateBundleFillsV3(bundleFillsV3, fill, realizedLpFeePct, chainToSendRefundTo, repaymentToken, fill.relayer);
1067
1047
  });
@@ -1072,7 +1052,7 @@ var BundleDataClient = (function () {
1072
1052
  if (validatedBundleSlowFills.slice(0, idx).some(function (d) { return (0, utils_1.getRelayEventKey)(d) === relayDataHash; })) {
1073
1053
  return;
1074
1054
  }
1075
- (0, assert_1.default)(!_depositIsExpired(deposit), "Cannot create slow fill leaf for expired deposit.");
1055
+ (0, utils_1.assert)(!_depositIsExpired(deposit), "Cannot create slow fill leaf for expired deposit.");
1076
1056
  updateBundleSlowFills(bundleSlowFillsV3, tslib_1.__assign(tslib_1.__assign({}, deposit), { lpFeePct: lpFeePct }));
1077
1057
  });
1078
1058
  v3UnexecutableSlowFillLpFees.forEach(function (_a, idx) {
@@ -1193,8 +1173,8 @@ var BundleDataClient = (function () {
1193
1173
  ]), startTime = _a[0], _endTime = _a[1];
1194
1174
  endBlockDelta = endBlockForChain > startBlockForChain ? 1 : 0;
1195
1175
  endTime = Math.max(0, _endTime - endBlockDelta);
1196
- (0, assert_1.default)(endTime >= startTime, "End time for block ".concat(endBlockForChain, " should be greater than start time for block ").concat(startBlockForChain, ": ").concat(endTime, " >= ").concat(startTime, "."));
1197
- (0, assert_1.default)(startBlockForChain === 0 || startTime > 0, "Start timestamp must be greater than 0 if the start block is greater than 0.");
1176
+ (0, utils_1.assert)(endTime >= startTime, "End time for block ".concat(endBlockForChain, " should be greater than start time for block ").concat(startBlockForChain, ": ").concat(endTime, " >= ").concat(startTime, "."));
1177
+ (0, utils_1.assert)(startBlockForChain === 0 || startTime > 0, "Start timestamp must be greater than 0 if the start block is greater than 0.");
1198
1178
  return [2, [chainId, [startTime, endTime]]];
1199
1179
  }
1200
1180
  });