@across-protocol/sdk 4.2.16 → 4.3.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 +8 -3
- package/dist/cjs/arch/evm/SpokeUtils.js +26 -11
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +8 -2
- package/dist/cjs/arch/svm/SpokeUtils.js +41 -50
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +4 -2
- 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 +16 -14
- 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 +59 -59
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +16 -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 +71 -71
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +13 -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 +85 -58
- 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/SVMSpokePoolClient.js +1 -3
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +66 -46
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/cjs/clients/SpokePoolClient/index.js +3 -1
- package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/clients/index.d.ts +1 -1
- package/dist/cjs/clients/index.js +2 -1
- package/dist/cjs/clients/index.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 +6 -4
- 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 +19 -14
- package/dist/cjs/interfaces/SpokePool.d.ts +18 -19
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +17 -9
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +24 -15
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +13 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +61 -58
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +15 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +13 -13
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +12 -8
- package/dist/cjs/utils/AddressUtils.js +33 -36
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +2 -2
- package/dist/cjs/utils/DepositUtils.js +1 -1
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +1 -3
- package/dist/cjs/utils/SpokeUtils.js +3 -25
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +5 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/esm/arch/evm/SpokeUtils.js +29 -14
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -3
- package/dist/esm/arch/svm/SpokeUtils.js +42 -55
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +5 -3
- 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 +17 -15
- 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 +60 -60
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +18 -15
- 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 +7 -7
- 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 +71 -71
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +20 -10
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -22
- package/dist/esm/clients/HubPoolClient.js +93 -66
- 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/SVMSpokePoolClient.js +2 -4
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +69 -48
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/esm/clients/SpokePoolClient/index.js +1 -0
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/clients/index.d.ts +1 -1
- package/dist/esm/clients/index.js +1 -1
- package/dist/esm/clients/index.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 +7 -5
- 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 +19 -14
- package/dist/esm/interfaces/SpokePool.d.ts +18 -19
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +28 -19
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +9 -6
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +67 -63
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +12 -12
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +12 -8
- package/dist/esm/utils/AddressUtils.js +36 -38
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +2 -2
- package/dist/esm/utils/DepositUtils.js +2 -2
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +1 -8
- package/dist/esm/utils/SpokeUtils.js +3 -29
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +6 -18
- package/dist/esm/utils/TokenUtils.js +6 -4
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +9 -3
- 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 +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 +71 -71
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +22 -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/SVMSpokePoolClient.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/index.d.ts +1 -0
- package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
- package/dist/types/clients/index.d.ts +1 -1
- package/dist/types/clients/index.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 +2 -2
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +19 -14
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +18 -19
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +12 -8
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +2 -2
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +1 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +6 -18
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/arch/evm/SpokeUtils.ts +72 -22
- package/src/arch/svm/SpokeUtils.ts +67 -53
- package/src/arch/svm/eventsClient.ts +40 -8
- package/src/arch/svm/utils.ts +6 -6
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +56 -56
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +32 -15
- package/src/clients/BundleDataClient/utils/FillUtils.ts +12 -8
- 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 +22 -10
- package/src/clients/HubPoolClient.ts +125 -86
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -2
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +1 -4
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +122 -37
- package/src/clients/SpokePoolClient/index.ts +1 -0
- package/src/clients/index.ts +1 -0
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +8 -5
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +20 -14
- package/src/interfaces/SpokePool.ts +19 -19
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +39 -21
- package/src/relayFeeCalculator/chain-queries/factory.ts +8 -5
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +73 -58
- package/src/relayFeeCalculator/relayFeeCalculator.ts +23 -21
- package/src/utils/AddressUtils.ts +39 -51
- package/src/utils/DepositUtils.ts +4 -4
- package/src/utils/SpokeUtils.ts +8 -36
- package/src/utils/TokenUtils.ts +10 -8
|
@@ -2,7 +2,7 @@ import assert from "assert";
|
|
|
2
2
|
import { Contract, EventFilter } from "ethers";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
import winston from "winston";
|
|
5
|
-
import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL, TOKEN_SYMBOLS_MAP
|
|
5
|
+
import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL, TOKEN_SYMBOLS_MAP } from "../constants";
|
|
6
6
|
import {
|
|
7
7
|
CachingMechanismInterface,
|
|
8
8
|
CancelledRootBundle,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
DestinationTokenWithBlock,
|
|
13
13
|
DisputedRootBundle,
|
|
14
14
|
ExecutedRootBundle,
|
|
15
|
-
|
|
15
|
+
TokenInfo,
|
|
16
16
|
Log,
|
|
17
17
|
LpToken,
|
|
18
18
|
PendingRootBundle,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
RealizedLpFee,
|
|
21
21
|
SetPoolRebalanceRoot,
|
|
22
22
|
TokenRunningBalance,
|
|
23
|
+
L1TokenInfo,
|
|
23
24
|
} from "../interfaces";
|
|
24
25
|
import * as lpFeeCalculator from "../lpFeeCalculator";
|
|
25
26
|
import { EVMBlockFinder } from "../arch/evm";
|
|
@@ -43,10 +44,11 @@ import {
|
|
|
43
44
|
toBN,
|
|
44
45
|
getTokenInfo,
|
|
45
46
|
getUsdcSymbol,
|
|
46
|
-
compareAddressesSimple,
|
|
47
47
|
chainIsSvm,
|
|
48
48
|
getDeployedAddress,
|
|
49
49
|
SvmAddress,
|
|
50
|
+
EvmAddress,
|
|
51
|
+
Address,
|
|
50
52
|
} from "../utils";
|
|
51
53
|
import { AcrossConfigStoreClient as ConfigStoreClient } from "./AcrossConfigStoreClient/AcrossConfigStoreClient";
|
|
52
54
|
import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "./BaseAbstractClient";
|
|
@@ -84,7 +86,8 @@ export type LpFeeRequest = Pick<Deposit, "originChainId" | "inputToken" | "input
|
|
|
84
86
|
export class HubPoolClient extends BaseAbstractClient {
|
|
85
87
|
// L1Token -> destinationChainId -> destinationToken
|
|
86
88
|
protected l1TokensToDestinationTokens: L1TokensToDestinationTokens = {};
|
|
87
|
-
protected l1Tokens:
|
|
89
|
+
protected l1Tokens: L1TokenInfo[] = []; // L1Tokens and their associated info.
|
|
90
|
+
// @dev `token` here is a 20-byte hex sting
|
|
88
91
|
protected lpTokens: { [token: string]: LpToken } = {};
|
|
89
92
|
protected proposedRootBundles: ProposedRootBundle[] = [];
|
|
90
93
|
protected canceledRootBundles: CancelledRootBundle[] = [];
|
|
@@ -92,6 +95,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
92
95
|
protected executedRootBundles: ExecutedRootBundle[] = [];
|
|
93
96
|
protected crossChainContracts: { [l2ChainId: number]: CrossChainContractsSet[] } = {};
|
|
94
97
|
protected l1TokensToDestinationTokensWithBlock: {
|
|
98
|
+
// @dev `l1Token` here is a 20-byte hex sting
|
|
95
99
|
[l1Token: string]: { [destinationChainId: number]: DestinationTokenWithBlock[] };
|
|
96
100
|
} = {};
|
|
97
101
|
protected pendingRootBundle: PendingRootBundle | undefined;
|
|
@@ -160,7 +164,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
160
164
|
return this.executedRootBundles;
|
|
161
165
|
}
|
|
162
166
|
|
|
163
|
-
getSpokePoolForBlock(chain: number, block: number = Number.MAX_SAFE_INTEGER):
|
|
167
|
+
getSpokePoolForBlock(chain: number, block: number = Number.MAX_SAFE_INTEGER): Address {
|
|
164
168
|
if (!this.crossChainContracts[chain]) {
|
|
165
169
|
throw new Error(`No cross chain contracts set for ${chain}`);
|
|
166
170
|
}
|
|
@@ -174,33 +178,33 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
|
|
177
|
-
getSpokePoolActivationBlock(chain: number, spokePool:
|
|
181
|
+
getSpokePoolActivationBlock(chain: number, spokePool: Address): number | undefined {
|
|
178
182
|
// Return first time that this spoke pool was registered in the HubPool as a cross chain contract. We can use
|
|
179
183
|
// this block as the oldest block that we should query for SpokePoolClient purposes.
|
|
180
|
-
const mostRecentSpokePoolUpdateBeforeBlock = this.crossChainContracts[chain].find(
|
|
181
|
-
|
|
184
|
+
const mostRecentSpokePoolUpdateBeforeBlock = this.crossChainContracts[chain].find((crossChainContract) =>
|
|
185
|
+
crossChainContract.spokePool.eq(spokePool)
|
|
182
186
|
);
|
|
183
187
|
return mostRecentSpokePoolUpdateBeforeBlock?.blockNumber;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
// Returns the latest L2 token to use for an L1 token as of the input hub block.
|
|
187
191
|
getL2TokenForL1TokenAtBlock(
|
|
188
|
-
l1Token:
|
|
192
|
+
l1Token: EvmAddress,
|
|
189
193
|
destinationChainId: number,
|
|
190
194
|
latestHubBlock = Number.MAX_SAFE_INTEGER
|
|
191
|
-
):
|
|
192
|
-
if (!this.l1TokensToDestinationTokensWithBlock?.[l1Token]?.[destinationChainId]) {
|
|
195
|
+
): Address {
|
|
196
|
+
if (!this.l1TokensToDestinationTokensWithBlock?.[l1Token.toEvmAddress()]?.[destinationChainId]) {
|
|
193
197
|
const chain = getNetworkName(destinationChainId);
|
|
194
|
-
const { symbol } = this.l1Tokens.find(({ address }) => address
|
|
198
|
+
const { symbol } = this.l1Tokens.find(({ address }) => address.eq(l1Token)) ?? { symbol: l1Token.toString() };
|
|
195
199
|
throw new Error(`Could not find SpokePool mapping for ${symbol} on ${chain} and L1 token ${l1Token}`);
|
|
196
200
|
}
|
|
197
201
|
// Find the last mapping published before the target block.
|
|
198
202
|
const l2Token: DestinationTokenWithBlock | undefined = sortEventsDescending(
|
|
199
|
-
this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId]
|
|
203
|
+
this.l1TokensToDestinationTokensWithBlock[l1Token.toEvmAddress()][destinationChainId]
|
|
200
204
|
).find((mapping: DestinationTokenWithBlock) => mapping.blockNumber <= latestHubBlock);
|
|
201
205
|
if (!l2Token) {
|
|
202
206
|
const chain = getNetworkName(destinationChainId);
|
|
203
|
-
const { symbol } = this.l1Tokens.find(({ address }) => address
|
|
207
|
+
const { symbol } = this.l1Tokens.find(({ address }) => address.eq(l1Token)) ?? { symbol: l1Token.toString() };
|
|
204
208
|
throw new Error(
|
|
205
209
|
`Could not find SpokePool mapping for ${symbol} on ${chain} at or before HubPool block ${latestHubBlock}!`
|
|
206
210
|
);
|
|
@@ -210,16 +214,19 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
210
214
|
|
|
211
215
|
// Returns the latest L1 token to use for an L2 token as of the input hub block.
|
|
212
216
|
getL1TokenForL2TokenAtBlock(
|
|
213
|
-
l2Token:
|
|
217
|
+
l2Token: Address,
|
|
214
218
|
destinationChainId: number,
|
|
215
219
|
latestHubBlock = Number.MAX_SAFE_INTEGER
|
|
216
|
-
):
|
|
220
|
+
): EvmAddress {
|
|
217
221
|
const l2Tokens = Object.keys(this.l1TokensToDestinationTokensWithBlock)
|
|
218
|
-
.filter((l1Token) => this.l2TokenEnabledForL1Token(l1Token, destinationChainId))
|
|
222
|
+
.filter((l1Token) => this.l2TokenEnabledForL1Token(EvmAddress.from(l1Token), destinationChainId))
|
|
219
223
|
.map((l1Token) => {
|
|
220
224
|
// Return all matching L2 token mappings that are equal to or earlier than the target block.
|
|
225
|
+
// @dev Since tokens on L2s (like Solana) can have 32 byte addresses, filter on the lower 20 bytes of the token only.
|
|
221
226
|
return this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId].filter(
|
|
222
|
-
(
|
|
227
|
+
(dstTokenWithBlock) =>
|
|
228
|
+
dstTokenWithBlock.l2Token.truncateToBytes20() === l2Token.truncateToBytes20() &&
|
|
229
|
+
dstTokenWithBlock.blockNumber <= latestHubBlock
|
|
223
230
|
);
|
|
224
231
|
})
|
|
225
232
|
.flat();
|
|
@@ -235,32 +242,32 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
235
242
|
|
|
236
243
|
protected getL1TokenForDeposit(
|
|
237
244
|
deposit: Pick<DepositWithBlock, "originChainId" | "inputToken" | "quoteBlockNumber">
|
|
238
|
-
):
|
|
245
|
+
): EvmAddress {
|
|
239
246
|
// L1-->L2 token mappings are set via PoolRebalanceRoutes which occur on mainnet,
|
|
240
247
|
// so we use the latest token mapping. This way if a very old deposit is filled, the relayer can use the
|
|
241
248
|
// latest L2 token mapping to find the L1 token counterpart.
|
|
242
249
|
return this.getL1TokenForL2TokenAtBlock(deposit.inputToken, deposit.originChainId, deposit.quoteBlockNumber);
|
|
243
250
|
}
|
|
244
251
|
|
|
245
|
-
l2TokenEnabledForL1Token(l1Token:
|
|
246
|
-
return this.l1TokensToDestinationTokens?.[l1Token]?.[destinationChainId] != undefined;
|
|
252
|
+
l2TokenEnabledForL1Token(l1Token: EvmAddress, destinationChainId: number): boolean {
|
|
253
|
+
return this.l1TokensToDestinationTokens?.[l1Token.toEvmAddress()]?.[destinationChainId] != undefined;
|
|
247
254
|
}
|
|
248
255
|
|
|
249
|
-
l2TokenEnabledForL1TokenAtBlock(l1Token:
|
|
256
|
+
l2TokenEnabledForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, hubBlockNumber: number): boolean {
|
|
250
257
|
// Find the last mapping published before the target block.
|
|
251
258
|
const l2Token: DestinationTokenWithBlock | undefined = sortEventsDescending(
|
|
252
|
-
this.l1TokensToDestinationTokensWithBlock?.[l1Token]?.[destinationChainId] ?? []
|
|
259
|
+
this.l1TokensToDestinationTokensWithBlock?.[l1Token.toEvmAddress()]?.[destinationChainId] ?? []
|
|
253
260
|
).find((mapping: DestinationTokenWithBlock) => mapping.blockNumber <= hubBlockNumber);
|
|
254
261
|
return l2Token !== undefined;
|
|
255
262
|
}
|
|
256
263
|
|
|
257
|
-
l2TokenHasPoolRebalanceRoute(l2Token:
|
|
264
|
+
l2TokenHasPoolRebalanceRoute(l2Token: Address, l2ChainId: number, hubPoolBlock = this.latestHeightSearched): boolean {
|
|
258
265
|
return Object.values(this.l1TokensToDestinationTokensWithBlock).some((destinationTokenMapping) => {
|
|
259
266
|
return Object.entries(destinationTokenMapping).some(([_l2ChainId, setPoolRebalanceRouteEvents]) => {
|
|
260
267
|
return setPoolRebalanceRouteEvents.some((e) => {
|
|
261
268
|
return (
|
|
262
269
|
e.blockNumber <= hubPoolBlock &&
|
|
263
|
-
|
|
270
|
+
e.l2Token.truncateToBytes20() === l2Token.truncateToBytes20() &&
|
|
264
271
|
Number(_l2ChainId) === l2ChainId
|
|
265
272
|
);
|
|
266
273
|
});
|
|
@@ -271,15 +278,16 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
271
278
|
/**
|
|
272
279
|
* @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw.
|
|
273
280
|
* @param tokenAddress Token address on `chain`
|
|
274
|
-
* @param
|
|
281
|
+
* @param chainId Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP.
|
|
275
282
|
* @returns Token info for the given token address on the L2 chain including symbol and decimal.
|
|
276
283
|
*/
|
|
277
|
-
|
|
278
|
-
|
|
284
|
+
// TODO: didn't change `tokenAddress` here to Address because of downstream getTokenInfo impl
|
|
285
|
+
getTokenInfoForAddress(tokenAddress: string, chainId: number): TokenInfo {
|
|
286
|
+
const tokenInfo = getTokenInfo(tokenAddress, chainId);
|
|
279
287
|
// @dev Temporarily handle case where an L2 token for chain ID can map to more than one TOKEN_SYMBOLS_MAP
|
|
280
288
|
// entry. For example, L2 Bridged USDC maps to both the USDC and USDC.e/USDbC entries in TOKEN_SYMBOLS_MAP.
|
|
281
|
-
if (tokenInfo.symbol.toLowerCase() === "usdc" &&
|
|
282
|
-
tokenInfo.symbol = getUsdcSymbol(tokenAddress,
|
|
289
|
+
if (tokenInfo.symbol.toLowerCase() === "usdc" && chainId !== this.chainId) {
|
|
290
|
+
tokenInfo.symbol = getUsdcSymbol(tokenAddress, chainId) ?? "UNKNOWN";
|
|
283
291
|
}
|
|
284
292
|
return tokenInfo;
|
|
285
293
|
}
|
|
@@ -311,7 +319,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
311
319
|
return blockNumbers;
|
|
312
320
|
}
|
|
313
321
|
|
|
314
|
-
async getCurrentPoolUtilization(l1Token:
|
|
322
|
+
async getCurrentPoolUtilization(l1Token: EvmAddress): Promise<BigNumber> {
|
|
315
323
|
const blockNumber = this.latestHeightSearched ?? (await this.hubPool.provider.getBlockNumber());
|
|
316
324
|
return await this.getUtilization(l1Token, blockNumber, bnZero, getCurrentTime(), 0);
|
|
317
325
|
}
|
|
@@ -326,7 +334,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
326
334
|
* @returns HubPool utilization at `blockNumber` after optional `amount` increase in utilization.
|
|
327
335
|
*/
|
|
328
336
|
protected async getUtilization(
|
|
329
|
-
hubPoolToken:
|
|
337
|
+
hubPoolToken: EvmAddress,
|
|
330
338
|
blockNumber: number,
|
|
331
339
|
depositAmount: BigNumber,
|
|
332
340
|
timestamp: number,
|
|
@@ -337,10 +345,14 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
337
345
|
const overrides = { blockTag: blockNumber };
|
|
338
346
|
if (depositAmount.eq(0)) {
|
|
339
347
|
// For zero amount, just get the utilisation at `blockNumber`.
|
|
340
|
-
return await this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken, overrides);
|
|
348
|
+
return await this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken.toEvmAddress(), overrides);
|
|
341
349
|
}
|
|
342
350
|
|
|
343
|
-
return await this.hubPool.callStatic.liquidityUtilizationPostRelay(
|
|
351
|
+
return await this.hubPool.callStatic.liquidityUtilizationPostRelay(
|
|
352
|
+
hubPoolToken.toEvmAddress(),
|
|
353
|
+
depositAmount,
|
|
354
|
+
overrides
|
|
355
|
+
);
|
|
344
356
|
};
|
|
345
357
|
|
|
346
358
|
// Resolve the cache locally so that we can appease typescript
|
|
@@ -355,8 +367,8 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
355
367
|
// @note Avoid collisions with pre-existing cache keys by appending an underscore (_) for post-relay utilization.
|
|
356
368
|
// @fixme This can be removed once the existing keys have been ejected from the cache (i.e. 7 days).
|
|
357
369
|
const key = depositAmount.eq(0)
|
|
358
|
-
? `utilization_${hubPoolToken}_${blockNumber}`
|
|
359
|
-
: `utilization_${hubPoolToken}_${blockNumber}_${depositAmount.toString()}_`;
|
|
370
|
+
? `utilization_${hubPoolToken.toEvmAddress()}_${blockNumber}`
|
|
371
|
+
: `utilization_${hubPoolToken.toEvmAddress()}_${blockNumber}_${depositAmount.toString()}_`;
|
|
360
372
|
const result = await cache.get<string>(key);
|
|
361
373
|
if (isDefined(result)) {
|
|
362
374
|
return BigNumber.from(result);
|
|
@@ -393,14 +405,14 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
393
405
|
|
|
394
406
|
// Map SpokePool token addresses to HubPool token addresses.
|
|
395
407
|
// Note: Should only be accessed via `getHubPoolToken()` or `getHubPoolTokens()`.
|
|
396
|
-
const hubPoolTokens: { [k: string]:
|
|
397
|
-
const getHubPoolToken = (deposit: LpFeeRequest, quoteBlockNumber: number):
|
|
408
|
+
const hubPoolTokens: { [k: string]: EvmAddress } = {};
|
|
409
|
+
const getHubPoolToken = (deposit: LpFeeRequest, quoteBlockNumber: number): EvmAddress | undefined => {
|
|
398
410
|
const tokenKey = `${deposit.originChainId}-${deposit.inputToken}`;
|
|
399
411
|
if (this.l2TokenHasPoolRebalanceRoute(deposit.inputToken, deposit.originChainId, quoteBlockNumber)) {
|
|
400
412
|
return (hubPoolTokens[tokenKey] ??= this.getL1TokenForDeposit({ ...deposit, quoteBlockNumber }));
|
|
401
413
|
} else return undefined;
|
|
402
414
|
};
|
|
403
|
-
const getHubPoolTokens = ():
|
|
415
|
+
const getHubPoolTokens = (): EvmAddress[] => dedupArray(Object.values(hubPoolTokens).filter(isDefined));
|
|
404
416
|
|
|
405
417
|
// Helper to resolve the unqiue hubPoolToken & quoteTimestamp mappings.
|
|
406
418
|
const resolveUniqueQuoteTimestamps = (deposit: LpFeeRequest): void => {
|
|
@@ -414,17 +426,17 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
414
426
|
}
|
|
415
427
|
|
|
416
428
|
// Append the quoteTimestamp for this HubPool token, if it isn't already enqueued.
|
|
417
|
-
utilizationTimestamps[hubPoolToken] ??= [];
|
|
418
|
-
if (!utilizationTimestamps[hubPoolToken].includes(quoteTimestamp)) {
|
|
419
|
-
utilizationTimestamps[hubPoolToken].push(quoteTimestamp);
|
|
429
|
+
utilizationTimestamps[hubPoolToken.toEvmAddress()] ??= [];
|
|
430
|
+
if (!utilizationTimestamps[hubPoolToken.toEvmAddress()].includes(quoteTimestamp)) {
|
|
431
|
+
utilizationTimestamps[hubPoolToken.toEvmAddress()].push(quoteTimestamp);
|
|
420
432
|
}
|
|
421
433
|
};
|
|
422
434
|
|
|
423
435
|
// Helper to resolve existing HubPool token utilisation for an array of unique block numbers.
|
|
424
436
|
// Produces a mapping of blockNumber -> utilization for a specific token.
|
|
425
|
-
const resolveUtilization = async (hubPoolToken:
|
|
437
|
+
const resolveUtilization = async (hubPoolToken: EvmAddress): Promise<Record<number, BigNumber>> => {
|
|
426
438
|
return Object.fromEntries(
|
|
427
|
-
await mapAsync(utilizationTimestamps[hubPoolToken], async (quoteTimestamp) => {
|
|
439
|
+
await mapAsync(utilizationTimestamps[hubPoolToken.toEvmAddress()], async (quoteTimestamp) => {
|
|
428
440
|
const blockNumber = quoteBlocks[quoteTimestamp];
|
|
429
441
|
const utilization = await this.getUtilization(
|
|
430
442
|
hubPoolToken,
|
|
@@ -460,7 +472,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
460
472
|
quoteBlock
|
|
461
473
|
);
|
|
462
474
|
|
|
463
|
-
const preUtilization = utilization[hubPoolToken][quoteBlock];
|
|
475
|
+
const preUtilization = utilization[hubPoolToken.toEvmAddress()][quoteBlock];
|
|
464
476
|
const postUtilization = await this.getUtilization(
|
|
465
477
|
hubPoolToken,
|
|
466
478
|
quoteBlock,
|
|
@@ -488,7 +500,10 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
488
500
|
// For each token / quoteBlock pair, resolve the utilisation for each quoted block.
|
|
489
501
|
// This can be reused for each deposit with the same HubPool token and quoteTimestamp pair.
|
|
490
502
|
utilization = Object.fromEntries(
|
|
491
|
-
await mapAsync(getHubPoolTokens(), async (hubPoolToken) => [
|
|
503
|
+
await mapAsync(getHubPoolTokens(), async (hubPoolToken) => [
|
|
504
|
+
hubPoolToken.toEvmAddress(),
|
|
505
|
+
await resolveUtilization(hubPoolToken),
|
|
506
|
+
])
|
|
492
507
|
);
|
|
493
508
|
|
|
494
509
|
// For each deposit, compute the post-relay HubPool utilisation independently.
|
|
@@ -506,22 +521,22 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
506
521
|
});
|
|
507
522
|
}
|
|
508
523
|
|
|
509
|
-
getL1Tokens():
|
|
524
|
+
getL1Tokens(): L1TokenInfo[] {
|
|
510
525
|
return this.l1Tokens;
|
|
511
526
|
}
|
|
512
527
|
|
|
513
|
-
getTokenInfoForL1Token(l1Token:
|
|
514
|
-
return this.l1Tokens.find((token) => token.address
|
|
528
|
+
getTokenInfoForL1Token(l1Token: EvmAddress): L1TokenInfo | undefined {
|
|
529
|
+
return this.l1Tokens.find((token) => token.address.eq(l1Token));
|
|
515
530
|
}
|
|
516
531
|
|
|
517
|
-
getLpTokenInfoForL1Token(l1Token:
|
|
518
|
-
return this.lpTokens[l1Token];
|
|
532
|
+
getLpTokenInfoForL1Token(l1Token: EvmAddress): LpToken | undefined {
|
|
533
|
+
return this.lpTokens[l1Token.toEvmAddress()];
|
|
519
534
|
}
|
|
520
535
|
|
|
521
536
|
areTokensEquivalent(
|
|
522
|
-
tokenA:
|
|
537
|
+
tokenA: Address,
|
|
523
538
|
chainIdA: number,
|
|
524
|
-
tokenB:
|
|
539
|
+
tokenB: Address,
|
|
525
540
|
chainIdB: number,
|
|
526
541
|
hubPoolBlock = this.latestHeightSearched
|
|
527
542
|
): boolean {
|
|
@@ -534,14 +549,14 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
534
549
|
// Resolve both SpokePool tokens back to their respective HubPool tokens and verify that they match.
|
|
535
550
|
const l1TokenA = this.getL1TokenForL2TokenAtBlock(tokenA, chainIdA, hubPoolBlock);
|
|
536
551
|
const l1TokenB = this.getL1TokenForL2TokenAtBlock(tokenB, chainIdB, hubPoolBlock);
|
|
537
|
-
if (l1TokenA
|
|
552
|
+
if (!l1TokenA.eq(l1TokenB)) {
|
|
538
553
|
return false;
|
|
539
554
|
}
|
|
540
555
|
|
|
541
556
|
// Resolve both HubPool tokens back to a current SpokePool token and verify that they match.
|
|
542
557
|
const _tokenA = this.getL2TokenForL1TokenAtBlock(l1TokenA, chainIdA, hubPoolBlock);
|
|
543
558
|
const _tokenB = this.getL2TokenForL1TokenAtBlock(l1TokenB, chainIdB, hubPoolBlock);
|
|
544
|
-
return tokenA
|
|
559
|
+
return tokenA.eq(_tokenA) && tokenB.eq(_tokenB);
|
|
545
560
|
}
|
|
546
561
|
|
|
547
562
|
getSpokeActivationBlockForChain(chainId: number): number {
|
|
@@ -778,34 +793,34 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
778
793
|
getLatestExecutedRootBundleContainingL1Token(
|
|
779
794
|
block: number,
|
|
780
795
|
chain: number,
|
|
781
|
-
l1Token:
|
|
796
|
+
l1Token: EvmAddress
|
|
782
797
|
): ExecutedRootBundle | undefined {
|
|
783
798
|
// Search ExecutedRootBundles in descending block order to find the most recent event before the target block.
|
|
784
799
|
return sortEventsDescending(this.executedRootBundles).find((executedLeaf: ExecutedRootBundle) => {
|
|
785
800
|
return (
|
|
786
801
|
executedLeaf.blockNumber <= block &&
|
|
787
802
|
executedLeaf.chainId === chain &&
|
|
788
|
-
executedLeaf.l1Tokens.some((token) => token.
|
|
803
|
+
executedLeaf.l1Tokens.some((token) => token.eq(l1Token))
|
|
789
804
|
);
|
|
790
805
|
});
|
|
791
806
|
}
|
|
792
807
|
|
|
793
|
-
getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token:
|
|
808
|
+
getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: EvmAddress): TokenRunningBalance {
|
|
794
809
|
const executedRootBundle = this.getLatestExecutedRootBundleContainingL1Token(block, chain, l1Token);
|
|
795
810
|
|
|
796
811
|
return this.getRunningBalanceForToken(l1Token, executedRootBundle);
|
|
797
812
|
}
|
|
798
813
|
|
|
799
814
|
public getRunningBalanceForToken(
|
|
800
|
-
l1Token:
|
|
815
|
+
l1Token: EvmAddress,
|
|
801
816
|
executedRootBundle: ExecutedRootBundle | undefined
|
|
802
817
|
): TokenRunningBalance {
|
|
803
818
|
let runningBalance = toBN(0);
|
|
804
819
|
if (executedRootBundle) {
|
|
805
|
-
const indexOfL1Token = executedRootBundle.l1Tokens
|
|
806
|
-
|
|
807
|
-
.
|
|
808
|
-
|
|
820
|
+
const indexOfL1Token = executedRootBundle.l1Tokens.findIndex((tokenInBundle) => tokenInBundle.eq(l1Token));
|
|
821
|
+
if (indexOfL1Token !== -1) {
|
|
822
|
+
runningBalance = executedRootBundle.runningBalances[indexOfL1Token];
|
|
823
|
+
}
|
|
809
824
|
}
|
|
810
825
|
|
|
811
826
|
return { runningBalance };
|
|
@@ -873,7 +888,10 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
873
888
|
return {
|
|
874
889
|
success: true,
|
|
875
890
|
currentTime,
|
|
876
|
-
pendingRootBundleProposal
|
|
891
|
+
pendingRootBundleProposal: {
|
|
892
|
+
...pendingRootBundleProposal,
|
|
893
|
+
proposer: EvmAddress.from(pendingRootBundleProposal.proposer),
|
|
894
|
+
},
|
|
877
895
|
searchEndBlock: searchConfig.to,
|
|
878
896
|
events: _events,
|
|
879
897
|
};
|
|
@@ -898,25 +916,25 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
898
916
|
|
|
899
917
|
if (eventsToQuery.includes("CrossChainContractsSet")) {
|
|
900
918
|
for (const event of events["CrossChainContractsSet"]) {
|
|
901
|
-
const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet;
|
|
919
|
+
const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet & { spokePool: string };
|
|
902
920
|
const dataToAdd: CrossChainContractsSet = {
|
|
903
|
-
spokePool: args.spokePool,
|
|
921
|
+
spokePool: EvmAddress.from(args.spokePool),
|
|
904
922
|
blockNumber: args.blockNumber,
|
|
905
923
|
txnRef: args.txnRef,
|
|
906
924
|
logIndex: args.logIndex,
|
|
907
925
|
txnIndex: args.txnIndex,
|
|
908
926
|
l2ChainId: args.l2ChainId,
|
|
909
927
|
};
|
|
910
|
-
|
|
911
|
-
//
|
|
912
|
-
//
|
|
913
|
-
// address by using the `getDeployedAddress` function.
|
|
928
|
+
|
|
929
|
+
// If the chain is SVM then the resulting SpokePool address will be inferred based on the lower 20
|
|
930
|
+
// bytes of the address. Matching addresses will be promoted to a full 32-byte SvmAddress type.
|
|
914
931
|
if (chainIsSvm(args.l2ChainId)) {
|
|
915
932
|
const solanaSpokePool = getDeployedAddress("SvmSpoke", args.l2ChainId);
|
|
916
933
|
if (!solanaSpokePool) {
|
|
917
934
|
throw new Error(`SVM spoke pool not found for chain ${args.l2ChainId}`);
|
|
918
935
|
}
|
|
919
|
-
const
|
|
936
|
+
const svmSpoke = SvmAddress.from(solanaSpokePool);
|
|
937
|
+
const truncatedAddress = svmSpoke.truncateToBytes20();
|
|
920
938
|
// Verify the event address matches our expected truncated address
|
|
921
939
|
if (args.spokePool.toLowerCase() !== truncatedAddress.toLowerCase()) {
|
|
922
940
|
throw new Error(
|
|
@@ -924,8 +942,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
924
942
|
`Expected ${truncatedAddress}, got ${args.spokePool}`
|
|
925
943
|
);
|
|
926
944
|
}
|
|
927
|
-
|
|
928
|
-
dataToAdd.spokePool = SvmAddress.from(solanaSpokePool).toBytes32();
|
|
945
|
+
dataToAdd.spokePool = svmSpoke;
|
|
929
946
|
}
|
|
930
947
|
assign(this.crossChainContracts, [args.l2ChainId], [dataToAdd]);
|
|
931
948
|
}
|
|
@@ -933,34 +950,37 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
933
950
|
|
|
934
951
|
if (eventsToQuery.includes("SetPoolRebalanceRoute")) {
|
|
935
952
|
for (const event of events["SetPoolRebalanceRoute"]) {
|
|
936
|
-
const args = spreadEventWithBlockNumber(event) as SetPoolRebalanceRoot
|
|
953
|
+
const args = spreadEventWithBlockNumber(event) as SetPoolRebalanceRoot & {
|
|
954
|
+
l1Token: string;
|
|
955
|
+
destinationToken: string;
|
|
956
|
+
};
|
|
937
957
|
|
|
938
958
|
// If the destination chain is SVM, then we need to convert the destination token to the Solana address.
|
|
939
959
|
// This is because the HubPool contract only holds a truncated address for the USDC token and currently
|
|
940
960
|
// only supports USDC as a destination token for Solana.
|
|
941
|
-
let destinationToken = args.destinationToken;
|
|
961
|
+
let destinationToken: Address = EvmAddress.from(args.destinationToken);
|
|
942
962
|
if (chainIsSvm(args.destinationChainId)) {
|
|
943
963
|
const usdcTokenSol = TOKEN_SYMBOLS_MAP.USDC.addresses[args.destinationChainId];
|
|
944
|
-
const
|
|
945
|
-
if (destinationToken.
|
|
964
|
+
const svmUsdc = SvmAddress.from(usdcTokenSol);
|
|
965
|
+
if (destinationToken.truncateToBytes20() !== svmUsdc.truncateToBytes20()) {
|
|
946
966
|
throw new Error(
|
|
947
967
|
`SVM USDC address mismatch for chain ${args.destinationChainId}. ` +
|
|
948
|
-
`Expected ${
|
|
968
|
+
`Expected ${svmUsdc.truncateToBytes20()}, got ${destinationToken}`
|
|
949
969
|
);
|
|
950
970
|
}
|
|
951
|
-
destinationToken =
|
|
971
|
+
destinationToken = svmUsdc;
|
|
952
972
|
}
|
|
953
973
|
|
|
954
974
|
// If the destination token is set to the zero address in an event, then this means Across should no longer
|
|
955
975
|
// rebalance to this chain.
|
|
956
|
-
if (destinationToken
|
|
976
|
+
if (!destinationToken.isZeroAddress()) {
|
|
957
977
|
assign(this.l1TokensToDestinationTokens, [args.l1Token, args.destinationChainId], destinationToken);
|
|
958
978
|
assign(
|
|
959
979
|
this.l1TokensToDestinationTokensWithBlock,
|
|
960
980
|
[args.l1Token, args.destinationChainId],
|
|
961
981
|
[
|
|
962
982
|
{
|
|
963
|
-
l1Token: args.l1Token,
|
|
983
|
+
l1Token: EvmAddress.from(args.l1Token),
|
|
964
984
|
l2Token: destinationToken,
|
|
965
985
|
blockNumber: args.blockNumber,
|
|
966
986
|
txnIndex: args.txnIndex,
|
|
@@ -982,7 +1002,15 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
982
1002
|
);
|
|
983
1003
|
|
|
984
1004
|
const [tokenInfo, lpTokenInfo] = await Promise.all([
|
|
985
|
-
Promise.all(
|
|
1005
|
+
Promise.all(
|
|
1006
|
+
uniqueL1Tokens.map(async (l1Token: string) => {
|
|
1007
|
+
const tokenInfo = await fetchTokenInfo(l1Token, this.hubPool.provider);
|
|
1008
|
+
return {
|
|
1009
|
+
...tokenInfo,
|
|
1010
|
+
address: EvmAddress.from(l1Token),
|
|
1011
|
+
};
|
|
1012
|
+
})
|
|
1013
|
+
),
|
|
986
1014
|
Promise.all(
|
|
987
1015
|
uniqueL1Tokens.map(
|
|
988
1016
|
async (l1Token: string) => await this.hubPool.pooledTokens(l1Token, { blockTag: update.searchEndBlock })
|
|
@@ -990,7 +1018,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
990
1018
|
),
|
|
991
1019
|
]);
|
|
992
1020
|
for (const info of tokenInfo) {
|
|
993
|
-
if (!this.l1Tokens.find((token) =>
|
|
1021
|
+
if (!this.l1Tokens.find((token) => token.address.eq(info.address))) {
|
|
994
1022
|
if (info.decimals > 0 && info.decimals <= 18) {
|
|
995
1023
|
this.l1Tokens.push(info);
|
|
996
1024
|
} else {
|
|
@@ -1011,7 +1039,13 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1011
1039
|
this.proposedRootBundles.push(
|
|
1012
1040
|
...events["ProposeRootBundle"]
|
|
1013
1041
|
.filter((event) => !this.configOverride.ignoredHubProposedBundles.includes(event.blockNumber))
|
|
1014
|
-
.map((
|
|
1042
|
+
.map((_event) => {
|
|
1043
|
+
const args = spreadEventWithBlockNumber(_event) as ProposedRootBundle & { proposer: string };
|
|
1044
|
+
return {
|
|
1045
|
+
...args,
|
|
1046
|
+
proposer: EvmAddress.from(args.proposer),
|
|
1047
|
+
};
|
|
1048
|
+
})
|
|
1015
1049
|
);
|
|
1016
1050
|
}
|
|
1017
1051
|
|
|
@@ -1034,7 +1068,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1034
1068
|
}
|
|
1035
1069
|
|
|
1036
1070
|
// Set running balances and incentive balances for this bundle.
|
|
1037
|
-
const executedRootBundle = spreadEventWithBlockNumber(event) as ExecutedRootBundle;
|
|
1071
|
+
const executedRootBundle = spreadEventWithBlockNumber(event) as ExecutedRootBundle & { l1Tokens: string[] };
|
|
1038
1072
|
const { l1Tokens, runningBalances } = executedRootBundle;
|
|
1039
1073
|
const nTokens = l1Tokens.length;
|
|
1040
1074
|
|
|
@@ -1046,7 +1080,12 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1046
1080
|
);
|
|
1047
1081
|
}
|
|
1048
1082
|
executedRootBundle.runningBalances = runningBalances.slice(0, nTokens);
|
|
1049
|
-
this.executedRootBundles.push(
|
|
1083
|
+
this.executedRootBundles.push({
|
|
1084
|
+
...executedRootBundle,
|
|
1085
|
+
l1Tokens: l1Tokens.map((token: string) => {
|
|
1086
|
+
return EvmAddress.from(token, "base16");
|
|
1087
|
+
}),
|
|
1088
|
+
});
|
|
1050
1089
|
}
|
|
1051
1090
|
}
|
|
1052
1091
|
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
DepositSearchResult,
|
|
14
14
|
getNetworkName,
|
|
15
15
|
InvalidFill,
|
|
16
|
-
isZeroAddress,
|
|
17
16
|
MakeOptional,
|
|
18
17
|
toBN,
|
|
19
18
|
EvmAddress,
|
|
19
|
+
toAddressType,
|
|
20
20
|
} from "../../utils";
|
|
21
21
|
import {
|
|
22
22
|
EventSearchConfig,
|
|
@@ -194,13 +194,18 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
194
194
|
|
|
195
195
|
deposit = {
|
|
196
196
|
...spreadEventWithBlockNumber(event),
|
|
197
|
+
inputToken: toAddressType(event.args.inputToken, event.args.originChainId),
|
|
198
|
+
outputToken: toAddressType(event.args.outputToken, event.args.destinationChainId),
|
|
199
|
+
depositor: toAddressType(event.args.depositor, this.chainId),
|
|
200
|
+
recipient: toAddressType(event.args.recipient, event.args.destinationChainId),
|
|
201
|
+
exclusiveRelayer: toAddressType(event.args.exclusiveRelayer, event.args.destinationChainId),
|
|
197
202
|
originChainId: this.chainId,
|
|
198
203
|
quoteBlockNumber: await this.getBlockNumber(Number(event.args["quoteTimestamp"])),
|
|
199
204
|
fromLiteChain: true, // To be updated immediately afterwards.
|
|
200
205
|
toLiteChain: true, // To be updated immediately afterwards.
|
|
201
206
|
} as DepositWithBlock;
|
|
202
207
|
|
|
203
|
-
if (
|
|
208
|
+
if (deposit.outputToken.isZeroAddress()) {
|
|
204
209
|
deposit.outputToken = this.getDestinationTokenForDeposit(deposit);
|
|
205
210
|
}
|
|
206
211
|
deposit.fromLiteChain = this.isOriginLiteChain(deposit);
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
DepositSearchResult,
|
|
18
18
|
EventSearchConfig,
|
|
19
19
|
InvalidFill,
|
|
20
|
-
isZeroAddress,
|
|
21
20
|
MakeOptional,
|
|
22
21
|
sortEventsAscendingInPlace,
|
|
23
22
|
SvmAddress,
|
|
@@ -214,6 +213,7 @@ export class SVMSpokePoolClient extends SpokePoolClient {
|
|
|
214
213
|
reason: `Deposit with ID ${depositId} not found`,
|
|
215
214
|
};
|
|
216
215
|
}
|
|
216
|
+
|
|
217
217
|
// Because we have additional context about this deposit, we can enrich it
|
|
218
218
|
// with additional information.
|
|
219
219
|
return {
|
|
@@ -224,9 +224,6 @@ export class SVMSpokePoolClient extends SpokePoolClient {
|
|
|
224
224
|
originChainId: this.chainId,
|
|
225
225
|
fromLiteChain: this.isOriginLiteChain(deposit),
|
|
226
226
|
toLiteChain: this.isDestinationLiteChain(deposit),
|
|
227
|
-
outputToken: isZeroAddress(deposit.outputToken)
|
|
228
|
-
? this.getDestinationTokenForDeposit(deposit)
|
|
229
|
-
: deposit.outputToken,
|
|
230
227
|
},
|
|
231
228
|
};
|
|
232
229
|
}
|