@across-protocol/sdk 4.2.16 → 4.3.0
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 +60 -56
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +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 +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 +65 -45
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +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 +15 -7
- 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.js +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +12 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +46 -44
- 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 +12 -8
- package/dist/cjs/utils/AddressUtils.js +33 -36
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
- package/dist/cjs/utils/SpokeUtils.js +4 -22
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +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 +61 -57
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +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 +91 -62
- 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 +68 -47
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +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 +18 -10
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +29 -20
- 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 +14 -6
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +51 -48
- 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 +12 -8
- package/dist/esm/utils/AddressUtils.js +36 -38
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +3 -8
- package/dist/esm/utils/SpokeUtils.js +4 -26
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +22 -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/SpokePoolClient.d.ts +2 -2
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +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 +18 -10
- 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 +14 -6
- 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 +12 -8
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +3 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +22 -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 +57 -53
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- 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 +123 -82
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +6 -0
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +121 -35
- 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 -20
- package/src/relayFeeCalculator/chain-queries/factory.ts +2 -2
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +57 -56
- package/src/relayFeeCalculator/relayFeeCalculator.ts +15 -13
- package/src/utils/AddressUtils.ts +39 -51
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +10 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Contract, EventFilter } from "ethers";
|
|
2
2
|
import winston from "winston";
|
|
3
|
-
import { CachingMechanismInterface, CancelledRootBundle, CrossChainContractsSet, Deposit, DepositWithBlock, DestinationTokenWithBlock, DisputedRootBundle, ExecutedRootBundle,
|
|
3
|
+
import { CachingMechanismInterface, CancelledRootBundle, CrossChainContractsSet, Deposit, DepositWithBlock, DestinationTokenWithBlock, DisputedRootBundle, ExecutedRootBundle, TokenInfo, Log, LpToken, PendingRootBundle, ProposedRootBundle, RealizedLpFee, TokenRunningBalance, L1TokenInfo } from "../interfaces";
|
|
4
4
|
import { EVMBlockFinder } from "../arch/evm";
|
|
5
|
-
import { BigNumber, EventSearchConfig, MakeOptional } from "../utils";
|
|
5
|
+
import { BigNumber, EventSearchConfig, MakeOptional, EvmAddress, Address } from "../utils";
|
|
6
6
|
import { AcrossConfigStoreClient as ConfigStoreClient } from "./AcrossConfigStoreClient/AcrossConfigStoreClient";
|
|
7
7
|
import { BaseAbstractClient, UpdateFailureReason } from "./BaseAbstractClient";
|
|
8
8
|
type HubPoolUpdateSuccess = {
|
|
@@ -38,7 +38,7 @@ export declare class HubPoolClient extends BaseAbstractClient {
|
|
|
38
38
|
timeToCache?: number;
|
|
39
39
|
};
|
|
40
40
|
protected l1TokensToDestinationTokens: L1TokensToDestinationTokens;
|
|
41
|
-
protected l1Tokens:
|
|
41
|
+
protected l1Tokens: L1TokenInfo[];
|
|
42
42
|
protected lpTokens: {
|
|
43
43
|
[token: string]: LpToken;
|
|
44
44
|
};
|
|
@@ -69,21 +69,21 @@ export declare class HubPoolClient extends BaseAbstractClient {
|
|
|
69
69
|
getCancelledRootBundles(): CancelledRootBundle[];
|
|
70
70
|
getDisputedRootBundles(): DisputedRootBundle[];
|
|
71
71
|
getExecutedRootBundles(): ExecutedRootBundle[];
|
|
72
|
-
getSpokePoolForBlock(chain: number, block?: number):
|
|
73
|
-
getSpokePoolActivationBlock(chain: number, spokePool:
|
|
74
|
-
getL2TokenForL1TokenAtBlock(l1Token:
|
|
75
|
-
getL1TokenForL2TokenAtBlock(l2Token:
|
|
76
|
-
protected getL1TokenForDeposit(deposit: Pick<DepositWithBlock, "originChainId" | "inputToken" | "quoteBlockNumber">):
|
|
77
|
-
l2TokenEnabledForL1Token(l1Token:
|
|
78
|
-
l2TokenEnabledForL1TokenAtBlock(l1Token:
|
|
79
|
-
l2TokenHasPoolRebalanceRoute(l2Token:
|
|
72
|
+
getSpokePoolForBlock(chain: number, block?: number): Address;
|
|
73
|
+
getSpokePoolActivationBlock(chain: number, spokePool: Address): number | undefined;
|
|
74
|
+
getL2TokenForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, latestHubBlock?: number): Address;
|
|
75
|
+
getL1TokenForL2TokenAtBlock(l2Token: Address, destinationChainId: number, latestHubBlock?: number): EvmAddress;
|
|
76
|
+
protected getL1TokenForDeposit(deposit: Pick<DepositWithBlock, "originChainId" | "inputToken" | "quoteBlockNumber">): EvmAddress;
|
|
77
|
+
l2TokenEnabledForL1Token(l1Token: EvmAddress, destinationChainId: number): boolean;
|
|
78
|
+
l2TokenEnabledForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, hubBlockNumber: number): boolean;
|
|
79
|
+
l2TokenHasPoolRebalanceRoute(l2Token: Address, l2ChainId: number, hubPoolBlock?: number): boolean;
|
|
80
80
|
/**
|
|
81
81
|
* @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw.
|
|
82
82
|
* @param tokenAddress Token address on `chain`
|
|
83
|
-
* @param
|
|
83
|
+
* @param chainId Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP.
|
|
84
84
|
* @returns Token info for the given token address on the L2 chain including symbol and decimal.
|
|
85
85
|
*/
|
|
86
|
-
getTokenInfoForAddress(tokenAddress: string,
|
|
86
|
+
getTokenInfoForAddress(tokenAddress: string, chainId: number): TokenInfo;
|
|
87
87
|
/**
|
|
88
88
|
* Resolve a given timestamp to a block number on the HubPool chain.
|
|
89
89
|
* @param timestamp A single timestamp to be resolved to a block number on the HubPool chain.
|
|
@@ -100,7 +100,7 @@ export declare class HubPoolClient extends BaseAbstractClient {
|
|
|
100
100
|
getBlockNumbers(timestamps: number[]): Promise<{
|
|
101
101
|
[quoteTimestamp: number]: number;
|
|
102
102
|
}>;
|
|
103
|
-
getCurrentPoolUtilization(l1Token:
|
|
103
|
+
getCurrentPoolUtilization(l1Token: EvmAddress): Promise<BigNumber>;
|
|
104
104
|
/**
|
|
105
105
|
* For a HubPool token at a specific block number, compute the relevant utilization.
|
|
106
106
|
* @param hubPoolToken HubPool token to query utilization for.
|
|
@@ -110,13 +110,13 @@ export declare class HubPoolClient extends BaseAbstractClient {
|
|
|
110
110
|
* @param timeToCache Age at which the response is able to be cached.
|
|
111
111
|
* @returns HubPool utilization at `blockNumber` after optional `amount` increase in utilization.
|
|
112
112
|
*/
|
|
113
|
-
protected getUtilization(hubPoolToken:
|
|
113
|
+
protected getUtilization(hubPoolToken: EvmAddress, blockNumber: number, depositAmount: BigNumber, timestamp: number, timeToCache: number): Promise<BigNumber>;
|
|
114
114
|
computeRealizedLpFeePct(deposit: LpFeeRequest): Promise<RealizedLpFee>;
|
|
115
115
|
batchComputeRealizedLpFeePct(deposits: LpFeeRequest[]): Promise<RealizedLpFee[]>;
|
|
116
|
-
getL1Tokens():
|
|
117
|
-
getTokenInfoForL1Token(l1Token:
|
|
118
|
-
getLpTokenInfoForL1Token(l1Token:
|
|
119
|
-
areTokensEquivalent(tokenA:
|
|
116
|
+
getL1Tokens(): L1TokenInfo[];
|
|
117
|
+
getTokenInfoForL1Token(l1Token: EvmAddress): L1TokenInfo | undefined;
|
|
118
|
+
getLpTokenInfoForL1Token(l1Token: EvmAddress): LpToken | undefined;
|
|
119
|
+
areTokensEquivalent(tokenA: Address, chainIdA: number, tokenB: Address, chainIdB: number, hubPoolBlock?: number): boolean;
|
|
120
120
|
getSpokeActivationBlockForChain(chainId: number): number;
|
|
121
121
|
isRootBundleValid(rootBundle: ProposedRootBundle, latestMainnetBlock: number): boolean;
|
|
122
122
|
getRootBundleEvalBlockNumberContainingBlock(latestMainnetBlock: number, block: number, chain: number, chainIdListOverride?: number[]): number | undefined;
|
|
@@ -142,9 +142,9 @@ export declare class HubPoolClient extends BaseAbstractClient {
|
|
|
142
142
|
getNthFullyExecutedRootBundle(n: number, startBlock?: number): ProposedRootBundle | undefined;
|
|
143
143
|
getLatestBundleEndBlockForChain(chainIdList: number[], latestMainnetBlock: number, chainId: number): number;
|
|
144
144
|
getNextBundleStartBlockNumber(chainIdList: number[], latestMainnetBlock: number, chainId: number): number;
|
|
145
|
-
getLatestExecutedRootBundleContainingL1Token(block: number, chain: number, l1Token:
|
|
146
|
-
getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token:
|
|
147
|
-
getRunningBalanceForToken(l1Token:
|
|
145
|
+
getLatestExecutedRootBundleContainingL1Token(block: number, chain: number, l1Token: EvmAddress): ExecutedRootBundle | undefined;
|
|
146
|
+
getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: EvmAddress): TokenRunningBalance;
|
|
147
|
+
getRunningBalanceForToken(l1Token: EvmAddress, executedRootBundle: ExecutedRootBundle | undefined): TokenRunningBalance;
|
|
148
148
|
_update(eventNames: HubPoolEvent[]): Promise<HubPoolUpdate>;
|
|
149
149
|
update(eventsToQuery?: HubPoolEvent[]): Promise<void>;
|
|
150
150
|
protected getBundleEndBlockForChain(proposeRootBundleEvent: ProposedRootBundle, chainId: number, chainIdList: number[]): number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __assign, __awaiter, __extends, __generator, __spreadArray } from "tslib";
|
|
2
2
|
import assert from "assert";
|
|
3
3
|
import _ from "lodash";
|
|
4
|
-
import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL, TOKEN_SYMBOLS_MAP
|
|
4
|
+
import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL, TOKEN_SYMBOLS_MAP } from "../constants";
|
|
5
5
|
import * as lpFeeCalculator from "../lpFeeCalculator";
|
|
6
6
|
import { EVMBlockFinder } from "../arch/evm";
|
|
7
|
-
import { BigNumber, bnZero, dedupArray, assign, fetchTokenInfo, getCachedBlockForTimestamp, getCurrentTime, getNetworkName, isDefined, mapAsync, paginatedEventQuery, shouldCache, sortEventsDescending, spreadEventWithBlockNumber, toBN, getTokenInfo, getUsdcSymbol,
|
|
7
|
+
import { BigNumber, bnZero, dedupArray, assign, fetchTokenInfo, getCachedBlockForTimestamp, getCurrentTime, getNetworkName, isDefined, mapAsync, paginatedEventQuery, shouldCache, sortEventsDescending, spreadEventWithBlockNumber, toBN, getTokenInfo, getUsdcSymbol, chainIsSvm, getDeployedAddress, SvmAddress, EvmAddress, toAddressType, } from "../utils";
|
|
8
8
|
import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "./BaseAbstractClient";
|
|
9
9
|
var HubPoolClient = /** @class */ (function (_super) {
|
|
10
10
|
__extends(HubPoolClient, _super);
|
|
@@ -26,6 +26,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
26
26
|
// L1Token -> destinationChainId -> destinationToken
|
|
27
27
|
_this.l1TokensToDestinationTokens = {};
|
|
28
28
|
_this.l1Tokens = []; // L1Tokens and their associated info.
|
|
29
|
+
// @dev `token` here is a 20-byte hex sting
|
|
29
30
|
_this.lpTokens = {};
|
|
30
31
|
_this.proposedRootBundles = [];
|
|
31
32
|
_this.canceledRootBundles = [];
|
|
@@ -84,29 +85,31 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
84
85
|
HubPoolClient.prototype.getSpokePoolActivationBlock = function (chain, spokePool) {
|
|
85
86
|
// Return first time that this spoke pool was registered in the HubPool as a cross chain contract. We can use
|
|
86
87
|
// this block as the oldest block that we should query for SpokePoolClient purposes.
|
|
87
|
-
var mostRecentSpokePoolUpdateBeforeBlock = this.crossChainContracts[chain].find(function (crossChainContract) {
|
|
88
|
+
var mostRecentSpokePoolUpdateBeforeBlock = this.crossChainContracts[chain].find(function (crossChainContract) {
|
|
89
|
+
return crossChainContract.spokePool.eq(spokePool);
|
|
90
|
+
});
|
|
88
91
|
return mostRecentSpokePoolUpdateBeforeBlock === null || mostRecentSpokePoolUpdateBeforeBlock === void 0 ? void 0 : mostRecentSpokePoolUpdateBeforeBlock.blockNumber;
|
|
89
92
|
};
|
|
90
93
|
// Returns the latest L2 token to use for an L1 token as of the input hub block.
|
|
91
94
|
HubPoolClient.prototype.getL2TokenForL1TokenAtBlock = function (l1Token, destinationChainId, latestHubBlock) {
|
|
92
95
|
var _a, _b, _c, _d;
|
|
93
96
|
if (latestHubBlock === void 0) { latestHubBlock = Number.MAX_SAFE_INTEGER; }
|
|
94
|
-
if (!((_b = (_a = this.l1TokensToDestinationTokensWithBlock) === null || _a === void 0 ? void 0 : _a[l1Token]) === null || _b === void 0 ? void 0 : _b[destinationChainId])) {
|
|
97
|
+
if (!((_b = (_a = this.l1TokensToDestinationTokensWithBlock) === null || _a === void 0 ? void 0 : _a[l1Token.toEvmAddress()]) === null || _b === void 0 ? void 0 : _b[destinationChainId])) {
|
|
95
98
|
var chain = getNetworkName(destinationChainId);
|
|
96
99
|
var symbol = ((_c = this.l1Tokens.find(function (_a) {
|
|
97
100
|
var address = _a.address;
|
|
98
|
-
return address
|
|
99
|
-
})) !== null && _c !== void 0 ? _c : { symbol: l1Token }).symbol;
|
|
101
|
+
return address.eq(l1Token);
|
|
102
|
+
})) !== null && _c !== void 0 ? _c : { symbol: l1Token.toString() }).symbol;
|
|
100
103
|
throw new Error("Could not find SpokePool mapping for ".concat(symbol, " on ").concat(chain, " and L1 token ").concat(l1Token));
|
|
101
104
|
}
|
|
102
105
|
// Find the last mapping published before the target block.
|
|
103
|
-
var l2Token = sortEventsDescending(this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId]).find(function (mapping) { return mapping.blockNumber <= latestHubBlock; });
|
|
106
|
+
var l2Token = sortEventsDescending(this.l1TokensToDestinationTokensWithBlock[l1Token.toEvmAddress()][destinationChainId]).find(function (mapping) { return mapping.blockNumber <= latestHubBlock; });
|
|
104
107
|
if (!l2Token) {
|
|
105
108
|
var chain = getNetworkName(destinationChainId);
|
|
106
109
|
var symbol = ((_d = this.l1Tokens.find(function (_a) {
|
|
107
110
|
var address = _a.address;
|
|
108
|
-
return address
|
|
109
|
-
})) !== null && _d !== void 0 ? _d : { symbol: l1Token }).symbol;
|
|
111
|
+
return address.eq(l1Token);
|
|
112
|
+
})) !== null && _d !== void 0 ? _d : { symbol: l1Token.toString() }).symbol;
|
|
110
113
|
throw new Error("Could not find SpokePool mapping for ".concat(symbol, " on ").concat(chain, " at or before HubPool block ").concat(latestHubBlock, "!"));
|
|
111
114
|
}
|
|
112
115
|
return l2Token.l2Token;
|
|
@@ -116,10 +119,14 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
116
119
|
var _this = this;
|
|
117
120
|
if (latestHubBlock === void 0) { latestHubBlock = Number.MAX_SAFE_INTEGER; }
|
|
118
121
|
var l2Tokens = Object.keys(this.l1TokensToDestinationTokensWithBlock)
|
|
119
|
-
.filter(function (l1Token) { return _this.l2TokenEnabledForL1Token(l1Token, destinationChainId); })
|
|
122
|
+
.filter(function (l1Token) { return _this.l2TokenEnabledForL1Token(EvmAddress.from(l1Token), destinationChainId); })
|
|
120
123
|
.map(function (l1Token) {
|
|
121
124
|
// Return all matching L2 token mappings that are equal to or earlier than the target block.
|
|
122
|
-
|
|
125
|
+
// @dev Since tokens on L2s (like Solana) can have 32 byte addresses, filter on the lower 20 bytes of the token only.
|
|
126
|
+
return _this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId].filter(function (dstTokenWithBlock) {
|
|
127
|
+
return dstTokenWithBlock.l2Token.truncateToBytes20() === l2Token.truncateToBytes20() &&
|
|
128
|
+
dstTokenWithBlock.blockNumber <= latestHubBlock;
|
|
129
|
+
});
|
|
123
130
|
})
|
|
124
131
|
.flat();
|
|
125
132
|
if (l2Tokens.length === 0) {
|
|
@@ -137,12 +144,12 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
137
144
|
};
|
|
138
145
|
HubPoolClient.prototype.l2TokenEnabledForL1Token = function (l1Token, destinationChainId) {
|
|
139
146
|
var _a, _b;
|
|
140
|
-
return ((_b = (_a = this.l1TokensToDestinationTokens) === null || _a === void 0 ? void 0 : _a[l1Token]) === null || _b === void 0 ? void 0 : _b[destinationChainId]) != undefined;
|
|
147
|
+
return ((_b = (_a = this.l1TokensToDestinationTokens) === null || _a === void 0 ? void 0 : _a[l1Token.toEvmAddress()]) === null || _b === void 0 ? void 0 : _b[destinationChainId]) != undefined;
|
|
141
148
|
};
|
|
142
149
|
HubPoolClient.prototype.l2TokenEnabledForL1TokenAtBlock = function (l1Token, destinationChainId, hubBlockNumber) {
|
|
143
150
|
var _a, _b, _c;
|
|
144
151
|
// Find the last mapping published before the target block.
|
|
145
|
-
var l2Token = sortEventsDescending((_c = (_b = (_a = this.l1TokensToDestinationTokensWithBlock) === null || _a === void 0 ? void 0 : _a[l1Token]) === null || _b === void 0 ? void 0 : _b[destinationChainId]) !== null && _c !== void 0 ? _c : []).find(function (mapping) { return mapping.blockNumber <= hubBlockNumber; });
|
|
152
|
+
var l2Token = sortEventsDescending((_c = (_b = (_a = this.l1TokensToDestinationTokensWithBlock) === null || _a === void 0 ? void 0 : _a[l1Token.toEvmAddress()]) === null || _b === void 0 ? void 0 : _b[destinationChainId]) !== null && _c !== void 0 ? _c : []).find(function (mapping) { return mapping.blockNumber <= hubBlockNumber; });
|
|
146
153
|
return l2Token !== undefined;
|
|
147
154
|
};
|
|
148
155
|
HubPoolClient.prototype.l2TokenHasPoolRebalanceRoute = function (l2Token, l2ChainId, hubPoolBlock) {
|
|
@@ -152,7 +159,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
152
159
|
var _l2ChainId = _a[0], setPoolRebalanceRouteEvents = _a[1];
|
|
153
160
|
return setPoolRebalanceRouteEvents.some(function (e) {
|
|
154
161
|
return (e.blockNumber <= hubPoolBlock &&
|
|
155
|
-
|
|
162
|
+
e.l2Token.truncateToBytes20() === l2Token.truncateToBytes20() &&
|
|
156
163
|
Number(_l2ChainId) === l2ChainId);
|
|
157
164
|
});
|
|
158
165
|
});
|
|
@@ -161,16 +168,17 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
161
168
|
/**
|
|
162
169
|
* @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw.
|
|
163
170
|
* @param tokenAddress Token address on `chain`
|
|
164
|
-
* @param
|
|
171
|
+
* @param chainId Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP.
|
|
165
172
|
* @returns Token info for the given token address on the L2 chain including symbol and decimal.
|
|
166
173
|
*/
|
|
167
|
-
|
|
174
|
+
// TODO: didn't change `tokenAddress` here to Address because of downstream getTokenInfo impl
|
|
175
|
+
HubPoolClient.prototype.getTokenInfoForAddress = function (tokenAddress, chainId) {
|
|
168
176
|
var _a;
|
|
169
|
-
var tokenInfo = getTokenInfo(tokenAddress,
|
|
177
|
+
var tokenInfo = getTokenInfo(tokenAddress, chainId);
|
|
170
178
|
// @dev Temporarily handle case where an L2 token for chain ID can map to more than one TOKEN_SYMBOLS_MAP
|
|
171
179
|
// entry. For example, L2 Bridged USDC maps to both the USDC and USDC.e/USDbC entries in TOKEN_SYMBOLS_MAP.
|
|
172
|
-
if (tokenInfo.symbol.toLowerCase() === "usdc" &&
|
|
173
|
-
tokenInfo.symbol = (_a = getUsdcSymbol(tokenAddress,
|
|
180
|
+
if (tokenInfo.symbol.toLowerCase() === "usdc" && chainId !== this.chainId) {
|
|
181
|
+
tokenInfo.symbol = (_a = getUsdcSymbol(tokenAddress, chainId)) !== null && _a !== void 0 ? _a : "UNKNOWN";
|
|
174
182
|
}
|
|
175
183
|
return tokenInfo;
|
|
176
184
|
};
|
|
@@ -262,11 +270,11 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
262
270
|
case 0:
|
|
263
271
|
overrides = { blockTag: blockNumber };
|
|
264
272
|
if (!depositAmount.eq(0)) return [3 /*break*/, 2];
|
|
265
|
-
return [4 /*yield*/, this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken, overrides)];
|
|
273
|
+
return [4 /*yield*/, this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken.toEvmAddress(), overrides)];
|
|
266
274
|
case 1:
|
|
267
275
|
// For zero amount, just get the utilisation at `blockNumber`.
|
|
268
276
|
return [2 /*return*/, _a.sent()];
|
|
269
|
-
case 2: return [4 /*yield*/, this.hubPool.callStatic.liquidityUtilizationPostRelay(hubPoolToken, depositAmount, overrides)];
|
|
277
|
+
case 2: return [4 /*yield*/, this.hubPool.callStatic.liquidityUtilizationPostRelay(hubPoolToken.toEvmAddress(), depositAmount, overrides)];
|
|
270
278
|
case 3: return [2 /*return*/, _a.sent()];
|
|
271
279
|
}
|
|
272
280
|
});
|
|
@@ -277,8 +285,8 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
277
285
|
return [2 /*return*/, resolver()];
|
|
278
286
|
}
|
|
279
287
|
key = depositAmount.eq(0)
|
|
280
|
-
? "utilization_".concat(hubPoolToken, "_").concat(blockNumber)
|
|
281
|
-
: "utilization_".concat(hubPoolToken, "_").concat(blockNumber, "_").concat(depositAmount.toString(), "_");
|
|
288
|
+
? "utilization_".concat(hubPoolToken.toEvmAddress(), "_").concat(blockNumber)
|
|
289
|
+
: "utilization_".concat(hubPoolToken.toEvmAddress(), "_").concat(blockNumber, "_").concat(depositAmount.toString(), "_");
|
|
282
290
|
return [4 /*yield*/, cache.get(key)];
|
|
283
291
|
case 1:
|
|
284
292
|
result = _a.sent();
|
|
@@ -341,6 +349,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
341
349
|
getHubPoolTokens = function () { return dedupArray(Object.values(hubPoolTokens).filter(isDefined)); };
|
|
342
350
|
resolveUniqueQuoteTimestamps = function (deposit) {
|
|
343
351
|
var _a;
|
|
352
|
+
var _b;
|
|
344
353
|
var quoteTimestamp = deposit.quoteTimestamp;
|
|
345
354
|
// Resolve the HubPool token address for this origin chainId/token pair, if it isn't already known.
|
|
346
355
|
var quoteBlockNumber = quoteBlocks[quoteTimestamp];
|
|
@@ -349,9 +358,9 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
349
358
|
return;
|
|
350
359
|
}
|
|
351
360
|
// Append the quoteTimestamp for this HubPool token, if it isn't already enqueued.
|
|
352
|
-
(_a = utilizationTimestamps[hubPoolToken]) !== null && _a !== void 0 ? _a : (utilizationTimestamps[
|
|
353
|
-
if (!utilizationTimestamps[hubPoolToken].includes(quoteTimestamp)) {
|
|
354
|
-
utilizationTimestamps[hubPoolToken].push(quoteTimestamp);
|
|
361
|
+
(_a = utilizationTimestamps[_b = hubPoolToken.toEvmAddress()]) !== null && _a !== void 0 ? _a : (utilizationTimestamps[_b] = []);
|
|
362
|
+
if (!utilizationTimestamps[hubPoolToken.toEvmAddress()].includes(quoteTimestamp)) {
|
|
363
|
+
utilizationTimestamps[hubPoolToken.toEvmAddress()].push(quoteTimestamp);
|
|
355
364
|
}
|
|
356
365
|
};
|
|
357
366
|
resolveUtilization = function (hubPoolToken) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -361,7 +370,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
361
370
|
switch (_c.label) {
|
|
362
371
|
case 0:
|
|
363
372
|
_b = (_a = Object).fromEntries;
|
|
364
|
-
return [4 /*yield*/, mapAsync(utilizationTimestamps[hubPoolToken], function (quoteTimestamp) { return __awaiter(_this, void 0, void 0, function () {
|
|
373
|
+
return [4 /*yield*/, mapAsync(utilizationTimestamps[hubPoolToken.toEvmAddress()], function (quoteTimestamp) { return __awaiter(_this, void 0, void 0, function () {
|
|
365
374
|
var blockNumber, utilization;
|
|
366
375
|
return __generator(this, function (_a) {
|
|
367
376
|
switch (_a.label) {
|
|
@@ -394,7 +403,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
394
403
|
throw new Error("Cannot computeRealizedLpFeePct for deposit with no pool rebalance route for input token ".concat(deposit.inputToken, " on ").concat(originChainId));
|
|
395
404
|
}
|
|
396
405
|
rateModel = this.configStoreClient.getRateModelForBlockNumber(hubPoolToken, originChainId, paymentChainId, quoteBlock);
|
|
397
|
-
preUtilization = utilization[hubPoolToken][quoteBlock];
|
|
406
|
+
preUtilization = utilization[hubPoolToken.toEvmAddress()][quoteBlock];
|
|
398
407
|
return [4 /*yield*/, this.getUtilization(hubPoolToken, quoteBlock, inputAmount, quoteTimestamp, timeToCache)];
|
|
399
408
|
case 1:
|
|
400
409
|
postUtilization = _a.sent();
|
|
@@ -414,14 +423,19 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
414
423
|
// Identify the unique hubPoolToken & quoteTimestamp mappings. This is used to optimise subsequent HubPool queries.
|
|
415
424
|
deposits.forEach(function (deposit) { return resolveUniqueQuoteTimestamps(deposit); });
|
|
416
425
|
_c = (_b = Object).fromEntries;
|
|
417
|
-
return [4 /*yield*/, mapAsync(getHubPoolTokens(), function (hubPoolToken) { return __awaiter(_this, void 0, void 0, function () {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
426
|
+
return [4 /*yield*/, mapAsync(getHubPoolTokens(), function (hubPoolToken) { return __awaiter(_this, void 0, void 0, function () {
|
|
427
|
+
var _a;
|
|
428
|
+
return __generator(this, function (_b) {
|
|
429
|
+
switch (_b.label) {
|
|
430
|
+
case 0:
|
|
431
|
+
_a = [hubPoolToken.toEvmAddress()];
|
|
432
|
+
return [4 /*yield*/, resolveUtilization(hubPoolToken)];
|
|
433
|
+
case 1: return [2 /*return*/, _a.concat([
|
|
434
|
+
_b.sent()
|
|
435
|
+
])];
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}); })];
|
|
425
439
|
case 2:
|
|
426
440
|
// For each token / quoteBlock pair, resolve the utilisation for each quoted block.
|
|
427
441
|
// This can be reused for each deposit with the same HubPool token and quoteTimestamp pair.
|
|
@@ -454,10 +468,10 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
454
468
|
return this.l1Tokens;
|
|
455
469
|
};
|
|
456
470
|
HubPoolClient.prototype.getTokenInfoForL1Token = function (l1Token) {
|
|
457
|
-
return this.l1Tokens.find(function (token) { return token.address
|
|
471
|
+
return this.l1Tokens.find(function (token) { return token.address.eq(l1Token); });
|
|
458
472
|
};
|
|
459
473
|
HubPoolClient.prototype.getLpTokenInfoForL1Token = function (l1Token) {
|
|
460
|
-
return this.lpTokens[l1Token];
|
|
474
|
+
return this.lpTokens[l1Token.toEvmAddress()];
|
|
461
475
|
};
|
|
462
476
|
HubPoolClient.prototype.areTokensEquivalent = function (tokenA, chainIdA, tokenB, chainIdB, hubPoolBlock) {
|
|
463
477
|
if (hubPoolBlock === void 0) { hubPoolBlock = this.latestHeightSearched; }
|
|
@@ -468,13 +482,13 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
468
482
|
// Resolve both SpokePool tokens back to their respective HubPool tokens and verify that they match.
|
|
469
483
|
var l1TokenA = this.getL1TokenForL2TokenAtBlock(tokenA, chainIdA, hubPoolBlock);
|
|
470
484
|
var l1TokenB = this.getL1TokenForL2TokenAtBlock(tokenB, chainIdB, hubPoolBlock);
|
|
471
|
-
if (l1TokenA
|
|
485
|
+
if (!l1TokenA.eq(l1TokenB)) {
|
|
472
486
|
return false;
|
|
473
487
|
}
|
|
474
488
|
// Resolve both HubPool tokens back to a current SpokePool token and verify that they match.
|
|
475
489
|
var _tokenA = this.getL2TokenForL1TokenAtBlock(l1TokenA, chainIdA, hubPoolBlock);
|
|
476
490
|
var _tokenB = this.getL2TokenForL1TokenAtBlock(l1TokenB, chainIdB, hubPoolBlock);
|
|
477
|
-
return tokenA
|
|
491
|
+
return tokenA.eq(_tokenA) && tokenB.eq(_tokenB);
|
|
478
492
|
};
|
|
479
493
|
HubPoolClient.prototype.getSpokeActivationBlockForChain = function (chainId) {
|
|
480
494
|
var _a;
|
|
@@ -661,7 +675,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
661
675
|
return sortEventsDescending(this.executedRootBundles).find(function (executedLeaf) {
|
|
662
676
|
return (executedLeaf.blockNumber <= block &&
|
|
663
677
|
executedLeaf.chainId === chain &&
|
|
664
|
-
executedLeaf.l1Tokens.some(function (token) { return token.
|
|
678
|
+
executedLeaf.l1Tokens.some(function (token) { return token.eq(l1Token); }));
|
|
665
679
|
});
|
|
666
680
|
};
|
|
667
681
|
HubPoolClient.prototype.getRunningBalanceBeforeBlockForChain = function (block, chain, l1Token) {
|
|
@@ -671,10 +685,10 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
671
685
|
HubPoolClient.prototype.getRunningBalanceForToken = function (l1Token, executedRootBundle) {
|
|
672
686
|
var runningBalance = toBN(0);
|
|
673
687
|
if (executedRootBundle) {
|
|
674
|
-
var indexOfL1Token = executedRootBundle.l1Tokens
|
|
675
|
-
|
|
676
|
-
.
|
|
677
|
-
|
|
688
|
+
var indexOfL1Token = executedRootBundle.l1Tokens.findIndex(function (tokenInBundle) { return tokenInBundle.eq(l1Token); });
|
|
689
|
+
if (indexOfL1Token !== -1) {
|
|
690
|
+
runningBalance = executedRootBundle.runningBalances[indexOfL1Token];
|
|
691
|
+
}
|
|
678
692
|
}
|
|
679
693
|
return { runningBalance: runningBalance };
|
|
680
694
|
};
|
|
@@ -738,7 +752,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
738
752
|
return [2 /*return*/, {
|
|
739
753
|
success: true,
|
|
740
754
|
currentTime: currentTime,
|
|
741
|
-
pendingRootBundleProposal: pendingRootBundleProposal,
|
|
755
|
+
pendingRootBundleProposal: __assign(__assign({}, pendingRootBundleProposal), { proposer: toAddressType(pendingRootBundleProposal.proposer, this.chainId) }),
|
|
742
756
|
searchEndBlock: searchConfig.to,
|
|
743
757
|
events: _events,
|
|
744
758
|
}];
|
|
@@ -749,7 +763,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
749
763
|
HubPoolClient.prototype.update = function (eventsToQuery) {
|
|
750
764
|
if (eventsToQuery === void 0) { eventsToQuery = Object.keys(this.hubPoolEventFilters()); }
|
|
751
765
|
return __awaiter(this, void 0, void 0, function () {
|
|
752
|
-
var update, events, currentTime, pendingRootBundleProposal, searchEndBlock, _i, _a, event_1, args, dataToAdd, solanaSpokePool, truncatedAddress, _b, _c, event_2, args, destinationToken, usdcTokenSol,
|
|
766
|
+
var update, events, currentTime, pendingRootBundleProposal, searchEndBlock, _i, _a, event_1, args, dataToAdd, solanaSpokePool, svmSpoke, truncatedAddress, _b, _c, event_2, args, destinationToken, usdcTokenSol, svmUsdc, uniqueL1Tokens, _d, tokenInfo, lpTokenInfo_1, _loop_1, this_1, _e, tokenInfo_1, info, _f, _g, event_3, executedRootBundle, l1Tokens, runningBalances, nTokens, mostRecentProposedRootBundle;
|
|
753
767
|
var _h, _j, _k;
|
|
754
768
|
var _this = this;
|
|
755
769
|
return __generator(this, function (_l) {
|
|
@@ -774,7 +788,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
774
788
|
event_1 = _a[_i];
|
|
775
789
|
args = spreadEventWithBlockNumber(event_1);
|
|
776
790
|
dataToAdd = {
|
|
777
|
-
spokePool: args.spokePool,
|
|
791
|
+
spokePool: toAddressType(args.spokePool, this.chainId),
|
|
778
792
|
blockNumber: args.blockNumber,
|
|
779
793
|
txnRef: args.txnRef,
|
|
780
794
|
logIndex: args.logIndex,
|
|
@@ -790,14 +804,14 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
790
804
|
if (!solanaSpokePool) {
|
|
791
805
|
throw new Error("SVM spoke pool not found for chain ".concat(args.l2ChainId));
|
|
792
806
|
}
|
|
793
|
-
|
|
807
|
+
svmSpoke = SvmAddress.from(solanaSpokePool);
|
|
808
|
+
truncatedAddress = svmSpoke.truncateToBytes20();
|
|
794
809
|
// Verify the event address matches our expected truncated address
|
|
795
810
|
if (args.spokePool.toLowerCase() !== truncatedAddress.toLowerCase()) {
|
|
796
811
|
throw new Error("SVM spoke pool address mismatch for chain ".concat(args.l2ChainId, ". ") +
|
|
797
812
|
"Expected ".concat(truncatedAddress, ", got ").concat(args.spokePool));
|
|
798
813
|
}
|
|
799
|
-
|
|
800
|
-
dataToAdd.spokePool = SvmAddress.from(solanaSpokePool).toBytes32();
|
|
814
|
+
dataToAdd.spokePool = svmSpoke;
|
|
801
815
|
}
|
|
802
816
|
assign(this.crossChainContracts, [args.l2ChainId], [dataToAdd]);
|
|
803
817
|
}
|
|
@@ -806,23 +820,23 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
806
820
|
for (_b = 0, _c = events["SetPoolRebalanceRoute"]; _b < _c.length; _b++) {
|
|
807
821
|
event_2 = _c[_b];
|
|
808
822
|
args = spreadEventWithBlockNumber(event_2);
|
|
809
|
-
destinationToken = args.destinationToken;
|
|
823
|
+
destinationToken = toAddressType(args.destinationToken, this.chainId);
|
|
810
824
|
if (chainIsSvm(args.destinationChainId)) {
|
|
811
825
|
usdcTokenSol = TOKEN_SYMBOLS_MAP.USDC.addresses[args.destinationChainId];
|
|
812
|
-
|
|
813
|
-
if (destinationToken.
|
|
826
|
+
svmUsdc = SvmAddress.from(usdcTokenSol);
|
|
827
|
+
if (destinationToken.truncateToBytes20() !== svmUsdc.truncateToBytes20()) {
|
|
814
828
|
throw new Error("SVM USDC address mismatch for chain ".concat(args.destinationChainId, ". ") +
|
|
815
|
-
"Expected ".concat(
|
|
829
|
+
"Expected ".concat(svmUsdc.truncateToBytes20(), ", got ").concat(destinationToken));
|
|
816
830
|
}
|
|
817
|
-
destinationToken =
|
|
831
|
+
destinationToken = svmUsdc;
|
|
818
832
|
}
|
|
819
833
|
// If the destination token is set to the zero address in an event, then this means Across should no longer
|
|
820
834
|
// rebalance to this chain.
|
|
821
|
-
if (destinationToken
|
|
835
|
+
if (!destinationToken.isZeroAddress()) {
|
|
822
836
|
assign(this.l1TokensToDestinationTokens, [args.l1Token, args.destinationChainId], destinationToken);
|
|
823
837
|
assign(this.l1TokensToDestinationTokensWithBlock, [args.l1Token, args.destinationChainId], [
|
|
824
838
|
{
|
|
825
|
-
l1Token: args.l1Token,
|
|
839
|
+
l1Token: toAddressType(args.l1Token, this.chainId),
|
|
826
840
|
l2Token: destinationToken,
|
|
827
841
|
blockNumber: args.blockNumber,
|
|
828
842
|
txnIndex: args.txnIndex,
|
|
@@ -836,7 +850,17 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
836
850
|
if (!eventsToQuery.includes("L1TokenEnabledForLiquidityProvision")) return [3 /*break*/, 3];
|
|
837
851
|
uniqueL1Tokens = dedupArray(events["L1TokenEnabledForLiquidityProvision"].map(function (event) { return String(event.args["l1Token"]); }));
|
|
838
852
|
return [4 /*yield*/, Promise.all([
|
|
839
|
-
Promise.all(uniqueL1Tokens.map(function (l1Token) { return
|
|
853
|
+
Promise.all(uniqueL1Tokens.map(function (l1Token) { return __awaiter(_this, void 0, void 0, function () {
|
|
854
|
+
var tokenInfo;
|
|
855
|
+
return __generator(this, function (_a) {
|
|
856
|
+
switch (_a.label) {
|
|
857
|
+
case 0: return [4 /*yield*/, fetchTokenInfo(l1Token, this.hubPool.provider)];
|
|
858
|
+
case 1:
|
|
859
|
+
tokenInfo = _a.sent();
|
|
860
|
+
return [2 /*return*/, __assign(__assign({}, tokenInfo), { address: EvmAddress.from(l1Token) })];
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
}); })),
|
|
840
864
|
Promise.all(uniqueL1Tokens.map(function (l1Token) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
841
865
|
switch (_a.label) {
|
|
842
866
|
case 0: return [4 /*yield*/, this.hubPool.pooledTokens(l1Token, { blockTag: update.searchEndBlock })];
|
|
@@ -847,7 +871,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
847
871
|
case 2:
|
|
848
872
|
_d = _l.sent(), tokenInfo = _d[0], lpTokenInfo_1 = _d[1];
|
|
849
873
|
_loop_1 = function (info) {
|
|
850
|
-
if (!this_1.l1Tokens.find(function (token) { return
|
|
874
|
+
if (!this_1.l1Tokens.find(function (token) { return token.address.eq(info.address); })) {
|
|
851
875
|
if (info.decimals > 0 && info.decimals <= 18) {
|
|
852
876
|
this_1.l1Tokens.push(info);
|
|
853
877
|
}
|
|
@@ -872,7 +896,10 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
872
896
|
if (eventsToQuery.includes("ProposeRootBundle")) {
|
|
873
897
|
(_h = this.proposedRootBundles).push.apply(_h, events["ProposeRootBundle"]
|
|
874
898
|
.filter(function (event) { return !_this.configOverride.ignoredHubProposedBundles.includes(event.blockNumber); })
|
|
875
|
-
.map(function (
|
|
899
|
+
.map(function (_event) {
|
|
900
|
+
var args = spreadEventWithBlockNumber(_event);
|
|
901
|
+
return __assign(__assign({}, args), { proposer: EvmAddress.from(args.proposer) });
|
|
902
|
+
}));
|
|
876
903
|
}
|
|
877
904
|
if (eventsToQuery.includes("RootBundleCanceled")) {
|
|
878
905
|
(_j = this.canceledRootBundles).push.apply(_j, events["RootBundleCanceled"].map(function (event) { return spreadEventWithBlockNumber(event); }));
|
|
@@ -895,7 +922,9 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
895
922
|
" Expected ".concat(nTokens, " or ").concat(nTokens * 2, " for chain ").concat(this.chainId, " transaction ").concat(event_3.transactionHash));
|
|
896
923
|
}
|
|
897
924
|
executedRootBundle.runningBalances = runningBalances.slice(0, nTokens);
|
|
898
|
-
this.executedRootBundles.push(executedRootBundle)
|
|
925
|
+
this.executedRootBundles.push(__assign(__assign({}, executedRootBundle), { l1Tokens: l1Tokens.map(function (token) {
|
|
926
|
+
return EvmAddress.from(token, "base16");
|
|
927
|
+
}) }));
|
|
899
928
|
}
|
|
900
929
|
}
|
|
901
930
|
// If the contract's current rootBundleProposal() value has an unclaimedPoolRebalanceLeafCount > 0, then
|