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