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