@across-protocol/sdk 4.0.0-beta.3 → 4.0.0-beta.30
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 +340 -174
- 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 +13 -4
- 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 +1 -1
- package/dist/cjs/constants.js +2 -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 +2 -0
- package/dist/cjs/utils/AddressUtils.js +19 -1
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/CachingUtils.js +1 -1
- package/dist/cjs/utils/CachingUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +2 -1
- package/dist/cjs/utils/DepositUtils.js +13 -4
- 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.d.ts +1 -0
- package/dist/cjs/utils/NetworkUtils.js +6 -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 +18 -11
- 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 +410 -208
- 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 +20 -4
- 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 +1 -1
- package/dist/esm/constants.js +2 -2
- 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 +2 -0
- package/dist/esm/utils/AddressUtils.js +25 -0
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/CachingUtils.js +1 -1
- package/dist/esm/utils/CachingUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +2 -1
- package/dist/esm/utils/DepositUtils.js +14 -5
- 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.d.ts +6 -0
- package/dist/esm/utils/NetworkUtils.js +10 -0
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +1 -0
- package/dist/esm/utils/SpokeUtils.js +17 -11
- package/dist/esm/utils/SpokeUtils.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 +1 -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 +2 -0
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +2 -1
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/EventUtils.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts +6 -0
- 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/common.d.ts +1 -0
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +413 -184
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +0 -8
- package/src/clients/BundleDataClient/utils/FillUtils.ts +66 -2
- package/src/clients/SpokePoolClient.ts +19 -6
- package/src/clients/mocks/MockSpokePoolClient.ts +14 -0
- package/src/constants.ts +3 -3
- package/src/providers/index.ts +1 -0
- package/src/providers/mockProvider.ts +77 -0
- package/src/utils/AddressUtils.ts +26 -0
- package/src/utils/CachingUtils.ts +1 -1
- package/src/utils/DepositUtils.ts +14 -5
- package/src/utils/EventUtils.ts +29 -1
- package/src/utils/NetworkUtils.ts +11 -0
- package/src/utils/SpokeUtils.ts +27 -13
- package/src/utils/common.ts +2 -0
|
@@ -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,9 @@ 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
|
+
(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");
|
|
28
33
|
if (!((_a = dict === null || dict === void 0 ? void 0 : dict[repaymentChainId]) === null || _a === void 0 ? void 0 : _a[repaymentToken])) {
|
|
29
34
|
(0, utils_1.assign)(dict, [repaymentChainId, repaymentToken], {
|
|
30
35
|
fills: [],
|
|
@@ -33,22 +38,22 @@ function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentTo
|
|
|
33
38
|
refunds: {},
|
|
34
39
|
});
|
|
35
40
|
}
|
|
36
|
-
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 });
|
|
37
42
|
(0, utils_1.assign)(dict, [repaymentChainId, repaymentToken, "fills"], [bundleFill]);
|
|
38
43
|
var refundObj = dict[repaymentChainId][repaymentToken];
|
|
39
|
-
var realizedLpFee =
|
|
44
|
+
var realizedLpFee = bundleFill.inputAmount.mul(bundleFill.lpFeePct).div(utils_1.fixedPointAdjustment);
|
|
40
45
|
refundObj.realizedLpFees = refundObj.realizedLpFees ? refundObj.realizedLpFees.add(realizedLpFee) : realizedLpFee;
|
|
41
|
-
if (!(0, utils_1.isSlowFill)(
|
|
42
|
-
var refundAmount =
|
|
46
|
+
if (!(0, utils_1.isSlowFill)(bundleFill)) {
|
|
47
|
+
var refundAmount = bundleFill.inputAmount.mul(utils_1.fixedPointAdjustment.sub(lpFeePct)).div(utils_1.fixedPointAdjustment);
|
|
43
48
|
refundObj.totalRefundAmount = refundObj.totalRefundAmount
|
|
44
49
|
? refundObj.totalRefundAmount.add(refundAmount)
|
|
45
50
|
: refundAmount;
|
|
46
51
|
(_b = refundObj.refunds) !== null && _b !== void 0 ? _b : (refundObj.refunds = {});
|
|
47
|
-
if (refundObj.refunds[
|
|
48
|
-
refundObj.refunds[
|
|
52
|
+
if (refundObj.refunds[bundleFill.relayer]) {
|
|
53
|
+
refundObj.refunds[bundleFill.relayer] = refundObj.refunds[bundleFill.relayer].add(refundAmount);
|
|
49
54
|
}
|
|
50
55
|
else {
|
|
51
|
-
refundObj.refunds[
|
|
56
|
+
refundObj.refunds[bundleFill.relayer] = refundAmount;
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
}
|
|
@@ -62,6 +67,9 @@ function updateBundleExcessSlowFills(dict, deposit) {
|
|
|
62
67
|
}
|
|
63
68
|
function updateBundleSlowFills(dict, deposit) {
|
|
64
69
|
var _a;
|
|
70
|
+
if ((0, utils_1.chainIsEvm)(deposit.destinationChainId) && !(0, utils_1.isValidEvmAddress)(deposit.recipient)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
65
73
|
var destinationChainId = deposit.destinationChainId, outputToken = deposit.outputToken;
|
|
66
74
|
if (!((_a = dict === null || dict === void 0 ? void 0 : dict[destinationChainId]) === null || _a === void 0 ? void 0 : _a[outputToken])) {
|
|
67
75
|
(0, utils_1.assign)(dict, [destinationChainId, outputToken], []);
|
|
@@ -146,7 +154,7 @@ var BundleDataClient = (function () {
|
|
|
146
154
|
at: "BundleDataClient#loadPersistedDataFromArweave",
|
|
147
155
|
message: "Loaded persisted data from Arweave in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
148
156
|
blockRanges: JSON.stringify(blockRangesForChains),
|
|
149
|
-
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),
|
|
150
158
|
});
|
|
151
159
|
return [2, bundleData];
|
|
152
160
|
}
|
|
@@ -188,64 +196,107 @@ var BundleDataClient = (function () {
|
|
|
188
196
|
return [4, this.loadArweaveData(bundleEvaluationBlockRanges)];
|
|
189
197
|
case 1:
|
|
190
198
|
arweaveData = _a.sent();
|
|
191
|
-
if (arweaveData === undefined)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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)];
|
|
204
214
|
}
|
|
205
215
|
});
|
|
206
216
|
});
|
|
207
217
|
};
|
|
208
218
|
BundleDataClient.prototype.getApproximateRefundsForBlockRange = function (chainIds, blockRanges) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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];
|
|
224
297
|
}
|
|
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
298
|
});
|
|
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;
|
|
299
|
+
});
|
|
249
300
|
};
|
|
250
301
|
BundleDataClient.prototype.getUpcomingDepositAmount = function (chainId, l2Token, latestBlockToSearch) {
|
|
251
302
|
if (this.spokePoolClients[chainId] === undefined) {
|
|
@@ -288,12 +339,10 @@ var BundleDataClient = (function () {
|
|
|
288
339
|
case 1:
|
|
289
340
|
_a = _b.sent(), bundleData = _a.bundleData, blockRanges = _a.blockRanges;
|
|
290
341
|
hubPoolClient = this.clients.hubPoolClient;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
case 2:
|
|
296
|
-
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
|
+
});
|
|
297
346
|
return [2, {
|
|
298
347
|
root: root,
|
|
299
348
|
blockRanges: blockRanges,
|
|
@@ -317,32 +366,39 @@ var BundleDataClient = (function () {
|
|
|
317
366
|
return [initialBlockRange[1] + 1, blockRange[1]];
|
|
318
367
|
});
|
|
319
368
|
}
|
|
320
|
-
var hubPoolClient, nextBundleMainnetStartBlock, chainIds, combinedRefunds, widestBundleBlockRanges, pendingBundleBlockRanges, arweaveData, bundleFillsV3, expiredDepositsToRefundV3, start;
|
|
321
|
-
return tslib_1.__generator(this, function (
|
|
322
|
-
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) {
|
|
323
372
|
case 0:
|
|
324
373
|
hubPoolClient = this.clients.hubPoolClient;
|
|
325
374
|
nextBundleMainnetStartBlock = hubPoolClient.getNextBundleStartBlockNumber(this.chainIdListForBundleEvaluationBlockNumbers, hubPoolClient.latestBlockSearched, hubPoolClient.chainId);
|
|
326
375
|
chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(nextBundleMainnetStartBlock);
|
|
327
376
|
combinedRefunds = [];
|
|
328
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));
|
|
329
|
-
if (!hubPoolClient.hasPendingProposal()) return [3,
|
|
378
|
+
if (!hubPoolClient.hasPendingProposal()) return [3, 5];
|
|
330
379
|
pendingBundleBlockRanges = (0, utils_1.getImpliedBundleBlockRanges)(hubPoolClient, this.clients.configStoreClient, hubPoolClient.getLatestProposedRootBundle());
|
|
331
380
|
return [4, this.loadArweaveData(pendingBundleBlockRanges)];
|
|
332
381
|
case 1:
|
|
333
|
-
arweaveData =
|
|
334
|
-
if (arweaveData === undefined)
|
|
335
|
-
|
|
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;
|
|
382
|
+
arweaveData = _e.sent();
|
|
383
|
+
if (!(arweaveData === undefined)) return [3, 3];
|
|
384
|
+
_b = (_a = combinedRefunds).push;
|
|
385
|
+
return [4, this.getApproximateRefundsForBlockRange(chainIds, pendingBundleBlockRanges)];
|
|
343
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:
|
|
344
397
|
start = performance.now();
|
|
345
|
-
combinedRefunds.push
|
|
398
|
+
_d = (_c = combinedRefunds).push;
|
|
399
|
+
return [4, this.getApproximateRefundsForBlockRange(chainIds, widestBundleBlockRanges)];
|
|
400
|
+
case 6:
|
|
401
|
+
_d.apply(_c, [_e.sent()]);
|
|
346
402
|
this.logger.debug({
|
|
347
403
|
at: "BundleDataClient#getNextBundleRefunds",
|
|
348
404
|
message: "Loading approximate refunds for next bundle in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
@@ -473,7 +529,7 @@ var BundleDataClient = (function () {
|
|
|
473
529
|
};
|
|
474
530
|
BundleDataClient.prototype.loadDataFromScratch = function (blockRangesForChains, spokePoolClients) {
|
|
475
531
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
476
|
-
var start, key, chainIds, bundleDepositsV3, bundleFillsV3, bundleInvalidFillsV3, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills, _isChainDisabled, _canCreateSlowFillLeaf, _depositIsExpired, _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;
|
|
532
|
+
var start, key, chainIds, bundleDepositsV3, bundleFillsV3, bundleInvalidFillsV3, bundleUnrepayableFillsV3, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills, _isChainDisabled, _canCreateSlowFillLeaf, _depositIsExpired, _getFillStatusForDeposit, allChainIds, _cachedBundleTimestamps, bundleBlockTimestamps, v3RelayHashes, bundleDepositHashes, olderDepositHashes, decodeBundleDepositHash, 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
533
|
var _this = this;
|
|
478
534
|
return tslib_1.__generator(this, function (_c) {
|
|
479
535
|
switch (_c.label) {
|
|
@@ -493,6 +549,7 @@ var BundleDataClient = (function () {
|
|
|
493
549
|
bundleDepositsV3 = {};
|
|
494
550
|
bundleFillsV3 = {};
|
|
495
551
|
bundleInvalidFillsV3 = [];
|
|
552
|
+
bundleUnrepayableFillsV3 = [];
|
|
496
553
|
bundleSlowFillsV3 = {};
|
|
497
554
|
expiredDepositsToRefundV3 = {};
|
|
498
555
|
unexecutableSlowFills = {};
|
|
@@ -541,6 +598,13 @@ var BundleDataClient = (function () {
|
|
|
541
598
|
v3RelayHashes = {};
|
|
542
599
|
bundleDepositHashes = [];
|
|
543
600
|
olderDepositHashes = [];
|
|
601
|
+
decodeBundleDepositHash = function (depositHash) {
|
|
602
|
+
var _a = depositHash.split("@"), relayDataHash = _a[0], i = _a[1];
|
|
603
|
+
return { relayDataHash: relayDataHash, index: Number(i) };
|
|
604
|
+
};
|
|
605
|
+
startBlockForMainnet = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, this.clients.hubPoolClient.chainId, this.chainIdListForBundleEvaluationBlockNumbers)[0];
|
|
606
|
+
versionAtProposalBlock = this.clients.configStoreClient.getConfigStoreVersionForBlock(startBlockForMainnet);
|
|
607
|
+
canRefundPrefills = versionAtProposalBlock >= constants_1.PRE_FILL_MIN_CONFIG_STORE_VERSION || process.env.FORCE_REFUND_PREFILLS === "true";
|
|
544
608
|
depositCounter = 0;
|
|
545
609
|
_loop_2 = function (originChainId) {
|
|
546
610
|
var originClient = spokePoolClients[originChainId];
|
|
@@ -558,20 +622,27 @@ var BundleDataClient = (function () {
|
|
|
558
622
|
var relayDataHash = _this.getRelayHashFromEvent(deposit);
|
|
559
623
|
if (!v3RelayHashes[relayDataHash]) {
|
|
560
624
|
v3RelayHashes[relayDataHash] = {
|
|
561
|
-
|
|
625
|
+
deposits: [deposit],
|
|
562
626
|
fill: undefined,
|
|
563
627
|
slowFillRequest: undefined,
|
|
564
628
|
};
|
|
565
629
|
}
|
|
630
|
+
else {
|
|
631
|
+
v3RelayHashes[relayDataHash].deposits.push(deposit);
|
|
632
|
+
}
|
|
566
633
|
if (deposit.inputAmount.eq(0)) {
|
|
567
634
|
return;
|
|
568
635
|
}
|
|
636
|
+
var newBundleDepositHash = "".concat(relayDataHash, "@").concat(v3RelayHashes[relayDataHash].deposits.length - 1);
|
|
637
|
+
var decodedBundleDepositHash = decodeBundleDepositHash(newBundleDepositHash);
|
|
638
|
+
(0, utils_1.assert)(decodedBundleDepositHash.relayDataHash === relayDataHash &&
|
|
639
|
+
decodedBundleDepositHash.index === v3RelayHashes[relayDataHash].deposits.length - 1, "Not using correct bundle deposit hash key");
|
|
569
640
|
if (deposit.blockNumber >= originChainBlockRange[0]) {
|
|
570
|
-
bundleDepositHashes.push(
|
|
641
|
+
bundleDepositHashes.push(newBundleDepositHash);
|
|
571
642
|
updateBundleDepositsV3(bundleDepositsV3, deposit);
|
|
572
643
|
}
|
|
573
644
|
else if (deposit.blockNumber < originChainBlockRange[0]) {
|
|
574
|
-
olderDepositHashes.push(
|
|
645
|
+
olderDepositHashes.push(newBundleDepositHash);
|
|
575
646
|
}
|
|
576
647
|
});
|
|
577
648
|
}
|
|
@@ -596,7 +667,7 @@ var BundleDataClient = (function () {
|
|
|
596
667
|
case 0:
|
|
597
668
|
originClient = spokePoolClients[originChainId];
|
|
598
669
|
_loop_4 = function (destinationChainId) {
|
|
599
|
-
var destinationClient, destinationChainBlockRange,
|
|
670
|
+
var destinationClient, destinationChainBlockRange, originChainBlockRange, fastFillsReplacingSlowFills;
|
|
600
671
|
return tslib_1.__generator(this, function (_g) {
|
|
601
672
|
switch (_g.label) {
|
|
602
673
|
case 0:
|
|
@@ -605,58 +676,90 @@ var BundleDataClient = (function () {
|
|
|
605
676
|
}
|
|
606
677
|
destinationClient = spokePoolClients[destinationChainId];
|
|
607
678
|
destinationChainBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
679
|
+
originChainBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, originChainId, chainIds);
|
|
608
680
|
fastFillsReplacingSlowFills = [];
|
|
609
681
|
return [4, (0, utils_1.forEachAsync)(destinationClient
|
|
610
682
|
.getFillsForOriginChain(originChainId)
|
|
611
683
|
.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 () {
|
|
612
|
-
var relayDataHash, historicalDeposit, matchedDeposit;
|
|
684
|
+
var relayDataHash, fillToRefund_1, duplicateDeposits, historicalDeposit, matchedDeposit, fillToRefund;
|
|
613
685
|
return tslib_1.__generator(this, function (_a) {
|
|
614
686
|
switch (_a.label) {
|
|
615
687
|
case 0:
|
|
616
|
-
relayDataHash = this.getRelayHashFromEvent(fill);
|
|
617
688
|
fillCounter++;
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
689
|
+
relayDataHash = this.getRelayHashFromEvent(fill);
|
|
690
|
+
if (!v3RelayHashes[relayDataHash]) return [3, 5];
|
|
691
|
+
if (!!v3RelayHashes[relayDataHash].fill) return [3, 3];
|
|
692
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposits) && v3RelayHashes[relayDataHash].deposits.length > 0, "Deposit should exist in relay hash dictionary.");
|
|
693
|
+
v3RelayHashes[relayDataHash].fill = fill;
|
|
694
|
+
if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 2];
|
|
695
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, v3RelayHashes[relayDataHash].deposits[0], allChainIds)];
|
|
696
|
+
case 1:
|
|
697
|
+
fillToRefund_1 = _a.sent();
|
|
698
|
+
if (!(0, utils_1.isDefined)(fillToRefund_1)) {
|
|
699
|
+
bundleUnrepayableFillsV3.push(fill);
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
v3RelayHashes[relayDataHash].fill = fillToRefund_1;
|
|
703
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund_1), { quoteTimestamp: v3RelayHashes[relayDataHash].deposits[0].quoteTimestamp }));
|
|
704
|
+
duplicateDeposits = v3RelayHashes[relayDataHash].deposits.slice(1);
|
|
705
|
+
duplicateDeposits.forEach(function (duplicateDeposit) {
|
|
706
|
+
if ((0, utils_1.isSlowFill)(fill)) {
|
|
707
|
+
updateExpiredDepositsV3(expiredDepositsToRefundV3, duplicateDeposit);
|
|
628
708
|
}
|
|
629
|
-
|
|
630
|
-
|
|
709
|
+
else {
|
|
710
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund_1), { quoteTimestamp: duplicateDeposit.quoteTimestamp }));
|
|
711
|
+
}
|
|
712
|
+
});
|
|
631
713
|
}
|
|
714
|
+
if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
|
|
715
|
+
_canCreateSlowFillLeaf(v3RelayHashes[relayDataHash].deposits[0])) {
|
|
716
|
+
fastFillsReplacingSlowFills.push(relayDataHash);
|
|
717
|
+
}
|
|
718
|
+
_a.label = 2;
|
|
719
|
+
case 2: return [3, 4];
|
|
720
|
+
case 3: throw new Error("Duplicate fill detected");
|
|
721
|
+
case 4: return [2];
|
|
722
|
+
case 5:
|
|
632
723
|
v3RelayHashes[relayDataHash] = {
|
|
633
|
-
|
|
724
|
+
deposits: undefined,
|
|
634
725
|
fill: fill,
|
|
635
726
|
slowFillRequest: undefined,
|
|
636
727
|
};
|
|
637
|
-
if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3,
|
|
728
|
+
if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 9];
|
|
638
729
|
if (!exports.INFINITE_FILL_DEADLINE.eq(fill.fillDeadline)) {
|
|
639
730
|
bundleInvalidFillsV3.push(fill);
|
|
640
731
|
return [2];
|
|
641
732
|
}
|
|
642
733
|
return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, fill)];
|
|
643
|
-
case
|
|
734
|
+
case 6:
|
|
644
735
|
historicalDeposit = _a.sent();
|
|
645
|
-
if (
|
|
736
|
+
if (!!historicalDeposit.found) return [3, 7];
|
|
737
|
+
bundleInvalidFillsV3.push(fill);
|
|
738
|
+
return [3, 9];
|
|
739
|
+
case 7:
|
|
740
|
+
matchedDeposit = historicalDeposit.deposit;
|
|
741
|
+
if (matchedDeposit.blockNumber > originChainBlockRange[1]) {
|
|
646
742
|
bundleInvalidFillsV3.push(fill);
|
|
743
|
+
return [2];
|
|
744
|
+
}
|
|
745
|
+
v3RelayHashes[relayDataHash].deposits = [matchedDeposit];
|
|
746
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, matchedDeposit, allChainIds)];
|
|
747
|
+
case 8:
|
|
748
|
+
fillToRefund = _a.sent();
|
|
749
|
+
if (!(0, utils_1.isDefined)(fillToRefund)) {
|
|
750
|
+
bundleUnrepayableFillsV3.push(fill);
|
|
647
751
|
}
|
|
648
752
|
else {
|
|
649
|
-
matchedDeposit = historicalDeposit.deposit;
|
|
650
753
|
(0, utils_1.assert)(this.getRelayHashFromEvent(matchedDeposit) === relayDataHash, "Relay hashes should match.");
|
|
651
|
-
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({},
|
|
652
|
-
v3RelayHashes[relayDataHash].
|
|
653
|
-
if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
|
|
654
|
-
_canCreateSlowFillLeaf(matchedDeposit)) {
|
|
655
|
-
fastFillsReplacingSlowFills.push(relayDataHash);
|
|
656
|
-
}
|
|
754
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund), { quoteTimestamp: matchedDeposit.quoteTimestamp }));
|
|
755
|
+
v3RelayHashes[relayDataHash].fill = fillToRefund;
|
|
657
756
|
}
|
|
658
|
-
|
|
659
|
-
|
|
757
|
+
if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
|
|
758
|
+
_canCreateSlowFillLeaf(matchedDeposit)) {
|
|
759
|
+
fastFillsReplacingSlowFills.push(relayDataHash);
|
|
760
|
+
}
|
|
761
|
+
_a.label = 9;
|
|
762
|
+
case 9: return [2];
|
|
660
763
|
}
|
|
661
764
|
});
|
|
662
765
|
}); })];
|
|
@@ -678,23 +781,26 @@ var BundleDataClient = (function () {
|
|
|
678
781
|
if (v3RelayHashes[relayDataHash].fill) {
|
|
679
782
|
return [2];
|
|
680
783
|
}
|
|
681
|
-
(0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].
|
|
682
|
-
matchedDeposit = v3RelayHashes[relayDataHash].
|
|
784
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].deposits) && v3RelayHashes[relayDataHash].deposits.length > 0, "Deposit should exist in relay hash dictionary.");
|
|
785
|
+
matchedDeposit = v3RelayHashes[relayDataHash].deposits[0];
|
|
683
786
|
if (slowFillRequest.blockNumber >= destinationChainBlockRange[0] &&
|
|
684
787
|
_canCreateSlowFillLeaf(matchedDeposit) &&
|
|
685
788
|
!_depositIsExpired(matchedDeposit)) {
|
|
686
789
|
validatedBundleSlowFills.push(matchedDeposit);
|
|
687
790
|
}
|
|
688
791
|
}
|
|
792
|
+
else {
|
|
793
|
+
throw new Error("Duplicate slow fill request detected.");
|
|
794
|
+
}
|
|
689
795
|
return [2];
|
|
690
796
|
}
|
|
691
797
|
v3RelayHashes[relayDataHash] = {
|
|
692
|
-
|
|
798
|
+
deposits: undefined,
|
|
693
799
|
fill: undefined,
|
|
694
800
|
slowFillRequest: slowFillRequest,
|
|
695
801
|
};
|
|
696
|
-
if (!(slowFillRequest.
|
|
697
|
-
|
|
802
|
+
if (!(exports.INFINITE_FILL_DEADLINE.eq(slowFillRequest.fillDeadline) &&
|
|
803
|
+
slowFillRequest.blockNumber >= destinationChainBlockRange[0])) return [3, 2];
|
|
698
804
|
return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, slowFillRequest)];
|
|
699
805
|
case 1:
|
|
700
806
|
historicalDeposit = _a.sent();
|
|
@@ -702,8 +808,11 @@ var BundleDataClient = (function () {
|
|
|
702
808
|
return [2];
|
|
703
809
|
}
|
|
704
810
|
matchedDeposit = historicalDeposit.deposit;
|
|
811
|
+
if (matchedDeposit.blockNumber > originChainBlockRange[1]) {
|
|
812
|
+
return [2];
|
|
813
|
+
}
|
|
705
814
|
(0, utils_1.assert)(this.getRelayHashFromEvent(matchedDeposit) === relayDataHash, "Deposit relay hashes should match.");
|
|
706
|
-
v3RelayHashes[relayDataHash].
|
|
815
|
+
v3RelayHashes[relayDataHash].deposits = [matchedDeposit];
|
|
707
816
|
if (!_canCreateSlowFillLeaf(matchedDeposit) ||
|
|
708
817
|
_depositIsExpired(matchedDeposit)) {
|
|
709
818
|
return [2];
|
|
@@ -716,77 +825,106 @@ var BundleDataClient = (function () {
|
|
|
716
825
|
}); })];
|
|
717
826
|
case 2:
|
|
718
827
|
_g.sent();
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
var
|
|
722
|
-
return (
|
|
723
|
-
|
|
724
|
-
deposit.destinationChainId === destinationChainId &&
|
|
725
|
-
deposit.blockNumber >= originBlockRange[0] &&
|
|
726
|
-
deposit.blockNumber <= originBlockRange[1] &&
|
|
727
|
-
!(0, utils_1.isZeroValueDeposit)(deposit));
|
|
728
|
-
}), function (depositHash) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
729
|
-
var _a, deposit, fill, slowFillRequest, fillStatus, prefill;
|
|
730
|
-
return tslib_1.__generator(this, function (_b) {
|
|
731
|
-
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) {
|
|
732
833
|
case 0:
|
|
733
|
-
_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];
|
|
734
840
|
if (!deposit)
|
|
735
841
|
throw new Error("Deposit should exist in relay hash dictionary.");
|
|
736
|
-
if (
|
|
737
|
-
if (fill.blockNumber < destinationChainBlockRange[0] && !(0, utils_1.isSlowFill)(fill)) {
|
|
738
|
-
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fill), { quoteTimestamp: deposit.quoteTimestamp }));
|
|
739
|
-
}
|
|
842
|
+
if (deposit.originChainId !== originChainId || deposit.destinationChainId !== destinationChainId) {
|
|
740
843
|
return [2];
|
|
741
844
|
}
|
|
845
|
+
if (!fill) return [3, 4];
|
|
846
|
+
if (!(canRefundPrefills && fill.blockNumber < destinationChainBlockRange[0])) return [3, 3];
|
|
847
|
+
if (!!(0, utils_1.isSlowFill)(fill)) return [3, 2];
|
|
848
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, v3RelayHashes[relayDataHash].deposits[0], allChainIds)];
|
|
849
|
+
case 1:
|
|
850
|
+
fillToRefund = _c.sent();
|
|
851
|
+
if (!(0, utils_1.isDefined)(fillToRefund)) {
|
|
852
|
+
bundleUnrepayableFillsV3.push(fill);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
v3RelayHashes[relayDataHash].fill = fillToRefund;
|
|
856
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund), { quoteTimestamp: deposit.quoteTimestamp }));
|
|
857
|
+
}
|
|
858
|
+
return [3, 3];
|
|
859
|
+
case 2:
|
|
860
|
+
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
861
|
+
_c.label = 3;
|
|
862
|
+
case 3: return [2];
|
|
863
|
+
case 4:
|
|
742
864
|
if (slowFillRequest) {
|
|
743
865
|
if (_depositIsExpired(deposit)) {
|
|
744
866
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
745
867
|
}
|
|
746
|
-
else if (
|
|
747
|
-
|
|
868
|
+
else if (canRefundPrefills &&
|
|
869
|
+
slowFillRequest.blockNumber < destinationChainBlockRange[0] &&
|
|
870
|
+
_canCreateSlowFillLeaf(deposit) &&
|
|
871
|
+
validatedBundleSlowFills.every(function (d) { return _this.getRelayHashFromEvent(d) !== relayDataHash; })) {
|
|
748
872
|
validatedBundleSlowFills.push(deposit);
|
|
749
873
|
}
|
|
750
874
|
return [2];
|
|
751
875
|
}
|
|
752
876
|
return [4, _getFillStatusForDeposit(deposit, destinationChainBlockRange[1])];
|
|
753
|
-
case
|
|
754
|
-
fillStatus =
|
|
755
|
-
if (!(fillStatus === interfaces_1.FillStatus.Filled)) return [3,
|
|
756
|
-
return [4,
|
|
757
|
-
case
|
|
758
|
-
prefill =
|
|
759
|
-
|
|
760
|
-
|
|
877
|
+
case 5:
|
|
878
|
+
fillStatus = _c.sent();
|
|
879
|
+
if (!(fillStatus === interfaces_1.FillStatus.Filled)) return [3, 9];
|
|
880
|
+
return [4, this.findMatchingFillEvent(deposit, destinationClient)];
|
|
881
|
+
case 6:
|
|
882
|
+
prefill = _c.sent();
|
|
883
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(prefill), "findFillEvent# Cannot find prefill: ".concat(relayDataHash));
|
|
884
|
+
(0, utils_1.assert)(this.getRelayHashFromEvent(prefill) === relayDataHash, "Relay hashes should match.");
|
|
885
|
+
if (!canRefundPrefills) return [3, 8];
|
|
886
|
+
return [4, (0, utils_2.verifyFillRepayment)(prefill, destinationClient.spokePool.provider, deposit, allChainIds)];
|
|
887
|
+
case 7:
|
|
888
|
+
verifiedFill = _c.sent();
|
|
889
|
+
if (!(0, utils_1.isDefined)(verifiedFill)) {
|
|
890
|
+
bundleUnrepayableFillsV3.push(prefill);
|
|
891
|
+
}
|
|
892
|
+
else if (!(0, utils_1.isSlowFill)(verifiedFill)) {
|
|
893
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, verifiedFill), { quoteTimestamp: deposit.quoteTimestamp }));
|
|
761
894
|
}
|
|
762
|
-
|
|
763
|
-
|
|
895
|
+
else {
|
|
896
|
+
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
897
|
+
}
|
|
898
|
+
_c.label = 8;
|
|
899
|
+
case 8: return [3, 10];
|
|
900
|
+
case 9:
|
|
764
901
|
if (_depositIsExpired(deposit)) {
|
|
765
902
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
766
903
|
}
|
|
767
|
-
else if (fillStatus === interfaces_1.FillStatus.RequestedSlowFill
|
|
768
|
-
|
|
904
|
+
else if (fillStatus === interfaces_1.FillStatus.RequestedSlowFill &&
|
|
905
|
+
validatedBundleSlowFills.every(function (d) { return _this.getRelayHashFromEvent(d) !== relayDataHash; })) {
|
|
906
|
+
if (canRefundPrefills && _canCreateSlowFillLeaf(deposit)) {
|
|
769
907
|
validatedBundleSlowFills.push(deposit);
|
|
770
908
|
}
|
|
771
909
|
}
|
|
772
|
-
|
|
773
|
-
case
|
|
910
|
+
_c.label = 10;
|
|
911
|
+
case 10: return [2];
|
|
774
912
|
}
|
|
775
913
|
});
|
|
776
914
|
}); })];
|
|
777
915
|
case 3:
|
|
778
916
|
_g.sent();
|
|
779
917
|
fastFillsReplacingSlowFills.forEach(function (relayDataHash) {
|
|
780
|
-
var _a = v3RelayHashes[relayDataHash],
|
|
918
|
+
var _a = v3RelayHashes[relayDataHash], deposits = _a.deposits, slowFillRequest = _a.slowFillRequest, fill = _a.fill;
|
|
781
919
|
(0, utils_1.assert)((fill === null || fill === void 0 ? void 0 : fill.relayExecutionInfo.fillType) === interfaces_1.FillType.ReplacedSlowFill, "Fill type should be ReplacedSlowFill.");
|
|
782
|
-
if (!
|
|
920
|
+
if (!deposits || deposits.length < 1) {
|
|
783
921
|
throw new Error("Deposit should exist in relay hash dictionary.");
|
|
784
922
|
}
|
|
785
|
-
(0, utils_1.assert)(_canCreateSlowFillLeaf(
|
|
923
|
+
(0, utils_1.assert)(_canCreateSlowFillLeaf(deposits[0]), "fastFillsReplacingSlowFills should contain only deposits that can be slow filled");
|
|
786
924
|
var destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
787
925
|
if (!slowFillRequest ||
|
|
788
926
|
slowFillRequest.blockNumber < destinationBlockRange[0]) {
|
|
789
|
-
validatedBundleUnexecutableSlowFills.push(
|
|
927
|
+
validatedBundleUnexecutableSlowFills.push(deposits[0]);
|
|
790
928
|
}
|
|
791
929
|
});
|
|
792
930
|
return [2];
|
|
@@ -827,13 +965,17 @@ var BundleDataClient = (function () {
|
|
|
827
965
|
message: "Processed ".concat(fillCounter, " fills in ").concat(performance.now() - start, "ms."),
|
|
828
966
|
});
|
|
829
967
|
start = performance.now();
|
|
830
|
-
return [4, (0, utils_1.forEachAsync)(olderDepositHashes, function (
|
|
831
|
-
var _a,
|
|
832
|
-
return tslib_1.__generator(this, function (
|
|
833
|
-
switch (
|
|
968
|
+
return [4, (0, utils_1.forEachAsync)(olderDepositHashes, function (depositHash) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
969
|
+
var _a, relayDataHash, index, _b, deposits, slowFillRequest, fill, deposit, destinationChainId, destinationBlockRange, fillStatus;
|
|
970
|
+
return tslib_1.__generator(this, function (_c) {
|
|
971
|
+
switch (_c.label) {
|
|
834
972
|
case 0:
|
|
835
|
-
_a =
|
|
836
|
-
|
|
973
|
+
_a = decodeBundleDepositHash(depositHash), relayDataHash = _a.relayDataHash, index = _a.index;
|
|
974
|
+
_b = v3RelayHashes[relayDataHash], deposits = _b.deposits, slowFillRequest = _b.slowFillRequest, fill = _b.fill;
|
|
975
|
+
if (!deposits || deposits.length < 1) {
|
|
976
|
+
throw new Error("Deposit should exist in relay hash dictionary.");
|
|
977
|
+
}
|
|
978
|
+
deposit = deposits[index];
|
|
837
979
|
destinationChainId = deposit.destinationChainId;
|
|
838
980
|
destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
839
981
|
if (!(!fill &&
|
|
@@ -843,7 +985,7 @@ var BundleDataClient = (function () {
|
|
|
843
985
|
spokePoolClients[destinationChainId] !== undefined)) return [3, 2];
|
|
844
986
|
return [4, _getFillStatusForDeposit(deposit, destinationBlockRange[1])];
|
|
845
987
|
case 1:
|
|
846
|
-
fillStatus =
|
|
988
|
+
fillStatus = _c.sent();
|
|
847
989
|
if (fillStatus !== interfaces_1.FillStatus.Filled) {
|
|
848
990
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
849
991
|
}
|
|
@@ -853,7 +995,7 @@ var BundleDataClient = (function () {
|
|
|
853
995
|
if (!slowFillRequest || slowFillRequest.blockNumber < destinationBlockRange[0]) {
|
|
854
996
|
validatedBundleUnexecutableSlowFills.push(deposit);
|
|
855
997
|
}
|
|
856
|
-
|
|
998
|
+
_c.label = 2;
|
|
857
999
|
case 2: return [2];
|
|
858
1000
|
}
|
|
859
1001
|
});
|
|
@@ -864,7 +1006,7 @@ var BundleDataClient = (function () {
|
|
|
864
1006
|
promises = [
|
|
865
1007
|
validatedBundleV3Fills.length > 0
|
|
866
1008
|
? this.clients.hubPoolClient.batchComputeRealizedLpFeePct(validatedBundleV3Fills.map(function (fill) {
|
|
867
|
-
var matchedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].
|
|
1009
|
+
var matchedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].deposits[0];
|
|
868
1010
|
(0, utils_1.assert)((0, utils_1.isDefined)(matchedDeposit), "Deposit should exist in relay hash dictionary.");
|
|
869
1011
|
var paymentChainId = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRangesForChains, chainIds, matchedDeposit.fromLiteChain).chainToSendRefundTo;
|
|
870
1012
|
return tslib_1.__assign(tslib_1.__assign({}, fill), { paymentChainId: paymentChainId });
|
|
@@ -891,14 +1033,18 @@ var BundleDataClient = (function () {
|
|
|
891
1033
|
v3FillLpFees.forEach(function (_a, idx) {
|
|
892
1034
|
var realizedLpFeePct = _a.realizedLpFeePct;
|
|
893
1035
|
var fill = validatedBundleV3Fills[idx];
|
|
894
|
-
var associatedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].
|
|
1036
|
+
var associatedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].deposits[0];
|
|
895
1037
|
(0, utils_1.assert)((0, utils_1.isDefined)(associatedDeposit), "Deposit should exist in relay hash dictionary.");
|
|
896
1038
|
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);
|
|
1039
|
+
updateBundleFillsV3(bundleFillsV3, fill, realizedLpFeePct, chainToSendRefundTo, repaymentToken, fill.relayer);
|
|
898
1040
|
});
|
|
899
1041
|
v3SlowFillLpFees.forEach(function (_a, idx) {
|
|
900
1042
|
var lpFeePct = _a.realizedLpFeePct;
|
|
901
1043
|
var deposit = validatedBundleSlowFills[idx];
|
|
1044
|
+
var relayDataHash = _this.getRelayHashFromEvent(deposit);
|
|
1045
|
+
if (validatedBundleSlowFills.slice(0, idx).some(function (d) { return _this.getRelayHashFromEvent(d) === relayDataHash; })) {
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
902
1048
|
updateBundleSlowFills(bundleSlowFillsV3, tslib_1.__assign(tslib_1.__assign({}, deposit), { lpFeePct: lpFeePct }));
|
|
903
1049
|
});
|
|
904
1050
|
v3UnexecutableSlowFillLpFees.forEach(function (_a, idx) {
|
|
@@ -906,7 +1052,7 @@ var BundleDataClient = (function () {
|
|
|
906
1052
|
var deposit = validatedBundleUnexecutableSlowFills[idx];
|
|
907
1053
|
updateBundleExcessSlowFills(unexecutableSlowFills, tslib_1.__assign(tslib_1.__assign({}, deposit), { lpFeePct: lpFeePct }));
|
|
908
1054
|
});
|
|
909
|
-
v3SpokeEventsReadable = (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleDepositsV3, bundleFillsV3,
|
|
1055
|
+
v3SpokeEventsReadable = (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleDepositsV3, bundleFillsV3, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills);
|
|
910
1056
|
if (bundleInvalidFillsV3.length > 0) {
|
|
911
1057
|
this.logger.debug({
|
|
912
1058
|
at: "BundleDataClient#loadData",
|
|
@@ -915,6 +1061,14 @@ var BundleDataClient = (function () {
|
|
|
915
1061
|
bundleInvalidFillsV3: bundleInvalidFillsV3,
|
|
916
1062
|
});
|
|
917
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 V3 fills in range",
|
|
1068
|
+
blockRangesForChains: blockRangesForChains,
|
|
1069
|
+
bundleUnrepayableFillsV3: bundleUnrepayableFillsV3,
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
918
1072
|
this.logger.debug({
|
|
919
1073
|
at: "BundleDataClient#loadDataFromScratch",
|
|
920
1074
|
message: "Computed bundle data in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
@@ -933,7 +1087,17 @@ var BundleDataClient = (function () {
|
|
|
933
1087
|
});
|
|
934
1088
|
};
|
|
935
1089
|
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);
|
|
1090
|
+
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);
|
|
1091
|
+
};
|
|
1092
|
+
BundleDataClient.prototype.findMatchingFillEvent = function (deposit, spokePoolClient) {
|
|
1093
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1094
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1095
|
+
switch (_a.label) {
|
|
1096
|
+
case 0: return [4, (0, utils_1.findFillEvent)(spokePoolClient.spokePool, deposit, spokePoolClient.deploymentBlock, spokePoolClient.latestBlockSearched)];
|
|
1097
|
+
case 1: return [2, _a.sent()];
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
});
|
|
937
1101
|
};
|
|
938
1102
|
BundleDataClient.prototype.getBundleBlockTimestamps = function (chainIds, blockRangesForChains, spokePoolClients) {
|
|
939
1103
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -944,7 +1108,7 @@ var BundleDataClient = (function () {
|
|
|
944
1108
|
case 0:
|
|
945
1109
|
_b = (_a = Object).fromEntries;
|
|
946
1110
|
return [4, (0, utils_1.mapAsync)(chainIds, function (chainId, index) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
947
|
-
var blockRangeForChain, _startBlockForChain, _endBlockForChain, spokePoolClient, startBlockForChain, endBlockForChain, _a, startTime,
|
|
1111
|
+
var blockRangeForChain, _startBlockForChain, _endBlockForChain, spokePoolClient, startBlockForChain, endBlockForChain, _a, startTime, _endTime, _b, endBlockDelta, endTime;
|
|
948
1112
|
return tslib_1.__generator(this, function (_c) {
|
|
949
1113
|
switch (_c.label) {
|
|
950
1114
|
case 0:
|
|
@@ -958,7 +1122,7 @@ var BundleDataClient = (function () {
|
|
|
958
1122
|
return [2];
|
|
959
1123
|
}
|
|
960
1124
|
startBlockForChain = Math.min(_startBlockForChain, spokePoolClient.latestBlockSearched);
|
|
961
|
-
endBlockForChain = Math.min(_endBlockForChain, spokePoolClient.latestBlockSearched);
|
|
1125
|
+
endBlockForChain = Math.min(_endBlockForChain + 1, spokePoolClient.latestBlockSearched);
|
|
962
1126
|
return [4, spokePoolClient.getTimestampForBlock(startBlockForChain)];
|
|
963
1127
|
case 1:
|
|
964
1128
|
_b = [
|
|
@@ -968,8 +1132,10 @@ var BundleDataClient = (function () {
|
|
|
968
1132
|
case 2:
|
|
969
1133
|
_a = _b.concat([
|
|
970
1134
|
_c.sent()
|
|
971
|
-
]), startTime = _a[0],
|
|
972
|
-
|
|
1135
|
+
]), startTime = _a[0], _endTime = _a[1];
|
|
1136
|
+
endBlockDelta = endBlockForChain > startBlockForChain ? 1 : 0;
|
|
1137
|
+
endTime = Math.max(0, _endTime - endBlockDelta);
|
|
1138
|
+
(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, "."));
|
|
973
1139
|
(0, utils_1.assert)(startBlockForChain === 0 || startTime > 0, "Start timestamp must be greater than 0 if the start block is greater than 0.");
|
|
974
1140
|
return [2, [chainId, [startTime, endTime]]];
|
|
975
1141
|
}
|