@across-protocol/sdk 4.2.9-alpha.0 → 4.2.9-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/arch/evm/SpokeUtils.d.ts +2 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +3 -18
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +16 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +135 -34
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +5 -1
- package/dist/cjs/arch/svm/utils.js +26 -16
- 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 +2 -4
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +2 -2
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +53 -57
- 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 +1 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +2 -3
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.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 +8 -11
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +20 -20
- package/dist/cjs/clients/HubPoolClient.js +57 -78
- 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 +3 -5
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +29 -35
- 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 +9 -15
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +13 -9
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +56 -40
- 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 +13 -18
- package/dist/cjs/interfaces/SpokePool.d.ts +16 -14
- 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 +7 -8
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +73 -64
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +4 -7
- package/dist/cjs/utils/AddressUtils.js +8 -21
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
- package/dist/cjs/utils/SpokeUtils.js +22 -4
- 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 +2 -2
- package/dist/esm/arch/evm/SpokeUtils.js +4 -19
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +46 -6
- package/dist/esm/arch/svm/SpokeUtils.js +164 -43
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +11 -1
- package/dist/esm/arch/svm/utils.js +31 -16
- 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 +2 -4
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +2 -2
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +54 -58
- 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 +1 -2
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +3 -4
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.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 +9 -12
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +21 -22
- package/dist/esm/clients/HubPoolClient.js +61 -91
- 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 +3 -5
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +30 -37
- 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 +10 -16
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +13 -9
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +60 -44
- 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 +13 -18
- package/dist/esm/interfaces/SpokePool.d.ts +16 -14
- 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 +8 -9
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +77 -66
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +4 -7
- package/dist/esm/utils/AddressUtils.js +10 -25
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +8 -3
- package/dist/esm/utils/SpokeUtils.js +26 -4
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +16 -4
- 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 +2 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +46 -6
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +11 -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 +2 -2
- 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 +1 -2
- package/dist/types/clients/BundleDataClient/utils/FillUtils.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 +21 -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 +3 -5
- 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 +13 -9
- 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 +13 -18
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +16 -14
- 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 +8 -9
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +4 -7
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +8 -3
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +16 -4
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/arch/evm/SpokeUtils.ts +8 -22
- package/src/arch/svm/SpokeUtils.ts +156 -49
- package/src/arch/svm/utils.ts +22 -3
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +4 -7
- package/src/clients/BundleDataClient/BundleDataClient.ts +47 -49
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +13 -28
- package/src/clients/BundleDataClient/utils/FillUtils.ts +4 -6
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +9 -13
- package/src/clients/HubPoolClient.ts +79 -113
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +1 -7
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +37 -104
- package/src/clients/mocks/MockHubPoolClient.ts +19 -24
- package/src/clients/mocks/MockSpokePoolClient.ts +74 -53
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +3 -12
- package/src/interfaces/HubPool.ts +13 -22
- package/src/interfaces/SpokePool.ts +17 -14
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +8 -10
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +92 -91
- package/src/relayFeeCalculator/relayFeeCalculator.ts +14 -16
- package/src/utils/AddressUtils.ts +14 -32
- package/src/utils/SpokeUtils.ts +33 -11
- package/src/utils/TokenUtils.ts +7 -7
|
@@ -13,12 +13,13 @@ import {
|
|
|
13
13
|
isDefined,
|
|
14
14
|
getMessageHash,
|
|
15
15
|
isSlowFill,
|
|
16
|
+
isValidEvmAddress,
|
|
16
17
|
isZeroAddress,
|
|
18
|
+
toAddress,
|
|
17
19
|
validateFillForDeposit,
|
|
18
20
|
chainIsEvm,
|
|
19
21
|
chainIsProd,
|
|
20
22
|
Address,
|
|
21
|
-
toAddressType,
|
|
22
23
|
} from "../../utils";
|
|
23
24
|
import { duplicateEvent, sortEventsAscendingInPlace } from "../../utils/EventUtils";
|
|
24
25
|
import { ZERO_ADDRESS } from "../../constants";
|
|
@@ -36,7 +37,6 @@ import {
|
|
|
36
37
|
SortableEvent,
|
|
37
38
|
SpeedUpWithBlock,
|
|
38
39
|
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: string): FillWithBlock[] {
|
|
206
|
+
return this.getFills().filter((fill) => fill.relayer === relayer);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
/**
|
|
@@ -251,8 +251,7 @@ 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
|
-
|
|
255
|
-
const speedups = this.speedUps[depositor.toEvmAddress()]?.[depositId.toString()];
|
|
254
|
+
const speedups = this.speedUps[toAddress(depositor)]?.[depositId.toString()];
|
|
256
255
|
|
|
257
256
|
if (!isDefined(speedups) || speedups.length === 0) {
|
|
258
257
|
return deposit;
|
|
@@ -303,10 +302,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
303
302
|
* @param relayData RelayData field for the SlowFill request.
|
|
304
303
|
* @returns The corresponding SlowFillRequest event if found, otherwise undefined.
|
|
305
304
|
*/
|
|
306
|
-
public getSlowFillRequest(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const hash = getRelayEventKey({ ...relayData, destinationChainId: this.chainId });
|
|
305
|
+
public getSlowFillRequest(relayData: RelayData): SlowFillRequestWithBlock | undefined {
|
|
306
|
+
const messageHash = getMessageHash(relayData.message);
|
|
307
|
+
const hash = getRelayEventKey({ ...relayData, messageHash, destinationChainId: this.chainId });
|
|
310
308
|
return this.slowFillRequests[hash];
|
|
311
309
|
}
|
|
312
310
|
|
|
@@ -385,8 +383,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
385
383
|
if (
|
|
386
384
|
this.hubPoolClient &&
|
|
387
385
|
!isSlowFill(fill) &&
|
|
388
|
-
chainIsEvm(repaymentChainId)
|
|
389
|
-
!fill.relayer.isValidEvmAddress()
|
|
386
|
+
(!chainIsEvm(repaymentChainId) || !isValidEvmAddress(fill.relayer))
|
|
390
387
|
) {
|
|
391
388
|
groupedFills.unrepayableFills.push(fill);
|
|
392
389
|
}
|
|
@@ -419,7 +416,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
419
416
|
chainId: this.chainId,
|
|
420
417
|
message: "Invalid fills found matching deposit ID",
|
|
421
418
|
deposit,
|
|
422
|
-
invalidFills: Object.fromEntries(invalidFillsForDeposit.map((x) => [x.relayer
|
|
419
|
+
invalidFills: Object.fromEntries(invalidFillsForDeposit.map((x) => [x.relayer, x])),
|
|
423
420
|
notificationPath: "across-invalid-fills",
|
|
424
421
|
});
|
|
425
422
|
}
|
|
@@ -430,7 +427,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
430
427
|
chainId: this.chainId,
|
|
431
428
|
message: "Unrepayable fills found where we need to switch repayment address and or chain",
|
|
432
429
|
deposit,
|
|
433
|
-
unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer
|
|
430
|
+
unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer, x])),
|
|
434
431
|
notificationPath: "across-unrepayable-fills",
|
|
435
432
|
});
|
|
436
433
|
}
|
|
@@ -502,36 +499,14 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
502
499
|
const { events: queryResults, currentTime, searchEndBlock } = update;
|
|
503
500
|
|
|
504
501
|
if (eventsToQuery.includes("TokensBridged")) {
|
|
505
|
-
for (const
|
|
506
|
-
|
|
507
|
-
l2TokenAddress: string;
|
|
508
|
-
};
|
|
509
|
-
this.tokensBridged.push({
|
|
510
|
-
...event,
|
|
511
|
-
l2TokenAddress: toAddressType(event.l2TokenAddress),
|
|
512
|
-
} as TokensBridged);
|
|
502
|
+
for (const event of queryResults[eventsToQuery.indexOf("TokensBridged")] as TokensBridged[]) {
|
|
503
|
+
this.tokensBridged.push(event);
|
|
513
504
|
}
|
|
514
505
|
}
|
|
515
506
|
|
|
516
507
|
// Performs the indexing of a deposit-like spoke pool event.
|
|
517
508
|
const queryDepositEvents = async (eventName: string) => {
|
|
518
|
-
const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
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),
|
|
529
|
-
recipient: toAddressType(event.recipient),
|
|
530
|
-
inputToken: toAddressType(event.inputToken),
|
|
531
|
-
outputToken: toAddressType(event.outputToken),
|
|
532
|
-
exclusiveRelayer: toAddressType(event.exclusiveRelayer),
|
|
533
|
-
} as DepositWithBlock;
|
|
534
|
-
}) as DepositWithBlock[];
|
|
509
|
+
const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []) as DepositWithBlock[];
|
|
535
510
|
if (depositEvents.length > 0) {
|
|
536
511
|
this.log(
|
|
537
512
|
"debug",
|
|
@@ -580,7 +555,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
580
555
|
}
|
|
581
556
|
};
|
|
582
557
|
|
|
583
|
-
for (const event of ["FundsDeposited"]) {
|
|
558
|
+
for (const event of ["V3FundsDeposited", "FundsDeposited"]) {
|
|
584
559
|
if (eventsToQuery.includes(event)) {
|
|
585
560
|
await queryDepositEvents(event);
|
|
586
561
|
}
|
|
@@ -588,21 +563,11 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
588
563
|
|
|
589
564
|
// Performs indexing of a "speed up deposit"-like event.
|
|
590
565
|
const querySpeedUpDepositEvents = (eventName: string) => {
|
|
591
|
-
const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
592
|
-
const event = _event as SpeedUpWithBlock & { depositor: string; updatedRecipient: string };
|
|
593
|
-
return {
|
|
594
|
-
...event,
|
|
595
|
-
depositor: toAddressType(event.depositor),
|
|
596
|
-
updatedRecipient: toAddressType(event.updatedRecipient),
|
|
597
|
-
} as SpeedUpWithBlock;
|
|
598
|
-
});
|
|
566
|
+
const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []) as SpeedUpWithBlock[];
|
|
599
567
|
|
|
600
568
|
for (const event of speedUpEvents) {
|
|
601
|
-
const speedUp = {
|
|
602
|
-
|
|
603
|
-
originChainId: this.chainId,
|
|
604
|
-
};
|
|
605
|
-
assign(this.speedUps, [speedUp.depositor.toAddress(), speedUp.depositId.toString()], [speedUp]);
|
|
569
|
+
const speedUp = { ...event, originChainId: this.chainId };
|
|
570
|
+
assign(this.speedUps, [speedUp.depositor, speedUp.depositId.toString()], [speedUp]);
|
|
606
571
|
|
|
607
572
|
// Find deposit hash matching this speed up event and update the deposit data associated with the hash,
|
|
608
573
|
// if the hash+data exists.
|
|
@@ -618,7 +583,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
618
583
|
};
|
|
619
584
|
|
|
620
585
|
// Update deposits with speed up requests from depositor.
|
|
621
|
-
["RequestedSpeedUpDeposit"].forEach((event) => {
|
|
586
|
+
["RequestedSpeedUpV3Deposit", "RequestedSpeedUpDeposit"].forEach((event) => {
|
|
622
587
|
if (eventsToQuery.includes(event)) {
|
|
623
588
|
querySpeedUpDepositEvents(event);
|
|
624
589
|
}
|
|
@@ -626,29 +591,17 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
626
591
|
|
|
627
592
|
// Performs indexing of "requested slow fill"-like events.
|
|
628
593
|
const queryRequestedSlowFillEvents = (eventName: string) => {
|
|
629
|
-
const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
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),
|
|
640
|
-
recipient: toAddressType(event.recipient),
|
|
641
|
-
inputToken: toAddressType(event.inputToken),
|
|
642
|
-
outputToken: toAddressType(event.outputToken),
|
|
643
|
-
exclusiveRelayer: toAddressType(event.exclusiveRelayer),
|
|
644
|
-
} as SlowFillRequestWithBlock;
|
|
645
|
-
}) as SlowFillRequestWithBlock[];
|
|
594
|
+
const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? []) as SlowFillRequestWithBlock[];
|
|
646
595
|
for (const event of slowFillRequests) {
|
|
647
596
|
const slowFillRequest = {
|
|
648
597
|
...event,
|
|
649
598
|
destinationChainId: this.chainId,
|
|
650
599
|
};
|
|
651
600
|
|
|
601
|
+
if (eventName === "RequestedV3SlowFill") {
|
|
602
|
+
slowFillRequest.messageHash = getMessageHash(slowFillRequest.message);
|
|
603
|
+
}
|
|
604
|
+
|
|
652
605
|
const depositHash = getRelayEventKey({ ...slowFillRequest, destinationChainId: this.chainId });
|
|
653
606
|
|
|
654
607
|
// Sanity check that this event is not a duplicate.
|
|
@@ -661,7 +614,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
661
614
|
}
|
|
662
615
|
};
|
|
663
616
|
|
|
664
|
-
["RequestedSlowFill"].forEach((event) => {
|
|
617
|
+
["RequestedV3SlowFill", "RequestedSlowFill"].forEach((event) => {
|
|
665
618
|
if (eventsToQuery.includes(event)) {
|
|
666
619
|
queryRequestedSlowFillEvents(event);
|
|
667
620
|
}
|
|
@@ -669,30 +622,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
669
622
|
|
|
670
623
|
// Performs indexing of filled relay-like events.
|
|
671
624
|
const queryFilledRelayEvents = (eventName: string) => {
|
|
672
|
-
const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
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),
|
|
685
|
-
recipient: toAddressType(event.recipient),
|
|
686
|
-
inputToken: toAddressType(event.inputToken),
|
|
687
|
-
outputToken: toAddressType(event.outputToken),
|
|
688
|
-
exclusiveRelayer: toAddressType(event.exclusiveRelayer),
|
|
689
|
-
relayer: toAddressType(event.relayer),
|
|
690
|
-
relayExecutionInfo: {
|
|
691
|
-
...event.relayExecutionInfo,
|
|
692
|
-
updatedRecipient: toAddressType(event.relayExecutionInfo.updatedRecipient),
|
|
693
|
-
},
|
|
694
|
-
} as FillWithBlock;
|
|
695
|
-
}) as FillWithBlock[];
|
|
625
|
+
const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []) as FillWithBlock[];
|
|
696
626
|
|
|
697
627
|
if (fillEvents.length > 0) {
|
|
698
628
|
this.log("debug", `Using ${fillEvents.length} newly queried ${eventName} events for chain ${this.chainId}`, {
|
|
@@ -708,6 +638,11 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
708
638
|
destinationChainId: this.chainId,
|
|
709
639
|
};
|
|
710
640
|
|
|
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
|
+
|
|
711
646
|
// Sanity check that this event is not a duplicate.
|
|
712
647
|
const duplicateFill = this.fills[fill.originChainId]?.find((f) => duplicateEvent(fill, f));
|
|
713
648
|
if (duplicateFill) {
|
|
@@ -721,7 +656,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
721
656
|
};
|
|
722
657
|
|
|
723
658
|
// Update observed fills with ingested event data.
|
|
724
|
-
["FilledRelay"].forEach((event) => {
|
|
659
|
+
["FilledV3Relay", "FilledRelay"].forEach((event) => {
|
|
725
660
|
if (eventsToQuery.includes(event)) {
|
|
726
661
|
queryFilledRelayEvents(event);
|
|
727
662
|
}
|
|
@@ -796,9 +731,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
796
731
|
* @param deposit The deposit to retrieve the destination token for.
|
|
797
732
|
* @returns The destination token.
|
|
798
733
|
*/
|
|
799
|
-
protected getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
734
|
+
protected getDestinationTokenForDeposit(deposit: DepositWithBlock): string {
|
|
800
735
|
if (!this.canResolveZeroAddressOutputToken(deposit)) {
|
|
801
|
-
return
|
|
736
|
+
return ZERO_ADDRESS;
|
|
802
737
|
}
|
|
803
738
|
// L1 token should be resolved if we get here:
|
|
804
739
|
const l1Token = this.hubPoolClient!.getL1TokenForL2TokenAtBlock(
|
|
@@ -806,12 +741,10 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
806
741
|
deposit.originChainId,
|
|
807
742
|
deposit.quoteBlockNumber
|
|
808
743
|
)!;
|
|
809
|
-
|
|
810
|
-
l1Token,
|
|
811
|
-
|
|
812
|
-
deposit.quoteBlockNumber
|
|
744
|
+
return (
|
|
745
|
+
this.hubPoolClient!.getL2TokenForL1TokenAtBlock(l1Token, deposit.destinationChainId, deposit.quoteBlockNumber) ??
|
|
746
|
+
ZERO_ADDRESS
|
|
813
747
|
);
|
|
814
|
-
return counterpartToken ?? toAddressType(ZERO_ADDRESS);
|
|
815
748
|
}
|
|
816
749
|
|
|
817
750
|
/**
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
2
|
import { Contract } from "ethers";
|
|
3
|
-
import { BigNumber, randomAddress, assign, bnZero
|
|
4
|
-
import {
|
|
3
|
+
import { BigNumber, randomAddress, assign, bnZero } from "../../utils";
|
|
4
|
+
import { L1Token, Log, PendingRootBundle, RealizedLpFee } 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";
|
|
9
8
|
|
|
10
9
|
const emptyRootBundle: PendingRootBundle = {
|
|
11
10
|
poolRebalanceRoot: "",
|
|
12
11
|
relayerRefundRoot: "",
|
|
13
12
|
slowRelayRoot: "",
|
|
14
|
-
proposer:
|
|
13
|
+
proposer: "",
|
|
15
14
|
unclaimedPoolRebalanceLeafCount: 0,
|
|
16
15
|
challengePeriodEndTimestamp: 0,
|
|
17
16
|
bundleEvaluationBlockNumbers: [],
|
|
@@ -23,9 +22,9 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
23
22
|
private realizedLpFeePct: BigNumber = bnZero;
|
|
24
23
|
private realizedLpFeePctOverride = false;
|
|
25
24
|
|
|
26
|
-
private l1TokensMock:
|
|
25
|
+
private l1TokensMock: L1Token[] = []; // L1Tokens and their associated info.
|
|
27
26
|
|
|
28
|
-
private spokePoolTokens: { [l1Token: string]: { [chainId: number]:
|
|
27
|
+
private spokePoolTokens: { [l1Token: string]: { [chainId: number]: string } } = {};
|
|
29
28
|
|
|
30
29
|
private eventManager: EventManager;
|
|
31
30
|
|
|
@@ -70,7 +69,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
70
69
|
[chainId],
|
|
71
70
|
[
|
|
72
71
|
{
|
|
73
|
-
spokePool:
|
|
72
|
+
spokePool: contract,
|
|
74
73
|
blockNumber: blockNumber,
|
|
75
74
|
transactionIndex: 0,
|
|
76
75
|
logIndex: 0,
|
|
@@ -83,7 +82,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
83
82
|
this.latestHeightSearched = blockNumber;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
addL1Token(l1Token:
|
|
85
|
+
addL1Token(l1Token: L1Token) {
|
|
87
86
|
this.l1TokensMock.push(l1Token);
|
|
88
87
|
}
|
|
89
88
|
|
|
@@ -93,19 +92,19 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
93
92
|
|
|
94
93
|
setTokenMapping(l1Token: string, chainId: number, l2Token: string) {
|
|
95
94
|
this.spokePoolTokens[l1Token] ??= {};
|
|
96
|
-
this.spokePoolTokens[l1Token][chainId] =
|
|
95
|
+
this.spokePoolTokens[l1Token][chainId] = l2Token;
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
l2TokenEnabledForL1TokenAtBlock(l1Token:
|
|
100
|
-
if (this.spokePoolTokens[l1Token
|
|
98
|
+
l2TokenEnabledForL1TokenAtBlock(l1Token: string, destinationChainId: number, hubBlockNumber: number): boolean {
|
|
99
|
+
if (this.spokePoolTokens[l1Token]?.[destinationChainId]) {
|
|
101
100
|
return true;
|
|
102
101
|
} else {
|
|
103
102
|
return super.l2TokenEnabledForL1TokenAtBlock(l1Token, destinationChainId, hubBlockNumber);
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
|
-
l2TokenHasPoolRebalanceRoute(l2Token:
|
|
105
|
+
l2TokenHasPoolRebalanceRoute(l2Token: string, chainId: number, hubPoolBlock: number): boolean {
|
|
107
106
|
const l1Token = Object.keys(this.spokePoolTokens).find(
|
|
108
|
-
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId]
|
|
107
|
+
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId] === l2Token
|
|
109
108
|
);
|
|
110
109
|
if (!l1Token) {
|
|
111
110
|
return super.l2TokenHasPoolRebalanceRoute(l2Token, chainId, hubPoolBlock);
|
|
@@ -116,24 +115,20 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
116
115
|
delete this.spokePoolTokens[l1Token]?.[chainId];
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
getL1TokenForL2TokenAtBlock(l2Token:
|
|
118
|
+
getL1TokenForL2TokenAtBlock(l2Token: string, chainId: number, blockNumber: number): string {
|
|
120
119
|
const l1Token = Object.keys(this.spokePoolTokens).find(
|
|
121
|
-
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId]
|
|
120
|
+
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId] === l2Token
|
|
122
121
|
);
|
|
123
|
-
|
|
124
|
-
return EvmAddress.from(l1Token);
|
|
125
|
-
} else {
|
|
126
|
-
return super.getL1TokenForL2TokenAtBlock(l2Token, chainId, blockNumber);
|
|
127
|
-
}
|
|
122
|
+
return l1Token ?? super.getL1TokenForL2TokenAtBlock(l2Token, chainId, blockNumber);
|
|
128
123
|
}
|
|
129
124
|
|
|
130
|
-
getL2TokenForL1TokenAtBlock(l1Token:
|
|
131
|
-
const l2Token = this.spokePoolTokens[l1Token
|
|
125
|
+
getL2TokenForL1TokenAtBlock(l1Token: string, chainId: number, blockNumber: number): string {
|
|
126
|
+
const l2Token = this.spokePoolTokens[l1Token]?.[chainId];
|
|
132
127
|
return l2Token ?? super.getL2TokenForL1TokenAtBlock(l1Token, chainId, blockNumber);
|
|
133
128
|
}
|
|
134
129
|
|
|
135
|
-
getTokenInfoForL1Token(l1Token:
|
|
136
|
-
return this.l1TokensMock.find((token) => token.address
|
|
130
|
+
getTokenInfoForL1Token(l1Token: string): L1Token | undefined {
|
|
131
|
+
return this.l1TokensMock.find((token) => token.address === l1Token);
|
|
137
132
|
}
|
|
138
133
|
|
|
139
134
|
_update(eventNames: string[]): Promise<HubPoolUpdate> {
|
|
@@ -2,7 +2,7 @@ import assert from "assert";
|
|
|
2
2
|
import { Contract } from "ethers";
|
|
3
3
|
import { random } from "lodash";
|
|
4
4
|
import winston from "winston";
|
|
5
|
-
import { EMPTY_MESSAGE, ZERO_ADDRESS
|
|
5
|
+
import { EMPTY_MESSAGE, ZERO_ADDRESS } from "../../constants";
|
|
6
6
|
import {
|
|
7
7
|
Log,
|
|
8
8
|
Deposit,
|
|
@@ -25,11 +25,9 @@ import {
|
|
|
25
25
|
BigNumber,
|
|
26
26
|
bnZero,
|
|
27
27
|
bnOne,
|
|
28
|
+
toAddress,
|
|
28
29
|
toBytes32,
|
|
29
30
|
spreadEventWithBlockNumber,
|
|
30
|
-
Address,
|
|
31
|
-
toAddressType,
|
|
32
|
-
isDefined,
|
|
33
31
|
} from "../../utils";
|
|
34
32
|
import { EVMSpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
|
|
35
33
|
import { HubPoolClient } from "../HubPoolClient";
|
|
@@ -65,9 +63,8 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
65
63
|
this.destinationTokenForChainOverride[chainId] = token;
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
69
|
-
|
|
70
|
-
return isDefined(override) ? toAddressType(override) : super.getDestinationTokenForDeposit(deposit);
|
|
66
|
+
getDestinationTokenForDeposit(deposit: DepositWithBlock): string {
|
|
67
|
+
return this.destinationTokenForChainOverride[deposit.originChainId] ?? super.getDestinationTokenForDeposit(deposit);
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
setLatestBlockNumber(blockNumber: number): void {
|
|
@@ -88,7 +85,6 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
88
85
|
lastDepositId = _depositIds[i];
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
|
-
|
|
92
88
|
_getDepositIdAtBlock(blockTag: number): Promise<BigNumber> {
|
|
93
89
|
return Promise.resolve(this.depositIdAtBlock[blockTag]);
|
|
94
90
|
}
|
|
@@ -133,26 +129,28 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
133
129
|
return this._deposit("FundsDeposited", deposit);
|
|
134
130
|
}
|
|
135
131
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
depositV3(deposit: Omit<Deposit, "messageHash"> & Partial<SortableEvent>): Log {
|
|
133
|
+
return this._deposit("V3FundsDeposited", deposit);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
protected _deposit(event: string, deposit: Omit<Deposit, "messageHash"> & Partial<SortableEvent>): Log {
|
|
140
137
|
const { blockNumber, txnIndex } = deposit;
|
|
141
138
|
let { depositId, destinationChainId, inputAmount, outputAmount } = deposit;
|
|
142
139
|
depositId ??= this.numberOfDeposits;
|
|
143
140
|
this.numberOfDeposits = depositId.add(bnOne);
|
|
144
141
|
|
|
145
142
|
destinationChainId ??= random(1, 42161, false);
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const
|
|
143
|
+
const addressModifier = event === "FundsDeposited" ? toBytes32 : toAddress;
|
|
144
|
+
const depositor = addressModifier(deposit.depositor ?? randomAddress());
|
|
145
|
+
const recipient = addressModifier(deposit.recipient ?? depositor);
|
|
146
|
+
const inputToken = addressModifier(deposit.inputToken ?? randomAddress());
|
|
147
|
+
const outputToken = addressModifier(deposit.outputToken ?? inputToken);
|
|
148
|
+
const exclusiveRelayer = addressModifier(deposit.exclusiveRelayer ?? ZERO_ADDRESS);
|
|
151
149
|
|
|
152
150
|
inputAmount ??= toBNWei(random(1, 1000, false));
|
|
153
151
|
outputAmount ??= inputAmount.mul(toBN("0.95"));
|
|
154
152
|
|
|
155
|
-
const message = deposit
|
|
153
|
+
const message = deposit["message"] ?? "0x";
|
|
156
154
|
const topics = [destinationChainId, depositId, depositor];
|
|
157
155
|
const quoteTimestamp = deposit.quoteTimestamp ?? getCurrentTime();
|
|
158
156
|
const args = {
|
|
@@ -182,13 +180,17 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
182
180
|
});
|
|
183
181
|
}
|
|
184
182
|
|
|
185
|
-
|
|
183
|
+
fillV3Relay(fill: Omit<Fill, "messageHash"> & { message: string } & Partial<SortableEvent>): Log {
|
|
184
|
+
return this._fillRelay("FilledV3Relay", fill);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
fillRelay(fill: Omit<Fill, "messageHash"> & { message: string } & Partial<SortableEvent>): Log {
|
|
186
188
|
return this._fillRelay("FilledRelay", fill);
|
|
187
189
|
}
|
|
188
190
|
|
|
189
191
|
protected _fillRelay(
|
|
190
192
|
event: string,
|
|
191
|
-
fill: Omit<Fill, "messageHash"> & { message
|
|
193
|
+
fill: Omit<Fill, "messageHash"> & { message: string } & Partial<SortableEvent>
|
|
192
194
|
): Log {
|
|
193
195
|
const { blockNumber, txnIndex } = fill;
|
|
194
196
|
let { originChainId, depositId, inputAmount, outputAmount, fillDeadline } = fill;
|
|
@@ -198,20 +200,20 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
198
200
|
outputAmount ??= inputAmount;
|
|
199
201
|
fillDeadline ??= getCurrentTime() + 60;
|
|
200
202
|
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const
|
|
203
|
+
const addressModifier = event === "FilledRelay" ? toBytes32 : toAddress;
|
|
204
|
+
const depositor = addressModifier(fill.depositor ?? randomAddress());
|
|
205
|
+
const recipient = addressModifier(fill.recipient ?? depositor);
|
|
206
|
+
const inputToken = addressModifier(fill.inputToken ?? randomAddress());
|
|
207
|
+
const outputToken = addressModifier(fill.outputToken ?? ZERO_ADDRESS);
|
|
208
|
+
const exclusiveRelayer = addressModifier(fill.exclusiveRelayer ?? ZERO_ADDRESS);
|
|
209
|
+
const relayer = addressModifier(fill.relayer ?? randomAddress());
|
|
207
210
|
|
|
208
|
-
const topics = [originChainId, depositId, relayer];
|
|
211
|
+
const topics = [originChainId, depositId, relayer]; // @todo verify
|
|
209
212
|
const message = fill.message ?? EMPTY_MESSAGE;
|
|
210
213
|
const updatedMessage = fill.relayExecutionInfo?.updatedMessage ?? message;
|
|
211
|
-
const updatedRecipient = fill.relayExecutionInfo?.updatedRecipient.toBytes32() ?? recipient;
|
|
212
214
|
|
|
213
215
|
const relayExecutionInfo = {
|
|
214
|
-
updatedRecipient,
|
|
216
|
+
updatedRecipient: fill.relayExecutionInfo?.updatedRecipient ?? recipient,
|
|
215
217
|
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
216
218
|
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
217
219
|
};
|
|
@@ -231,20 +233,31 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
231
233
|
depositor,
|
|
232
234
|
recipient,
|
|
233
235
|
relayExecutionInfo: {
|
|
234
|
-
updatedRecipient,
|
|
236
|
+
updatedRecipient: fill.relayExecutionInfo?.updatedRecipient ?? recipient,
|
|
235
237
|
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
236
238
|
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
237
239
|
},
|
|
238
240
|
};
|
|
239
241
|
|
|
240
|
-
const args =
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
242
|
+
const args =
|
|
243
|
+
event === "FilledRelay"
|
|
244
|
+
? {
|
|
245
|
+
..._args,
|
|
246
|
+
messageHash: getMessageHash(message),
|
|
247
|
+
relayExecutionInfo: {
|
|
248
|
+
...relayExecutionInfo,
|
|
249
|
+
updatedMessageHash: getMessageHash(updatedMessage),
|
|
250
|
+
},
|
|
251
|
+
}
|
|
252
|
+
: {
|
|
253
|
+
// FilledV3Relay
|
|
254
|
+
..._args,
|
|
255
|
+
message,
|
|
256
|
+
relayExecutionInfo: {
|
|
257
|
+
...relayExecutionInfo,
|
|
258
|
+
updatedMessage,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
248
261
|
|
|
249
262
|
return this.eventManager.generateEvent({
|
|
250
263
|
event,
|
|
@@ -256,12 +269,17 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
256
269
|
});
|
|
257
270
|
}
|
|
258
271
|
|
|
272
|
+
speedUpV3Deposit(speedUp: SpeedUp): Log {
|
|
273
|
+
return this._speedUpDeposit("RequestedSpeedUpV3Deposit", speedUp);
|
|
274
|
+
}
|
|
275
|
+
|
|
259
276
|
speedUpDeposit(speedUp: SpeedUp): Log {
|
|
260
277
|
return this._speedUpDeposit("RequestedSpeedUpDeposit", speedUp);
|
|
261
278
|
}
|
|
262
279
|
|
|
263
280
|
protected _speedUpDeposit(event: string, speedUp: SpeedUp): Log {
|
|
264
|
-
const
|
|
281
|
+
const addressModifier = event === "RequestedSpeedUpDeposit" ? toBytes32 : toAddress;
|
|
282
|
+
const depositor = addressModifier(speedUp.depositor);
|
|
265
283
|
const topics = [speedUp.depositId, depositor];
|
|
266
284
|
const args = { ...speedUp };
|
|
267
285
|
|
|
@@ -272,7 +290,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
272
290
|
args: {
|
|
273
291
|
...args,
|
|
274
292
|
depositor,
|
|
275
|
-
updatedRecipient: speedUp.updatedRecipient
|
|
293
|
+
updatedRecipient: addressModifier(speedUp.updatedRecipient),
|
|
276
294
|
},
|
|
277
295
|
});
|
|
278
296
|
}
|
|
@@ -290,19 +308,24 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
290
308
|
});
|
|
291
309
|
}
|
|
292
310
|
|
|
293
|
-
|
|
311
|
+
requestV3SlowFill(request: Omit<SlowFillRequest, "messageHash"> & Partial<SortableEvent>): Log {
|
|
312
|
+
return this._requestSlowFill("RequestedV3SlowFill", request);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
requestSlowFill(request: Omit<SlowFillRequest, "messageHash"> & Partial<SortableEvent>): Log {
|
|
294
316
|
return this._requestSlowFill("RequestedSlowFill", request);
|
|
295
317
|
}
|
|
296
318
|
|
|
297
319
|
protected _requestSlowFill(
|
|
298
320
|
event: string,
|
|
299
|
-
request: Omit<SlowFillRequest, "
|
|
321
|
+
request: Omit<SlowFillRequest, "messageHash"> & Partial<SortableEvent>
|
|
300
322
|
): Log {
|
|
301
323
|
const { originChainId, depositId } = request;
|
|
302
324
|
const topics = [originChainId, depositId];
|
|
303
325
|
const args = { ...request };
|
|
304
326
|
|
|
305
|
-
const
|
|
327
|
+
const addressModifier = event === "RequestedSlowFill" ? toBytes32 : toAddress;
|
|
328
|
+
const depositor = addressModifier(args.depositor ?? randomAddress());
|
|
306
329
|
|
|
307
330
|
return this.eventManager.generateEvent({
|
|
308
331
|
event,
|
|
@@ -310,26 +333,24 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
310
333
|
topics: topics.map((topic) => topic.toString()),
|
|
311
334
|
args: {
|
|
312
335
|
...args,
|
|
313
|
-
destinationChainId: this.chainId,
|
|
314
336
|
depositor,
|
|
315
|
-
recipient: args.recipient
|
|
316
|
-
inputToken: args.inputToken
|
|
317
|
-
outputToken: args.outputToken
|
|
318
|
-
exclusiveRelayer: args.exclusiveRelayer
|
|
319
|
-
messageHash: args.messageHash ?? ZERO_BYTES,
|
|
337
|
+
recipient: addressModifier(args.recipient ?? depositor),
|
|
338
|
+
inputToken: addressModifier(args.inputToken ?? randomAddress()),
|
|
339
|
+
outputToken: addressModifier(args.outputToken ?? ZERO_ADDRESS),
|
|
340
|
+
exclusiveRelayer: addressModifier(args.exclusiveRelayer ?? ZERO_ADDRESS),
|
|
320
341
|
},
|
|
321
342
|
blockNumber: request.blockNumber,
|
|
322
343
|
transactionIndex: request.txnIndex,
|
|
323
344
|
});
|
|
324
345
|
}
|
|
325
346
|
|
|
326
|
-
// This is a simple wrapper around
|
|
347
|
+
// This is a simple wrapper around fillV3Relay().
|
|
327
348
|
// rootBundleId and proof are discarded here - we have no interest in verifying that.
|
|
328
|
-
|
|
349
|
+
executeV3SlowRelayLeaf(leaf: Omit<SlowFillLeaf, "messageHash">): Log {
|
|
329
350
|
const fill = {
|
|
330
351
|
...leaf.relayData,
|
|
331
352
|
destinationChainId: this.chainId,
|
|
332
|
-
relayer:
|
|
353
|
+
relayer: ZERO_ADDRESS,
|
|
333
354
|
repaymentChainId: 0,
|
|
334
355
|
relayExecutionInfo: {
|
|
335
356
|
updatedRecipient: leaf.relayData.recipient,
|
|
@@ -340,7 +361,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
340
361
|
},
|
|
341
362
|
};
|
|
342
363
|
|
|
343
|
-
return this.
|
|
364
|
+
return this.fillV3Relay(fill);
|
|
344
365
|
}
|
|
345
366
|
|
|
346
367
|
executeRelayerRefundLeaf(refund: RelayerRefundExecution & Partial<SortableEvent>): Log {
|