@across-protocol/sdk 4.2.9-alpha.1 → 4.2.9-alpha.3
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/arch/evm/SpokeUtils.d.ts +5 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +22 -5
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +14 -11
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +1 -1
- package/dist/cjs/arch/svm/utils.js +15 -13
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +60 -56
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +11 -8
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
- package/dist/cjs/clients/HubPoolClient.js +83 -59
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +55 -49
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +9 -13
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +42 -56
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/interfaces/HubPool.d.ts +19 -14
- package/dist/cjs/interfaces/SpokePool.d.ts +14 -16
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +7 -7
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +14 -15
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +6 -3
- package/dist/cjs/utils/AddressUtils.js +42 -14
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
- package/dist/cjs/utils/SpokeUtils.js +4 -22
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +3 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +5 -2
- package/dist/esm/arch/evm/SpokeUtils.js +23 -6
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +14 -11
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +1 -1
- package/dist/esm/arch/svm/utils.js +15 -13
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +61 -57
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +4 -3
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +12 -9
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +23 -22
- package/dist/esm/clients/HubPoolClient.js +96 -63
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +57 -50
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +9 -13
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +46 -60
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/interfaces/HubPool.d.ts +19 -14
- package/dist/esm/interfaces/SpokePool.d.ts +14 -16
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +8 -8
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +15 -16
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +7 -3
- package/dist/esm/utils/AddressUtils.js +52 -19
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +3 -8
- package/dist/esm/utils/SpokeUtils.js +4 -26
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +18 -16
- package/dist/esm/utils/TokenUtils.js +3 -3
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +5 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +1 -1
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +23 -22
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +9 -13
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +19 -14
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +14 -16
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +7 -3
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +3 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +18 -16
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/arch/evm/SpokeUtils.ts +41 -11
- package/src/arch/svm/SpokeUtils.ts +23 -9
- package/src/arch/svm/utils.ts +3 -3
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +54 -52
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +6 -4
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +13 -9
- package/src/clients/HubPoolClient.ts +122 -82
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -1
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +113 -43
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +55 -74
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +23 -14
- package/src/interfaces/SpokePool.ts +14 -17
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +10 -8
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +16 -21
- package/src/relayFeeCalculator/relayFeeCalculator.ts +20 -12
- package/src/utils/AddressUtils.ts +56 -21
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +7 -7
|
@@ -13,13 +13,12 @@ import {
|
|
|
13
13
|
isDefined,
|
|
14
14
|
getMessageHash,
|
|
15
15
|
isSlowFill,
|
|
16
|
-
isValidEvmAddress,
|
|
17
16
|
isZeroAddress,
|
|
18
|
-
toAddress,
|
|
19
17
|
validateFillForDeposit,
|
|
20
18
|
chainIsEvm,
|
|
21
19
|
chainIsProd,
|
|
22
20
|
Address,
|
|
21
|
+
toAddressType,
|
|
23
22
|
} from "../../utils";
|
|
24
23
|
import { duplicateEvent, sortEventsAscendingInPlace } from "../../utils/EventUtils";
|
|
25
24
|
import { ZERO_ADDRESS } from "../../constants";
|
|
@@ -37,6 +36,7 @@ import {
|
|
|
37
36
|
SortableEvent,
|
|
38
37
|
SpeedUpWithBlock,
|
|
39
38
|
TokensBridged,
|
|
39
|
+
RelayExecutionEventInfo,
|
|
40
40
|
} from "../../interfaces";
|
|
41
41
|
import { BaseAbstractClient, UpdateFailureReason } from "../BaseAbstractClient";
|
|
42
42
|
import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
@@ -202,8 +202,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
202
202
|
* @param relayer The relayer address.
|
|
203
203
|
* @returns A list of fills.
|
|
204
204
|
*/
|
|
205
|
-
public getFillsForRelayer(relayer:
|
|
206
|
-
return this.getFills().filter((fill) => fill.relayer
|
|
205
|
+
public getFillsForRelayer(relayer: Address): FillWithBlock[] {
|
|
206
|
+
return this.getFills().filter((fill) => fill.relayer.eq(relayer));
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
/**
|
|
@@ -251,7 +251,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
251
251
|
const { depositId, depositor } = deposit;
|
|
252
252
|
|
|
253
253
|
// Note: we know depositor cannot be more than 20 bytes since this is guaranteed by contracts.
|
|
254
|
-
|
|
254
|
+
// Additionally, speed ups can only be done on EVM networks.
|
|
255
|
+
const speedups = this.speedUps[depositor.toEvmAddress()]?.[depositId.toString()];
|
|
255
256
|
|
|
256
257
|
if (!isDefined(speedups) || speedups.length === 0) {
|
|
257
258
|
return deposit;
|
|
@@ -302,9 +303,10 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
302
303
|
* @param relayData RelayData field for the SlowFill request.
|
|
303
304
|
* @returns The corresponding SlowFillRequest event if found, otherwise undefined.
|
|
304
305
|
*/
|
|
305
|
-
public getSlowFillRequest(
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
public getSlowFillRequest(
|
|
307
|
+
relayData: Omit<RelayData, "message"> & { messageHash: string }
|
|
308
|
+
): SlowFillRequestWithBlock | undefined {
|
|
309
|
+
const hash = getRelayEventKey({ ...relayData, destinationChainId: this.chainId });
|
|
308
310
|
return this.slowFillRequests[hash];
|
|
309
311
|
}
|
|
310
312
|
|
|
@@ -383,7 +385,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
383
385
|
if (
|
|
384
386
|
this.hubPoolClient &&
|
|
385
387
|
!isSlowFill(fill) &&
|
|
386
|
-
|
|
388
|
+
chainIsEvm(repaymentChainId) &&
|
|
389
|
+
!fill.relayer.isValidEvmAddress()
|
|
387
390
|
) {
|
|
388
391
|
groupedFills.unrepayableFills.push(fill);
|
|
389
392
|
}
|
|
@@ -416,7 +419,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
416
419
|
chainId: this.chainId,
|
|
417
420
|
message: "Invalid fills found matching deposit ID",
|
|
418
421
|
deposit,
|
|
419
|
-
invalidFills: Object.fromEntries(invalidFillsForDeposit.map((x) => [x.relayer, x])),
|
|
422
|
+
invalidFills: Object.fromEntries(invalidFillsForDeposit.map((x) => [x.relayer.toAddress(), x])),
|
|
420
423
|
notificationPath: "across-invalid-fills",
|
|
421
424
|
});
|
|
422
425
|
}
|
|
@@ -427,7 +430,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
427
430
|
chainId: this.chainId,
|
|
428
431
|
message: "Unrepayable fills found where we need to switch repayment address and or chain",
|
|
429
432
|
deposit,
|
|
430
|
-
unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer, x])),
|
|
433
|
+
unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer.toAddress(), x])),
|
|
431
434
|
notificationPath: "across-unrepayable-fills",
|
|
432
435
|
});
|
|
433
436
|
}
|
|
@@ -499,14 +502,36 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
499
502
|
const { events: queryResults, currentTime, searchEndBlock } = update;
|
|
500
503
|
|
|
501
504
|
if (eventsToQuery.includes("TokensBridged")) {
|
|
502
|
-
for (const
|
|
503
|
-
|
|
505
|
+
for (const _event of queryResults[eventsToQuery.indexOf("TokensBridged")]) {
|
|
506
|
+
const event = _event as TokensBridged & {
|
|
507
|
+
l2TokenAddress: string;
|
|
508
|
+
};
|
|
509
|
+
this.tokensBridged.push({
|
|
510
|
+
...event,
|
|
511
|
+
l2TokenAddress: toAddressType(event.l2TokenAddress, this.chainId),
|
|
512
|
+
});
|
|
504
513
|
}
|
|
505
514
|
}
|
|
506
515
|
|
|
507
516
|
// Performs the indexing of a deposit-like spoke pool event.
|
|
508
517
|
const queryDepositEvents = async (eventName: string) => {
|
|
509
|
-
const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
518
|
+
const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
519
|
+
const event = _event as DepositWithBlock & {
|
|
520
|
+
depositor: string;
|
|
521
|
+
recipient: string;
|
|
522
|
+
inputToken: string;
|
|
523
|
+
outputToken: string;
|
|
524
|
+
exclusiveRelayer: string;
|
|
525
|
+
};
|
|
526
|
+
return {
|
|
527
|
+
...event,
|
|
528
|
+
depositor: toAddressType(event.depositor, this.chainId),
|
|
529
|
+
recipient: toAddressType(event.recipient, event.destinationChainId),
|
|
530
|
+
inputToken: toAddressType(event.inputToken, this.chainId),
|
|
531
|
+
outputToken: toAddressType(event.outputToken, event.destinationChainId),
|
|
532
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, event.destinationChainId),
|
|
533
|
+
} as DepositWithBlock;
|
|
534
|
+
});
|
|
510
535
|
if (depositEvents.length > 0) {
|
|
511
536
|
this.log(
|
|
512
537
|
"debug",
|
|
@@ -555,7 +580,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
555
580
|
}
|
|
556
581
|
};
|
|
557
582
|
|
|
558
|
-
for (const event of ["
|
|
583
|
+
for (const event of ["FundsDeposited"]) {
|
|
559
584
|
if (eventsToQuery.includes(event)) {
|
|
560
585
|
await queryDepositEvents(event);
|
|
561
586
|
}
|
|
@@ -563,11 +588,21 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
563
588
|
|
|
564
589
|
// Performs indexing of a "speed up deposit"-like event.
|
|
565
590
|
const querySpeedUpDepositEvents = (eventName: string) => {
|
|
566
|
-
const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
591
|
+
const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
592
|
+
const event = _event as SpeedUpWithBlock & { depositor: string; updatedRecipient: string };
|
|
593
|
+
return {
|
|
594
|
+
...event,
|
|
595
|
+
depositor: toAddressType(event.depositor, this.chainId),
|
|
596
|
+
updatedRecipient: toAddressType(event.updatedRecipient),
|
|
597
|
+
} as SpeedUpWithBlock;
|
|
598
|
+
});
|
|
567
599
|
|
|
568
600
|
for (const event of speedUpEvents) {
|
|
569
|
-
const speedUp = {
|
|
570
|
-
|
|
601
|
+
const speedUp = {
|
|
602
|
+
...event,
|
|
603
|
+
originChainId: this.chainId,
|
|
604
|
+
};
|
|
605
|
+
assign(this.speedUps, [speedUp.depositor.toAddress(), speedUp.depositId.toString()], [speedUp]);
|
|
571
606
|
|
|
572
607
|
// Find deposit hash matching this speed up event and update the deposit data associated with the hash,
|
|
573
608
|
// if the hash+data exists.
|
|
@@ -583,7 +618,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
583
618
|
};
|
|
584
619
|
|
|
585
620
|
// Update deposits with speed up requests from depositor.
|
|
586
|
-
["
|
|
621
|
+
["RequestedSpeedUpDeposit"].forEach((event) => {
|
|
587
622
|
if (eventsToQuery.includes(event)) {
|
|
588
623
|
querySpeedUpDepositEvents(event);
|
|
589
624
|
}
|
|
@@ -591,17 +626,29 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
591
626
|
|
|
592
627
|
// Performs indexing of "requested slow fill"-like events.
|
|
593
628
|
const queryRequestedSlowFillEvents = (eventName: string) => {
|
|
594
|
-
const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
629
|
+
const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
630
|
+
const event = _event as SlowFillRequestWithBlock & {
|
|
631
|
+
depositor: string;
|
|
632
|
+
recipient: string;
|
|
633
|
+
inputToken: string;
|
|
634
|
+
outputToken: string;
|
|
635
|
+
exclusiveRelayer: string;
|
|
636
|
+
};
|
|
637
|
+
return {
|
|
638
|
+
...event,
|
|
639
|
+
depositor: toAddressType(event.depositor, event.originChainId),
|
|
640
|
+
recipient: toAddressType(event.recipient, this.chainId),
|
|
641
|
+
inputToken: toAddressType(event.inputToken, event.originChainId),
|
|
642
|
+
outputToken: toAddressType(event.outputToken, this.chainId),
|
|
643
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, this.chainId),
|
|
644
|
+
} as SlowFillRequestWithBlock;
|
|
645
|
+
});
|
|
595
646
|
for (const event of slowFillRequests) {
|
|
596
647
|
const slowFillRequest = {
|
|
597
648
|
...event,
|
|
598
649
|
destinationChainId: this.chainId,
|
|
599
650
|
};
|
|
600
651
|
|
|
601
|
-
if (eventName === "RequestedV3SlowFill") {
|
|
602
|
-
slowFillRequest.messageHash = getMessageHash(slowFillRequest.message);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
652
|
const depositHash = getRelayEventKey({ ...slowFillRequest, destinationChainId: this.chainId });
|
|
606
653
|
|
|
607
654
|
// Sanity check that this event is not a duplicate.
|
|
@@ -614,7 +661,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
614
661
|
}
|
|
615
662
|
};
|
|
616
663
|
|
|
617
|
-
["
|
|
664
|
+
["RequestedSlowFill"].forEach((event) => {
|
|
618
665
|
if (eventsToQuery.includes(event)) {
|
|
619
666
|
queryRequestedSlowFillEvents(event);
|
|
620
667
|
}
|
|
@@ -622,7 +669,30 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
622
669
|
|
|
623
670
|
// Performs indexing of filled relay-like events.
|
|
624
671
|
const queryFilledRelayEvents = (eventName: string) => {
|
|
625
|
-
const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
672
|
+
const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
673
|
+
const event = _event as FillWithBlock & {
|
|
674
|
+
depositor: string;
|
|
675
|
+
recipient: string;
|
|
676
|
+
inputToken: string;
|
|
677
|
+
outputToken: string;
|
|
678
|
+
exclusiveRelayer: string;
|
|
679
|
+
relayer: string;
|
|
680
|
+
relayExecutionInfo: RelayExecutionEventInfo & { updatedRecipient: string };
|
|
681
|
+
};
|
|
682
|
+
return {
|
|
683
|
+
...event,
|
|
684
|
+
depositor: toAddressType(event.depositor, event.originChainId),
|
|
685
|
+
recipient: toAddressType(event.recipient, this.chainId),
|
|
686
|
+
inputToken: toAddressType(event.inputToken, event.originChainId),
|
|
687
|
+
outputToken: toAddressType(event.outputToken, this.chainId),
|
|
688
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, this.chainId),
|
|
689
|
+
relayer: toAddressType(event.relayer, this.chainId),
|
|
690
|
+
relayExecutionInfo: {
|
|
691
|
+
...event.relayExecutionInfo,
|
|
692
|
+
updatedRecipient: toAddressType(event.relayExecutionInfo.updatedRecipient, this.chainId),
|
|
693
|
+
},
|
|
694
|
+
} as FillWithBlock;
|
|
695
|
+
});
|
|
626
696
|
|
|
627
697
|
if (fillEvents.length > 0) {
|
|
628
698
|
this.log("debug", `Using ${fillEvents.length} newly queried ${eventName} events for chain ${this.chainId}`, {
|
|
@@ -638,11 +708,6 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
638
708
|
destinationChainId: this.chainId,
|
|
639
709
|
};
|
|
640
710
|
|
|
641
|
-
if (eventName === "FilledV3Relay") {
|
|
642
|
-
fill.messageHash = getMessageHash((event as unknown as { message: string }).message);
|
|
643
|
-
fill.relayExecutionInfo.updatedMessageHash = getMessageHash(event.relayExecutionInfo.updatedMessage!);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
711
|
// Sanity check that this event is not a duplicate.
|
|
647
712
|
const duplicateFill = this.fills[fill.originChainId]?.find((f) => duplicateEvent(fill, f));
|
|
648
713
|
if (duplicateFill) {
|
|
@@ -656,15 +721,16 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
656
721
|
};
|
|
657
722
|
|
|
658
723
|
// Update observed fills with ingested event data.
|
|
659
|
-
["
|
|
724
|
+
["FilledRelay"].forEach((event) => {
|
|
660
725
|
if (eventsToQuery.includes(event)) {
|
|
661
726
|
queryFilledRelayEvents(event);
|
|
662
727
|
}
|
|
663
728
|
});
|
|
664
729
|
|
|
665
730
|
if (eventsToQuery.includes("EnabledDepositRoute")) {
|
|
666
|
-
const enableDepositsEvents =
|
|
667
|
-
|
|
731
|
+
const enableDepositsEvents = queryResults[
|
|
732
|
+
eventsToQuery.indexOf("EnabledDepositRoute")
|
|
733
|
+
] as EnabledDepositRouteWithBlock[];
|
|
668
734
|
|
|
669
735
|
for (const event of enableDepositsEvents) {
|
|
670
736
|
assign(this.depositRoutes, [event.originToken, event.destinationChainId], event.enabled);
|
|
@@ -672,16 +738,18 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
672
738
|
}
|
|
673
739
|
|
|
674
740
|
if (eventsToQuery.includes("RelayedRootBundle")) {
|
|
675
|
-
const relayedRootBundleEvents =
|
|
676
|
-
|
|
741
|
+
const relayedRootBundleEvents = queryResults[
|
|
742
|
+
eventsToQuery.indexOf("RelayedRootBundle")
|
|
743
|
+
] as RootBundleRelayWithBlock[];
|
|
677
744
|
for (const event of relayedRootBundleEvents) {
|
|
678
745
|
this.rootBundleRelays.push(event);
|
|
679
746
|
}
|
|
680
747
|
}
|
|
681
748
|
|
|
682
749
|
if (eventsToQuery.includes("ExecutedRelayerRefundRoot")) {
|
|
683
|
-
const refundEvents =
|
|
684
|
-
|
|
750
|
+
const refundEvents = queryResults[
|
|
751
|
+
eventsToQuery.indexOf("ExecutedRelayerRefundRoot")
|
|
752
|
+
] as RelayerRefundExecutionWithBlock[];
|
|
685
753
|
for (const event of refundEvents) {
|
|
686
754
|
this.relayerRefundExecutions.push(event);
|
|
687
755
|
}
|
|
@@ -731,9 +799,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
731
799
|
* @param deposit The deposit to retrieve the destination token for.
|
|
732
800
|
* @returns The destination token.
|
|
733
801
|
*/
|
|
734
|
-
protected getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
802
|
+
protected getDestinationTokenForDeposit(deposit: DepositWithBlock): Address {
|
|
735
803
|
if (!this.canResolveZeroAddressOutputToken(deposit)) {
|
|
736
|
-
return ZERO_ADDRESS;
|
|
804
|
+
return toAddressType(ZERO_ADDRESS);
|
|
737
805
|
}
|
|
738
806
|
// L1 token should be resolved if we get here:
|
|
739
807
|
const l1Token = this.hubPoolClient!.getL1TokenForL2TokenAtBlock(
|
|
@@ -741,10 +809,12 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
741
809
|
deposit.originChainId,
|
|
742
810
|
deposit.quoteBlockNumber
|
|
743
811
|
)!;
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
812
|
+
const counterpartToken = this.hubPoolClient!.getL2TokenForL1TokenAtBlock(
|
|
813
|
+
l1Token,
|
|
814
|
+
deposit.destinationChainId,
|
|
815
|
+
deposit.quoteBlockNumber
|
|
747
816
|
);
|
|
817
|
+
return counterpartToken ?? toAddressType(ZERO_ADDRESS);
|
|
748
818
|
}
|
|
749
819
|
|
|
750
820
|
/**
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
2
|
import { Contract } from "ethers";
|
|
3
|
-
import { BigNumber, randomAddress, assign, bnZero } from "../../utils";
|
|
4
|
-
import {
|
|
3
|
+
import { BigNumber, randomAddress, assign, bnZero, toAddressType, EvmAddress, Address, isDefined } from "../../utils";
|
|
4
|
+
import { TokenInfo, Log, PendingRootBundle, RealizedLpFee, L1TokenInfo } from "../../interfaces";
|
|
5
5
|
import { AcrossConfigStoreClient as ConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
6
6
|
import { HubPoolClient, HubPoolUpdate, LpFeeRequest } from "../HubPoolClient";
|
|
7
7
|
import { EventManager, EventOverrides, getEventManager } from "./MockEvents";
|
|
8
|
+
import { ZERO_ADDRESS } from "../../constants";
|
|
8
9
|
|
|
9
10
|
const emptyRootBundle: PendingRootBundle = {
|
|
10
11
|
poolRebalanceRoot: "",
|
|
11
12
|
relayerRefundRoot: "",
|
|
12
13
|
slowRelayRoot: "",
|
|
13
|
-
proposer:
|
|
14
|
+
proposer: EvmAddress.from(ZERO_ADDRESS),
|
|
14
15
|
unclaimedPoolRebalanceLeafCount: 0,
|
|
15
16
|
challengePeriodEndTimestamp: 0,
|
|
16
17
|
bundleEvaluationBlockNumbers: [],
|
|
@@ -22,9 +23,9 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
22
23
|
private realizedLpFeePct: BigNumber = bnZero;
|
|
23
24
|
private realizedLpFeePctOverride = false;
|
|
24
25
|
|
|
25
|
-
private l1TokensMock:
|
|
26
|
+
private l1TokensMock: L1TokenInfo[] = []; // L1Tokens and their associated info.
|
|
26
27
|
|
|
27
|
-
private spokePoolTokens: { [l1Token: string]: { [chainId: number]:
|
|
28
|
+
private spokePoolTokens: { [l1Token: string]: { [chainId: number]: Address } } = {};
|
|
28
29
|
|
|
29
30
|
private eventManager: EventManager;
|
|
30
31
|
|
|
@@ -69,7 +70,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
69
70
|
[chainId],
|
|
70
71
|
[
|
|
71
72
|
{
|
|
72
|
-
spokePool: contract,
|
|
73
|
+
spokePool: toAddressType(contract),
|
|
73
74
|
blockNumber: blockNumber,
|
|
74
75
|
transactionIndex: 0,
|
|
75
76
|
logIndex: 0,
|
|
@@ -82,7 +83,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
82
83
|
this.latestHeightSearched = blockNumber;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
addL1Token(l1Token:
|
|
86
|
+
addL1Token(l1Token: TokenInfo) {
|
|
86
87
|
this.l1TokensMock.push(l1Token);
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -92,19 +93,19 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
92
93
|
|
|
93
94
|
setTokenMapping(l1Token: string, chainId: number, l2Token: string) {
|
|
94
95
|
this.spokePoolTokens[l1Token] ??= {};
|
|
95
|
-
this.spokePoolTokens[l1Token][chainId] = l2Token;
|
|
96
|
+
this.spokePoolTokens[l1Token][chainId] = toAddressType(l2Token);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
l2TokenEnabledForL1TokenAtBlock(l1Token:
|
|
99
|
-
if (this.spokePoolTokens[l1Token]?.[destinationChainId]) {
|
|
99
|
+
l2TokenEnabledForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, hubBlockNumber: number): boolean {
|
|
100
|
+
if (this.spokePoolTokens[l1Token.toEvmAddress()]?.[destinationChainId]) {
|
|
100
101
|
return true;
|
|
101
102
|
} else {
|
|
102
103
|
return super.l2TokenEnabledForL1TokenAtBlock(l1Token, destinationChainId, hubBlockNumber);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
l2TokenHasPoolRebalanceRoute(l2Token:
|
|
106
|
+
l2TokenHasPoolRebalanceRoute(l2Token: Address, chainId: number, hubPoolBlock: number): boolean {
|
|
106
107
|
const l1Token = Object.keys(this.spokePoolTokens).find(
|
|
107
|
-
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId]
|
|
108
|
+
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId]?.eq(l2Token)
|
|
108
109
|
);
|
|
109
110
|
if (!l1Token) {
|
|
110
111
|
return super.l2TokenHasPoolRebalanceRoute(l2Token, chainId, hubPoolBlock);
|
|
@@ -115,20 +116,24 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
115
116
|
delete this.spokePoolTokens[l1Token]?.[chainId];
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
getL1TokenForL2TokenAtBlock(l2Token:
|
|
119
|
+
getL1TokenForL2TokenAtBlock(l2Token: Address, chainId: number, blockNumber: number): EvmAddress {
|
|
119
120
|
const l1Token = Object.keys(this.spokePoolTokens).find(
|
|
120
|
-
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId]
|
|
121
|
+
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId].eq(l2Token)
|
|
121
122
|
);
|
|
122
|
-
|
|
123
|
+
if (isDefined(l1Token)) {
|
|
124
|
+
return EvmAddress.from(l1Token);
|
|
125
|
+
} else {
|
|
126
|
+
return super.getL1TokenForL2TokenAtBlock(l2Token, chainId, blockNumber);
|
|
127
|
+
}
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
getL2TokenForL1TokenAtBlock(l1Token:
|
|
126
|
-
const l2Token = this.spokePoolTokens[l1Token]?.[chainId];
|
|
130
|
+
getL2TokenForL1TokenAtBlock(l1Token: EvmAddress, chainId: number, blockNumber: number): Address {
|
|
131
|
+
const l2Token = this.spokePoolTokens[l1Token.toEvmAddress()]?.[chainId];
|
|
127
132
|
return l2Token ?? super.getL2TokenForL1TokenAtBlock(l1Token, chainId, blockNumber);
|
|
128
133
|
}
|
|
129
134
|
|
|
130
|
-
getTokenInfoForL1Token(l1Token:
|
|
131
|
-
return this.l1TokensMock.find((token) => token.address
|
|
135
|
+
getTokenInfoForL1Token(l1Token: EvmAddress): TokenInfo | undefined {
|
|
136
|
+
return this.l1TokensMock.find((token) => token.address.eq(l1Token));
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
_update(eventNames: string[]): Promise<HubPoolUpdate> {
|