@across-protocol/sdk 4.0.0-beta.9 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +5 -4
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +345 -187
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.d.ts +1 -2
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +1 -2
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +5 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +47 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +4 -4
- package/dist/cjs/clients/SpokePoolClient.d.ts +1 -0
- package/dist/cjs/clients/SpokePoolClient.js +10 -1
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +2 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +11 -0
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/constants.d.ts +0 -1
- package/dist/cjs/constants.js +1 -2
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/providers/index.d.ts +1 -0
- package/dist/cjs/providers/index.js +2 -0
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/providers/mockProvider.d.ts +19 -0
- package/dist/cjs/providers/mockProvider.js +70 -0
- package/dist/cjs/providers/mockProvider.js.map +1 -0
- package/dist/cjs/utils/AddressUtils.d.ts +1 -0
- package/dist/cjs/utils/AddressUtils.js +6 -1
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/BlockUtils.js +1 -0
- package/dist/cjs/utils/BlockUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.js +1 -1
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.js +21 -0
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.js +2 -1
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +1 -0
- package/dist/cjs/utils/SpokeUtils.js +15 -8
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/common.d.ts +1 -0
- package/dist/cjs/utils/common.js +2 -1
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +5 -4
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +448 -281
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.d.ts +1 -2
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +2 -3
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +5 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +54 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +4 -4
- package/dist/esm/clients/SpokePoolClient.d.ts +8 -0
- package/dist/esm/clients/SpokePoolClient.js +17 -1
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +2 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +11 -0
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/constants.d.ts +0 -1
- package/dist/esm/constants.js +0 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/providers/index.d.ts +1 -0
- package/dist/esm/providers/index.js +2 -0
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/providers/mockProvider.d.ts +23 -0
- package/dist/esm/providers/mockProvider.js +73 -0
- package/dist/esm/providers/mockProvider.js.map +1 -0
- package/dist/esm/utils/AddressUtils.d.ts +1 -0
- package/dist/esm/utils/AddressUtils.js +9 -0
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/BlockUtils.js +1 -0
- package/dist/esm/utils/BlockUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.js +2 -2
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.js +29 -1
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.js +2 -1
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +1 -0
- package/dist/esm/utils/SpokeUtils.js +13 -7
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/abi/typechain/Multicall3.d.ts +4 -1
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/esm/utils/common.d.ts +1 -0
- package/dist/esm/utils/common.js +1 -0
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +5 -4
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts +1 -2
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +5 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +4 -4
- package/dist/types/clients/SpokePoolClient.d.ts +8 -0
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +2 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/providers/index.d.ts +1 -0
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/providers/mockProvider.d.ts +24 -0
- package/dist/types/providers/mockProvider.d.ts.map +1 -0
- package/dist/types/utils/AddressUtils.d.ts +1 -0
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/BlockUtils.d.ts.map +1 -1
- package/dist/types/utils/EventUtils.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +1 -0
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/Multicall3.d.ts +4 -1
- package/dist/types/utils/abi/typechain/Multicall3.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/common.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts.map +1 -1
- package/dist/types/utils/common.d.ts +1 -0
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/BundleDataClient/BundleDataClient.ts +406 -249
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +0 -8
- package/src/clients/BundleDataClient/utils/FillUtils.ts +66 -2
- package/src/clients/SpokePoolClient.ts +16 -3
- package/src/clients/mocks/MockSpokePoolClient.ts +14 -0
- package/src/constants.ts +0 -2
- package/src/providers/index.ts +1 -0
- package/src/providers/mockProvider.ts +77 -0
- package/src/utils/AddressUtils.ts +10 -0
- package/src/utils/BlockUtils.ts +1 -0
- package/src/utils/DepositUtils.ts +2 -2
- package/src/utils/EventUtils.ts +29 -1
- package/src/utils/NetworkUtils.ts +2 -1
- package/src/utils/SpokeUtils.ts +21 -8
- package/src/utils/common.ts +2 -0
|
@@ -27,11 +27,9 @@ function updateBundleDepositsV3(dict, deposit) {
|
|
|
27
27
|
}
|
|
28
28
|
dict[originChainId][inputToken].push(deposit);
|
|
29
29
|
}
|
|
30
|
-
function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentToken) {
|
|
30
|
+
function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentToken, repaymentAddress) {
|
|
31
31
|
var _a, _b;
|
|
32
|
-
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
32
|
+
(0, utils_1.assert)((0, utils_1.chainIsEvm)(repaymentChainId) && (0, utils_2.isEvmRepaymentValid)(fill, repaymentChainId), "validatedBundleV3Fills dictionary should only contain fills with valid repayment information");
|
|
35
33
|
if (!((_a = dict === null || dict === void 0 ? void 0 : dict[repaymentChainId]) === null || _a === void 0 ? void 0 : _a[repaymentToken])) {
|
|
36
34
|
(0, utils_1.assign)(dict, [repaymentChainId, repaymentToken], {
|
|
37
35
|
fills: [],
|
|
@@ -40,22 +38,22 @@ function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentTo
|
|
|
40
38
|
refunds: {},
|
|
41
39
|
});
|
|
42
40
|
}
|
|
43
|
-
var bundleFill = tslib_1.__assign(tslib_1.__assign({}, fill), { lpFeePct: lpFeePct });
|
|
41
|
+
var bundleFill = tslib_1.__assign(tslib_1.__assign({}, fill), { lpFeePct: lpFeePct, relayer: repaymentAddress });
|
|
44
42
|
(0, utils_1.assign)(dict, [repaymentChainId, repaymentToken, "fills"], [bundleFill]);
|
|
45
43
|
var refundObj = dict[repaymentChainId][repaymentToken];
|
|
46
|
-
var realizedLpFee =
|
|
44
|
+
var realizedLpFee = bundleFill.inputAmount.mul(bundleFill.lpFeePct).div(utils_1.fixedPointAdjustment);
|
|
47
45
|
refundObj.realizedLpFees = refundObj.realizedLpFees ? refundObj.realizedLpFees.add(realizedLpFee) : realizedLpFee;
|
|
48
|
-
if (!(0, utils_1.isSlowFill)(
|
|
49
|
-
var refundAmount =
|
|
46
|
+
if (!(0, utils_1.isSlowFill)(bundleFill)) {
|
|
47
|
+
var refundAmount = bundleFill.inputAmount.mul(utils_1.fixedPointAdjustment.sub(lpFeePct)).div(utils_1.fixedPointAdjustment);
|
|
50
48
|
refundObj.totalRefundAmount = refundObj.totalRefundAmount
|
|
51
49
|
? refundObj.totalRefundAmount.add(refundAmount)
|
|
52
50
|
: refundAmount;
|
|
53
51
|
(_b = refundObj.refunds) !== null && _b !== void 0 ? _b : (refundObj.refunds = {});
|
|
54
|
-
if (refundObj.refunds[
|
|
55
|
-
refundObj.refunds[
|
|
52
|
+
if (refundObj.refunds[bundleFill.relayer]) {
|
|
53
|
+
refundObj.refunds[bundleFill.relayer] = refundObj.refunds[bundleFill.relayer].add(refundAmount);
|
|
56
54
|
}
|
|
57
55
|
else {
|
|
58
|
-
refundObj.refunds[
|
|
56
|
+
refundObj.refunds[bundleFill.relayer] = refundAmount;
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
}
|
|
@@ -69,6 +67,9 @@ function updateBundleExcessSlowFills(dict, deposit) {
|
|
|
69
67
|
}
|
|
70
68
|
function updateBundleSlowFills(dict, deposit) {
|
|
71
69
|
var _a;
|
|
70
|
+
if ((0, utils_1.chainIsEvm)(deposit.destinationChainId) && !(0, utils_1.isValidEvmAddress)(deposit.recipient)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
72
73
|
var destinationChainId = deposit.destinationChainId, outputToken = deposit.outputToken;
|
|
73
74
|
if (!((_a = dict === null || dict === void 0 ? void 0 : dict[destinationChainId]) === null || _a === void 0 ? void 0 : _a[outputToken])) {
|
|
74
75
|
(0, utils_1.assign)(dict, [destinationChainId, outputToken], []);
|
|
@@ -153,7 +154,7 @@ var BundleDataClient = (function () {
|
|
|
153
154
|
at: "BundleDataClient#loadPersistedDataFromArweave",
|
|
154
155
|
message: "Loaded persisted data from Arweave in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
155
156
|
blockRanges: JSON.stringify(blockRangesForChains),
|
|
156
|
-
bundleData: (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleData.bundleDepositsV3, bundleData.bundleFillsV3,
|
|
157
|
+
bundleData: (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleData.bundleDepositsV3, bundleData.bundleFillsV3, bundleData.bundleSlowFillsV3, bundleData.expiredDepositsToRefundV3, bundleData.unexecutableSlowFills),
|
|
157
158
|
});
|
|
158
159
|
return [2, bundleData];
|
|
159
160
|
}
|
|
@@ -195,64 +196,107 @@ var BundleDataClient = (function () {
|
|
|
195
196
|
return [4, this.loadArweaveData(bundleEvaluationBlockRanges)];
|
|
196
197
|
case 1:
|
|
197
198
|
arweaveData = _a.sent();
|
|
198
|
-
if (arweaveData === undefined)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
199
|
+
if (!(arweaveData === undefined)) return [3, 3];
|
|
200
|
+
return [4, this.getApproximateRefundsForBlockRange(chainIds, bundleEvaluationBlockRanges)];
|
|
201
|
+
case 2:
|
|
202
|
+
combinedRefunds = _a.sent();
|
|
203
|
+
return [3, 4];
|
|
204
|
+
case 3:
|
|
205
|
+
bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
|
|
206
|
+
combinedRefunds = (0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3);
|
|
207
|
+
Object.keys(combinedRefunds).forEach(function (chainId) {
|
|
208
|
+
if (_this.spokePoolClients[Number(chainId)] === undefined) {
|
|
209
|
+
delete combinedRefunds[Number(chainId)];
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
_a.label = 4;
|
|
213
|
+
case 4: return [2, this.deductExecutedRefunds(combinedRefunds, bundle)];
|
|
211
214
|
}
|
|
212
215
|
});
|
|
213
216
|
});
|
|
214
217
|
};
|
|
215
218
|
BundleDataClient.prototype.getApproximateRefundsForBlockRange = function (chainIds, blockRanges) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
219
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
220
|
+
var refundsForChain, _loop_1, this_1, _i, chainIds_1, chainId;
|
|
221
|
+
var _this = this;
|
|
222
|
+
return tslib_1.__generator(this, function (_a) {
|
|
223
|
+
switch (_a.label) {
|
|
224
|
+
case 0:
|
|
225
|
+
refundsForChain = {};
|
|
226
|
+
_loop_1 = function (chainId) {
|
|
227
|
+
var chainIndex, fillsToCount;
|
|
228
|
+
return tslib_1.__generator(this, function (_b) {
|
|
229
|
+
switch (_b.label) {
|
|
230
|
+
case 0:
|
|
231
|
+
if (this_1.spokePoolClients[chainId] === undefined) {
|
|
232
|
+
return [2, "continue"];
|
|
233
|
+
}
|
|
234
|
+
chainIndex = chainIds.indexOf(chainId);
|
|
235
|
+
return [4, (0, utils_1.filterAsync)(this_1.spokePoolClients[chainId].getFills(), function (fill) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
236
|
+
var matchingDeposit, hasMatchingDeposit, validRepayment;
|
|
237
|
+
return tslib_1.__generator(this, function (_a) {
|
|
238
|
+
switch (_a.label) {
|
|
239
|
+
case 0:
|
|
240
|
+
if (fill.blockNumber < blockRanges[chainIndex][0] ||
|
|
241
|
+
fill.blockNumber > blockRanges[chainIndex][1] ||
|
|
242
|
+
(0, utils_1.isZeroValueFillOrSlowFillRequest)(fill)) {
|
|
243
|
+
return [2, false];
|
|
244
|
+
}
|
|
245
|
+
if (this.spokePoolClients[fill.originChainId] === undefined) {
|
|
246
|
+
return [2, false];
|
|
247
|
+
}
|
|
248
|
+
matchingDeposit = this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
|
|
249
|
+
hasMatchingDeposit = matchingDeposit !== undefined &&
|
|
250
|
+
this.getRelayHashFromEvent(fill) === this.getRelayHashFromEvent(matchingDeposit);
|
|
251
|
+
if (!hasMatchingDeposit) return [3, 2];
|
|
252
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, this.spokePoolClients[fill.destinationChainId].spokePool.provider, matchingDeposit, this.clients.configStoreClient
|
|
253
|
+
.getChainIdIndicesForBlock(blockRanges[0][1])
|
|
254
|
+
.filter(function (_chainId, i) { return !(0, utils_2.isChainDisabled)(blockRanges[i]); }))];
|
|
255
|
+
case 1:
|
|
256
|
+
validRepayment = _a.sent();
|
|
257
|
+
if (!(0, utils_1.isDefined)(validRepayment)) {
|
|
258
|
+
return [2, false];
|
|
259
|
+
}
|
|
260
|
+
_a.label = 2;
|
|
261
|
+
case 2: return [2, hasMatchingDeposit];
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}); })];
|
|
265
|
+
case 1:
|
|
266
|
+
fillsToCount = _b.sent();
|
|
267
|
+
fillsToCount.forEach(function (fill) {
|
|
268
|
+
var _a, _b, _c;
|
|
269
|
+
var _d;
|
|
270
|
+
var matchingDeposit = _this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
|
|
271
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(matchingDeposit), "Deposit not found for fill.");
|
|
272
|
+
var _e = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRanges, _this.chainIdListForBundleEvaluationBlockNumbers, matchingDeposit.fromLiteChain), chainToSendRefundTo = _e.chainToSendRefundTo, repaymentToken = _e.repaymentToken;
|
|
273
|
+
var relayer = fill.relayer, refundAmount = fill.inputAmount;
|
|
274
|
+
(_a = refundsForChain[chainToSendRefundTo]) !== null && _a !== void 0 ? _a : (refundsForChain[chainToSendRefundTo] = {});
|
|
275
|
+
(_b = (_d = refundsForChain[chainToSendRefundTo])[repaymentToken]) !== null && _b !== void 0 ? _b : (_d[repaymentToken] = {});
|
|
276
|
+
var existingRefundAmount = (_c = refundsForChain[chainToSendRefundTo][repaymentToken][relayer]) !== null && _c !== void 0 ? _c : utils_1.bnZero;
|
|
277
|
+
refundsForChain[chainToSendRefundTo][repaymentToken][relayer] = existingRefundAmount.add(refundAmount);
|
|
278
|
+
});
|
|
279
|
+
return [2];
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
this_1 = this;
|
|
284
|
+
_i = 0, chainIds_1 = chainIds;
|
|
285
|
+
_a.label = 1;
|
|
286
|
+
case 1:
|
|
287
|
+
if (!(_i < chainIds_1.length)) return [3, 4];
|
|
288
|
+
chainId = chainIds_1[_i];
|
|
289
|
+
return [5, _loop_1(chainId)];
|
|
290
|
+
case 2:
|
|
291
|
+
_a.sent();
|
|
292
|
+
_a.label = 3;
|
|
293
|
+
case 3:
|
|
294
|
+
_i++;
|
|
295
|
+
return [3, 1];
|
|
296
|
+
case 4: return [2, refundsForChain];
|
|
231
297
|
}
|
|
232
|
-
var matchingDeposit = _this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
|
|
233
|
-
var hasMatchingDeposit = matchingDeposit !== undefined &&
|
|
234
|
-
_this.getRelayHashFromEvent(fill) === _this.getRelayHashFromEvent(matchingDeposit);
|
|
235
|
-
return hasMatchingDeposit;
|
|
236
|
-
})
|
|
237
|
-
.forEach(function (fill) {
|
|
238
|
-
var _a, _b, _c;
|
|
239
|
-
var _d;
|
|
240
|
-
var matchingDeposit = _this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
|
|
241
|
-
(0, utils_1.assert)((0, utils_1.isDefined)(matchingDeposit), "Deposit not found for fill.");
|
|
242
|
-
var _e = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRanges, _this.chainIdListForBundleEvaluationBlockNumbers, matchingDeposit.fromLiteChain), chainToSendRefundTo = _e.chainToSendRefundTo, repaymentToken = _e.repaymentToken;
|
|
243
|
-
var relayer = fill.relayer, refundAmount = fill.inputAmount;
|
|
244
|
-
(_a = refundsForChain[chainToSendRefundTo]) !== null && _a !== void 0 ? _a : (refundsForChain[chainToSendRefundTo] = {});
|
|
245
|
-
(_b = (_d = refundsForChain[chainToSendRefundTo])[repaymentToken]) !== null && _b !== void 0 ? _b : (_d[repaymentToken] = {});
|
|
246
|
-
var existingRefundAmount = (_c = refundsForChain[chainToSendRefundTo][repaymentToken][relayer]) !== null && _c !== void 0 ? _c : utils_1.bnZero;
|
|
247
|
-
refundsForChain[chainToSendRefundTo][repaymentToken][relayer] = existingRefundAmount.add(refundAmount);
|
|
248
298
|
});
|
|
249
|
-
};
|
|
250
|
-
var this_1 = this;
|
|
251
|
-
for (var _i = 0, chainIds_1 = chainIds; _i < chainIds_1.length; _i++) {
|
|
252
|
-
var chainId = chainIds_1[_i];
|
|
253
|
-
_loop_1(chainId);
|
|
254
|
-
}
|
|
255
|
-
return refundsForChain;
|
|
299
|
+
});
|
|
256
300
|
};
|
|
257
301
|
BundleDataClient.prototype.getUpcomingDepositAmount = function (chainId, l2Token, latestBlockToSearch) {
|
|
258
302
|
if (this.spokePoolClients[chainId] === undefined) {
|
|
@@ -295,12 +339,10 @@ var BundleDataClient = (function () {
|
|
|
295
339
|
case 1:
|
|
296
340
|
_a = _b.sent(), bundleData = _a.bundleData, blockRanges = _a.blockRanges;
|
|
297
341
|
hubPoolClient = this.clients.hubPoolClient;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
case 2:
|
|
303
|
-
root = _b.sent();
|
|
342
|
+
root = (0, utils_2._buildPoolRebalanceRoot)(hubPoolClient.latestBlockSearched, blockRanges[0][1], bundleData.bundleDepositsV3, bundleData.bundleFillsV3, bundleData.bundleSlowFillsV3, bundleData.unexecutableSlowFills, bundleData.expiredDepositsToRefundV3, {
|
|
343
|
+
hubPoolClient: hubPoolClient,
|
|
344
|
+
configStoreClient: hubPoolClient.configStoreClient,
|
|
345
|
+
});
|
|
304
346
|
return [2, {
|
|
305
347
|
root: root,
|
|
306
348
|
blockRanges: blockRanges,
|
|
@@ -324,32 +366,39 @@ var BundleDataClient = (function () {
|
|
|
324
366
|
return [initialBlockRange[1] + 1, blockRange[1]];
|
|
325
367
|
});
|
|
326
368
|
}
|
|
327
|
-
var hubPoolClient, nextBundleMainnetStartBlock, chainIds, combinedRefunds, widestBundleBlockRanges, pendingBundleBlockRanges, arweaveData, bundleFillsV3, expiredDepositsToRefundV3, start;
|
|
328
|
-
return tslib_1.__generator(this, function (
|
|
329
|
-
switch (
|
|
369
|
+
var hubPoolClient, nextBundleMainnetStartBlock, chainIds, combinedRefunds, widestBundleBlockRanges, pendingBundleBlockRanges, arweaveData, _a, _b, bundleFillsV3, expiredDepositsToRefundV3, start, _c, _d;
|
|
370
|
+
return tslib_1.__generator(this, function (_e) {
|
|
371
|
+
switch (_e.label) {
|
|
330
372
|
case 0:
|
|
331
373
|
hubPoolClient = this.clients.hubPoolClient;
|
|
332
374
|
nextBundleMainnetStartBlock = hubPoolClient.getNextBundleStartBlockNumber(this.chainIdListForBundleEvaluationBlockNumbers, hubPoolClient.latestBlockSearched, hubPoolClient.chainId);
|
|
333
375
|
chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(nextBundleMainnetStartBlock);
|
|
334
376
|
combinedRefunds = [];
|
|
335
377
|
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));
|
|
336
|
-
if (!hubPoolClient.hasPendingProposal()) return [3,
|
|
378
|
+
if (!hubPoolClient.hasPendingProposal()) return [3, 5];
|
|
337
379
|
pendingBundleBlockRanges = (0, utils_1.getImpliedBundleBlockRanges)(hubPoolClient, this.clients.configStoreClient, hubPoolClient.getLatestProposedRootBundle());
|
|
338
380
|
return [4, this.loadArweaveData(pendingBundleBlockRanges)];
|
|
339
381
|
case 1:
|
|
340
|
-
arweaveData =
|
|
341
|
-
if (arweaveData === undefined)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
else {
|
|
345
|
-
bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
|
|
346
|
-
combinedRefunds.push((0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3));
|
|
347
|
-
}
|
|
348
|
-
widestBundleBlockRanges = getBlockRangeDelta(pendingBundleBlockRanges);
|
|
349
|
-
_a.label = 2;
|
|
382
|
+
arweaveData = _e.sent();
|
|
383
|
+
if (!(arweaveData === undefined)) return [3, 3];
|
|
384
|
+
_b = (_a = combinedRefunds).push;
|
|
385
|
+
return [4, this.getApproximateRefundsForBlockRange(chainIds, pendingBundleBlockRanges)];
|
|
350
386
|
case 2:
|
|
387
|
+
_b.apply(_a, [_e.sent()]);
|
|
388
|
+
return [3, 4];
|
|
389
|
+
case 3:
|
|
390
|
+
bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
|
|
391
|
+
combinedRefunds.push((0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3));
|
|
392
|
+
_e.label = 4;
|
|
393
|
+
case 4:
|
|
394
|
+
widestBundleBlockRanges = getBlockRangeDelta(pendingBundleBlockRanges);
|
|
395
|
+
_e.label = 5;
|
|
396
|
+
case 5:
|
|
351
397
|
start = performance.now();
|
|
352
|
-
combinedRefunds.push
|
|
398
|
+
_d = (_c = combinedRefunds).push;
|
|
399
|
+
return [4, this.getApproximateRefundsForBlockRange(chainIds, widestBundleBlockRanges)];
|
|
400
|
+
case 6:
|
|
401
|
+
_d.apply(_c, [_e.sent()]);
|
|
353
402
|
this.logger.debug({
|
|
354
403
|
at: "BundleDataClient#getNextBundleRefunds",
|
|
355
404
|
message: "Loading approximate refunds for next bundle in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
@@ -480,7 +529,7 @@ var BundleDataClient = (function () {
|
|
|
480
529
|
};
|
|
481
530
|
BundleDataClient.prototype.loadDataFromScratch = function (blockRangesForChains, spokePoolClients) {
|
|
482
531
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
483
|
-
var start, key, chainIds, bundleDepositsV3, bundleFillsV3, bundleInvalidFillsV3, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills, _isChainDisabled, _canCreateSlowFillLeaf, _depositIsExpired, _getFillStatusForDeposit, allChainIds, _cachedBundleTimestamps, bundleBlockTimestamps, v3RelayHashes, bundleDepositHashes, olderDepositHashes, startBlockForMainnet, versionAtProposalBlock, canRefundPrefills,
|
|
532
|
+
var start, key, chainIds, bundleDepositsV3, bundleFillsV3, bundleInvalidFillsV3, bundleUnrepayableFillsV3, bundleInvalidSlowFillRequests, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills, _isChainDisabled, _canCreateSlowFillLeaf, _depositIsExpired, _getFillStatusForDeposit, allChainIds, _cachedBundleTimestamps, bundleBlockTimestamps, v3RelayHashes, bundleDepositHashes, olderDepositHashes, decodeBundleDepositHash, startBlockForMainnet, versionAtProposalBlock, canRefundPrefills, _loop_2, _i, allChainIds_1, originChainId, validatedBundleV3Fills, validatedBundleSlowFills, validatedBundleUnexecutableSlowFills, fillCounter, _loop_3, _a, allChainIds_2, originChainId, promises, _b, v3FillLpFees, v3SlowFillLpFees, v3UnexecutableSlowFillLpFees, v3SpokeEventsReadable;
|
|
484
533
|
var _this = this;
|
|
485
534
|
return tslib_1.__generator(this, function (_c) {
|
|
486
535
|
switch (_c.label) {
|
|
@@ -500,6 +549,8 @@ var BundleDataClient = (function () {
|
|
|
500
549
|
bundleDepositsV3 = {};
|
|
501
550
|
bundleFillsV3 = {};
|
|
502
551
|
bundleInvalidFillsV3 = [];
|
|
552
|
+
bundleUnrepayableFillsV3 = [];
|
|
553
|
+
bundleInvalidSlowFillRequests = [];
|
|
503
554
|
bundleSlowFillsV3 = {};
|
|
504
555
|
expiredDepositsToRefundV3 = {};
|
|
505
556
|
unexecutableSlowFills = {};
|
|
@@ -548,10 +599,13 @@ var BundleDataClient = (function () {
|
|
|
548
599
|
v3RelayHashes = {};
|
|
549
600
|
bundleDepositHashes = [];
|
|
550
601
|
olderDepositHashes = [];
|
|
602
|
+
decodeBundleDepositHash = function (depositHash) {
|
|
603
|
+
var _a = depositHash.split("@"), relayDataHash = _a[0], i = _a[1];
|
|
604
|
+
return { relayDataHash: relayDataHash, index: Number(i) };
|
|
605
|
+
};
|
|
551
606
|
startBlockForMainnet = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, this.clients.hubPoolClient.chainId, this.chainIdListForBundleEvaluationBlockNumbers)[0];
|
|
552
607
|
versionAtProposalBlock = this.clients.configStoreClient.getConfigStoreVersionForBlock(startBlockForMainnet);
|
|
553
608
|
canRefundPrefills = versionAtProposalBlock >= constants_1.PRE_FILL_MIN_CONFIG_STORE_VERSION || process.env.FORCE_REFUND_PREFILLS === "true";
|
|
554
|
-
depositCounter = 0;
|
|
555
609
|
_loop_2 = function (originChainId) {
|
|
556
610
|
var originClient = spokePoolClients[originChainId];
|
|
557
611
|
var originChainBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, originChainId, chainIds);
|
|
@@ -564,24 +618,27 @@ var BundleDataClient = (function () {
|
|
|
564
618
|
if (deposit.blockNumber > originChainBlockRange[1] || (0, utils_1.isZeroValueDeposit)(deposit)) {
|
|
565
619
|
return;
|
|
566
620
|
}
|
|
567
|
-
depositCounter++;
|
|
568
621
|
var relayDataHash = _this.getRelayHashFromEvent(deposit);
|
|
569
622
|
if (!v3RelayHashes[relayDataHash]) {
|
|
570
623
|
v3RelayHashes[relayDataHash] = {
|
|
571
|
-
|
|
624
|
+
deposits: [deposit],
|
|
572
625
|
fill: undefined,
|
|
573
626
|
slowFillRequest: undefined,
|
|
574
627
|
};
|
|
575
628
|
}
|
|
576
|
-
|
|
577
|
-
|
|
629
|
+
else {
|
|
630
|
+
v3RelayHashes[relayDataHash].deposits.push(deposit);
|
|
578
631
|
}
|
|
632
|
+
var newBundleDepositHash = "".concat(relayDataHash, "@").concat(v3RelayHashes[relayDataHash].deposits.length - 1);
|
|
633
|
+
var decodedBundleDepositHash = decodeBundleDepositHash(newBundleDepositHash);
|
|
634
|
+
(0, utils_1.assert)(decodedBundleDepositHash.relayDataHash === relayDataHash &&
|
|
635
|
+
decodedBundleDepositHash.index === v3RelayHashes[relayDataHash].deposits.length - 1, "Not using correct bundle deposit hash key");
|
|
579
636
|
if (deposit.blockNumber >= originChainBlockRange[0]) {
|
|
580
|
-
bundleDepositHashes.push(
|
|
637
|
+
bundleDepositHashes.push(newBundleDepositHash);
|
|
581
638
|
updateBundleDepositsV3(bundleDepositsV3, deposit);
|
|
582
639
|
}
|
|
583
640
|
else if (deposit.blockNumber < originChainBlockRange[0]) {
|
|
584
|
-
olderDepositHashes.push(
|
|
641
|
+
olderDepositHashes.push(newBundleDepositHash);
|
|
585
642
|
}
|
|
586
643
|
});
|
|
587
644
|
}
|
|
@@ -592,7 +649,7 @@ var BundleDataClient = (function () {
|
|
|
592
649
|
}
|
|
593
650
|
this.logger.debug({
|
|
594
651
|
at: "BundleDataClient#loadData",
|
|
595
|
-
message: "Processed ".concat(
|
|
652
|
+
message: "Processed ".concat(bundleDepositHashes.length + olderDepositHashes.length, " deposits in ").concat(performance.now() - start, "ms."),
|
|
596
653
|
});
|
|
597
654
|
start = performance.now();
|
|
598
655
|
validatedBundleV3Fills = [];
|
|
@@ -606,7 +663,7 @@ var BundleDataClient = (function () {
|
|
|
606
663
|
case 0:
|
|
607
664
|
originClient = spokePoolClients[originChainId];
|
|
608
665
|
_loop_4 = function (destinationChainId) {
|
|
609
|
-
var destinationClient, destinationChainBlockRange, fastFillsReplacingSlowFills;
|
|
666
|
+
var destinationClient, destinationChainBlockRange, originChainBlockRange, fastFillsReplacingSlowFills;
|
|
610
667
|
return tslib_1.__generator(this, function (_g) {
|
|
611
668
|
switch (_g.label) {
|
|
612
669
|
case 0:
|
|
@@ -615,69 +672,90 @@ var BundleDataClient = (function () {
|
|
|
615
672
|
}
|
|
616
673
|
destinationClient = spokePoolClients[destinationChainId];
|
|
617
674
|
destinationChainBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
675
|
+
originChainBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, originChainId, chainIds);
|
|
618
676
|
fastFillsReplacingSlowFills = [];
|
|
619
677
|
return [4, (0, utils_1.forEachAsync)(destinationClient
|
|
620
678
|
.getFillsForOriginChain(originChainId)
|
|
621
679
|
.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 () {
|
|
622
|
-
var relayDataHash,
|
|
680
|
+
var relayDataHash, fillToRefund_1, duplicateDeposits, historicalDeposit, matchedDeposit, fillToRefund;
|
|
623
681
|
return tslib_1.__generator(this, function (_a) {
|
|
624
682
|
switch (_a.label) {
|
|
625
683
|
case 0:
|
|
626
|
-
relayDataHash = this.getRelayHashFromEvent(fill);
|
|
627
684
|
fillCounter++;
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
685
|
+
relayDataHash = this.getRelayHashFromEvent(fill);
|
|
686
|
+
if (!v3RelayHashes[relayDataHash]) return [3, 5];
|
|
687
|
+
if (!!v3RelayHashes[relayDataHash].fill) return [3, 3];
|
|
688
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposits) && v3RelayHashes[relayDataHash].deposits.length > 0, "Deposit should exist in relay hash dictionary.");
|
|
689
|
+
v3RelayHashes[relayDataHash].fill = fill;
|
|
690
|
+
if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 2];
|
|
691
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, v3RelayHashes[relayDataHash].deposits[0], allChainIds)];
|
|
692
|
+
case 1:
|
|
693
|
+
fillToRefund_1 = _a.sent();
|
|
694
|
+
if (!(0, utils_1.isDefined)(fillToRefund_1)) {
|
|
695
|
+
bundleUnrepayableFillsV3.push(fill);
|
|
696
|
+
}
|
|
697
|
+
else {
|
|
698
|
+
v3RelayHashes[relayDataHash].fill = fillToRefund_1;
|
|
699
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund_1), { quoteTimestamp: v3RelayHashes[relayDataHash].deposits[0].quoteTimestamp }));
|
|
700
|
+
duplicateDeposits = v3RelayHashes[relayDataHash].deposits.slice(1);
|
|
701
|
+
duplicateDeposits.forEach(function (duplicateDeposit) {
|
|
702
|
+
if ((0, utils_1.isSlowFill)(fill)) {
|
|
703
|
+
updateExpiredDepositsV3(expiredDepositsToRefundV3, duplicateDeposit);
|
|
638
704
|
}
|
|
639
|
-
|
|
640
|
-
|
|
705
|
+
else {
|
|
706
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund_1), { quoteTimestamp: duplicateDeposit.quoteTimestamp }));
|
|
707
|
+
}
|
|
708
|
+
});
|
|
641
709
|
}
|
|
710
|
+
if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
|
|
711
|
+
_canCreateSlowFillLeaf(v3RelayHashes[relayDataHash].deposits[0])) {
|
|
712
|
+
fastFillsReplacingSlowFills.push(relayDataHash);
|
|
713
|
+
}
|
|
714
|
+
_a.label = 2;
|
|
715
|
+
case 2: return [3, 4];
|
|
716
|
+
case 3: throw new Error("Duplicate fill detected");
|
|
717
|
+
case 4: return [2];
|
|
718
|
+
case 5:
|
|
642
719
|
v3RelayHashes[relayDataHash] = {
|
|
643
|
-
|
|
720
|
+
deposits: undefined,
|
|
644
721
|
fill: fill,
|
|
645
722
|
slowFillRequest: undefined,
|
|
646
723
|
};
|
|
647
|
-
if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3,
|
|
724
|
+
if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 9];
|
|
648
725
|
if (!exports.INFINITE_FILL_DEADLINE.eq(fill.fillDeadline)) {
|
|
649
726
|
bundleInvalidFillsV3.push(fill);
|
|
650
727
|
return [2];
|
|
651
728
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
729
|
+
return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, fill)];
|
|
730
|
+
case 6:
|
|
731
|
+
historicalDeposit = _a.sent();
|
|
732
|
+
if (!!historicalDeposit.found) return [3, 7];
|
|
733
|
+
bundleInvalidFillsV3.push(fill);
|
|
734
|
+
return [3, 9];
|
|
735
|
+
case 7:
|
|
736
|
+
matchedDeposit = historicalDeposit.deposit;
|
|
737
|
+
if (matchedDeposit.blockNumber > originChainBlockRange[1]) {
|
|
658
738
|
bundleInvalidFillsV3.push(fill);
|
|
659
739
|
return [2];
|
|
660
740
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
case
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
bundleInvalidFillsV3.push(fill);
|
|
741
|
+
v3RelayHashes[relayDataHash].deposits = [matchedDeposit];
|
|
742
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, matchedDeposit, allChainIds)];
|
|
743
|
+
case 8:
|
|
744
|
+
fillToRefund = _a.sent();
|
|
745
|
+
if (!(0, utils_1.isDefined)(fillToRefund)) {
|
|
746
|
+
bundleUnrepayableFillsV3.push(fill);
|
|
668
747
|
}
|
|
669
748
|
else {
|
|
670
|
-
matchedDeposit = historicalDeposit.deposit;
|
|
671
749
|
(0, utils_1.assert)(this.getRelayHashFromEvent(matchedDeposit) === relayDataHash, "Relay hashes should match.");
|
|
672
|
-
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({},
|
|
673
|
-
v3RelayHashes[relayDataHash].
|
|
674
|
-
if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
|
|
675
|
-
_canCreateSlowFillLeaf(matchedDeposit)) {
|
|
676
|
-
fastFillsReplacingSlowFills.push(relayDataHash);
|
|
677
|
-
}
|
|
750
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund), { quoteTimestamp: matchedDeposit.quoteTimestamp }));
|
|
751
|
+
v3RelayHashes[relayDataHash].fill = fillToRefund;
|
|
678
752
|
}
|
|
679
|
-
|
|
680
|
-
|
|
753
|
+
if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
|
|
754
|
+
_canCreateSlowFillLeaf(matchedDeposit)) {
|
|
755
|
+
fastFillsReplacingSlowFills.push(relayDataHash);
|
|
756
|
+
}
|
|
757
|
+
_a.label = 9;
|
|
758
|
+
case 9: return [2];
|
|
681
759
|
}
|
|
682
760
|
});
|
|
683
761
|
}); })];
|
|
@@ -699,34 +777,44 @@ var BundleDataClient = (function () {
|
|
|
699
777
|
if (v3RelayHashes[relayDataHash].fill) {
|
|
700
778
|
return [2];
|
|
701
779
|
}
|
|
702
|
-
(0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].
|
|
703
|
-
matchedDeposit = v3RelayHashes[relayDataHash].
|
|
780
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposits) && v3RelayHashes[relayDataHash].deposits.length > 0, "Deposit should exist in relay hash dictionary.");
|
|
781
|
+
matchedDeposit = v3RelayHashes[relayDataHash].deposits[0];
|
|
704
782
|
if (slowFillRequest.blockNumber >= destinationChainBlockRange[0] &&
|
|
705
783
|
_canCreateSlowFillLeaf(matchedDeposit) &&
|
|
706
784
|
!_depositIsExpired(matchedDeposit)) {
|
|
707
785
|
validatedBundleSlowFills.push(matchedDeposit);
|
|
708
786
|
}
|
|
709
787
|
}
|
|
788
|
+
else {
|
|
789
|
+
throw new Error("Duplicate slow fill request detected.");
|
|
790
|
+
}
|
|
710
791
|
return [2];
|
|
711
792
|
}
|
|
712
793
|
v3RelayHashes[relayDataHash] = {
|
|
713
|
-
|
|
794
|
+
deposits: undefined,
|
|
714
795
|
fill: undefined,
|
|
715
796
|
slowFillRequest: slowFillRequest,
|
|
716
797
|
};
|
|
717
|
-
if (!(slowFillRequest.blockNumber >= destinationChainBlockRange[0]
|
|
718
|
-
|
|
798
|
+
if (!(slowFillRequest.blockNumber >= destinationChainBlockRange[0])) return [3, 2];
|
|
799
|
+
if (!exports.INFINITE_FILL_DEADLINE.eq(slowFillRequest.fillDeadline)) {
|
|
800
|
+
bundleInvalidSlowFillRequests.push(slowFillRequest);
|
|
801
|
+
return [2];
|
|
802
|
+
}
|
|
719
803
|
return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, slowFillRequest)];
|
|
720
804
|
case 1:
|
|
721
805
|
historicalDeposit = _a.sent();
|
|
722
806
|
if (!historicalDeposit.found) {
|
|
807
|
+
bundleInvalidSlowFillRequests.push(slowFillRequest);
|
|
723
808
|
return [2];
|
|
724
809
|
}
|
|
725
810
|
matchedDeposit = historicalDeposit.deposit;
|
|
811
|
+
if (matchedDeposit.blockNumber > originChainBlockRange[1]) {
|
|
812
|
+
bundleInvalidSlowFillRequests.push(slowFillRequest);
|
|
813
|
+
return [2];
|
|
814
|
+
}
|
|
726
815
|
(0, utils_1.assert)(this.getRelayHashFromEvent(matchedDeposit) === relayDataHash, "Deposit relay hashes should match.");
|
|
727
|
-
v3RelayHashes[relayDataHash].
|
|
728
|
-
if (!_canCreateSlowFillLeaf(matchedDeposit) ||
|
|
729
|
-
_depositIsExpired(matchedDeposit)) {
|
|
816
|
+
v3RelayHashes[relayDataHash].deposits = [matchedDeposit];
|
|
817
|
+
if (!_canCreateSlowFillLeaf(matchedDeposit) || _depositIsExpired(matchedDeposit)) {
|
|
730
818
|
return [2];
|
|
731
819
|
}
|
|
732
820
|
validatedBundleSlowFills.push(matchedDeposit);
|
|
@@ -737,72 +825,105 @@ var BundleDataClient = (function () {
|
|
|
737
825
|
}); })];
|
|
738
826
|
case 2:
|
|
739
827
|
_g.sent();
|
|
740
|
-
return [4, (0, utils_1.mapAsync)(bundleDepositHashes.
|
|
741
|
-
var deposit
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
return tslib_1.__generator(this, function (_b) {
|
|
746
|
-
switch (_b.label) {
|
|
828
|
+
return [4, (0, utils_1.mapAsync)(bundleDepositHashes, function (depositHash) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
829
|
+
var _a, relayDataHash, index, _b, deposits, fill, slowFillRequest, deposit, fillToRefund, fillStatus, prefill, verifiedFill;
|
|
830
|
+
var _this = this;
|
|
831
|
+
return tslib_1.__generator(this, function (_c) {
|
|
832
|
+
switch (_c.label) {
|
|
747
833
|
case 0:
|
|
748
|
-
_a =
|
|
834
|
+
_a = decodeBundleDepositHash(depositHash), relayDataHash = _a.relayDataHash, index = _a.index;
|
|
835
|
+
_b = v3RelayHashes[relayDataHash], deposits = _b.deposits, fill = _b.fill, slowFillRequest = _b.slowFillRequest;
|
|
836
|
+
if (!deposits || deposits.length === 0) {
|
|
837
|
+
throw new Error("Deposits should exist in relay hash dictionary.");
|
|
838
|
+
}
|
|
839
|
+
deposit = deposits[index];
|
|
749
840
|
if (!deposit)
|
|
750
841
|
throw new Error("Deposit should exist in relay hash dictionary.");
|
|
751
|
-
if (
|
|
752
|
-
if (canRefundPrefills && fill.blockNumber < destinationChainBlockRange[0] && !(0, utils_1.isSlowFill)(fill)) {
|
|
753
|
-
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fill), { quoteTimestamp: deposit.quoteTimestamp }));
|
|
754
|
-
}
|
|
842
|
+
if (deposit.originChainId !== originChainId || deposit.destinationChainId !== destinationChainId) {
|
|
755
843
|
return [2];
|
|
756
844
|
}
|
|
845
|
+
if (!fill) return [3, 3];
|
|
846
|
+
if (!(canRefundPrefills && fill.blockNumber < destinationChainBlockRange[0])) return [3, 2];
|
|
847
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, v3RelayHashes[relayDataHash].deposits[0], allChainIds)];
|
|
848
|
+
case 1:
|
|
849
|
+
fillToRefund = _c.sent();
|
|
850
|
+
if (!(0, utils_1.isDefined)(fillToRefund)) {
|
|
851
|
+
bundleUnrepayableFillsV3.push(fill);
|
|
852
|
+
}
|
|
853
|
+
else if (!(0, utils_1.isSlowFill)(fill)) {
|
|
854
|
+
v3RelayHashes[relayDataHash].fill = fillToRefund;
|
|
855
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund), { quoteTimestamp: deposit.quoteTimestamp }));
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
859
|
+
}
|
|
860
|
+
_c.label = 2;
|
|
861
|
+
case 2: return [2];
|
|
862
|
+
case 3:
|
|
757
863
|
if (slowFillRequest) {
|
|
758
864
|
if (_depositIsExpired(deposit)) {
|
|
759
865
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
760
866
|
}
|
|
761
867
|
else if (canRefundPrefills &&
|
|
762
868
|
slowFillRequest.blockNumber < destinationChainBlockRange[0] &&
|
|
763
|
-
_canCreateSlowFillLeaf(deposit)
|
|
869
|
+
_canCreateSlowFillLeaf(deposit) &&
|
|
870
|
+
validatedBundleSlowFills.every(function (d) { return _this.getRelayHashFromEvent(d) !== relayDataHash; })) {
|
|
764
871
|
validatedBundleSlowFills.push(deposit);
|
|
765
872
|
}
|
|
766
873
|
return [2];
|
|
767
874
|
}
|
|
768
875
|
return [4, _getFillStatusForDeposit(deposit, destinationChainBlockRange[1])];
|
|
769
|
-
case
|
|
770
|
-
fillStatus =
|
|
771
|
-
if (!(fillStatus === interfaces_1.FillStatus.Filled)) return [3,
|
|
772
|
-
return [4,
|
|
773
|
-
case
|
|
774
|
-
prefill =
|
|
775
|
-
|
|
776
|
-
|
|
876
|
+
case 4:
|
|
877
|
+
fillStatus = _c.sent();
|
|
878
|
+
if (!(fillStatus === interfaces_1.FillStatus.Filled)) return [3, 8];
|
|
879
|
+
return [4, this.findMatchingFillEvent(deposit, destinationClient)];
|
|
880
|
+
case 5:
|
|
881
|
+
prefill = _c.sent();
|
|
882
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(prefill), "findFillEvent# Cannot find prefill: ".concat(relayDataHash));
|
|
883
|
+
(0, utils_1.assert)(this.getRelayHashFromEvent(prefill) === relayDataHash, "Relay hashes should match.");
|
|
884
|
+
if (!canRefundPrefills) return [3, 7];
|
|
885
|
+
return [4, (0, utils_2.verifyFillRepayment)(prefill, destinationClient.spokePool.provider, deposit, allChainIds)];
|
|
886
|
+
case 6:
|
|
887
|
+
verifiedFill = _c.sent();
|
|
888
|
+
if (!(0, utils_1.isDefined)(verifiedFill)) {
|
|
889
|
+
bundleUnrepayableFillsV3.push(prefill);
|
|
777
890
|
}
|
|
778
|
-
|
|
779
|
-
|
|
891
|
+
else if (!(0, utils_1.isSlowFill)(verifiedFill)) {
|
|
892
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, verifiedFill), { quoteTimestamp: deposit.quoteTimestamp }));
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
896
|
+
}
|
|
897
|
+
_c.label = 7;
|
|
898
|
+
case 7: return [3, 9];
|
|
899
|
+
case 8:
|
|
780
900
|
if (_depositIsExpired(deposit)) {
|
|
781
901
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
782
902
|
}
|
|
783
|
-
else if (fillStatus === interfaces_1.FillStatus.RequestedSlowFill
|
|
903
|
+
else if (fillStatus === interfaces_1.FillStatus.RequestedSlowFill &&
|
|
904
|
+
validatedBundleSlowFills.every(function (d) { return _this.getRelayHashFromEvent(d) !== relayDataHash; })) {
|
|
784
905
|
if (canRefundPrefills && _canCreateSlowFillLeaf(deposit)) {
|
|
785
906
|
validatedBundleSlowFills.push(deposit);
|
|
786
907
|
}
|
|
787
908
|
}
|
|
788
|
-
|
|
789
|
-
case
|
|
909
|
+
_c.label = 9;
|
|
910
|
+
case 9: return [2];
|
|
790
911
|
}
|
|
791
912
|
});
|
|
792
913
|
}); })];
|
|
793
914
|
case 3:
|
|
794
915
|
_g.sent();
|
|
795
916
|
fastFillsReplacingSlowFills.forEach(function (relayDataHash) {
|
|
796
|
-
var _a = v3RelayHashes[relayDataHash],
|
|
917
|
+
var _a = v3RelayHashes[relayDataHash], deposits = _a.deposits, slowFillRequest = _a.slowFillRequest, fill = _a.fill;
|
|
797
918
|
(0, utils_1.assert)((fill === null || fill === void 0 ? void 0 : fill.relayExecutionInfo.fillType) === interfaces_1.FillType.ReplacedSlowFill, "Fill type should be ReplacedSlowFill.");
|
|
798
|
-
if (!
|
|
919
|
+
if (!deposits || deposits.length < 1) {
|
|
799
920
|
throw new Error("Deposit should exist in relay hash dictionary.");
|
|
800
921
|
}
|
|
801
|
-
(0, utils_1.assert)(_canCreateSlowFillLeaf(
|
|
922
|
+
(0, utils_1.assert)(_canCreateSlowFillLeaf(deposits[0]), "fastFillsReplacingSlowFills should contain only deposits that can be slow filled");
|
|
802
923
|
var destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
803
924
|
if (!slowFillRequest ||
|
|
804
925
|
slowFillRequest.blockNumber < destinationBlockRange[0]) {
|
|
805
|
-
validatedBundleUnexecutableSlowFills.push(
|
|
926
|
+
validatedBundleUnexecutableSlowFills.push(deposits[0]);
|
|
806
927
|
}
|
|
807
928
|
});
|
|
808
929
|
return [2];
|
|
@@ -843,13 +964,17 @@ var BundleDataClient = (function () {
|
|
|
843
964
|
message: "Processed ".concat(fillCounter, " fills in ").concat(performance.now() - start, "ms."),
|
|
844
965
|
});
|
|
845
966
|
start = performance.now();
|
|
846
|
-
return [4, (0, utils_1.forEachAsync)(olderDepositHashes, function (
|
|
847
|
-
var _a,
|
|
848
|
-
return tslib_1.__generator(this, function (
|
|
849
|
-
switch (
|
|
967
|
+
return [4, (0, utils_1.forEachAsync)(olderDepositHashes, function (depositHash) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
968
|
+
var _a, relayDataHash, index, _b, deposits, slowFillRequest, fill, deposit, destinationChainId, destinationBlockRange, fillStatus;
|
|
969
|
+
return tslib_1.__generator(this, function (_c) {
|
|
970
|
+
switch (_c.label) {
|
|
850
971
|
case 0:
|
|
851
|
-
_a =
|
|
852
|
-
|
|
972
|
+
_a = decodeBundleDepositHash(depositHash), relayDataHash = _a.relayDataHash, index = _a.index;
|
|
973
|
+
_b = v3RelayHashes[relayDataHash], deposits = _b.deposits, slowFillRequest = _b.slowFillRequest, fill = _b.fill;
|
|
974
|
+
if (!deposits || deposits.length < 1) {
|
|
975
|
+
throw new Error("Deposit should exist in relay hash dictionary.");
|
|
976
|
+
}
|
|
977
|
+
deposit = deposits[index];
|
|
853
978
|
destinationChainId = deposit.destinationChainId;
|
|
854
979
|
destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
855
980
|
if (!(!fill &&
|
|
@@ -859,7 +984,7 @@ var BundleDataClient = (function () {
|
|
|
859
984
|
spokePoolClients[destinationChainId] !== undefined)) return [3, 2];
|
|
860
985
|
return [4, _getFillStatusForDeposit(deposit, destinationBlockRange[1])];
|
|
861
986
|
case 1:
|
|
862
|
-
fillStatus =
|
|
987
|
+
fillStatus = _c.sent();
|
|
863
988
|
if (fillStatus !== interfaces_1.FillStatus.Filled) {
|
|
864
989
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
865
990
|
}
|
|
@@ -869,7 +994,7 @@ var BundleDataClient = (function () {
|
|
|
869
994
|
if (!slowFillRequest || slowFillRequest.blockNumber < destinationBlockRange[0]) {
|
|
870
995
|
validatedBundleUnexecutableSlowFills.push(deposit);
|
|
871
996
|
}
|
|
872
|
-
|
|
997
|
+
_c.label = 2;
|
|
873
998
|
case 2: return [2];
|
|
874
999
|
}
|
|
875
1000
|
});
|
|
@@ -880,7 +1005,7 @@ var BundleDataClient = (function () {
|
|
|
880
1005
|
promises = [
|
|
881
1006
|
validatedBundleV3Fills.length > 0
|
|
882
1007
|
? this.clients.hubPoolClient.batchComputeRealizedLpFeePct(validatedBundleV3Fills.map(function (fill) {
|
|
883
|
-
var matchedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].
|
|
1008
|
+
var matchedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].deposits[0];
|
|
884
1009
|
(0, utils_1.assert)((0, utils_1.isDefined)(matchedDeposit), "Deposit should exist in relay hash dictionary.");
|
|
885
1010
|
var paymentChainId = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRangesForChains, chainIds, matchedDeposit.fromLiteChain).chainToSendRefundTo;
|
|
886
1011
|
return tslib_1.__assign(tslib_1.__assign({}, fill), { paymentChainId: paymentChainId });
|
|
@@ -907,14 +1032,19 @@ var BundleDataClient = (function () {
|
|
|
907
1032
|
v3FillLpFees.forEach(function (_a, idx) {
|
|
908
1033
|
var realizedLpFeePct = _a.realizedLpFeePct;
|
|
909
1034
|
var fill = validatedBundleV3Fills[idx];
|
|
910
|
-
var associatedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].
|
|
1035
|
+
var associatedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].deposits[0];
|
|
911
1036
|
(0, utils_1.assert)((0, utils_1.isDefined)(associatedDeposit), "Deposit should exist in relay hash dictionary.");
|
|
912
1037
|
var _b = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRangesForChains, chainIds, associatedDeposit.fromLiteChain), chainToSendRefundTo = _b.chainToSendRefundTo, repaymentToken = _b.repaymentToken;
|
|
913
|
-
updateBundleFillsV3(bundleFillsV3, fill, realizedLpFeePct, chainToSendRefundTo, repaymentToken);
|
|
1038
|
+
updateBundleFillsV3(bundleFillsV3, fill, realizedLpFeePct, chainToSendRefundTo, repaymentToken, fill.relayer);
|
|
914
1039
|
});
|
|
915
1040
|
v3SlowFillLpFees.forEach(function (_a, idx) {
|
|
916
1041
|
var lpFeePct = _a.realizedLpFeePct;
|
|
917
1042
|
var deposit = validatedBundleSlowFills[idx];
|
|
1043
|
+
var relayDataHash = _this.getRelayHashFromEvent(deposit);
|
|
1044
|
+
if (validatedBundleSlowFills.slice(0, idx).some(function (d) { return _this.getRelayHashFromEvent(d) === relayDataHash; })) {
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
(0, utils_1.assert)(!_depositIsExpired(deposit), "Cannot create slow fill leaf for expired deposit.");
|
|
918
1048
|
updateBundleSlowFills(bundleSlowFillsV3, tslib_1.__assign(tslib_1.__assign({}, deposit), { lpFeePct: lpFeePct }));
|
|
919
1049
|
});
|
|
920
1050
|
v3UnexecutableSlowFillLpFees.forEach(function (_a, idx) {
|
|
@@ -922,15 +1052,31 @@ var BundleDataClient = (function () {
|
|
|
922
1052
|
var deposit = validatedBundleUnexecutableSlowFills[idx];
|
|
923
1053
|
updateBundleExcessSlowFills(unexecutableSlowFills, tslib_1.__assign(tslib_1.__assign({}, deposit), { lpFeePct: lpFeePct }));
|
|
924
1054
|
});
|
|
925
|
-
v3SpokeEventsReadable = (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleDepositsV3, bundleFillsV3,
|
|
1055
|
+
v3SpokeEventsReadable = (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleDepositsV3, bundleFillsV3, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills);
|
|
926
1056
|
if (bundleInvalidFillsV3.length > 0) {
|
|
927
1057
|
this.logger.debug({
|
|
928
1058
|
at: "BundleDataClient#loadData",
|
|
929
|
-
message: "Finished loading V3 spoke pool data and found some invalid
|
|
1059
|
+
message: "Finished loading V3 spoke pool data and found some invalid fills in range",
|
|
930
1060
|
blockRangesForChains: blockRangesForChains,
|
|
931
1061
|
bundleInvalidFillsV3: bundleInvalidFillsV3,
|
|
932
1062
|
});
|
|
933
1063
|
}
|
|
1064
|
+
if (bundleUnrepayableFillsV3.length > 0) {
|
|
1065
|
+
this.logger.debug({
|
|
1066
|
+
at: "BundleDataClient#loadData",
|
|
1067
|
+
message: "Finished loading V3 spoke pool data and found some unrepayable fills in range",
|
|
1068
|
+
blockRangesForChains: blockRangesForChains,
|
|
1069
|
+
bundleUnrepayableFillsV3: bundleUnrepayableFillsV3,
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
if (bundleInvalidSlowFillRequests.length > 0) {
|
|
1073
|
+
this.logger.debug({
|
|
1074
|
+
at: "BundleDataClient#loadData",
|
|
1075
|
+
message: "Finished loading V3 spoke pool data and found some invalid slow fill requests in range",
|
|
1076
|
+
blockRangesForChains: blockRangesForChains,
|
|
1077
|
+
bundleInvalidSlowFillRequests: bundleInvalidSlowFillRequests,
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
934
1080
|
this.logger.debug({
|
|
935
1081
|
at: "BundleDataClient#loadDataFromScratch",
|
|
936
1082
|
message: "Computed bundle data in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
@@ -951,6 +1097,16 @@ var BundleDataClient = (function () {
|
|
|
951
1097
|
BundleDataClient.prototype.getRelayHashFromEvent = function (event) {
|
|
952
1098
|
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);
|
|
953
1099
|
};
|
|
1100
|
+
BundleDataClient.prototype.findMatchingFillEvent = function (deposit, spokePoolClient) {
|
|
1101
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1102
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1103
|
+
switch (_a.label) {
|
|
1104
|
+
case 0: return [4, (0, utils_1.findFillEvent)(spokePoolClient.spokePool, deposit, spokePoolClient.deploymentBlock, spokePoolClient.latestBlockSearched)];
|
|
1105
|
+
case 1: return [2, _a.sent()];
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
1109
|
+
};
|
|
954
1110
|
BundleDataClient.prototype.getBundleBlockTimestamps = function (chainIds, blockRangesForChains, spokePoolClients) {
|
|
955
1111
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
956
1112
|
var _a, _b;
|
|
@@ -960,7 +1116,7 @@ var BundleDataClient = (function () {
|
|
|
960
1116
|
case 0:
|
|
961
1117
|
_b = (_a = Object).fromEntries;
|
|
962
1118
|
return [4, (0, utils_1.mapAsync)(chainIds, function (chainId, index) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
963
|
-
var blockRangeForChain, _startBlockForChain, _endBlockForChain, spokePoolClient, startBlockForChain, endBlockForChain, _a, startTime,
|
|
1119
|
+
var blockRangeForChain, _startBlockForChain, _endBlockForChain, spokePoolClient, startBlockForChain, endBlockForChain, _a, startTime, _endTime, _b, endBlockDelta, endTime;
|
|
964
1120
|
return tslib_1.__generator(this, function (_c) {
|
|
965
1121
|
switch (_c.label) {
|
|
966
1122
|
case 0:
|
|
@@ -974,7 +1130,7 @@ var BundleDataClient = (function () {
|
|
|
974
1130
|
return [2];
|
|
975
1131
|
}
|
|
976
1132
|
startBlockForChain = Math.min(_startBlockForChain, spokePoolClient.latestBlockSearched);
|
|
977
|
-
endBlockForChain = Math.min(_endBlockForChain, spokePoolClient.latestBlockSearched);
|
|
1133
|
+
endBlockForChain = Math.min(_endBlockForChain + 1, spokePoolClient.latestBlockSearched);
|
|
978
1134
|
return [4, spokePoolClient.getTimestampForBlock(startBlockForChain)];
|
|
979
1135
|
case 1:
|
|
980
1136
|
_b = [
|
|
@@ -984,8 +1140,10 @@ var BundleDataClient = (function () {
|
|
|
984
1140
|
case 2:
|
|
985
1141
|
_a = _b.concat([
|
|
986
1142
|
_c.sent()
|
|
987
|
-
]), startTime = _a[0],
|
|
988
|
-
|
|
1143
|
+
]), startTime = _a[0], _endTime = _a[1];
|
|
1144
|
+
endBlockDelta = endBlockForChain > startBlockForChain ? 1 : 0;
|
|
1145
|
+
endTime = Math.max(0, _endTime - endBlockDelta);
|
|
1146
|
+
(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, "."));
|
|
989
1147
|
(0, utils_1.assert)(startBlockForChain === 0 || startTime > 0, "Start timestamp must be greater than 0 if the start block is greater than 0.");
|
|
990
1148
|
return [2, [chainId, [startTime, endTime]]];
|
|
991
1149
|
}
|