@across-protocol/sdk 4.0.0-beta.0 → 4.0.0-beta.10

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 (139) hide show
  1. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
  2. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +218 -148
  3. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  4. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
  5. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +33 -1
  6. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  7. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +12 -10
  8. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +3 -3
  9. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  10. package/dist/cjs/clients/SpokePoolClient.d.ts +12 -12
  11. package/dist/cjs/clients/SpokePoolClient.js +20 -18
  12. package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
  13. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -4
  14. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +6 -6
  15. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  16. package/dist/cjs/constants.d.ts +4 -2
  17. package/dist/cjs/constants.js +5 -3
  18. package/dist/cjs/constants.js.map +1 -1
  19. package/dist/cjs/interfaces/SpokePool.d.ts +2 -2
  20. package/dist/cjs/providers/index.d.ts +1 -0
  21. package/dist/cjs/providers/index.js +2 -0
  22. package/dist/cjs/providers/index.js.map +1 -1
  23. package/dist/cjs/providers/mockProvider.d.ts +19 -0
  24. package/dist/cjs/providers/mockProvider.js +70 -0
  25. package/dist/cjs/providers/mockProvider.js.map +1 -0
  26. package/dist/cjs/utils/AddressUtils.d.ts +1 -0
  27. package/dist/cjs/utils/AddressUtils.js +14 -1
  28. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  29. package/dist/cjs/utils/BigNumberUtils.d.ts +1 -0
  30. package/dist/cjs/utils/BigNumberUtils.js +5 -1
  31. package/dist/cjs/utils/BigNumberUtils.js.map +1 -1
  32. package/dist/cjs/utils/CachingUtils.js +1 -1
  33. package/dist/cjs/utils/CachingUtils.js.map +1 -1
  34. package/dist/cjs/utils/DepositUtils.d.ts +4 -1
  35. package/dist/cjs/utils/DepositUtils.js +23 -6
  36. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  37. package/dist/cjs/utils/EventUtils.js +4 -0
  38. package/dist/cjs/utils/EventUtils.js.map +1 -1
  39. package/dist/cjs/utils/NetworkUtils.d.ts +1 -0
  40. package/dist/cjs/utils/NetworkUtils.js +6 -1
  41. package/dist/cjs/utils/NetworkUtils.js.map +1 -1
  42. package/dist/cjs/utils/SpokeUtils.d.ts +5 -3
  43. package/dist/cjs/utils/SpokeUtils.js +18 -11
  44. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  45. package/dist/cjs/utils/ValidatorUtils.js +1 -1
  46. package/dist/cjs/utils/ValidatorUtils.js.map +1 -1
  47. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
  48. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +275 -186
  49. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  50. package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
  51. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +42 -1
  52. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  53. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +12 -10
  54. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +4 -4
  55. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  56. package/dist/esm/clients/SpokePoolClient.d.ts +12 -12
  57. package/dist/esm/clients/SpokePoolClient.js +21 -19
  58. package/dist/esm/clients/SpokePoolClient.js.map +1 -1
  59. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -4
  60. package/dist/esm/clients/mocks/MockSpokePoolClient.js +7 -7
  61. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  62. package/dist/esm/constants.d.ts +4 -2
  63. package/dist/esm/constants.js +5 -3
  64. package/dist/esm/constants.js.map +1 -1
  65. package/dist/esm/interfaces/SpokePool.d.ts +2 -2
  66. package/dist/esm/providers/index.d.ts +1 -0
  67. package/dist/esm/providers/index.js +2 -0
  68. package/dist/esm/providers/index.js.map +1 -1
  69. package/dist/esm/providers/mockProvider.d.ts +23 -0
  70. package/dist/esm/providers/mockProvider.js +73 -0
  71. package/dist/esm/providers/mockProvider.js.map +1 -0
  72. package/dist/esm/utils/AddressUtils.d.ts +1 -0
  73. package/dist/esm/utils/AddressUtils.js +16 -0
  74. package/dist/esm/utils/AddressUtils.js.map +1 -1
  75. package/dist/esm/utils/BigNumberUtils.d.ts +8 -0
  76. package/dist/esm/utils/BigNumberUtils.js +10 -0
  77. package/dist/esm/utils/BigNumberUtils.js.map +1 -1
  78. package/dist/esm/utils/CachingUtils.js +1 -1
  79. package/dist/esm/utils/CachingUtils.js.map +1 -1
  80. package/dist/esm/utils/DepositUtils.d.ts +4 -1
  81. package/dist/esm/utils/DepositUtils.js +21 -6
  82. package/dist/esm/utils/DepositUtils.js.map +1 -1
  83. package/dist/esm/utils/EventUtils.js +8 -0
  84. package/dist/esm/utils/EventUtils.js.map +1 -1
  85. package/dist/esm/utils/NetworkUtils.d.ts +6 -0
  86. package/dist/esm/utils/NetworkUtils.js +10 -0
  87. package/dist/esm/utils/NetworkUtils.js.map +1 -1
  88. package/dist/esm/utils/SpokeUtils.d.ts +5 -3
  89. package/dist/esm/utils/SpokeUtils.js +21 -13
  90. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  91. package/dist/esm/utils/ValidatorUtils.js +1 -1
  92. package/dist/esm/utils/ValidatorUtils.js.map +1 -1
  93. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
  94. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  95. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
  96. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  97. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +12 -10
  98. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  99. package/dist/types/clients/SpokePoolClient.d.ts +12 -12
  100. package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
  101. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -4
  102. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  103. package/dist/types/constants.d.ts +4 -2
  104. package/dist/types/constants.d.ts.map +1 -1
  105. package/dist/types/interfaces/SpokePool.d.ts +2 -2
  106. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  107. package/dist/types/providers/index.d.ts +1 -0
  108. package/dist/types/providers/index.d.ts.map +1 -1
  109. package/dist/types/providers/mockProvider.d.ts +24 -0
  110. package/dist/types/providers/mockProvider.d.ts.map +1 -0
  111. package/dist/types/utils/AddressUtils.d.ts +1 -0
  112. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  113. package/dist/types/utils/BigNumberUtils.d.ts +8 -0
  114. package/dist/types/utils/BigNumberUtils.d.ts.map +1 -1
  115. package/dist/types/utils/DepositUtils.d.ts +4 -1
  116. package/dist/types/utils/DepositUtils.d.ts.map +1 -1
  117. package/dist/types/utils/EventUtils.d.ts.map +1 -1
  118. package/dist/types/utils/NetworkUtils.d.ts +6 -0
  119. package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
  120. package/dist/types/utils/SpokeUtils.d.ts +5 -3
  121. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  122. package/package.json +2 -2
  123. package/src/clients/BundleDataClient/BundleDataClient.ts +179 -114
  124. package/src/clients/BundleDataClient/utils/FillUtils.ts +47 -2
  125. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +4 -2
  126. package/src/clients/SpokePoolClient.ts +30 -26
  127. package/src/clients/mocks/MockSpokePoolClient.ts +10 -10
  128. package/src/constants.ts +7 -3
  129. package/src/interfaces/SpokePool.ts +2 -2
  130. package/src/providers/index.ts +1 -0
  131. package/src/providers/mockProvider.ts +77 -0
  132. package/src/utils/AddressUtils.ts +16 -0
  133. package/src/utils/BigNumberUtils.ts +11 -0
  134. package/src/utils/CachingUtils.ts +1 -1
  135. package/src/utils/DepositUtils.ts +23 -6
  136. package/src/utils/EventUtils.ts +8 -0
  137. package/src/utils/NetworkUtils.ts +11 -0
  138. package/src/utils/SpokeUtils.ts +31 -19
  139. package/src/utils/ValidatorUtils.ts +1 -1
@@ -6,9 +6,13 @@ var lodash_1 = tslib_1.__importDefault(require("lodash"));
6
6
  var interfaces_1 = require("../../interfaces");
7
7
  var utils_1 = require("../../utils");
8
8
  var utils_2 = require("./utils");
9
+ var constants_1 = require("../../constants");
9
10
  exports.INFINITE_FILL_DEADLINE = utils_1.bnUint32Max;
10
11
  function updateExpiredDepositsV3(dict, deposit) {
11
12
  var _a;
13
+ if ((0, utils_1.chainIsEvm)(deposit.originChainId) && !(0, utils_1.isValidEvmAddress)(deposit.depositor)) {
14
+ return;
15
+ }
12
16
  var originChainId = deposit.originChainId, inputToken = deposit.inputToken;
13
17
  if (!((_a = dict === null || dict === void 0 ? void 0 : dict[originChainId]) === null || _a === void 0 ? void 0 : _a[inputToken])) {
14
18
  (0, utils_1.assign)(dict, [originChainId, inputToken], []);
@@ -23,8 +27,11 @@ function updateBundleDepositsV3(dict, deposit) {
23
27
  }
24
28
  dict[originChainId][inputToken].push(deposit);
25
29
  }
26
- function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentToken) {
30
+ function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentToken, repaymentAddress) {
27
31
  var _a, _b;
32
+ if ((0, utils_1.chainIsEvm)(repaymentChainId) && !(0, utils_1.isValidEvmAddress)(repaymentAddress)) {
33
+ return;
34
+ }
28
35
  if (!((_a = dict === null || dict === void 0 ? void 0 : dict[repaymentChainId]) === null || _a === void 0 ? void 0 : _a[repaymentToken])) {
29
36
  (0, utils_1.assign)(dict, [repaymentChainId, repaymentToken], {
30
37
  fills: [],
@@ -33,22 +40,22 @@ function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentTo
33
40
  refunds: {},
34
41
  });
35
42
  }
36
- var bundleFill = tslib_1.__assign(tslib_1.__assign({}, fill), { lpFeePct: lpFeePct });
43
+ var bundleFill = tslib_1.__assign(tslib_1.__assign({}, fill), { lpFeePct: lpFeePct, relayer: repaymentAddress });
37
44
  (0, utils_1.assign)(dict, [repaymentChainId, repaymentToken, "fills"], [bundleFill]);
38
45
  var refundObj = dict[repaymentChainId][repaymentToken];
39
- var realizedLpFee = fill.inputAmount.mul(bundleFill.lpFeePct).div(utils_1.fixedPointAdjustment);
46
+ var realizedLpFee = bundleFill.inputAmount.mul(bundleFill.lpFeePct).div(utils_1.fixedPointAdjustment);
40
47
  refundObj.realizedLpFees = refundObj.realizedLpFees ? refundObj.realizedLpFees.add(realizedLpFee) : realizedLpFee;
41
- if (!(0, utils_1.isSlowFill)(fill)) {
42
- var refundAmount = fill.inputAmount.mul(utils_1.fixedPointAdjustment.sub(lpFeePct)).div(utils_1.fixedPointAdjustment);
48
+ if (!(0, utils_1.isSlowFill)(bundleFill)) {
49
+ var refundAmount = bundleFill.inputAmount.mul(utils_1.fixedPointAdjustment.sub(lpFeePct)).div(utils_1.fixedPointAdjustment);
43
50
  refundObj.totalRefundAmount = refundObj.totalRefundAmount
44
51
  ? refundObj.totalRefundAmount.add(refundAmount)
45
52
  : refundAmount;
46
53
  (_b = refundObj.refunds) !== null && _b !== void 0 ? _b : (refundObj.refunds = {});
47
- if (refundObj.refunds[fill.relayer]) {
48
- refundObj.refunds[fill.relayer] = refundObj.refunds[fill.relayer].add(refundAmount);
54
+ if (refundObj.refunds[bundleFill.relayer]) {
55
+ refundObj.refunds[bundleFill.relayer] = refundObj.refunds[bundleFill.relayer].add(refundAmount);
49
56
  }
50
57
  else {
51
- refundObj.refunds[fill.relayer] = refundAmount;
58
+ refundObj.refunds[bundleFill.relayer] = refundAmount;
52
59
  }
53
60
  }
54
61
  }
@@ -188,64 +195,105 @@ var BundleDataClient = (function () {
188
195
  return [4, this.loadArweaveData(bundleEvaluationBlockRanges)];
189
196
  case 1:
190
197
  arweaveData = _a.sent();
191
- if (arweaveData === undefined) {
192
- combinedRefunds = this.getApproximateRefundsForBlockRange(chainIds, bundleEvaluationBlockRanges);
193
- }
194
- else {
195
- bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
196
- combinedRefunds = (0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3);
197
- Object.keys(combinedRefunds).forEach(function (chainId) {
198
- if (_this.spokePoolClients[Number(chainId)] === undefined) {
199
- delete combinedRefunds[Number(chainId)];
200
- }
201
- });
202
- }
203
- return [2, this.deductExecutedRefunds(combinedRefunds, bundle)];
198
+ if (!(arweaveData === undefined)) return [3, 3];
199
+ return [4, this.getApproximateRefundsForBlockRange(chainIds, bundleEvaluationBlockRanges)];
200
+ case 2:
201
+ combinedRefunds = _a.sent();
202
+ return [3, 4];
203
+ case 3:
204
+ bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
205
+ combinedRefunds = (0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3);
206
+ Object.keys(combinedRefunds).forEach(function (chainId) {
207
+ if (_this.spokePoolClients[Number(chainId)] === undefined) {
208
+ delete combinedRefunds[Number(chainId)];
209
+ }
210
+ });
211
+ _a.label = 4;
212
+ case 4: return [2, this.deductExecutedRefunds(combinedRefunds, bundle)];
204
213
  }
205
214
  });
206
215
  });
207
216
  };
208
217
  BundleDataClient.prototype.getApproximateRefundsForBlockRange = function (chainIds, blockRanges) {
209
- var _this = this;
210
- var refundsForChain = {};
211
- var _loop_1 = function (chainId) {
212
- if (this_1.spokePoolClients[chainId] === undefined) {
213
- return "continue";
214
- }
215
- var chainIndex = chainIds.indexOf(chainId);
216
- this_1.spokePoolClients[chainId]
217
- .getFills()
218
- .filter(function (fill) {
219
- if (fill.blockNumber < blockRanges[chainIndex][0] || fill.blockNumber > blockRanges[chainIndex][1]) {
220
- return false;
221
- }
222
- if (_this.spokePoolClients[fill.originChainId] === undefined) {
223
- return false;
218
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
219
+ var refundsForChain, _loop_1, this_1, _i, chainIds_1, chainId;
220
+ var _this = this;
221
+ return tslib_1.__generator(this, function (_a) {
222
+ switch (_a.label) {
223
+ case 0:
224
+ refundsForChain = {};
225
+ _loop_1 = function (chainId) {
226
+ var chainIndex, fillsToCount;
227
+ return tslib_1.__generator(this, function (_b) {
228
+ switch (_b.label) {
229
+ case 0:
230
+ if (this_1.spokePoolClients[chainId] === undefined) {
231
+ return [2, "continue"];
232
+ }
233
+ chainIndex = chainIds.indexOf(chainId);
234
+ return [4, (0, utils_1.filterAsync)(this_1.spokePoolClients[chainId].getFills(), function (fill) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
235
+ var matchingDeposit, hasMatchingDeposit, validRepayment;
236
+ return tslib_1.__generator(this, function (_a) {
237
+ switch (_a.label) {
238
+ case 0:
239
+ if (fill.blockNumber < blockRanges[chainIndex][0] || fill.blockNumber > blockRanges[chainIndex][1]) {
240
+ return [2, false];
241
+ }
242
+ if (this.spokePoolClients[fill.originChainId] === undefined) {
243
+ return [2, false];
244
+ }
245
+ matchingDeposit = this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
246
+ hasMatchingDeposit = matchingDeposit !== undefined &&
247
+ this.getRelayHashFromEvent(fill) === this.getRelayHashFromEvent(matchingDeposit);
248
+ if (!hasMatchingDeposit) return [3, 2];
249
+ return [4, (0, utils_2.verifyFillRepayment)(fill, this.spokePoolClients[fill.destinationChainId].spokePool.provider, matchingDeposit, this.clients.configStoreClient
250
+ .getChainIdIndicesForBlock(blockRanges[0][1])
251
+ .filter(function (_chainId, i) { return !(0, utils_2.isChainDisabled)(blockRanges[i]); }))];
252
+ case 1:
253
+ validRepayment = _a.sent();
254
+ if (!(0, utils_1.isDefined)(validRepayment)) {
255
+ return [2, false];
256
+ }
257
+ _a.label = 2;
258
+ case 2: return [2, hasMatchingDeposit];
259
+ }
260
+ });
261
+ }); })];
262
+ case 1:
263
+ fillsToCount = _b.sent();
264
+ fillsToCount.forEach(function (fill) {
265
+ var _a, _b, _c;
266
+ var _d;
267
+ var matchingDeposit = _this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
268
+ (0, utils_1.assert)((0, utils_1.isDefined)(matchingDeposit), "Deposit not found for fill.");
269
+ var _e = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRanges, _this.chainIdListForBundleEvaluationBlockNumbers, matchingDeposit.fromLiteChain), chainToSendRefundTo = _e.chainToSendRefundTo, repaymentToken = _e.repaymentToken;
270
+ var relayer = fill.relayer, refundAmount = fill.inputAmount;
271
+ (_a = refundsForChain[chainToSendRefundTo]) !== null && _a !== void 0 ? _a : (refundsForChain[chainToSendRefundTo] = {});
272
+ (_b = (_d = refundsForChain[chainToSendRefundTo])[repaymentToken]) !== null && _b !== void 0 ? _b : (_d[repaymentToken] = {});
273
+ var existingRefundAmount = (_c = refundsForChain[chainToSendRefundTo][repaymentToken][relayer]) !== null && _c !== void 0 ? _c : utils_1.bnZero;
274
+ refundsForChain[chainToSendRefundTo][repaymentToken][relayer] = existingRefundAmount.add(refundAmount);
275
+ });
276
+ return [2];
277
+ }
278
+ });
279
+ };
280
+ this_1 = this;
281
+ _i = 0, chainIds_1 = chainIds;
282
+ _a.label = 1;
283
+ case 1:
284
+ if (!(_i < chainIds_1.length)) return [3, 4];
285
+ chainId = chainIds_1[_i];
286
+ return [5, _loop_1(chainId)];
287
+ case 2:
288
+ _a.sent();
289
+ _a.label = 3;
290
+ case 3:
291
+ _i++;
292
+ return [3, 1];
293
+ case 4: return [2, refundsForChain];
224
294
  }
225
- var matchingDeposit = _this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
226
- var hasMatchingDeposit = matchingDeposit !== undefined &&
227
- _this.getRelayHashFromEvent(fill) === _this.getRelayHashFromEvent(matchingDeposit);
228
- return hasMatchingDeposit;
229
- })
230
- .forEach(function (fill) {
231
- var _a, _b, _c;
232
- var _d;
233
- var matchingDeposit = _this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
234
- (0, utils_1.assert)((0, utils_1.isDefined)(matchingDeposit), "Deposit not found for fill.");
235
- var _e = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRanges, _this.chainIdListForBundleEvaluationBlockNumbers, matchingDeposit.fromLiteChain), chainToSendRefundTo = _e.chainToSendRefundTo, repaymentToken = _e.repaymentToken;
236
- var relayer = fill.relayer, refundAmount = fill.inputAmount;
237
- (_a = refundsForChain[chainToSendRefundTo]) !== null && _a !== void 0 ? _a : (refundsForChain[chainToSendRefundTo] = {});
238
- (_b = (_d = refundsForChain[chainToSendRefundTo])[repaymentToken]) !== null && _b !== void 0 ? _b : (_d[repaymentToken] = {});
239
- var existingRefundAmount = (_c = refundsForChain[chainToSendRefundTo][repaymentToken][relayer]) !== null && _c !== void 0 ? _c : utils_1.bnZero;
240
- refundsForChain[chainToSendRefundTo][repaymentToken][relayer] = existingRefundAmount.add(refundAmount);
241
295
  });
242
- };
243
- var this_1 = this;
244
- for (var _i = 0, chainIds_1 = chainIds; _i < chainIds_1.length; _i++) {
245
- var chainId = chainIds_1[_i];
246
- _loop_1(chainId);
247
- }
248
- return refundsForChain;
296
+ });
249
297
  };
250
298
  BundleDataClient.prototype.getUpcomingDepositAmount = function (chainId, l2Token, latestBlockToSearch) {
251
299
  if (this.spokePoolClients[chainId] === undefined) {
@@ -317,32 +365,39 @@ var BundleDataClient = (function () {
317
365
  return [initialBlockRange[1] + 1, blockRange[1]];
318
366
  });
319
367
  }
320
- var hubPoolClient, nextBundleMainnetStartBlock, chainIds, combinedRefunds, widestBundleBlockRanges, pendingBundleBlockRanges, arweaveData, bundleFillsV3, expiredDepositsToRefundV3, start;
321
- return tslib_1.__generator(this, function (_a) {
322
- switch (_a.label) {
368
+ var hubPoolClient, nextBundleMainnetStartBlock, chainIds, combinedRefunds, widestBundleBlockRanges, pendingBundleBlockRanges, arweaveData, _a, _b, bundleFillsV3, expiredDepositsToRefundV3, start, _c, _d;
369
+ return tslib_1.__generator(this, function (_e) {
370
+ switch (_e.label) {
323
371
  case 0:
324
372
  hubPoolClient = this.clients.hubPoolClient;
325
373
  nextBundleMainnetStartBlock = hubPoolClient.getNextBundleStartBlockNumber(this.chainIdListForBundleEvaluationBlockNumbers, hubPoolClient.latestBlockSearched, hubPoolClient.chainId);
326
374
  chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(nextBundleMainnetStartBlock);
327
375
  combinedRefunds = [];
328
376
  widestBundleBlockRanges = (0, utils_2.getWidestPossibleExpectedBlockRange)(chainIds, this.spokePoolClients, (0, utils_2.getEndBlockBuffers)(chainIds, this.blockRangeEndBlockBuffer), this.clients, this.clients.hubPoolClient.latestBlockSearched, this.clients.configStoreClient.getEnabledChains(this.clients.hubPoolClient.latestBlockSearched));
329
- if (!hubPoolClient.hasPendingProposal()) return [3, 2];
377
+ if (!hubPoolClient.hasPendingProposal()) return [3, 5];
330
378
  pendingBundleBlockRanges = (0, utils_1.getImpliedBundleBlockRanges)(hubPoolClient, this.clients.configStoreClient, hubPoolClient.getLatestProposedRootBundle());
331
379
  return [4, this.loadArweaveData(pendingBundleBlockRanges)];
332
380
  case 1:
333
- arweaveData = _a.sent();
334
- if (arweaveData === undefined) {
335
- combinedRefunds.push(this.getApproximateRefundsForBlockRange(chainIds, pendingBundleBlockRanges));
336
- }
337
- else {
338
- bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
339
- combinedRefunds.push((0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3));
340
- }
341
- widestBundleBlockRanges = getBlockRangeDelta(pendingBundleBlockRanges);
342
- _a.label = 2;
381
+ arweaveData = _e.sent();
382
+ if (!(arweaveData === undefined)) return [3, 3];
383
+ _b = (_a = combinedRefunds).push;
384
+ return [4, this.getApproximateRefundsForBlockRange(chainIds, pendingBundleBlockRanges)];
343
385
  case 2:
386
+ _b.apply(_a, [_e.sent()]);
387
+ return [3, 4];
388
+ case 3:
389
+ bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
390
+ combinedRefunds.push((0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3));
391
+ _e.label = 4;
392
+ case 4:
393
+ widestBundleBlockRanges = getBlockRangeDelta(pendingBundleBlockRanges);
394
+ _e.label = 5;
395
+ case 5:
344
396
  start = performance.now();
345
- combinedRefunds.push(this.getApproximateRefundsForBlockRange(chainIds, widestBundleBlockRanges));
397
+ _d = (_c = combinedRefunds).push;
398
+ return [4, this.getApproximateRefundsForBlockRange(chainIds, widestBundleBlockRanges)];
399
+ case 6:
400
+ _d.apply(_c, [_e.sent()]);
346
401
  this.logger.debug({
347
402
  at: "BundleDataClient#getNextBundleRefunds",
348
403
  message: "Loading approximate refunds for next bundle in ".concat(Math.round(performance.now() - start) / 1000, "s."),
@@ -473,7 +528,7 @@ var BundleDataClient = (function () {
473
528
  };
474
529
  BundleDataClient.prototype.loadDataFromScratch = function (blockRangesForChains, spokePoolClients) {
475
530
  return tslib_1.__awaiter(this, void 0, void 0, function () {
476
- var start, key, chainIds, bundleDepositsV3, bundleFillsV3, bundleInvalidFillsV3, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills, _isChainDisabled, _canCreateSlowFillLeaf, _getFillStatusForDeposit, allChainIds, _cachedBundleTimestamps, bundleBlockTimestamps, v3RelayHashes, bundleDepositHashes, olderDepositHashes, depositCounter, _loop_2, _i, allChainIds_1, originChainId, validatedBundleV3Fills, validatedBundleSlowFills, validatedBundleUnexecutableSlowFills, fillCounter, _loop_3, _a, allChainIds_2, originChainId, promises, _b, v3FillLpFees, v3SlowFillLpFees, v3UnexecutableSlowFillLpFees, v3SpokeEventsReadable;
531
+ var start, key, chainIds, bundleDepositsV3, bundleFillsV3, bundleInvalidFillsV3, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills, _isChainDisabled, _canCreateSlowFillLeaf, _depositIsExpired, _getFillStatusForDeposit, allChainIds, _cachedBundleTimestamps, bundleBlockTimestamps, v3RelayHashes, bundleDepositHashes, olderDepositHashes, startBlockForMainnet, versionAtProposalBlock, canRefundPrefills, depositCounter, _loop_2, _i, allChainIds_1, originChainId, validatedBundleV3Fills, validatedBundleSlowFills, validatedBundleUnexecutableSlowFills, fillCounter, _loop_3, _a, allChainIds_2, originChainId, promises, _b, v3FillLpFees, v3SlowFillLpFees, v3UnexecutableSlowFillLpFees, v3SpokeEventsReadable;
477
532
  var _this = this;
478
533
  return tslib_1.__generator(this, function (_c) {
479
534
  switch (_c.label) {
@@ -505,6 +560,9 @@ var BundleDataClient = (function () {
505
560
  !deposit.fromLiteChain &&
506
561
  !deposit.toLiteChain);
507
562
  };
563
+ _depositIsExpired = function (deposit) {
564
+ return deposit.fillDeadline < bundleBlockTimestamps[deposit.destinationChainId][1];
565
+ };
508
566
  _getFillStatusForDeposit = function (deposit, queryBlock) {
509
567
  return spokePoolClients[deposit.destinationChainId].relayFillStatus(deposit, Math.min(queryBlock, spokePoolClients[deposit.destinationChainId].latestBlockSearched), deposit.destinationChainId);
510
568
  };
@@ -538,6 +596,9 @@ var BundleDataClient = (function () {
538
596
  v3RelayHashes = {};
539
597
  bundleDepositHashes = [];
540
598
  olderDepositHashes = [];
599
+ startBlockForMainnet = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, this.clients.hubPoolClient.chainId, this.chainIdListForBundleEvaluationBlockNumbers)[0];
600
+ versionAtProposalBlock = this.clients.configStoreClient.getConfigStoreVersionForBlock(startBlockForMainnet);
601
+ canRefundPrefills = versionAtProposalBlock >= constants_1.PRE_FILL_MIN_CONFIG_STORE_VERSION || process.env.FORCE_REFUND_PREFILLS === "true";
541
602
  depositCounter = 0;
542
603
  _loop_2 = function (originChainId) {
543
604
  var originClient = spokePoolClients[originChainId];
@@ -548,7 +609,7 @@ var BundleDataClient = (function () {
548
609
  continue;
549
610
  }
550
611
  originClient.getDepositsForDestinationChainWithDuplicates(destinationChainId).forEach(function (deposit) {
551
- if ((0, utils_1.isZeroValueDeposit)(deposit) || deposit.blockNumber > originChainBlockRange[1]) {
612
+ if (deposit.blockNumber > originChainBlockRange[1] || (0, utils_1.isZeroValueDeposit)(deposit)) {
552
613
  return;
553
614
  }
554
615
  depositCounter++;
@@ -593,7 +654,7 @@ var BundleDataClient = (function () {
593
654
  case 0:
594
655
  originClient = spokePoolClients[originChainId];
595
656
  _loop_4 = function (destinationChainId) {
596
- var destinationClient, destinationChainBlockRange, fastFillsReplacingSlowFills, originBlockRange;
657
+ var destinationClient, destinationChainBlockRange, fastFillsReplacingSlowFills;
597
658
  return tslib_1.__generator(this, function (_g) {
598
659
  switch (_g.label) {
599
660
  case 0:
@@ -605,57 +666,69 @@ var BundleDataClient = (function () {
605
666
  fastFillsReplacingSlowFills = [];
606
667
  return [4, (0, utils_1.forEachAsync)(destinationClient
607
668
  .getFillsForOriginChain(originChainId)
608
- .filter(function (fill) { return fill.blockNumber <= destinationChainBlockRange[1] && !(0, utils_1.isZeroValueDeposit)(fill); }), function (fill) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
609
- var relayDataHash, historicalDeposit, matchedDeposit;
669
+ .filter(function (fill) { return fill.blockNumber <= destinationChainBlockRange[1] && !(0, utils_1.isZeroValueDeposit)(fill); }), function (_fill) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
670
+ var relayDataHash, fill, historicalDeposit, matchedDeposit, fill;
610
671
  return tslib_1.__generator(this, function (_a) {
611
672
  switch (_a.label) {
612
673
  case 0:
613
- relayDataHash = this.getRelayHashFromEvent(fill);
614
674
  fillCounter++;
615
- if (v3RelayHashes[relayDataHash]) {
616
- if (!v3RelayHashes[relayDataHash].fill) {
617
- (0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposit), "Deposit should exist in relay hash dictionary.");
618
- v3RelayHashes[relayDataHash].fill = fill;
619
- if (fill.blockNumber >= destinationChainBlockRange[0]) {
620
- validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fill), { quoteTimestamp: v3RelayHashes[relayDataHash].deposit.quoteTimestamp }));
621
- if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
622
- !v3RelayHashes[relayDataHash].deposit.fromLiteChain &&
623
- !v3RelayHashes[relayDataHash].deposit.toLiteChain) {
624
- fastFillsReplacingSlowFills.push(relayDataHash);
625
- }
626
- }
627
- }
675
+ relayDataHash = this.getRelayHashFromEvent(_fill);
676
+ if (!v3RelayHashes[relayDataHash]) return [3, 3];
677
+ if (!!v3RelayHashes[relayDataHash].fill) return [3, 2];
678
+ (0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposit), "Deposit should exist in relay hash dictionary.");
679
+ return [4, (0, utils_2.verifyFillRepayment)(_fill, destinationClient.spokePool.provider, v3RelayHashes[relayDataHash].deposit, allChainIds)];
680
+ case 1:
681
+ fill = _a.sent();
682
+ if (!(0, utils_1.isDefined)(fill)) {
683
+ bundleInvalidFillsV3.push(_fill);
628
684
  return [2];
629
685
  }
686
+ v3RelayHashes[relayDataHash].fill = fill;
687
+ if (fill.blockNumber >= destinationChainBlockRange[0]) {
688
+ validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fill), { quoteTimestamp: v3RelayHashes[relayDataHash].deposit.quoteTimestamp }));
689
+ if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
690
+ _canCreateSlowFillLeaf(v3RelayHashes[relayDataHash].deposit)) {
691
+ fastFillsReplacingSlowFills.push(relayDataHash);
692
+ }
693
+ }
694
+ _a.label = 2;
695
+ case 2: return [2];
696
+ case 3:
630
697
  v3RelayHashes[relayDataHash] = {
631
698
  deposit: undefined,
632
- fill: fill,
699
+ fill: _fill,
633
700
  slowFillRequest: undefined,
634
701
  };
635
- if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 2];
636
- if (!exports.INFINITE_FILL_DEADLINE.eq(fill.fillDeadline)) {
637
- bundleInvalidFillsV3.push(fill);
702
+ if (!(_fill.blockNumber >= destinationChainBlockRange[0])) return [3, 7];
703
+ if (!exports.INFINITE_FILL_DEADLINE.eq(_fill.fillDeadline)) {
704
+ bundleInvalidFillsV3.push(_fill);
638
705
  return [2];
639
706
  }
640
- return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, fill)];
641
- case 1:
707
+ return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, _fill)];
708
+ case 4:
642
709
  historicalDeposit = _a.sent();
643
- if (!historicalDeposit.found) {
644
- bundleInvalidFillsV3.push(fill);
710
+ if (!!historicalDeposit.found) return [3, 5];
711
+ bundleInvalidFillsV3.push(_fill);
712
+ return [3, 7];
713
+ case 5:
714
+ matchedDeposit = historicalDeposit.deposit;
715
+ return [4, (0, utils_2.verifyFillRepayment)(_fill, destinationClient.spokePool.provider, matchedDeposit, allChainIds)];
716
+ case 6:
717
+ fill = _a.sent();
718
+ if (!(0, utils_1.isDefined)(fill)) {
719
+ bundleInvalidFillsV3.push(_fill);
720
+ return [2];
645
721
  }
646
- else {
647
- matchedDeposit = historicalDeposit.deposit;
648
- (0, utils_1.assert)(this.getRelayHashFromEvent(matchedDeposit) === relayDataHash, "Relay hashes should match.");
649
- validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fill), { quoteTimestamp: matchedDeposit.quoteTimestamp }));
650
- v3RelayHashes[relayDataHash].deposit = matchedDeposit;
651
- if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
652
- !matchedDeposit.fromLiteChain &&
653
- !matchedDeposit.toLiteChain) {
654
- fastFillsReplacingSlowFills.push(relayDataHash);
655
- }
722
+ v3RelayHashes[relayDataHash].fill = fill;
723
+ (0, utils_1.assert)(this.getRelayHashFromEvent(matchedDeposit) === relayDataHash, "Relay hashes should match.");
724
+ validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fill), { quoteTimestamp: matchedDeposit.quoteTimestamp }));
725
+ v3RelayHashes[relayDataHash].deposit = matchedDeposit;
726
+ if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
727
+ _canCreateSlowFillLeaf(matchedDeposit)) {
728
+ fastFillsReplacingSlowFills.push(relayDataHash);
656
729
  }
657
- _a.label = 2;
658
- case 2: return [2];
730
+ _a.label = 7;
731
+ case 7: return [2];
659
732
  }
660
733
  });
661
734
  }); })];
@@ -663,7 +736,9 @@ var BundleDataClient = (function () {
663
736
  _g.sent();
664
737
  return [4, (0, utils_1.forEachAsync)(destinationClient
665
738
  .getSlowFillRequestsForOriginChain(originChainId)
666
- .filter(function (request) { return request.blockNumber <= destinationChainBlockRange[1] && !(0, utils_1.isZeroValueDeposit)(request); }), function (slowFillRequest) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
739
+ .filter(function (request) {
740
+ return request.blockNumber <= destinationChainBlockRange[1] && !(0, utils_1.isZeroValueFillOrSlowFillRequest)(request);
741
+ }), function (slowFillRequest) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
667
742
  var relayDataHash, matchedDeposit, historicalDeposit, matchedDeposit;
668
743
  return tslib_1.__generator(this, function (_a) {
669
744
  switch (_a.label) {
@@ -677,11 +752,9 @@ var BundleDataClient = (function () {
677
752
  }
678
753
  (0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposit), "Deposit should exist in relay hash dictionary.");
679
754
  matchedDeposit = v3RelayHashes[relayDataHash].deposit;
680
- if (!_canCreateSlowFillLeaf(matchedDeposit)) {
681
- return [2];
682
- }
683
755
  if (slowFillRequest.blockNumber >= destinationChainBlockRange[0] &&
684
- slowFillRequest.fillDeadline >= bundleBlockTimestamps[destinationChainId][1]) {
756
+ _canCreateSlowFillLeaf(matchedDeposit) &&
757
+ !_depositIsExpired(matchedDeposit)) {
685
758
  validatedBundleSlowFills.push(matchedDeposit);
686
759
  }
687
760
  }
@@ -704,7 +777,7 @@ var BundleDataClient = (function () {
704
777
  (0, utils_1.assert)(this.getRelayHashFromEvent(matchedDeposit) === relayDataHash, "Deposit relay hashes should match.");
705
778
  v3RelayHashes[relayDataHash].deposit = matchedDeposit;
706
779
  if (!_canCreateSlowFillLeaf(matchedDeposit) ||
707
- slowFillRequest.fillDeadline < bundleBlockTimestamps[destinationChainId][1]) {
780
+ _depositIsExpired(matchedDeposit)) {
708
781
  return [2];
709
782
  }
710
783
  validatedBundleSlowFills.push(matchedDeposit);
@@ -715,17 +788,11 @@ var BundleDataClient = (function () {
715
788
  }); })];
716
789
  case 2:
717
790
  _g.sent();
718
- originBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, originChainId, chainIds);
719
791
  return [4, (0, utils_1.mapAsync)(bundleDepositHashes.filter(function (depositHash) {
720
792
  var deposit = v3RelayHashes[depositHash].deposit;
721
- return (deposit &&
722
- deposit.originChainId === originChainId &&
723
- deposit.destinationChainId === destinationChainId &&
724
- deposit.blockNumber >= originBlockRange[0] &&
725
- deposit.blockNumber <= originBlockRange[1] &&
726
- !(0, utils_1.isZeroValueDeposit)(deposit));
793
+ return (deposit && deposit.originChainId === originChainId && deposit.destinationChainId === destinationChainId);
727
794
  }), function (depositHash) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
728
- var _a, deposit, fill, slowFillRequest, fillStatus, prefill;
795
+ var _a, deposit, fill, slowFillRequest, fillStatus, prefill, verifiedFill;
729
796
  return tslib_1.__generator(this, function (_b) {
730
797
  switch (_b.label) {
731
798
  case 0:
@@ -733,17 +800,18 @@ var BundleDataClient = (function () {
733
800
  if (!deposit)
734
801
  throw new Error("Deposit should exist in relay hash dictionary.");
735
802
  if (fill) {
736
- if (!(0, utils_1.isSlowFill)(fill) && fill.blockNumber < destinationChainBlockRange[0]) {
803
+ if (canRefundPrefills && fill.blockNumber < destinationChainBlockRange[0] && !(0, utils_1.isSlowFill)(fill)) {
737
804
  validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fill), { quoteTimestamp: deposit.quoteTimestamp }));
738
805
  }
739
806
  return [2];
740
807
  }
741
808
  if (slowFillRequest) {
742
- if (deposit.fillDeadline < bundleBlockTimestamps[destinationChainId][1]) {
809
+ if (_depositIsExpired(deposit)) {
743
810
  updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
744
811
  }
745
- else if (_canCreateSlowFillLeaf(deposit) &&
746
- slowFillRequest.blockNumber < destinationChainBlockRange[0]) {
812
+ else if (canRefundPrefills &&
813
+ slowFillRequest.blockNumber < destinationChainBlockRange[0] &&
814
+ _canCreateSlowFillLeaf(deposit)) {
747
815
  validatedBundleSlowFills.push(deposit);
748
816
  }
749
817
  return [2];
@@ -751,25 +819,28 @@ var BundleDataClient = (function () {
751
819
  return [4, _getFillStatusForDeposit(deposit, destinationChainBlockRange[1])];
752
820
  case 1:
753
821
  fillStatus = _b.sent();
754
- if (!(fillStatus === interfaces_1.FillStatus.Filled)) return [3, 3];
822
+ if (!(fillStatus === interfaces_1.FillStatus.Filled)) return [3, 4];
755
823
  return [4, (0, utils_1.findFillEvent)(destinationClient.spokePool, deposit, destinationClient.deploymentBlock, destinationClient.latestBlockSearched)];
756
824
  case 2:
757
825
  prefill = (_b.sent());
758
- if (!(0, utils_1.isSlowFill)(prefill)) {
826
+ return [4, (0, utils_2.verifyFillRepayment)(prefill, destinationClient.spokePool.provider, deposit, allChainIds)];
827
+ case 3:
828
+ verifiedFill = _b.sent();
829
+ if (canRefundPrefills && (0, utils_1.isDefined)(verifiedFill) && !(0, utils_1.isSlowFill)(prefill)) {
759
830
  validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, prefill), { quoteTimestamp: deposit.quoteTimestamp }));
760
831
  }
761
- return [3, 4];
762
- case 3:
763
- if (deposit.fillDeadline < bundleBlockTimestamps[destinationChainId][1]) {
832
+ return [3, 5];
833
+ case 4:
834
+ if (_depositIsExpired(deposit)) {
764
835
  updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
765
836
  }
766
837
  else if (fillStatus === interfaces_1.FillStatus.RequestedSlowFill) {
767
- if (_canCreateSlowFillLeaf(deposit)) {
838
+ if (canRefundPrefills && _canCreateSlowFillLeaf(deposit)) {
768
839
  validatedBundleSlowFills.push(deposit);
769
840
  }
770
841
  }
771
- _b.label = 4;
772
- case 4: return [2];
842
+ _b.label = 5;
843
+ case 5: return [2];
773
844
  }
774
845
  });
775
846
  }); })];
@@ -781,10 +852,10 @@ var BundleDataClient = (function () {
781
852
  if (!deposit) {
782
853
  throw new Error("Deposit should exist in relay hash dictionary.");
783
854
  }
784
- (0, utils_1.assert)(!deposit.fromLiteChain && !deposit.toLiteChain, "fastFillsReplacingSlowFills should not contain lite chain deposits");
855
+ (0, utils_1.assert)(_canCreateSlowFillLeaf(deposit), "fastFillsReplacingSlowFills should contain only deposits that can be slow filled");
785
856
  var destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
786
- if (_this.clients.hubPoolClient.areTokensEquivalent(deposit.inputToken, deposit.originChainId, deposit.outputToken, deposit.destinationChainId, deposit.quoteBlockNumber) &&
787
- (!slowFillRequest || slowFillRequest.blockNumber < destinationBlockRange[0])) {
857
+ if (!slowFillRequest ||
858
+ slowFillRequest.blockNumber < destinationBlockRange[0]) {
788
859
  validatedBundleUnexecutableSlowFills.push(deposit);
789
860
  }
790
861
  });
@@ -837,7 +908,7 @@ var BundleDataClient = (function () {
837
908
  destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
838
909
  if (!(!fill &&
839
910
  (0, utils_1.isDefined)(deposit) &&
840
- deposit.fillDeadline < bundleBlockTimestamps[destinationChainId][1] &&
911
+ _depositIsExpired(deposit) &&
841
912
  deposit.fillDeadline >= bundleBlockTimestamps[destinationChainId][0] &&
842
913
  spokePoolClients[destinationChainId] !== undefined)) return [3, 2];
843
914
  return [4, _getFillStatusForDeposit(deposit, destinationBlockRange[1])];
@@ -846,11 +917,10 @@ var BundleDataClient = (function () {
846
917
  if (fillStatus !== interfaces_1.FillStatus.Filled) {
847
918
  updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
848
919
  }
849
- if (fillStatus !== interfaces_1.FillStatus.RequestedSlowFill || deposit.fromLiteChain || deposit.toLiteChain) {
920
+ if (fillStatus !== interfaces_1.FillStatus.RequestedSlowFill || !_canCreateSlowFillLeaf(deposit)) {
850
921
  return [2];
851
922
  }
852
- if (this.clients.hubPoolClient.areTokensEquivalent(deposit.inputToken, deposit.originChainId, deposit.outputToken, deposit.destinationChainId, deposit.quoteBlockNumber) &&
853
- (!slowFillRequest || slowFillRequest.blockNumber < destinationBlockRange[0])) {
923
+ if (!slowFillRequest || slowFillRequest.blockNumber < destinationBlockRange[0]) {
854
924
  validatedBundleUnexecutableSlowFills.push(deposit);
855
925
  }
856
926
  _b.label = 2;
@@ -894,7 +964,7 @@ var BundleDataClient = (function () {
894
964
  var associatedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].deposit;
895
965
  (0, utils_1.assert)((0, utils_1.isDefined)(associatedDeposit), "Deposit should exist in relay hash dictionary.");
896
966
  var _b = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRangesForChains, chainIds, associatedDeposit.fromLiteChain), chainToSendRefundTo = _b.chainToSendRefundTo, repaymentToken = _b.repaymentToken;
897
- updateBundleFillsV3(bundleFillsV3, fill, realizedLpFeePct, chainToSendRefundTo, repaymentToken);
967
+ updateBundleFillsV3(bundleFillsV3, fill, realizedLpFeePct, chainToSendRefundTo, repaymentToken, fill.relayer);
898
968
  });
899
969
  v3SlowFillLpFees.forEach(function (_a, idx) {
900
970
  var lpFeePct = _a.realizedLpFeePct;
@@ -933,7 +1003,7 @@ var BundleDataClient = (function () {
933
1003
  });
934
1004
  };
935
1005
  BundleDataClient.prototype.getRelayHashFromEvent = function (event) {
936
- return "".concat(event.depositor, "-").concat(event.recipient, "-").concat(event.exclusiveRelayer, "-").concat(event.inputToken, "-").concat(event.outputToken, "-").concat(event.inputAmount, "-").concat(event.outputAmount, "-").concat(event.originChainId, "-").concat(event.depositId, "-").concat(event.fillDeadline, "-").concat(event.exclusivityDeadline, "-").concat(event.message, "-").concat(event.destinationChainId);
1006
+ return "".concat(event.depositor, "-").concat(event.recipient, "-").concat(event.exclusiveRelayer, "-").concat(event.inputToken, "-").concat(event.outputToken, "-").concat(event.inputAmount, "-").concat(event.outputAmount, "-").concat(event.originChainId, "-").concat(event.depositId.toString(), "-").concat(event.fillDeadline, "-").concat(event.exclusivityDeadline, "-").concat(event.message, "-").concat(event.destinationChainId);
937
1007
  };
938
1008
  BundleDataClient.prototype.getBundleBlockTimestamps = function (chainIds, blockRangesForChains, spokePoolClients) {
939
1009
  return tslib_1.__awaiter(this, void 0, void 0, function () {