@across-protocol/sdk 4.0.0-beta.3 → 4.0.0-beta.31
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 +336 -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 +405 -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 +414 -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,11 @@ 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
|
+
(0, utils_1.assert)((0, utils_1.chainIsEvm)(deposit.originChainId) && (0, utils_1.isValidEvmAddress)(deposit.depositor), "expired depositor cannot be refunded");
|
|
12
14
|
var originChainId = deposit.originChainId, inputToken = deposit.inputToken;
|
|
13
15
|
if (!((_a = dict === null || dict === void 0 ? void 0 : dict[originChainId]) === null || _a === void 0 ? void 0 : _a[inputToken])) {
|
|
14
16
|
(0, utils_1.assign)(dict, [originChainId, inputToken], []);
|
|
@@ -23,8 +25,9 @@ function updateBundleDepositsV3(dict, deposit) {
|
|
|
23
25
|
}
|
|
24
26
|
dict[originChainId][inputToken].push(deposit);
|
|
25
27
|
}
|
|
26
|
-
function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentToken) {
|
|
28
|
+
function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentToken, repaymentAddress) {
|
|
27
29
|
var _a, _b;
|
|
30
|
+
(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
31
|
if (!((_a = dict === null || dict === void 0 ? void 0 : dict[repaymentChainId]) === null || _a === void 0 ? void 0 : _a[repaymentToken])) {
|
|
29
32
|
(0, utils_1.assign)(dict, [repaymentChainId, repaymentToken], {
|
|
30
33
|
fills: [],
|
|
@@ -33,22 +36,22 @@ function updateBundleFillsV3(dict, fill, lpFeePct, repaymentChainId, repaymentTo
|
|
|
33
36
|
refunds: {},
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
|
-
var bundleFill = tslib_1.__assign(tslib_1.__assign({}, fill), { lpFeePct: lpFeePct });
|
|
39
|
+
var bundleFill = tslib_1.__assign(tslib_1.__assign({}, fill), { lpFeePct: lpFeePct, relayer: repaymentAddress });
|
|
37
40
|
(0, utils_1.assign)(dict, [repaymentChainId, repaymentToken, "fills"], [bundleFill]);
|
|
38
41
|
var refundObj = dict[repaymentChainId][repaymentToken];
|
|
39
|
-
var realizedLpFee =
|
|
42
|
+
var realizedLpFee = bundleFill.inputAmount.mul(bundleFill.lpFeePct).div(utils_1.fixedPointAdjustment);
|
|
40
43
|
refundObj.realizedLpFees = refundObj.realizedLpFees ? refundObj.realizedLpFees.add(realizedLpFee) : realizedLpFee;
|
|
41
|
-
if (!(0, utils_1.isSlowFill)(
|
|
42
|
-
var refundAmount =
|
|
44
|
+
if (!(0, utils_1.isSlowFill)(bundleFill)) {
|
|
45
|
+
var refundAmount = bundleFill.inputAmount.mul(utils_1.fixedPointAdjustment.sub(lpFeePct)).div(utils_1.fixedPointAdjustment);
|
|
43
46
|
refundObj.totalRefundAmount = refundObj.totalRefundAmount
|
|
44
47
|
? refundObj.totalRefundAmount.add(refundAmount)
|
|
45
48
|
: refundAmount;
|
|
46
49
|
(_b = refundObj.refunds) !== null && _b !== void 0 ? _b : (refundObj.refunds = {});
|
|
47
|
-
if (refundObj.refunds[
|
|
48
|
-
refundObj.refunds[
|
|
50
|
+
if (refundObj.refunds[bundleFill.relayer]) {
|
|
51
|
+
refundObj.refunds[bundleFill.relayer] = refundObj.refunds[bundleFill.relayer].add(refundAmount);
|
|
49
52
|
}
|
|
50
53
|
else {
|
|
51
|
-
refundObj.refunds[
|
|
54
|
+
refundObj.refunds[bundleFill.relayer] = refundAmount;
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -62,6 +65,7 @@ function updateBundleExcessSlowFills(dict, deposit) {
|
|
|
62
65
|
}
|
|
63
66
|
function updateBundleSlowFills(dict, deposit) {
|
|
64
67
|
var _a;
|
|
68
|
+
(0, utils_1.assert)((0, utils_1.chainIsEvm)(deposit.destinationChainId) && (0, utils_1.isValidEvmAddress)(deposit.recipient), "slow fill recipient cannot be paid");
|
|
65
69
|
var destinationChainId = deposit.destinationChainId, outputToken = deposit.outputToken;
|
|
66
70
|
if (!((_a = dict === null || dict === void 0 ? void 0 : dict[destinationChainId]) === null || _a === void 0 ? void 0 : _a[outputToken])) {
|
|
67
71
|
(0, utils_1.assign)(dict, [destinationChainId, outputToken], []);
|
|
@@ -146,7 +150,7 @@ var BundleDataClient = (function () {
|
|
|
146
150
|
at: "BundleDataClient#loadPersistedDataFromArweave",
|
|
147
151
|
message: "Loaded persisted data from Arweave in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
148
152
|
blockRanges: JSON.stringify(blockRangesForChains),
|
|
149
|
-
bundleData: (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleData.bundleDepositsV3, bundleData.bundleFillsV3,
|
|
153
|
+
bundleData: (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleData.bundleDepositsV3, bundleData.bundleFillsV3, bundleData.bundleSlowFillsV3, bundleData.expiredDepositsToRefundV3, bundleData.unexecutableSlowFills),
|
|
150
154
|
});
|
|
151
155
|
return [2, bundleData];
|
|
152
156
|
}
|
|
@@ -188,64 +192,107 @@ var BundleDataClient = (function () {
|
|
|
188
192
|
return [4, this.loadArweaveData(bundleEvaluationBlockRanges)];
|
|
189
193
|
case 1:
|
|
190
194
|
arweaveData = _a.sent();
|
|
191
|
-
if (arweaveData === undefined)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
195
|
+
if (!(arweaveData === undefined)) return [3, 3];
|
|
196
|
+
return [4, this.getApproximateRefundsForBlockRange(chainIds, bundleEvaluationBlockRanges)];
|
|
197
|
+
case 2:
|
|
198
|
+
combinedRefunds = _a.sent();
|
|
199
|
+
return [3, 4];
|
|
200
|
+
case 3:
|
|
201
|
+
bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
|
|
202
|
+
combinedRefunds = (0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3);
|
|
203
|
+
Object.keys(combinedRefunds).forEach(function (chainId) {
|
|
204
|
+
if (_this.spokePoolClients[Number(chainId)] === undefined) {
|
|
205
|
+
delete combinedRefunds[Number(chainId)];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
_a.label = 4;
|
|
209
|
+
case 4: return [2, this.deductExecutedRefunds(combinedRefunds, bundle)];
|
|
204
210
|
}
|
|
205
211
|
});
|
|
206
212
|
});
|
|
207
213
|
};
|
|
208
214
|
BundleDataClient.prototype.getApproximateRefundsForBlockRange = function (chainIds, blockRanges) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
215
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
216
|
+
var refundsForChain, _loop_1, this_1, _i, chainIds_1, chainId;
|
|
217
|
+
var _this = this;
|
|
218
|
+
return tslib_1.__generator(this, function (_a) {
|
|
219
|
+
switch (_a.label) {
|
|
220
|
+
case 0:
|
|
221
|
+
refundsForChain = {};
|
|
222
|
+
_loop_1 = function (chainId) {
|
|
223
|
+
var chainIndex, fillsToCount;
|
|
224
|
+
return tslib_1.__generator(this, function (_b) {
|
|
225
|
+
switch (_b.label) {
|
|
226
|
+
case 0:
|
|
227
|
+
if (this_1.spokePoolClients[chainId] === undefined) {
|
|
228
|
+
return [2, "continue"];
|
|
229
|
+
}
|
|
230
|
+
chainIndex = chainIds.indexOf(chainId);
|
|
231
|
+
return [4, (0, utils_1.filterAsync)(this_1.spokePoolClients[chainId].getFills(), function (fill) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
232
|
+
var matchingDeposit, hasMatchingDeposit, validRepayment;
|
|
233
|
+
return tslib_1.__generator(this, function (_a) {
|
|
234
|
+
switch (_a.label) {
|
|
235
|
+
case 0:
|
|
236
|
+
if (fill.blockNumber < blockRanges[chainIndex][0] ||
|
|
237
|
+
fill.blockNumber > blockRanges[chainIndex][1] ||
|
|
238
|
+
(0, utils_1.isZeroValueFillOrSlowFillRequest)(fill)) {
|
|
239
|
+
return [2, false];
|
|
240
|
+
}
|
|
241
|
+
if (this.spokePoolClients[fill.originChainId] === undefined) {
|
|
242
|
+
return [2, false];
|
|
243
|
+
}
|
|
244
|
+
matchingDeposit = this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
|
|
245
|
+
hasMatchingDeposit = matchingDeposit !== undefined &&
|
|
246
|
+
this.getRelayHashFromEvent(fill) === this.getRelayHashFromEvent(matchingDeposit);
|
|
247
|
+
if (!hasMatchingDeposit) return [3, 2];
|
|
248
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, this.spokePoolClients[fill.destinationChainId].spokePool.provider, matchingDeposit, this.clients.configStoreClient
|
|
249
|
+
.getChainIdIndicesForBlock(blockRanges[0][1])
|
|
250
|
+
.filter(function (_chainId, i) { return !(0, utils_2.isChainDisabled)(blockRanges[i]); }))];
|
|
251
|
+
case 1:
|
|
252
|
+
validRepayment = _a.sent();
|
|
253
|
+
if (!(0, utils_1.isDefined)(validRepayment)) {
|
|
254
|
+
return [2, false];
|
|
255
|
+
}
|
|
256
|
+
_a.label = 2;
|
|
257
|
+
case 2: return [2, hasMatchingDeposit];
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}); })];
|
|
261
|
+
case 1:
|
|
262
|
+
fillsToCount = _b.sent();
|
|
263
|
+
fillsToCount.forEach(function (fill) {
|
|
264
|
+
var _a, _b, _c;
|
|
265
|
+
var _d;
|
|
266
|
+
var matchingDeposit = _this.spokePoolClients[fill.originChainId].getDeposit(fill.depositId);
|
|
267
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(matchingDeposit), "Deposit not found for fill.");
|
|
268
|
+
var _e = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRanges, _this.chainIdListForBundleEvaluationBlockNumbers, matchingDeposit.fromLiteChain), chainToSendRefundTo = _e.chainToSendRefundTo, repaymentToken = _e.repaymentToken;
|
|
269
|
+
var relayer = fill.relayer, refundAmount = fill.inputAmount;
|
|
270
|
+
(_a = refundsForChain[chainToSendRefundTo]) !== null && _a !== void 0 ? _a : (refundsForChain[chainToSendRefundTo] = {});
|
|
271
|
+
(_b = (_d = refundsForChain[chainToSendRefundTo])[repaymentToken]) !== null && _b !== void 0 ? _b : (_d[repaymentToken] = {});
|
|
272
|
+
var existingRefundAmount = (_c = refundsForChain[chainToSendRefundTo][repaymentToken][relayer]) !== null && _c !== void 0 ? _c : utils_1.bnZero;
|
|
273
|
+
refundsForChain[chainToSendRefundTo][repaymentToken][relayer] = existingRefundAmount.add(refundAmount);
|
|
274
|
+
});
|
|
275
|
+
return [2];
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
this_1 = this;
|
|
280
|
+
_i = 0, chainIds_1 = chainIds;
|
|
281
|
+
_a.label = 1;
|
|
282
|
+
case 1:
|
|
283
|
+
if (!(_i < chainIds_1.length)) return [3, 4];
|
|
284
|
+
chainId = chainIds_1[_i];
|
|
285
|
+
return [5, _loop_1(chainId)];
|
|
286
|
+
case 2:
|
|
287
|
+
_a.sent();
|
|
288
|
+
_a.label = 3;
|
|
289
|
+
case 3:
|
|
290
|
+
_i++;
|
|
291
|
+
return [3, 1];
|
|
292
|
+
case 4: return [2, refundsForChain];
|
|
224
293
|
}
|
|
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
294
|
});
|
|
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;
|
|
295
|
+
});
|
|
249
296
|
};
|
|
250
297
|
BundleDataClient.prototype.getUpcomingDepositAmount = function (chainId, l2Token, latestBlockToSearch) {
|
|
251
298
|
if (this.spokePoolClients[chainId] === undefined) {
|
|
@@ -288,12 +335,10 @@ var BundleDataClient = (function () {
|
|
|
288
335
|
case 1:
|
|
289
336
|
_a = _b.sent(), bundleData = _a.bundleData, blockRanges = _a.blockRanges;
|
|
290
337
|
hubPoolClient = this.clients.hubPoolClient;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
case 2:
|
|
296
|
-
root = _b.sent();
|
|
338
|
+
root = (0, utils_2._buildPoolRebalanceRoot)(hubPoolClient.latestBlockSearched, blockRanges[0][1], bundleData.bundleDepositsV3, bundleData.bundleFillsV3, bundleData.bundleSlowFillsV3, bundleData.unexecutableSlowFills, bundleData.expiredDepositsToRefundV3, {
|
|
339
|
+
hubPoolClient: hubPoolClient,
|
|
340
|
+
configStoreClient: hubPoolClient.configStoreClient,
|
|
341
|
+
});
|
|
297
342
|
return [2, {
|
|
298
343
|
root: root,
|
|
299
344
|
blockRanges: blockRanges,
|
|
@@ -317,32 +362,39 @@ var BundleDataClient = (function () {
|
|
|
317
362
|
return [initialBlockRange[1] + 1, blockRange[1]];
|
|
318
363
|
});
|
|
319
364
|
}
|
|
320
|
-
var hubPoolClient, nextBundleMainnetStartBlock, chainIds, combinedRefunds, widestBundleBlockRanges, pendingBundleBlockRanges, arweaveData, bundleFillsV3, expiredDepositsToRefundV3, start;
|
|
321
|
-
return tslib_1.__generator(this, function (
|
|
322
|
-
switch (
|
|
365
|
+
var hubPoolClient, nextBundleMainnetStartBlock, chainIds, combinedRefunds, widestBundleBlockRanges, pendingBundleBlockRanges, arweaveData, _a, _b, bundleFillsV3, expiredDepositsToRefundV3, start, _c, _d;
|
|
366
|
+
return tslib_1.__generator(this, function (_e) {
|
|
367
|
+
switch (_e.label) {
|
|
323
368
|
case 0:
|
|
324
369
|
hubPoolClient = this.clients.hubPoolClient;
|
|
325
370
|
nextBundleMainnetStartBlock = hubPoolClient.getNextBundleStartBlockNumber(this.chainIdListForBundleEvaluationBlockNumbers, hubPoolClient.latestBlockSearched, hubPoolClient.chainId);
|
|
326
371
|
chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(nextBundleMainnetStartBlock);
|
|
327
372
|
combinedRefunds = [];
|
|
328
373
|
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,
|
|
374
|
+
if (!hubPoolClient.hasPendingProposal()) return [3, 5];
|
|
330
375
|
pendingBundleBlockRanges = (0, utils_1.getImpliedBundleBlockRanges)(hubPoolClient, this.clients.configStoreClient, hubPoolClient.getLatestProposedRootBundle());
|
|
331
376
|
return [4, this.loadArweaveData(pendingBundleBlockRanges)];
|
|
332
377
|
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;
|
|
378
|
+
arweaveData = _e.sent();
|
|
379
|
+
if (!(arweaveData === undefined)) return [3, 3];
|
|
380
|
+
_b = (_a = combinedRefunds).push;
|
|
381
|
+
return [4, this.getApproximateRefundsForBlockRange(chainIds, pendingBundleBlockRanges)];
|
|
343
382
|
case 2:
|
|
383
|
+
_b.apply(_a, [_e.sent()]);
|
|
384
|
+
return [3, 4];
|
|
385
|
+
case 3:
|
|
386
|
+
bundleFillsV3 = arweaveData.bundleFillsV3, expiredDepositsToRefundV3 = arweaveData.expiredDepositsToRefundV3;
|
|
387
|
+
combinedRefunds.push((0, utils_2.getRefundsFromBundle)(bundleFillsV3, expiredDepositsToRefundV3));
|
|
388
|
+
_e.label = 4;
|
|
389
|
+
case 4:
|
|
390
|
+
widestBundleBlockRanges = getBlockRangeDelta(pendingBundleBlockRanges);
|
|
391
|
+
_e.label = 5;
|
|
392
|
+
case 5:
|
|
344
393
|
start = performance.now();
|
|
345
|
-
combinedRefunds.push
|
|
394
|
+
_d = (_c = combinedRefunds).push;
|
|
395
|
+
return [4, this.getApproximateRefundsForBlockRange(chainIds, widestBundleBlockRanges)];
|
|
396
|
+
case 6:
|
|
397
|
+
_d.apply(_c, [_e.sent()]);
|
|
346
398
|
this.logger.debug({
|
|
347
399
|
at: "BundleDataClient#getNextBundleRefunds",
|
|
348
400
|
message: "Loading approximate refunds for next bundle in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
@@ -473,7 +525,7 @@ var BundleDataClient = (function () {
|
|
|
473
525
|
};
|
|
474
526
|
BundleDataClient.prototype.loadDataFromScratch = function (blockRangesForChains, spokePoolClients) {
|
|
475
527
|
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;
|
|
528
|
+
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
529
|
var _this = this;
|
|
478
530
|
return tslib_1.__generator(this, function (_c) {
|
|
479
531
|
switch (_c.label) {
|
|
@@ -493,6 +545,7 @@ var BundleDataClient = (function () {
|
|
|
493
545
|
bundleDepositsV3 = {};
|
|
494
546
|
bundleFillsV3 = {};
|
|
495
547
|
bundleInvalidFillsV3 = [];
|
|
548
|
+
bundleUnrepayableFillsV3 = [];
|
|
496
549
|
bundleSlowFillsV3 = {};
|
|
497
550
|
expiredDepositsToRefundV3 = {};
|
|
498
551
|
unexecutableSlowFills = {};
|
|
@@ -541,6 +594,13 @@ var BundleDataClient = (function () {
|
|
|
541
594
|
v3RelayHashes = {};
|
|
542
595
|
bundleDepositHashes = [];
|
|
543
596
|
olderDepositHashes = [];
|
|
597
|
+
decodeBundleDepositHash = function (depositHash) {
|
|
598
|
+
var _a = depositHash.split("@"), relayDataHash = _a[0], i = _a[1];
|
|
599
|
+
return { relayDataHash: relayDataHash, index: Number(i) };
|
|
600
|
+
};
|
|
601
|
+
startBlockForMainnet = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, this.clients.hubPoolClient.chainId, this.chainIdListForBundleEvaluationBlockNumbers)[0];
|
|
602
|
+
versionAtProposalBlock = this.clients.configStoreClient.getConfigStoreVersionForBlock(startBlockForMainnet);
|
|
603
|
+
canRefundPrefills = versionAtProposalBlock >= constants_1.PRE_FILL_MIN_CONFIG_STORE_VERSION || process.env.FORCE_REFUND_PREFILLS === "true";
|
|
544
604
|
depositCounter = 0;
|
|
545
605
|
_loop_2 = function (originChainId) {
|
|
546
606
|
var originClient = spokePoolClients[originChainId];
|
|
@@ -558,20 +618,27 @@ var BundleDataClient = (function () {
|
|
|
558
618
|
var relayDataHash = _this.getRelayHashFromEvent(deposit);
|
|
559
619
|
if (!v3RelayHashes[relayDataHash]) {
|
|
560
620
|
v3RelayHashes[relayDataHash] = {
|
|
561
|
-
|
|
621
|
+
deposits: [deposit],
|
|
562
622
|
fill: undefined,
|
|
563
623
|
slowFillRequest: undefined,
|
|
564
624
|
};
|
|
565
625
|
}
|
|
626
|
+
else {
|
|
627
|
+
v3RelayHashes[relayDataHash].deposits.push(deposit);
|
|
628
|
+
}
|
|
566
629
|
if (deposit.inputAmount.eq(0)) {
|
|
567
630
|
return;
|
|
568
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");
|
|
569
636
|
if (deposit.blockNumber >= originChainBlockRange[0]) {
|
|
570
|
-
bundleDepositHashes.push(
|
|
637
|
+
bundleDepositHashes.push(newBundleDepositHash);
|
|
571
638
|
updateBundleDepositsV3(bundleDepositsV3, deposit);
|
|
572
639
|
}
|
|
573
640
|
else if (deposit.blockNumber < originChainBlockRange[0]) {
|
|
574
|
-
olderDepositHashes.push(
|
|
641
|
+
olderDepositHashes.push(newBundleDepositHash);
|
|
575
642
|
}
|
|
576
643
|
});
|
|
577
644
|
}
|
|
@@ -596,7 +663,7 @@ var BundleDataClient = (function () {
|
|
|
596
663
|
case 0:
|
|
597
664
|
originClient = spokePoolClients[originChainId];
|
|
598
665
|
_loop_4 = function (destinationChainId) {
|
|
599
|
-
var destinationClient, destinationChainBlockRange,
|
|
666
|
+
var destinationClient, destinationChainBlockRange, originChainBlockRange, fastFillsReplacingSlowFills;
|
|
600
667
|
return tslib_1.__generator(this, function (_g) {
|
|
601
668
|
switch (_g.label) {
|
|
602
669
|
case 0:
|
|
@@ -605,58 +672,90 @@ var BundleDataClient = (function () {
|
|
|
605
672
|
}
|
|
606
673
|
destinationClient = spokePoolClients[destinationChainId];
|
|
607
674
|
destinationChainBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
675
|
+
originChainBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, originChainId, chainIds);
|
|
608
676
|
fastFillsReplacingSlowFills = [];
|
|
609
677
|
return [4, (0, utils_1.forEachAsync)(destinationClient
|
|
610
678
|
.getFillsForOriginChain(originChainId)
|
|
611
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 () {
|
|
612
|
-
var relayDataHash, historicalDeposit, matchedDeposit;
|
|
680
|
+
var relayDataHash, fillToRefund_1, duplicateDeposits, historicalDeposit, matchedDeposit, fillToRefund;
|
|
613
681
|
return tslib_1.__generator(this, function (_a) {
|
|
614
682
|
switch (_a.label) {
|
|
615
683
|
case 0:
|
|
616
|
-
relayDataHash = this.getRelayHashFromEvent(fill);
|
|
617
684
|
fillCounter++;
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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);
|
|
628
704
|
}
|
|
629
|
-
|
|
630
|
-
|
|
705
|
+
else {
|
|
706
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund_1), { quoteTimestamp: duplicateDeposit.quoteTimestamp }));
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
if (fill.relayExecutionInfo.fillType === interfaces_1.FillType.ReplacedSlowFill &&
|
|
711
|
+
_canCreateSlowFillLeaf(v3RelayHashes[relayDataHash].deposits[0])) {
|
|
712
|
+
fastFillsReplacingSlowFills.push(relayDataHash);
|
|
631
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:
|
|
632
719
|
v3RelayHashes[relayDataHash] = {
|
|
633
|
-
|
|
720
|
+
deposits: undefined,
|
|
634
721
|
fill: fill,
|
|
635
722
|
slowFillRequest: undefined,
|
|
636
723
|
};
|
|
637
|
-
if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3,
|
|
724
|
+
if (!(fill.blockNumber >= destinationChainBlockRange[0])) return [3, 9];
|
|
638
725
|
if (!exports.INFINITE_FILL_DEADLINE.eq(fill.fillDeadline)) {
|
|
639
726
|
bundleInvalidFillsV3.push(fill);
|
|
640
727
|
return [2];
|
|
641
728
|
}
|
|
642
729
|
return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, fill)];
|
|
643
|
-
case
|
|
730
|
+
case 6:
|
|
644
731
|
historicalDeposit = _a.sent();
|
|
645
|
-
if (
|
|
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]) {
|
|
646
738
|
bundleInvalidFillsV3.push(fill);
|
|
739
|
+
return [2];
|
|
740
|
+
}
|
|
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);
|
|
647
747
|
}
|
|
648
748
|
else {
|
|
649
|
-
matchedDeposit = historicalDeposit.deposit;
|
|
650
749
|
(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
|
-
}
|
|
750
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund), { quoteTimestamp: matchedDeposit.quoteTimestamp }));
|
|
751
|
+
v3RelayHashes[relayDataHash].fill = fillToRefund;
|
|
657
752
|
}
|
|
658
|
-
|
|
659
|
-
|
|
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];
|
|
660
759
|
}
|
|
661
760
|
});
|
|
662
761
|
}); })];
|
|
@@ -678,23 +777,26 @@ var BundleDataClient = (function () {
|
|
|
678
777
|
if (v3RelayHashes[relayDataHash].fill) {
|
|
679
778
|
return [2];
|
|
680
779
|
}
|
|
681
|
-
(0, utils_1.assert)((0, utils_1.isDefined)(v3RelayHashes[relayDataHash].
|
|
682
|
-
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];
|
|
683
782
|
if (slowFillRequest.blockNumber >= destinationChainBlockRange[0] &&
|
|
684
783
|
_canCreateSlowFillLeaf(matchedDeposit) &&
|
|
685
784
|
!_depositIsExpired(matchedDeposit)) {
|
|
686
785
|
validatedBundleSlowFills.push(matchedDeposit);
|
|
687
786
|
}
|
|
688
787
|
}
|
|
788
|
+
else {
|
|
789
|
+
throw new Error("Duplicate slow fill request detected.");
|
|
790
|
+
}
|
|
689
791
|
return [2];
|
|
690
792
|
}
|
|
691
793
|
v3RelayHashes[relayDataHash] = {
|
|
692
|
-
|
|
794
|
+
deposits: undefined,
|
|
693
795
|
fill: undefined,
|
|
694
796
|
slowFillRequest: slowFillRequest,
|
|
695
797
|
};
|
|
696
|
-
if (!(slowFillRequest.
|
|
697
|
-
|
|
798
|
+
if (!(exports.INFINITE_FILL_DEADLINE.eq(slowFillRequest.fillDeadline) &&
|
|
799
|
+
slowFillRequest.blockNumber >= destinationChainBlockRange[0])) return [3, 2];
|
|
698
800
|
return [4, (0, utils_1.queryHistoricalDepositForFill)(originClient, slowFillRequest)];
|
|
699
801
|
case 1:
|
|
700
802
|
historicalDeposit = _a.sent();
|
|
@@ -702,8 +804,11 @@ var BundleDataClient = (function () {
|
|
|
702
804
|
return [2];
|
|
703
805
|
}
|
|
704
806
|
matchedDeposit = historicalDeposit.deposit;
|
|
807
|
+
if (matchedDeposit.blockNumber > originChainBlockRange[1]) {
|
|
808
|
+
return [2];
|
|
809
|
+
}
|
|
705
810
|
(0, utils_1.assert)(this.getRelayHashFromEvent(matchedDeposit) === relayDataHash, "Deposit relay hashes should match.");
|
|
706
|
-
v3RelayHashes[relayDataHash].
|
|
811
|
+
v3RelayHashes[relayDataHash].deposits = [matchedDeposit];
|
|
707
812
|
if (!_canCreateSlowFillLeaf(matchedDeposit) ||
|
|
708
813
|
_depositIsExpired(matchedDeposit)) {
|
|
709
814
|
return [2];
|
|
@@ -716,77 +821,106 @@ var BundleDataClient = (function () {
|
|
|
716
821
|
}); })];
|
|
717
822
|
case 2:
|
|
718
823
|
_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) {
|
|
824
|
+
return [4, (0, utils_1.mapAsync)(bundleDepositHashes, function (depositHash) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
825
|
+
var _a, relayDataHash, index, _b, deposits, fill, slowFillRequest, deposit, fillToRefund, fillStatus, prefill, verifiedFill;
|
|
826
|
+
var _this = this;
|
|
827
|
+
return tslib_1.__generator(this, function (_c) {
|
|
828
|
+
switch (_c.label) {
|
|
732
829
|
case 0:
|
|
733
|
-
_a =
|
|
830
|
+
_a = decodeBundleDepositHash(depositHash), relayDataHash = _a.relayDataHash, index = _a.index;
|
|
831
|
+
_b = v3RelayHashes[relayDataHash], deposits = _b.deposits, fill = _b.fill, slowFillRequest = _b.slowFillRequest;
|
|
832
|
+
if (!deposits || deposits.length === 0) {
|
|
833
|
+
throw new Error("Deposits should exist in relay hash dictionary.");
|
|
834
|
+
}
|
|
835
|
+
deposit = deposits[index];
|
|
734
836
|
if (!deposit)
|
|
735
837
|
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
|
-
}
|
|
838
|
+
if (deposit.originChainId !== originChainId || deposit.destinationChainId !== destinationChainId) {
|
|
740
839
|
return [2];
|
|
741
840
|
}
|
|
841
|
+
if (!fill) return [3, 4];
|
|
842
|
+
if (!(canRefundPrefills && fill.blockNumber < destinationChainBlockRange[0])) return [3, 3];
|
|
843
|
+
if (!!(0, utils_1.isSlowFill)(fill)) return [3, 2];
|
|
844
|
+
return [4, (0, utils_2.verifyFillRepayment)(fill, destinationClient.spokePool.provider, v3RelayHashes[relayDataHash].deposits[0], allChainIds)];
|
|
845
|
+
case 1:
|
|
846
|
+
fillToRefund = _c.sent();
|
|
847
|
+
if (!(0, utils_1.isDefined)(fillToRefund)) {
|
|
848
|
+
bundleUnrepayableFillsV3.push(fill);
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
v3RelayHashes[relayDataHash].fill = fillToRefund;
|
|
852
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, fillToRefund), { quoteTimestamp: deposit.quoteTimestamp }));
|
|
853
|
+
}
|
|
854
|
+
return [3, 3];
|
|
855
|
+
case 2:
|
|
856
|
+
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
857
|
+
_c.label = 3;
|
|
858
|
+
case 3: return [2];
|
|
859
|
+
case 4:
|
|
742
860
|
if (slowFillRequest) {
|
|
743
861
|
if (_depositIsExpired(deposit)) {
|
|
744
862
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
745
863
|
}
|
|
746
|
-
else if (
|
|
747
|
-
|
|
864
|
+
else if (canRefundPrefills &&
|
|
865
|
+
slowFillRequest.blockNumber < destinationChainBlockRange[0] &&
|
|
866
|
+
_canCreateSlowFillLeaf(deposit) &&
|
|
867
|
+
validatedBundleSlowFills.every(function (d) { return _this.getRelayHashFromEvent(d) !== relayDataHash; })) {
|
|
748
868
|
validatedBundleSlowFills.push(deposit);
|
|
749
869
|
}
|
|
750
870
|
return [2];
|
|
751
871
|
}
|
|
752
872
|
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
|
-
|
|
873
|
+
case 5:
|
|
874
|
+
fillStatus = _c.sent();
|
|
875
|
+
if (!(fillStatus === interfaces_1.FillStatus.Filled)) return [3, 9];
|
|
876
|
+
return [4, this.findMatchingFillEvent(deposit, destinationClient)];
|
|
877
|
+
case 6:
|
|
878
|
+
prefill = _c.sent();
|
|
879
|
+
(0, utils_1.assert)((0, utils_1.isDefined)(prefill), "findFillEvent# Cannot find prefill: ".concat(relayDataHash));
|
|
880
|
+
(0, utils_1.assert)(this.getRelayHashFromEvent(prefill) === relayDataHash, "Relay hashes should match.");
|
|
881
|
+
if (!canRefundPrefills) return [3, 8];
|
|
882
|
+
return [4, (0, utils_2.verifyFillRepayment)(prefill, destinationClient.spokePool.provider, deposit, allChainIds)];
|
|
883
|
+
case 7:
|
|
884
|
+
verifiedFill = _c.sent();
|
|
885
|
+
if (!(0, utils_1.isDefined)(verifiedFill)) {
|
|
886
|
+
bundleUnrepayableFillsV3.push(prefill);
|
|
887
|
+
}
|
|
888
|
+
else if (!(0, utils_1.isSlowFill)(verifiedFill)) {
|
|
889
|
+
validatedBundleV3Fills.push(tslib_1.__assign(tslib_1.__assign({}, verifiedFill), { quoteTimestamp: deposit.quoteTimestamp }));
|
|
761
890
|
}
|
|
762
|
-
|
|
763
|
-
|
|
891
|
+
else {
|
|
892
|
+
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
893
|
+
}
|
|
894
|
+
_c.label = 8;
|
|
895
|
+
case 8: return [3, 10];
|
|
896
|
+
case 9:
|
|
764
897
|
if (_depositIsExpired(deposit)) {
|
|
765
898
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
766
899
|
}
|
|
767
|
-
else if (fillStatus === interfaces_1.FillStatus.RequestedSlowFill
|
|
768
|
-
|
|
900
|
+
else if (fillStatus === interfaces_1.FillStatus.RequestedSlowFill &&
|
|
901
|
+
validatedBundleSlowFills.every(function (d) { return _this.getRelayHashFromEvent(d) !== relayDataHash; })) {
|
|
902
|
+
if (canRefundPrefills && _canCreateSlowFillLeaf(deposit)) {
|
|
769
903
|
validatedBundleSlowFills.push(deposit);
|
|
770
904
|
}
|
|
771
905
|
}
|
|
772
|
-
|
|
773
|
-
case
|
|
906
|
+
_c.label = 10;
|
|
907
|
+
case 10: return [2];
|
|
774
908
|
}
|
|
775
909
|
});
|
|
776
910
|
}); })];
|
|
777
911
|
case 3:
|
|
778
912
|
_g.sent();
|
|
779
913
|
fastFillsReplacingSlowFills.forEach(function (relayDataHash) {
|
|
780
|
-
var _a = v3RelayHashes[relayDataHash],
|
|
914
|
+
var _a = v3RelayHashes[relayDataHash], deposits = _a.deposits, slowFillRequest = _a.slowFillRequest, fill = _a.fill;
|
|
781
915
|
(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 (!
|
|
916
|
+
if (!deposits || deposits.length < 1) {
|
|
783
917
|
throw new Error("Deposit should exist in relay hash dictionary.");
|
|
784
918
|
}
|
|
785
|
-
(0, utils_1.assert)(_canCreateSlowFillLeaf(
|
|
919
|
+
(0, utils_1.assert)(_canCreateSlowFillLeaf(deposits[0]), "fastFillsReplacingSlowFills should contain only deposits that can be slow filled");
|
|
786
920
|
var destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
787
921
|
if (!slowFillRequest ||
|
|
788
922
|
slowFillRequest.blockNumber < destinationBlockRange[0]) {
|
|
789
|
-
validatedBundleUnexecutableSlowFills.push(
|
|
923
|
+
validatedBundleUnexecutableSlowFills.push(deposits[0]);
|
|
790
924
|
}
|
|
791
925
|
});
|
|
792
926
|
return [2];
|
|
@@ -827,13 +961,17 @@ var BundleDataClient = (function () {
|
|
|
827
961
|
message: "Processed ".concat(fillCounter, " fills in ").concat(performance.now() - start, "ms."),
|
|
828
962
|
});
|
|
829
963
|
start = performance.now();
|
|
830
|
-
return [4, (0, utils_1.forEachAsync)(olderDepositHashes, function (
|
|
831
|
-
var _a,
|
|
832
|
-
return tslib_1.__generator(this, function (
|
|
833
|
-
switch (
|
|
964
|
+
return [4, (0, utils_1.forEachAsync)(olderDepositHashes, function (depositHash) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
965
|
+
var _a, relayDataHash, index, _b, deposits, slowFillRequest, fill, deposit, destinationChainId, destinationBlockRange, fillStatus;
|
|
966
|
+
return tslib_1.__generator(this, function (_c) {
|
|
967
|
+
switch (_c.label) {
|
|
834
968
|
case 0:
|
|
835
|
-
_a =
|
|
836
|
-
|
|
969
|
+
_a = decodeBundleDepositHash(depositHash), relayDataHash = _a.relayDataHash, index = _a.index;
|
|
970
|
+
_b = v3RelayHashes[relayDataHash], deposits = _b.deposits, slowFillRequest = _b.slowFillRequest, fill = _b.fill;
|
|
971
|
+
if (!deposits || deposits.length < 1) {
|
|
972
|
+
throw new Error("Deposit should exist in relay hash dictionary.");
|
|
973
|
+
}
|
|
974
|
+
deposit = deposits[index];
|
|
837
975
|
destinationChainId = deposit.destinationChainId;
|
|
838
976
|
destinationBlockRange = (0, utils_1.getBlockRangeForChain)(blockRangesForChains, destinationChainId, chainIds);
|
|
839
977
|
if (!(!fill &&
|
|
@@ -843,7 +981,7 @@ var BundleDataClient = (function () {
|
|
|
843
981
|
spokePoolClients[destinationChainId] !== undefined)) return [3, 2];
|
|
844
982
|
return [4, _getFillStatusForDeposit(deposit, destinationBlockRange[1])];
|
|
845
983
|
case 1:
|
|
846
|
-
fillStatus =
|
|
984
|
+
fillStatus = _c.sent();
|
|
847
985
|
if (fillStatus !== interfaces_1.FillStatus.Filled) {
|
|
848
986
|
updateExpiredDepositsV3(expiredDepositsToRefundV3, deposit);
|
|
849
987
|
}
|
|
@@ -853,7 +991,7 @@ var BundleDataClient = (function () {
|
|
|
853
991
|
if (!slowFillRequest || slowFillRequest.blockNumber < destinationBlockRange[0]) {
|
|
854
992
|
validatedBundleUnexecutableSlowFills.push(deposit);
|
|
855
993
|
}
|
|
856
|
-
|
|
994
|
+
_c.label = 2;
|
|
857
995
|
case 2: return [2];
|
|
858
996
|
}
|
|
859
997
|
});
|
|
@@ -864,7 +1002,7 @@ var BundleDataClient = (function () {
|
|
|
864
1002
|
promises = [
|
|
865
1003
|
validatedBundleV3Fills.length > 0
|
|
866
1004
|
? this.clients.hubPoolClient.batchComputeRealizedLpFeePct(validatedBundleV3Fills.map(function (fill) {
|
|
867
|
-
var matchedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].
|
|
1005
|
+
var matchedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].deposits[0];
|
|
868
1006
|
(0, utils_1.assert)((0, utils_1.isDefined)(matchedDeposit), "Deposit should exist in relay hash dictionary.");
|
|
869
1007
|
var paymentChainId = (0, utils_2.getRefundInformationFromFill)(fill, _this.clients.hubPoolClient, blockRangesForChains, chainIds, matchedDeposit.fromLiteChain).chainToSendRefundTo;
|
|
870
1008
|
return tslib_1.__assign(tslib_1.__assign({}, fill), { paymentChainId: paymentChainId });
|
|
@@ -891,14 +1029,18 @@ var BundleDataClient = (function () {
|
|
|
891
1029
|
v3FillLpFees.forEach(function (_a, idx) {
|
|
892
1030
|
var realizedLpFeePct = _a.realizedLpFeePct;
|
|
893
1031
|
var fill = validatedBundleV3Fills[idx];
|
|
894
|
-
var associatedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].
|
|
1032
|
+
var associatedDeposit = v3RelayHashes[_this.getRelayHashFromEvent(fill)].deposits[0];
|
|
895
1033
|
(0, utils_1.assert)((0, utils_1.isDefined)(associatedDeposit), "Deposit should exist in relay hash dictionary.");
|
|
896
1034
|
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);
|
|
1035
|
+
updateBundleFillsV3(bundleFillsV3, fill, realizedLpFeePct, chainToSendRefundTo, repaymentToken, fill.relayer);
|
|
898
1036
|
});
|
|
899
1037
|
v3SlowFillLpFees.forEach(function (_a, idx) {
|
|
900
1038
|
var lpFeePct = _a.realizedLpFeePct;
|
|
901
1039
|
var deposit = validatedBundleSlowFills[idx];
|
|
1040
|
+
var relayDataHash = _this.getRelayHashFromEvent(deposit);
|
|
1041
|
+
if (validatedBundleSlowFills.slice(0, idx).some(function (d) { return _this.getRelayHashFromEvent(d) === relayDataHash; })) {
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
902
1044
|
updateBundleSlowFills(bundleSlowFillsV3, tslib_1.__assign(tslib_1.__assign({}, deposit), { lpFeePct: lpFeePct }));
|
|
903
1045
|
});
|
|
904
1046
|
v3UnexecutableSlowFillLpFees.forEach(function (_a, idx) {
|
|
@@ -906,7 +1048,7 @@ var BundleDataClient = (function () {
|
|
|
906
1048
|
var deposit = validatedBundleUnexecutableSlowFills[idx];
|
|
907
1049
|
updateBundleExcessSlowFills(unexecutableSlowFills, tslib_1.__assign(tslib_1.__assign({}, deposit), { lpFeePct: lpFeePct }));
|
|
908
1050
|
});
|
|
909
|
-
v3SpokeEventsReadable = (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleDepositsV3, bundleFillsV3,
|
|
1051
|
+
v3SpokeEventsReadable = (0, utils_2.prettyPrintV3SpokePoolEvents)(bundleDepositsV3, bundleFillsV3, bundleSlowFillsV3, expiredDepositsToRefundV3, unexecutableSlowFills);
|
|
910
1052
|
if (bundleInvalidFillsV3.length > 0) {
|
|
911
1053
|
this.logger.debug({
|
|
912
1054
|
at: "BundleDataClient#loadData",
|
|
@@ -915,6 +1057,14 @@ var BundleDataClient = (function () {
|
|
|
915
1057
|
bundleInvalidFillsV3: bundleInvalidFillsV3,
|
|
916
1058
|
});
|
|
917
1059
|
}
|
|
1060
|
+
if (bundleUnrepayableFillsV3.length > 0) {
|
|
1061
|
+
this.logger.debug({
|
|
1062
|
+
at: "BundleDataClient#loadData",
|
|
1063
|
+
message: "Finished loading V3 spoke pool data and found some unrepayable V3 fills in range",
|
|
1064
|
+
blockRangesForChains: blockRangesForChains,
|
|
1065
|
+
bundleUnrepayableFillsV3: bundleUnrepayableFillsV3,
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
918
1068
|
this.logger.debug({
|
|
919
1069
|
at: "BundleDataClient#loadDataFromScratch",
|
|
920
1070
|
message: "Computed bundle data in ".concat(Math.round(performance.now() - start) / 1000, "s."),
|
|
@@ -933,7 +1083,17 @@ var BundleDataClient = (function () {
|
|
|
933
1083
|
});
|
|
934
1084
|
};
|
|
935
1085
|
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);
|
|
1086
|
+
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);
|
|
1087
|
+
};
|
|
1088
|
+
BundleDataClient.prototype.findMatchingFillEvent = function (deposit, spokePoolClient) {
|
|
1089
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1090
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1091
|
+
switch (_a.label) {
|
|
1092
|
+
case 0: return [4, (0, utils_1.findFillEvent)(spokePoolClient.spokePool, deposit, spokePoolClient.deploymentBlock, spokePoolClient.latestBlockSearched)];
|
|
1093
|
+
case 1: return [2, _a.sent()];
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
937
1097
|
};
|
|
938
1098
|
BundleDataClient.prototype.getBundleBlockTimestamps = function (chainIds, blockRangesForChains, spokePoolClients) {
|
|
939
1099
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -944,7 +1104,7 @@ var BundleDataClient = (function () {
|
|
|
944
1104
|
case 0:
|
|
945
1105
|
_b = (_a = Object).fromEntries;
|
|
946
1106
|
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,
|
|
1107
|
+
var blockRangeForChain, _startBlockForChain, _endBlockForChain, spokePoolClient, startBlockForChain, endBlockForChain, _a, startTime, _endTime, _b, endBlockDelta, endTime;
|
|
948
1108
|
return tslib_1.__generator(this, function (_c) {
|
|
949
1109
|
switch (_c.label) {
|
|
950
1110
|
case 0:
|
|
@@ -958,7 +1118,7 @@ var BundleDataClient = (function () {
|
|
|
958
1118
|
return [2];
|
|
959
1119
|
}
|
|
960
1120
|
startBlockForChain = Math.min(_startBlockForChain, spokePoolClient.latestBlockSearched);
|
|
961
|
-
endBlockForChain = Math.min(_endBlockForChain, spokePoolClient.latestBlockSearched);
|
|
1121
|
+
endBlockForChain = Math.min(_endBlockForChain + 1, spokePoolClient.latestBlockSearched);
|
|
962
1122
|
return [4, spokePoolClient.getTimestampForBlock(startBlockForChain)];
|
|
963
1123
|
case 1:
|
|
964
1124
|
_b = [
|
|
@@ -968,8 +1128,10 @@ var BundleDataClient = (function () {
|
|
|
968
1128
|
case 2:
|
|
969
1129
|
_a = _b.concat([
|
|
970
1130
|
_c.sent()
|
|
971
|
-
]), startTime = _a[0],
|
|
972
|
-
|
|
1131
|
+
]), startTime = _a[0], _endTime = _a[1];
|
|
1132
|
+
endBlockDelta = endBlockForChain > startBlockForChain ? 1 : 0;
|
|
1133
|
+
endTime = Math.max(0, _endTime - endBlockDelta);
|
|
1134
|
+
(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
1135
|
(0, utils_1.assert)(startBlockForChain === 0 || startTime > 0, "Start timestamp must be greater than 0 if the start block is greater than 0.");
|
|
974
1136
|
return [2, [chainId, [startTime, endTime]]];
|
|
975
1137
|
}
|