@across-protocol/sdk 4.2.16-alpha.0 → 4.2.16-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 +6 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +21 -6
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +9 -5
- package/dist/cjs/arch/svm/SpokeUtils.js +70 -71
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +3 -5
- package/dist/cjs/arch/svm/utils.js +20 -28
- 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 -58
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +64 -45
- 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 +5 -3
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +3 -4
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +3 -3
- 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 +13 -13
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +10 -10
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +42 -49
- 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 +12 -13
- package/dist/cjs/utils/AddressUtils.js +44 -46
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.js +1 -1
- package/dist/cjs/utils/EventUtils.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 +4 -6
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +6 -2
- package/dist/esm/arch/evm/SpokeUtils.js +22 -7
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -5
- package/dist/esm/arch/svm/SpokeUtils.js +74 -75
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +6 -8
- package/dist/esm/arch/svm/utils.js +21 -27
- 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 +5 -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 +97 -63
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +67 -47
- 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 +5 -3
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +4 -5
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +3 -3
- 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 +13 -13
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +11 -11
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +44 -51
- 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 +13 -14
- package/dist/esm/utils/AddressUtils.js +50 -56
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.js +2 -2
- package/dist/esm/utils/EventUtils.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 +4 -16
- package/dist/esm/utils/TokenUtils.js +5 -7
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +6 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +9 -5
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +6 -8
- 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 +2 -2
- 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 +5 -3
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +3 -3
- 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 +13 -13
- 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 +6 -6
- 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 +13 -14
- 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 +4 -16
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/arch/evm/SpokeUtils.ts +52 -12
- package/src/arch/svm/SpokeUtils.ts +108 -59
- package/src/arch/svm/utils.ts +11 -20
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +57 -53
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +10 -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 +126 -82
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +6 -0
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +118 -35
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +3 -5
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +23 -14
- package/src/interfaces/SpokePool.ts +13 -13
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +14 -12
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +42 -46
- package/src/relayFeeCalculator/relayFeeCalculator.ts +20 -12
- package/src/utils/AddressUtils.ts +58 -60
- package/src/utils/EventUtils.ts +2 -2
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +10 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
|
+
import { utils as ethersUtils } from "ethers";
|
|
2
3
|
import {
|
|
3
4
|
AnyObject,
|
|
4
5
|
BigNumber,
|
|
@@ -6,6 +7,7 @@ import {
|
|
|
6
7
|
DefaultLogLevels,
|
|
7
8
|
DepositSearchResult,
|
|
8
9
|
EventSearchConfig,
|
|
10
|
+
EvmAddress,
|
|
9
11
|
MAX_BIG_INT,
|
|
10
12
|
MakeOptional,
|
|
11
13
|
assign,
|
|
@@ -13,16 +15,14 @@ import {
|
|
|
13
15
|
isDefined,
|
|
14
16
|
getMessageHash,
|
|
15
17
|
isSlowFill,
|
|
16
|
-
isValidEvmAddress,
|
|
17
18
|
isZeroAddress,
|
|
18
|
-
toAddress,
|
|
19
19
|
validateFillForDeposit,
|
|
20
|
-
chainIsEvm,
|
|
21
20
|
chainIsProd,
|
|
22
21
|
Address,
|
|
22
|
+
toAddressType,
|
|
23
23
|
} from "../../utils";
|
|
24
24
|
import { duplicateEvent, sortEventsAscendingInPlace } from "../../utils/EventUtils";
|
|
25
|
-
import { ZERO_ADDRESS } from "../../constants";
|
|
25
|
+
import { CHAIN_IDs, ZERO_ADDRESS } from "../../constants";
|
|
26
26
|
import {
|
|
27
27
|
BridgedToHubPoolWithBlock,
|
|
28
28
|
ClaimedRelayerRefundWithBlock,
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
SortableEvent,
|
|
40
40
|
SpeedUpWithBlock,
|
|
41
41
|
TokensBridged,
|
|
42
|
+
RelayExecutionEventInfo,
|
|
42
43
|
} from "../../interfaces";
|
|
43
44
|
import { BaseAbstractClient, UpdateFailureReason } from "../BaseAbstractClient";
|
|
44
45
|
import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
@@ -208,8 +209,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
208
209
|
* @param relayer The relayer address.
|
|
209
210
|
* @returns A list of fills.
|
|
210
211
|
*/
|
|
211
|
-
public getFillsForRelayer(relayer:
|
|
212
|
-
return this.getFills().filter((fill) => fill.relayer
|
|
212
|
+
public getFillsForRelayer(relayer: Address): FillWithBlock[] {
|
|
213
|
+
return this.getFills().filter((fill) => fill.relayer.eq(relayer));
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
/**
|
|
@@ -273,8 +274,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
273
274
|
const { depositId, depositor } = deposit;
|
|
274
275
|
|
|
275
276
|
// Note: we know depositor cannot be more than 20 bytes since this is guaranteed by contracts.
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
// Additionally, speed ups can only be done on EVM networks.
|
|
278
|
+
const speedups = this.speedUps[depositor.toEvmAddress()]?.[depositId.toString()];
|
|
278
279
|
if (!isDefined(speedups) || speedups.length === 0) {
|
|
279
280
|
return deposit;
|
|
280
281
|
}
|
|
@@ -403,11 +404,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
403
404
|
// is not a valid EVM chain. In the case where the repayment address is not a valid EVM address, the dataworker
|
|
404
405
|
// might be able to overwrite the repayment address to the msg.sender on the fill txn, but to keep this
|
|
405
406
|
// functioon synchronous, we can't make that decision now. So this function might log some false positives.
|
|
406
|
-
if (
|
|
407
|
-
this.hubPoolClient &&
|
|
408
|
-
!isSlowFill(fill) &&
|
|
409
|
-
(!chainIsEvm(repaymentChainId) || !isValidEvmAddress(fill.relayer))
|
|
410
|
-
) {
|
|
407
|
+
if (this.hubPoolClient && !isSlowFill(fill) && !fill.relayer.isValidOn(repaymentChainId)) {
|
|
411
408
|
groupedFills.unrepayableFills.push(fill);
|
|
412
409
|
}
|
|
413
410
|
// This fill is still valid and means that the deposit cannot be filled on-chain anymore, but it
|
|
@@ -429,7 +426,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
429
426
|
chainId: this.chainId,
|
|
430
427
|
message: "Unrepayable fills found where we need to switch repayment address and or chain",
|
|
431
428
|
deposit,
|
|
432
|
-
unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer, x])),
|
|
429
|
+
unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer.toNative(), x])),
|
|
433
430
|
notificationPath: "across-unrepayable-fills",
|
|
434
431
|
});
|
|
435
432
|
}
|
|
@@ -501,14 +498,36 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
501
498
|
const { events: queryResults, currentTime, searchEndBlock } = update;
|
|
502
499
|
|
|
503
500
|
if (eventsToQuery.includes("TokensBridged")) {
|
|
504
|
-
for (const
|
|
505
|
-
|
|
501
|
+
for (const _event of queryResults[eventsToQuery.indexOf("TokensBridged")]) {
|
|
502
|
+
const event = _event as TokensBridged & {
|
|
503
|
+
l2TokenAddress: string;
|
|
504
|
+
};
|
|
505
|
+
this.tokensBridged.push({
|
|
506
|
+
...event,
|
|
507
|
+
l2TokenAddress: toAddressType(event.l2TokenAddress, this.chainId),
|
|
508
|
+
});
|
|
506
509
|
}
|
|
507
510
|
}
|
|
508
511
|
|
|
509
512
|
// Performs the indexing of a deposit-like spoke pool event.
|
|
510
513
|
const queryDepositEvents = async (eventName: string) => {
|
|
511
|
-
const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
514
|
+
const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
515
|
+
const event = _event as DepositWithBlock & {
|
|
516
|
+
depositor: string;
|
|
517
|
+
recipient: string;
|
|
518
|
+
inputToken: string;
|
|
519
|
+
outputToken: string;
|
|
520
|
+
exclusiveRelayer: string;
|
|
521
|
+
};
|
|
522
|
+
return {
|
|
523
|
+
...event,
|
|
524
|
+
depositor: toAddressType(event.depositor, this.chainId),
|
|
525
|
+
recipient: toAddressType(event.recipient, event.destinationChainId),
|
|
526
|
+
inputToken: toAddressType(event.inputToken, this.chainId),
|
|
527
|
+
outputToken: toAddressType(event.outputToken, event.destinationChainId),
|
|
528
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, event.destinationChainId),
|
|
529
|
+
} as DepositWithBlock;
|
|
530
|
+
});
|
|
512
531
|
if (depositEvents.length > 0) {
|
|
513
532
|
this.log(
|
|
514
533
|
"debug",
|
|
@@ -565,11 +584,28 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
565
584
|
|
|
566
585
|
// Performs indexing of a "speed up deposit"-like event.
|
|
567
586
|
const querySpeedUpDepositEvents = (eventName: string) => {
|
|
568
|
-
const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
587
|
+
const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
588
|
+
.map((_event) => {
|
|
589
|
+
const event = _event as SpeedUpWithBlock & { depositor: string; updatedRecipient: string };
|
|
590
|
+
|
|
591
|
+
if (!EvmAddress.validate(ethersUtils.arrayify(event.updatedRecipient))) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
return {
|
|
596
|
+
...event,
|
|
597
|
+
depositor: toAddressType(event.depositor, this.chainId),
|
|
598
|
+
updatedRecipient: EvmAddress.from(event.updatedRecipient),
|
|
599
|
+
} as SpeedUpWithBlock;
|
|
600
|
+
})
|
|
601
|
+
.filter(isDefined);
|
|
569
602
|
|
|
570
603
|
for (const event of speedUpEvents) {
|
|
571
|
-
const speedUp = {
|
|
572
|
-
|
|
604
|
+
const speedUp = {
|
|
605
|
+
...event,
|
|
606
|
+
originChainId: this.chainId,
|
|
607
|
+
};
|
|
608
|
+
assign(this.speedUps, [speedUp.depositor.toEvmAddress(), speedUp.depositId.toString()], [speedUp]);
|
|
573
609
|
|
|
574
610
|
// Find deposit hash matching this speed up event and update the deposit data associated with the hash,
|
|
575
611
|
// if the hash+data exists.
|
|
@@ -593,7 +629,23 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
593
629
|
|
|
594
630
|
// Performs indexing of "requested slow fill"-like events.
|
|
595
631
|
const queryRequestedSlowFillEvents = (eventName: string) => {
|
|
596
|
-
const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
632
|
+
const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
633
|
+
const event = _event as SlowFillRequestWithBlock & {
|
|
634
|
+
depositor: string;
|
|
635
|
+
recipient: string;
|
|
636
|
+
inputToken: string;
|
|
637
|
+
outputToken: string;
|
|
638
|
+
exclusiveRelayer: string;
|
|
639
|
+
};
|
|
640
|
+
return {
|
|
641
|
+
...event,
|
|
642
|
+
depositor: toAddressType(event.depositor, event.originChainId),
|
|
643
|
+
recipient: toAddressType(event.recipient, this.chainId),
|
|
644
|
+
inputToken: toAddressType(event.inputToken, event.originChainId),
|
|
645
|
+
outputToken: toAddressType(event.outputToken, this.chainId),
|
|
646
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, this.chainId),
|
|
647
|
+
} as SlowFillRequestWithBlock;
|
|
648
|
+
});
|
|
597
649
|
for (const event of slowFillRequests) {
|
|
598
650
|
const slowFillRequest = {
|
|
599
651
|
...event,
|
|
@@ -620,7 +672,30 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
620
672
|
|
|
621
673
|
// Performs indexing of filled relay-like events.
|
|
622
674
|
const queryFilledRelayEvents = (eventName: string) => {
|
|
623
|
-
const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
675
|
+
const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
676
|
+
const event = _event as FillWithBlock & {
|
|
677
|
+
depositor: string;
|
|
678
|
+
recipient: string;
|
|
679
|
+
inputToken: string;
|
|
680
|
+
outputToken: string;
|
|
681
|
+
exclusiveRelayer: string;
|
|
682
|
+
relayer: string;
|
|
683
|
+
relayExecutionInfo: RelayExecutionEventInfo & { updatedRecipient: string };
|
|
684
|
+
};
|
|
685
|
+
return {
|
|
686
|
+
...event,
|
|
687
|
+
depositor: toAddressType(event.depositor, event.originChainId),
|
|
688
|
+
recipient: toAddressType(event.recipient, this.chainId),
|
|
689
|
+
inputToken: toAddressType(event.inputToken, event.originChainId),
|
|
690
|
+
outputToken: toAddressType(event.outputToken, this.chainId),
|
|
691
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, this.chainId),
|
|
692
|
+
relayer: toAddressType(event.relayer, this.chainId),
|
|
693
|
+
relayExecutionInfo: {
|
|
694
|
+
...event.relayExecutionInfo,
|
|
695
|
+
updatedRecipient: toAddressType(event.relayExecutionInfo.updatedRecipient, this.chainId),
|
|
696
|
+
},
|
|
697
|
+
} as FillWithBlock;
|
|
698
|
+
});
|
|
624
699
|
|
|
625
700
|
if (fillEvents.length > 0) {
|
|
626
701
|
this.log("debug", `Using ${fillEvents.length} newly queried ${eventName} events for chain ${this.chainId}`, {
|
|
@@ -656,8 +731,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
656
731
|
});
|
|
657
732
|
|
|
658
733
|
if (eventsToQuery.includes("EnabledDepositRoute")) {
|
|
659
|
-
const enableDepositsEvents =
|
|
660
|
-
|
|
734
|
+
const enableDepositsEvents = queryResults[
|
|
735
|
+
eventsToQuery.indexOf("EnabledDepositRoute")
|
|
736
|
+
] as EnabledDepositRouteWithBlock[];
|
|
661
737
|
|
|
662
738
|
for (const event of enableDepositsEvents) {
|
|
663
739
|
assign(this.depositRoutes, [event.originToken, event.destinationChainId], event.enabled);
|
|
@@ -665,18 +741,23 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
665
741
|
}
|
|
666
742
|
|
|
667
743
|
if (eventsToQuery.includes("RelayedRootBundle")) {
|
|
668
|
-
const relayedRootBundleEvents =
|
|
669
|
-
|
|
744
|
+
const relayedRootBundleEvents = queryResults[
|
|
745
|
+
eventsToQuery.indexOf("RelayedRootBundle")
|
|
746
|
+
] as RootBundleRelayWithBlock[];
|
|
670
747
|
for (const event of relayedRootBundleEvents) {
|
|
671
748
|
this.rootBundleRelays.push(event);
|
|
672
749
|
}
|
|
673
750
|
}
|
|
674
751
|
|
|
675
752
|
if (eventsToQuery.includes("ExecutedRelayerRefundRoot")) {
|
|
676
|
-
const refundEvents =
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
this.relayerRefundExecutions.push(
|
|
753
|
+
const refundEvents = queryResults[eventsToQuery.indexOf("ExecutedRelayerRefundRoot")];
|
|
754
|
+
for (const _event of refundEvents) {
|
|
755
|
+
const event = _event as { l2TokenAddress: string; refundAddresses: string[] } & RelayerRefundExecutionWithBlock;
|
|
756
|
+
this.relayerRefundExecutions.push({
|
|
757
|
+
...event,
|
|
758
|
+
l2TokenAddress: toAddressType(event.l2TokenAddress, this.chainId),
|
|
759
|
+
refundAddresses: event.refundAddresses.map((addr) => toAddressType(addr, this.chainId)),
|
|
760
|
+
});
|
|
680
761
|
}
|
|
681
762
|
}
|
|
682
763
|
|
|
@@ -743,9 +824,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
743
824
|
* @param deposit The deposit to retrieve the destination token for.
|
|
744
825
|
* @returns The destination token.
|
|
745
826
|
*/
|
|
746
|
-
protected getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
827
|
+
protected getDestinationTokenForDeposit(deposit: DepositWithBlock): Address {
|
|
747
828
|
if (!this.canResolveZeroAddressOutputToken(deposit)) {
|
|
748
|
-
return ZERO_ADDRESS;
|
|
829
|
+
return toAddressType(ZERO_ADDRESS, CHAIN_IDs.MAINNET);
|
|
749
830
|
}
|
|
750
831
|
// L1 token should be resolved if we get here:
|
|
751
832
|
const l1Token = this.hubPoolClient!.getL1TokenForL2TokenAtBlock(
|
|
@@ -753,10 +834,12 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
753
834
|
deposit.originChainId,
|
|
754
835
|
deposit.quoteBlockNumber
|
|
755
836
|
)!;
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
837
|
+
const counterpartToken = this.hubPoolClient!.getL2TokenForL1TokenAtBlock(
|
|
838
|
+
l1Token,
|
|
839
|
+
deposit.destinationChainId,
|
|
840
|
+
deposit.quoteBlockNumber
|
|
759
841
|
);
|
|
842
|
+
return counterpartToken ?? toAddressType(ZERO_ADDRESS, CHAIN_IDs.MAINNET);
|
|
760
843
|
}
|
|
761
844
|
|
|
762
845
|
/**
|
|
@@ -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, chainId),
|
|
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, chainId);
|
|
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> {
|
|
@@ -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 } from "../../constants";
|
|
5
|
+
import { EMPTY_MESSAGE, ZERO_ADDRESS, ZERO_BYTES } from "../../constants";
|
|
6
6
|
import {
|
|
7
7
|
Log,
|
|
8
8
|
Deposit,
|
|
@@ -27,6 +27,9 @@ import {
|
|
|
27
27
|
bnOne,
|
|
28
28
|
toBytes32,
|
|
29
29
|
spreadEventWithBlockNumber,
|
|
30
|
+
Address,
|
|
31
|
+
toAddressType,
|
|
32
|
+
isDefined,
|
|
30
33
|
} from "../../utils";
|
|
31
34
|
import { EVMSpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
|
|
32
35
|
import { HubPoolClient } from "../HubPoolClient";
|
|
@@ -62,8 +65,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
62
65
|
this.destinationTokenForChainOverride[chainId] = token;
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
66
|
-
|
|
68
|
+
getDestinationTokenForDeposit(deposit: DepositWithBlock): Address {
|
|
69
|
+
const override = this.destinationTokenForChainOverride[deposit.originChainId];
|
|
70
|
+
return isDefined(override)
|
|
71
|
+
? toAddressType(override, deposit.destinationChainId)
|
|
72
|
+
: super.getDestinationTokenForDeposit(deposit);
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
setLatestBlockNumber(blockNumber: number): void {
|
|
@@ -129,23 +135,26 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
129
135
|
return this._deposit("FundsDeposited", deposit);
|
|
130
136
|
}
|
|
131
137
|
|
|
132
|
-
protected _deposit(
|
|
138
|
+
protected _deposit(
|
|
139
|
+
event: string,
|
|
140
|
+
deposit: Omit<Deposit, "messageHash"> & { message?: string } & Partial<SortableEvent>
|
|
141
|
+
): Log {
|
|
133
142
|
const { blockNumber, txnIndex } = deposit;
|
|
134
143
|
let { depositId, destinationChainId, inputAmount, outputAmount } = deposit;
|
|
135
144
|
depositId ??= this.numberOfDeposits;
|
|
136
145
|
this.numberOfDeposits = depositId.add(bnOne);
|
|
137
146
|
|
|
138
147
|
destinationChainId ??= random(1, 42161, false);
|
|
139
|
-
const depositor =
|
|
140
|
-
const recipient =
|
|
141
|
-
const inputToken =
|
|
142
|
-
const outputToken =
|
|
143
|
-
const exclusiveRelayer =
|
|
148
|
+
const depositor = deposit.depositor?.toBytes32() ?? toBytes32(randomAddress());
|
|
149
|
+
const recipient = deposit.recipient?.toBytes32() ?? toBytes32(depositor);
|
|
150
|
+
const inputToken = deposit.inputToken?.toBytes32() ?? toBytes32(randomAddress());
|
|
151
|
+
const outputToken = deposit.outputToken?.toBytes32() ?? inputToken;
|
|
152
|
+
const exclusiveRelayer = deposit.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
|
|
144
153
|
|
|
145
154
|
inputAmount ??= toBNWei(random(1, 1000, false));
|
|
146
155
|
outputAmount ??= inputAmount.mul(toBN("0.95"));
|
|
147
156
|
|
|
148
|
-
const message = deposit
|
|
157
|
+
const message = deposit.message ?? "0x";
|
|
149
158
|
const topics = [destinationChainId, depositId, depositor];
|
|
150
159
|
const quoteTimestamp = deposit.quoteTimestamp ?? getCurrentTime();
|
|
151
160
|
const args = {
|
|
@@ -191,19 +200,20 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
191
200
|
outputAmount ??= inputAmount;
|
|
192
201
|
fillDeadline ??= getCurrentTime() + 60;
|
|
193
202
|
|
|
194
|
-
const depositor =
|
|
195
|
-
const recipient =
|
|
196
|
-
const inputToken =
|
|
197
|
-
const outputToken =
|
|
198
|
-
const exclusiveRelayer =
|
|
199
|
-
const relayer =
|
|
203
|
+
const depositor = fill.depositor?.toBytes32() ?? toBytes32(randomAddress());
|
|
204
|
+
const recipient = fill.recipient?.toBytes32() ?? toBytes32(depositor);
|
|
205
|
+
const inputToken = fill.inputToken?.toBytes32() ?? toBytes32(randomAddress());
|
|
206
|
+
const outputToken = fill.outputToken?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
|
|
207
|
+
const exclusiveRelayer = fill.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
|
|
208
|
+
const relayer = fill.relayer?.toBytes32() ?? toBytes32(randomAddress());
|
|
200
209
|
|
|
201
210
|
const topics = [originChainId, depositId, relayer];
|
|
202
211
|
const message = fill.message ?? EMPTY_MESSAGE;
|
|
203
212
|
const updatedMessage = fill.relayExecutionInfo?.updatedMessage ?? message;
|
|
213
|
+
const updatedRecipient = fill.relayExecutionInfo?.updatedRecipient.toBytes32() ?? recipient;
|
|
204
214
|
|
|
205
215
|
const relayExecutionInfo = {
|
|
206
|
-
updatedRecipient
|
|
216
|
+
updatedRecipient,
|
|
207
217
|
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
208
218
|
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
209
219
|
};
|
|
@@ -223,7 +233,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
223
233
|
depositor,
|
|
224
234
|
recipient,
|
|
225
235
|
relayExecutionInfo: {
|
|
226
|
-
updatedRecipient
|
|
236
|
+
updatedRecipient,
|
|
227
237
|
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
228
238
|
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
229
239
|
},
|
|
@@ -253,7 +263,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
253
263
|
}
|
|
254
264
|
|
|
255
265
|
protected _speedUpDeposit(event: string, speedUp: SpeedUp): Log {
|
|
256
|
-
const depositor =
|
|
266
|
+
const depositor = speedUp.depositor.toBytes32();
|
|
257
267
|
const topics = [speedUp.depositId, depositor];
|
|
258
268
|
const args = { ...speedUp };
|
|
259
269
|
|
|
@@ -264,7 +274,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
264
274
|
args: {
|
|
265
275
|
...args,
|
|
266
276
|
depositor,
|
|
267
|
-
updatedRecipient:
|
|
277
|
+
updatedRecipient: speedUp.updatedRecipient.toBytes32(),
|
|
268
278
|
},
|
|
269
279
|
});
|
|
270
280
|
}
|
|
@@ -294,7 +304,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
294
304
|
const topics = [originChainId, depositId];
|
|
295
305
|
const args = { ...request };
|
|
296
306
|
|
|
297
|
-
const depositor =
|
|
307
|
+
const depositor = args.depositor.toBytes32() ?? toBytes32(randomAddress());
|
|
298
308
|
|
|
299
309
|
return this.eventManager.generateEvent({
|
|
300
310
|
event,
|
|
@@ -304,10 +314,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
304
314
|
...args,
|
|
305
315
|
destinationChainId: this.chainId,
|
|
306
316
|
depositor,
|
|
307
|
-
recipient:
|
|
308
|
-
inputToken:
|
|
309
|
-
outputToken:
|
|
310
|
-
exclusiveRelayer:
|
|
317
|
+
recipient: args.recipient?.toBytes32() ?? depositor,
|
|
318
|
+
inputToken: args.inputToken?.toBytes32() ?? toBytes32(randomAddress()),
|
|
319
|
+
outputToken: args.outputToken?.toBytes32() ?? toBytes32(ZERO_ADDRESS),
|
|
320
|
+
exclusiveRelayer: args.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS),
|
|
321
|
+
messageHash: args.messageHash ?? ZERO_BYTES,
|
|
311
322
|
},
|
|
312
323
|
blockNumber: request.blockNumber,
|
|
313
324
|
transactionIndex: request.txnIndex,
|
|
@@ -317,10 +328,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
317
328
|
// This is a simple wrapper around fillRelay().
|
|
318
329
|
// rootBundleId and proof are discarded here - we have no interest in verifying that.
|
|
319
330
|
executeSlowRelayLeaf(leaf: Omit<SlowFillLeaf, "messageHash">): Log {
|
|
331
|
+
const destinationChainId = this.chainId;
|
|
320
332
|
const fill = {
|
|
321
333
|
...leaf.relayData,
|
|
322
|
-
destinationChainId
|
|
323
|
-
relayer: ZERO_ADDRESS,
|
|
334
|
+
destinationChainId,
|
|
335
|
+
relayer: toAddressType(ZERO_ADDRESS, destinationChainId),
|
|
324
336
|
repaymentChainId: 0,
|
|
325
337
|
relayExecutionInfo: {
|
|
326
338
|
updatedRecipient: leaf.relayData.recipient,
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
SVMEventNames,
|
|
17
17
|
SVMProvider,
|
|
18
18
|
getRandomSvmAddress,
|
|
19
|
-
bigToU8a32,
|
|
20
19
|
} from "../../arch/svm";
|
|
21
20
|
import { bnZero, bnOne, bs58, getCurrentTime, randomAddress, EvmAddress } from "../../utils";
|
|
22
21
|
import { FillType } from "../../interfaces";
|
|
@@ -80,7 +79,7 @@ export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
|
|
|
80
79
|
const inputToken = deposit.inputToken ?? getRandomSvmAddress();
|
|
81
80
|
const outputToken = deposit.outputToken ?? EvmAddress.from(randomAddress()).toBase58();
|
|
82
81
|
inputAmount ??= BigInt(random(1, 1000, false));
|
|
83
|
-
outputAmount ??=
|
|
82
|
+
outputAmount ??= (inputAmount * BigInt(95)) / BigInt(100);
|
|
84
83
|
const message = deposit.message ?? new Uint8Array(32);
|
|
85
84
|
const quoteTimestamp = deposit.quoteTimestamp ?? getCurrentTime();
|
|
86
85
|
|
|
@@ -112,9 +111,8 @@ export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
|
|
|
112
111
|
const { slot } = fill;
|
|
113
112
|
let { depositId, inputAmount, outputAmount, fillDeadline } = fill;
|
|
114
113
|
depositId ??= arrayify(hexZeroPad(hexlify(random(1, 100_000, false)), 32));
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
outputAmount ??= (inputAmountBigInt * BigInt(95)) / BigInt(100);
|
|
114
|
+
inputAmount ??= BigInt(random(1, 1000, false));
|
|
115
|
+
outputAmount ??= (inputAmount * BigInt(95)) / BigInt(100);
|
|
118
116
|
fillDeadline ??= getCurrentTime() + 60;
|
|
119
117
|
|
|
120
118
|
const depositor = fill.depositor ?? EvmAddress.from(randomAddress()).toBase58();
|
|
@@ -2,7 +2,15 @@ import winston from "winston";
|
|
|
2
2
|
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
3
3
|
import { Address } from "@solana/kit";
|
|
4
4
|
import { DepositWithBlock, RelayerRefundExecution, SortableEvent, SlowFillLeaf, Log } from "../../interfaces";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getCurrentTime,
|
|
7
|
+
bnZero,
|
|
8
|
+
MakeOptional,
|
|
9
|
+
EventSearchConfig,
|
|
10
|
+
Address as SDKAddress,
|
|
11
|
+
toAddressType,
|
|
12
|
+
isDefined,
|
|
13
|
+
} from "../../utils";
|
|
6
14
|
import { SpokePoolUpdate, SVMSpokePoolClient } from "../SpokePoolClient";
|
|
7
15
|
import { HubPoolClient } from "../HubPoolClient";
|
|
8
16
|
import { EventOverrides } from "./MockEvents";
|
|
@@ -46,8 +54,9 @@ export class MockSvmSpokePoolClient extends SVMSpokePoolClient {
|
|
|
46
54
|
this.destinationTokenForChainOverride[chainId] = token;
|
|
47
55
|
}
|
|
48
56
|
|
|
49
|
-
getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
50
|
-
|
|
57
|
+
getDestinationTokenForDeposit(deposit: DepositWithBlock): SDKAddress {
|
|
58
|
+
const override = this.destinationTokenForChainOverride[deposit.originChainId];
|
|
59
|
+
return isDefined(override) ? toAddressType(override, this.chainId) : super.getDestinationTokenForDeposit(deposit);
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
setLatestBlockNumber(blockNumber: number): void {
|