@across-protocol/sdk 4.2.7 → 4.2.9-alpha.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 +2 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +18 -3
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +7 -7
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +1 -1
- package/dist/cjs/arch/svm/utils.js +15 -13
- 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 +2 -2
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +57 -53
- 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/PoolRebalanceUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +11 -8
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +20 -20
- package/dist/cjs/clients/HubPoolClient.js +78 -57
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +35 -29
- 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 +9 -13
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -56
- package/dist/cjs/clients/mocks/MockSpokePoolClient.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 +18 -13
- package/dist/cjs/interfaces/SpokePool.d.ts +14 -16
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +7 -7
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +10 -10
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +7 -4
- package/dist/cjs/utils/AddressUtils.js +21 -8
- 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 +3 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +2 -2
- package/dist/esm/arch/evm/SpokeUtils.js +19 -4
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +8 -8
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +1 -1
- package/dist/esm/arch/svm/utils.js +15 -13
- 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 +2 -2
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +58 -54
- 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 +4 -3
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +12 -9
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -21
- package/dist/esm/clients/HubPoolClient.js +91 -61
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +37 -30
- 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 +9 -13
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +44 -60
- package/dist/esm/clients/mocks/MockSpokePoolClient.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 +18 -13
- package/dist/esm/interfaces/SpokePool.d.ts +14 -16
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +8 -8
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +10 -10
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +7 -4
- package/dist/esm/utils/AddressUtils.js +25 -10
- 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 +4 -16
- package/dist/esm/utils/TokenUtils.js +3 -3
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +2 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +1 -1
- 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 +2 -2
- 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/PoolRebalanceUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +22 -21
- 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 +5 -3
- 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 +9 -13
- package/dist/types/clients/mocks/MockSpokePoolClient.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 +18 -13
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +14 -16
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +7 -4
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +3 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +4 -16
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/arch/evm/SpokeUtils.ts +22 -8
- package/src/arch/svm/SpokeUtils.ts +7 -8
- package/src/arch/svm/utils.ts +3 -3
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +49 -47
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +6 -4
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +13 -9
- package/src/clients/HubPoolClient.ts +113 -79
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -1
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +104 -37
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +53 -74
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +22 -13
- package/src/interfaces/SpokePool.ts +14 -17
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +10 -8
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +10 -10
- package/src/relayFeeCalculator/relayFeeCalculator.ts +11 -9
- package/src/utils/AddressUtils.ts +32 -14
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +7 -7
|
@@ -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
|
);
|
|
@@ -208,18 +213,23 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
208
213
|
return l2Token.l2Token;
|
|
209
214
|
}
|
|
210
215
|
|
|
216
|
+
// TODO: this might have to deal with truncated Solana addresses? Depends on what input is given actually
|
|
217
|
+
// TODO: might craete `getL1TokenForL2EVMTokenAtBlock` and some other fn
|
|
211
218
|
// Returns the latest L1 token to use for an L2 token as of the input hub block.
|
|
212
219
|
getL1TokenForL2TokenAtBlock(
|
|
213
|
-
l2Token:
|
|
220
|
+
l2Token: Address, // ! TODO: assuming that for Svm token, we'll have a proper full SvmAddress in this var
|
|
214
221
|
destinationChainId: number,
|
|
215
222
|
latestHubBlock = Number.MAX_SAFE_INTEGER
|
|
216
|
-
):
|
|
223
|
+
): EvmAddress {
|
|
217
224
|
const l2Tokens = Object.keys(this.l1TokensToDestinationTokensWithBlock)
|
|
218
|
-
.filter((l1Token) => this.l2TokenEnabledForL1Token(l1Token, destinationChainId))
|
|
225
|
+
.filter((l1Token) => this.l2TokenEnabledForL1Token(EvmAddress.from(l1Token), destinationChainId))
|
|
219
226
|
.map((l1Token) => {
|
|
220
227
|
// Return all matching L2 token mappings that are equal to or earlier than the target block.
|
|
221
228
|
return this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId].filter(
|
|
222
|
-
|
|
229
|
+
// ! TODO: Okay. Here, in `l1TokensToDestinationTokensWithBlock`, we might be saving truncated solana addresses (as `l1TokensToDestinationTokensWithBlock` is probably generated from events)
|
|
230
|
+
// ! TODO: Considering this, this filtering should be a bit different. If .isSvmAddress => check not for equality, but for *truncated equality*. If .isEvmAddress, check for equality
|
|
231
|
+
(dstTokenWithBlock) =>
|
|
232
|
+
dstTokenWithBlock.l2Token.eq(l2Token) && dstTokenWithBlock.blockNumber <= latestHubBlock
|
|
223
233
|
);
|
|
224
234
|
})
|
|
225
235
|
.flat();
|
|
@@ -235,32 +245,33 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
235
245
|
|
|
236
246
|
protected getL1TokenForDeposit(
|
|
237
247
|
deposit: Pick<DepositWithBlock, "originChainId" | "inputToken" | "quoteBlockNumber">
|
|
238
|
-
):
|
|
248
|
+
): EvmAddress {
|
|
239
249
|
// L1-->L2 token mappings are set via PoolRebalanceRoutes which occur on mainnet,
|
|
240
250
|
// so we use the latest token mapping. This way if a very old deposit is filled, the relayer can use the
|
|
241
251
|
// latest L2 token mapping to find the L1 token counterpart.
|
|
242
252
|
return this.getL1TokenForL2TokenAtBlock(deposit.inputToken, deposit.originChainId, deposit.quoteBlockNumber);
|
|
243
253
|
}
|
|
244
254
|
|
|
245
|
-
l2TokenEnabledForL1Token(l1Token:
|
|
246
|
-
return this.l1TokensToDestinationTokens?.[l1Token]?.[destinationChainId] != undefined;
|
|
255
|
+
l2TokenEnabledForL1Token(l1Token: EvmAddress, destinationChainId: number): boolean {
|
|
256
|
+
return this.l1TokensToDestinationTokens?.[l1Token.toEvmAddress()]?.[destinationChainId] != undefined;
|
|
247
257
|
}
|
|
248
258
|
|
|
249
|
-
l2TokenEnabledForL1TokenAtBlock(l1Token:
|
|
259
|
+
l2TokenEnabledForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, hubBlockNumber: number): boolean {
|
|
250
260
|
// Find the last mapping published before the target block.
|
|
251
261
|
const l2Token: DestinationTokenWithBlock | undefined = sortEventsDescending(
|
|
252
|
-
this.l1TokensToDestinationTokensWithBlock?.[l1Token]?.[destinationChainId] ?? []
|
|
262
|
+
this.l1TokensToDestinationTokensWithBlock?.[l1Token.toEvmAddress()]?.[destinationChainId] ?? []
|
|
253
263
|
).find((mapping: DestinationTokenWithBlock) => mapping.blockNumber <= hubBlockNumber);
|
|
254
264
|
return l2Token !== undefined;
|
|
255
265
|
}
|
|
256
266
|
|
|
257
|
-
l2TokenHasPoolRebalanceRoute(l2Token:
|
|
267
|
+
l2TokenHasPoolRebalanceRoute(l2Token: Address, l2ChainId: number, hubPoolBlock = this.latestHeightSearched): boolean {
|
|
258
268
|
return Object.values(this.l1TokensToDestinationTokensWithBlock).some((destinationTokenMapping) => {
|
|
259
269
|
return Object.entries(destinationTokenMapping).some(([_l2ChainId, setPoolRebalanceRouteEvents]) => {
|
|
260
270
|
return setPoolRebalanceRouteEvents.some((e) => {
|
|
261
271
|
return (
|
|
262
272
|
e.blockNumber <= hubPoolBlock &&
|
|
263
|
-
|
|
273
|
+
// TODO: compare the last 20 bytes of l2Token only. Solana workaround, is this correct?
|
|
274
|
+
e.l2Token.eq(l2Token) &&
|
|
264
275
|
Number(_l2ChainId) === l2ChainId
|
|
265
276
|
);
|
|
266
277
|
});
|
|
@@ -271,15 +282,16 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
271
282
|
/**
|
|
272
283
|
* @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw.
|
|
273
284
|
* @param tokenAddress Token address on `chain`
|
|
274
|
-
* @param
|
|
285
|
+
* @param chainId Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP.
|
|
275
286
|
* @returns Token info for the given token address on the L2 chain including symbol and decimal.
|
|
276
287
|
*/
|
|
277
|
-
|
|
278
|
-
|
|
288
|
+
// TODO: didn't change `tokenAddress` here to Address because of downstream getTokenInfo impl
|
|
289
|
+
getTokenInfoForAddress(tokenAddress: string, chainId: number): TokenInfo {
|
|
290
|
+
const tokenInfo = getTokenInfo(tokenAddress, chainId);
|
|
279
291
|
// @dev Temporarily handle case where an L2 token for chain ID can map to more than one TOKEN_SYMBOLS_MAP
|
|
280
292
|
// 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,
|
|
293
|
+
if (tokenInfo.symbol.toLowerCase() === "usdc" && chainId !== this.chainId) {
|
|
294
|
+
tokenInfo.symbol = getUsdcSymbol(tokenAddress, chainId) ?? "UNKNOWN";
|
|
283
295
|
}
|
|
284
296
|
return tokenInfo;
|
|
285
297
|
}
|
|
@@ -311,7 +323,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
311
323
|
return blockNumbers;
|
|
312
324
|
}
|
|
313
325
|
|
|
314
|
-
async getCurrentPoolUtilization(l1Token:
|
|
326
|
+
async getCurrentPoolUtilization(l1Token: EvmAddress): Promise<BigNumber> {
|
|
315
327
|
const blockNumber = this.latestHeightSearched ?? (await this.hubPool.provider.getBlockNumber());
|
|
316
328
|
return await this.getUtilization(l1Token, blockNumber, bnZero, getCurrentTime(), 0);
|
|
317
329
|
}
|
|
@@ -326,7 +338,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
326
338
|
* @returns HubPool utilization at `blockNumber` after optional `amount` increase in utilization.
|
|
327
339
|
*/
|
|
328
340
|
protected async getUtilization(
|
|
329
|
-
hubPoolToken:
|
|
341
|
+
hubPoolToken: EvmAddress,
|
|
330
342
|
blockNumber: number,
|
|
331
343
|
depositAmount: BigNumber,
|
|
332
344
|
timestamp: number,
|
|
@@ -337,10 +349,14 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
337
349
|
const overrides = { blockTag: blockNumber };
|
|
338
350
|
if (depositAmount.eq(0)) {
|
|
339
351
|
// For zero amount, just get the utilisation at `blockNumber`.
|
|
340
|
-
return await this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken, overrides);
|
|
352
|
+
return await this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken.toEvmAddress(), overrides);
|
|
341
353
|
}
|
|
342
354
|
|
|
343
|
-
return await this.hubPool.callStatic.liquidityUtilizationPostRelay(
|
|
355
|
+
return await this.hubPool.callStatic.liquidityUtilizationPostRelay(
|
|
356
|
+
hubPoolToken.toEvmAddress(),
|
|
357
|
+
depositAmount,
|
|
358
|
+
overrides
|
|
359
|
+
);
|
|
344
360
|
};
|
|
345
361
|
|
|
346
362
|
// Resolve the cache locally so that we can appease typescript
|
|
@@ -355,8 +371,8 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
355
371
|
// @note Avoid collisions with pre-existing cache keys by appending an underscore (_) for post-relay utilization.
|
|
356
372
|
// @fixme This can be removed once the existing keys have been ejected from the cache (i.e. 7 days).
|
|
357
373
|
const key = depositAmount.eq(0)
|
|
358
|
-
? `utilization_${hubPoolToken}_${blockNumber}`
|
|
359
|
-
: `utilization_${hubPoolToken}_${blockNumber}_${depositAmount.toString()}_`;
|
|
374
|
+
? `utilization_${hubPoolToken.toEvmAddress()}_${blockNumber}`
|
|
375
|
+
: `utilization_${hubPoolToken.toEvmAddress()}_${blockNumber}_${depositAmount.toString()}_`;
|
|
360
376
|
const result = await cache.get<string>(key);
|
|
361
377
|
if (isDefined(result)) {
|
|
362
378
|
return BigNumber.from(result);
|
|
@@ -393,14 +409,14 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
393
409
|
|
|
394
410
|
// Map SpokePool token addresses to HubPool token addresses.
|
|
395
411
|
// Note: Should only be accessed via `getHubPoolToken()` or `getHubPoolTokens()`.
|
|
396
|
-
const hubPoolTokens: { [k: string]:
|
|
397
|
-
const getHubPoolToken = (deposit: LpFeeRequest, quoteBlockNumber: number):
|
|
412
|
+
const hubPoolTokens: { [k: string]: EvmAddress } = {};
|
|
413
|
+
const getHubPoolToken = (deposit: LpFeeRequest, quoteBlockNumber: number): EvmAddress | undefined => {
|
|
398
414
|
const tokenKey = `${deposit.originChainId}-${deposit.inputToken}`;
|
|
399
415
|
if (this.l2TokenHasPoolRebalanceRoute(deposit.inputToken, deposit.originChainId, quoteBlockNumber)) {
|
|
400
416
|
return (hubPoolTokens[tokenKey] ??= this.getL1TokenForDeposit({ ...deposit, quoteBlockNumber }));
|
|
401
417
|
} else return undefined;
|
|
402
418
|
};
|
|
403
|
-
const getHubPoolTokens = ():
|
|
419
|
+
const getHubPoolTokens = (): EvmAddress[] => dedupArray(Object.values(hubPoolTokens).filter(isDefined));
|
|
404
420
|
|
|
405
421
|
// Helper to resolve the unqiue hubPoolToken & quoteTimestamp mappings.
|
|
406
422
|
const resolveUniqueQuoteTimestamps = (deposit: LpFeeRequest): void => {
|
|
@@ -414,17 +430,17 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
414
430
|
}
|
|
415
431
|
|
|
416
432
|
// 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);
|
|
433
|
+
utilizationTimestamps[hubPoolToken.toEvmAddress()] ??= [];
|
|
434
|
+
if (!utilizationTimestamps[hubPoolToken.toEvmAddress()].includes(quoteTimestamp)) {
|
|
435
|
+
utilizationTimestamps[hubPoolToken.toEvmAddress()].push(quoteTimestamp);
|
|
420
436
|
}
|
|
421
437
|
};
|
|
422
438
|
|
|
423
439
|
// Helper to resolve existing HubPool token utilisation for an array of unique block numbers.
|
|
424
440
|
// Produces a mapping of blockNumber -> utilization for a specific token.
|
|
425
|
-
const resolveUtilization = async (hubPoolToken:
|
|
441
|
+
const resolveUtilization = async (hubPoolToken: EvmAddress): Promise<Record<number, BigNumber>> => {
|
|
426
442
|
return Object.fromEntries(
|
|
427
|
-
await mapAsync(utilizationTimestamps[hubPoolToken], async (quoteTimestamp) => {
|
|
443
|
+
await mapAsync(utilizationTimestamps[hubPoolToken.toEvmAddress()], async (quoteTimestamp) => {
|
|
428
444
|
const blockNumber = quoteBlocks[quoteTimestamp];
|
|
429
445
|
const utilization = await this.getUtilization(
|
|
430
446
|
hubPoolToken,
|
|
@@ -460,7 +476,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
460
476
|
quoteBlock
|
|
461
477
|
);
|
|
462
478
|
|
|
463
|
-
const preUtilization = utilization[hubPoolToken][quoteBlock];
|
|
479
|
+
const preUtilization = utilization[hubPoolToken.toEvmAddress()][quoteBlock];
|
|
464
480
|
const postUtilization = await this.getUtilization(
|
|
465
481
|
hubPoolToken,
|
|
466
482
|
quoteBlock,
|
|
@@ -488,7 +504,10 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
488
504
|
// For each token / quoteBlock pair, resolve the utilisation for each quoted block.
|
|
489
505
|
// This can be reused for each deposit with the same HubPool token and quoteTimestamp pair.
|
|
490
506
|
utilization = Object.fromEntries(
|
|
491
|
-
await mapAsync(getHubPoolTokens(), async (hubPoolToken) => [
|
|
507
|
+
await mapAsync(getHubPoolTokens(), async (hubPoolToken) => [
|
|
508
|
+
hubPoolToken.toEvmAddress(),
|
|
509
|
+
await resolveUtilization(hubPoolToken),
|
|
510
|
+
])
|
|
492
511
|
);
|
|
493
512
|
|
|
494
513
|
// For each deposit, compute the post-relay HubPool utilisation independently.
|
|
@@ -506,12 +525,12 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
506
525
|
});
|
|
507
526
|
}
|
|
508
527
|
|
|
509
|
-
getL1Tokens():
|
|
528
|
+
getL1Tokens(): L1TokenInfo[] {
|
|
510
529
|
return this.l1Tokens;
|
|
511
530
|
}
|
|
512
531
|
|
|
513
|
-
getTokenInfoForL1Token(l1Token:
|
|
514
|
-
return this.l1Tokens.find((token) => token.address
|
|
532
|
+
getTokenInfoForL1Token(l1Token: EvmAddress): L1TokenInfo | undefined {
|
|
533
|
+
return this.l1Tokens.find((token) => token.address.eq(l1Token));
|
|
515
534
|
}
|
|
516
535
|
|
|
517
536
|
getLpTokenInfoForL1Token(l1Token: string): LpToken | undefined {
|
|
@@ -519,9 +538,9 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
519
538
|
}
|
|
520
539
|
|
|
521
540
|
areTokensEquivalent(
|
|
522
|
-
tokenA:
|
|
541
|
+
tokenA: Address,
|
|
523
542
|
chainIdA: number,
|
|
524
|
-
tokenB:
|
|
543
|
+
tokenB: Address,
|
|
525
544
|
chainIdB: number,
|
|
526
545
|
hubPoolBlock = this.latestHeightSearched
|
|
527
546
|
): boolean {
|
|
@@ -534,14 +553,14 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
534
553
|
// Resolve both SpokePool tokens back to their respective HubPool tokens and verify that they match.
|
|
535
554
|
const l1TokenA = this.getL1TokenForL2TokenAtBlock(tokenA, chainIdA, hubPoolBlock);
|
|
536
555
|
const l1TokenB = this.getL1TokenForL2TokenAtBlock(tokenB, chainIdB, hubPoolBlock);
|
|
537
|
-
if (l1TokenA
|
|
556
|
+
if (!l1TokenA.eq(l1TokenB)) {
|
|
538
557
|
return false;
|
|
539
558
|
}
|
|
540
559
|
|
|
541
560
|
// Resolve both HubPool tokens back to a current SpokePool token and verify that they match.
|
|
542
561
|
const _tokenA = this.getL2TokenForL1TokenAtBlock(l1TokenA, chainIdA, hubPoolBlock);
|
|
543
562
|
const _tokenB = this.getL2TokenForL1TokenAtBlock(l1TokenB, chainIdB, hubPoolBlock);
|
|
544
|
-
return tokenA
|
|
563
|
+
return tokenA.eq(_tokenA) && tokenB.eq(_tokenB);
|
|
545
564
|
}
|
|
546
565
|
|
|
547
566
|
getSpokeActivationBlockForChain(chainId: number): number {
|
|
@@ -778,34 +797,35 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
778
797
|
getLatestExecutedRootBundleContainingL1Token(
|
|
779
798
|
block: number,
|
|
780
799
|
chain: number,
|
|
781
|
-
l1Token:
|
|
800
|
+
l1Token: EvmAddress
|
|
782
801
|
): ExecutedRootBundle | undefined {
|
|
783
802
|
// Search ExecutedRootBundles in descending block order to find the most recent event before the target block.
|
|
784
803
|
return sortEventsDescending(this.executedRootBundles).find((executedLeaf: ExecutedRootBundle) => {
|
|
785
804
|
return (
|
|
786
805
|
executedLeaf.blockNumber <= block &&
|
|
787
806
|
executedLeaf.chainId === chain &&
|
|
788
|
-
executedLeaf.l1Tokens.some((token) => token.
|
|
807
|
+
executedLeaf.l1Tokens.some((token) => token.eq(l1Token))
|
|
789
808
|
);
|
|
790
809
|
});
|
|
791
810
|
}
|
|
792
811
|
|
|
793
|
-
getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token:
|
|
812
|
+
getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: EvmAddress): TokenRunningBalance {
|
|
794
813
|
const executedRootBundle = this.getLatestExecutedRootBundleContainingL1Token(block, chain, l1Token);
|
|
795
814
|
|
|
796
815
|
return this.getRunningBalanceForToken(l1Token, executedRootBundle);
|
|
797
816
|
}
|
|
798
817
|
|
|
799
818
|
public getRunningBalanceForToken(
|
|
800
|
-
l1Token:
|
|
819
|
+
l1Token: EvmAddress,
|
|
801
820
|
executedRootBundle: ExecutedRootBundle | undefined
|
|
802
821
|
): TokenRunningBalance {
|
|
803
822
|
let runningBalance = toBN(0);
|
|
804
823
|
if (executedRootBundle) {
|
|
805
|
-
const indexOfL1Token = executedRootBundle.l1Tokens
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
824
|
+
const indexOfL1Token = executedRootBundle.l1Tokens.findIndex((tokenInBundle) => tokenInBundle.eq(l1Token));
|
|
825
|
+
// TODO: not sure this if is required. Wasn't here before. Probably `getRunningBalanceForToken` is used on checked tokens only
|
|
826
|
+
if (indexOfL1Token !== -1) {
|
|
827
|
+
runningBalance = executedRootBundle.runningBalances[indexOfL1Token];
|
|
828
|
+
}
|
|
809
829
|
}
|
|
810
830
|
|
|
811
831
|
return { runningBalance };
|
|
@@ -898,9 +918,9 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
898
918
|
|
|
899
919
|
if (eventsToQuery.includes("CrossChainContractsSet")) {
|
|
900
920
|
for (const event of events["CrossChainContractsSet"]) {
|
|
901
|
-
const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet;
|
|
921
|
+
const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet & { spokePool: string };
|
|
902
922
|
const dataToAdd: CrossChainContractsSet = {
|
|
903
|
-
spokePool: args.spokePool,
|
|
923
|
+
spokePool: toAddressType(args.spokePool),
|
|
904
924
|
blockNumber: args.blockNumber,
|
|
905
925
|
txnRef: args.txnRef,
|
|
906
926
|
logIndex: args.logIndex,
|
|
@@ -916,16 +936,15 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
916
936
|
if (!solanaSpokePool) {
|
|
917
937
|
throw new Error(`SVM spoke pool not found for chain ${args.l2ChainId}`);
|
|
918
938
|
}
|
|
919
|
-
const
|
|
939
|
+
const svmSpoke = SvmAddress.from(solanaSpokePool);
|
|
920
940
|
// Verify the event address matches our expected truncated address
|
|
921
|
-
if (args.spokePool.toLowerCase() !==
|
|
941
|
+
if (args.spokePool.toLowerCase() !== svmSpoke.truncateToBytes20().toLowerCase()) {
|
|
922
942
|
throw new Error(
|
|
923
943
|
`SVM spoke pool address mismatch for chain ${args.l2ChainId}. ` +
|
|
924
|
-
`Expected ${
|
|
944
|
+
`Expected ${svmSpoke.truncateToBytes20()}, 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);
|
|
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 !== ZERO_ADDRESS) {
|
|
978
|
+
if (destinationToken.toAddress() !== ZERO_ADDRESS) {
|
|
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),
|
|
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: L1TokenInfo = 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 {
|
|
@@ -1034,7 +1064,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1034
1064
|
}
|
|
1035
1065
|
|
|
1036
1066
|
// Set running balances and incentive balances for this bundle.
|
|
1037
|
-
const executedRootBundle = spreadEventWithBlockNumber(event) as ExecutedRootBundle;
|
|
1067
|
+
const executedRootBundle = spreadEventWithBlockNumber(event) as ExecutedRootBundle & { l1Tokens: string[] };
|
|
1038
1068
|
const { l1Tokens, runningBalances } = executedRootBundle;
|
|
1039
1069
|
const nTokens = l1Tokens.length;
|
|
1040
1070
|
|
|
@@ -1046,7 +1076,11 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1046
1076
|
);
|
|
1047
1077
|
}
|
|
1048
1078
|
executedRootBundle.runningBalances = runningBalances.slice(0, nTokens);
|
|
1049
|
-
|
|
1079
|
+
const executedRootBundleWithL1Tokens = {
|
|
1080
|
+
...executedRootBundle,
|
|
1081
|
+
l1Tokens: executedRootBundle.l1Tokens.map(toAddressType),
|
|
1082
|
+
};
|
|
1083
|
+
this.executedRootBundles.push(executedRootBundleWithL1Tokens);
|
|
1050
1084
|
}
|
|
1051
1085
|
}
|
|
1052
1086
|
|
|
@@ -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),
|
|
199
|
+
outputToken: toAddressType(event.args.outputToken),
|
|
200
|
+
depositor: toAddressType(event.args.depositor),
|
|
201
|
+
recipient: toAddressType(event.args.recipient),
|
|
202
|
+
exclusiveRelayer: toAddressType(event.args.exclusiveRelayer),
|
|
197
203
|
originChainId: this.chainId,
|
|
198
204
|
quoteBlockNumber: await this.getBlockNumber(Number(event.args["quoteTimestamp"])),
|
|
199
205
|
fromLiteChain: true, // To be updated immediately afterwards.
|
|
@@ -208,7 +214,7 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
208
214
|
|
|
209
215
|
this.logger.debug({
|
|
210
216
|
at: "SpokePoolClient#findDeposit",
|
|
211
|
-
message: "Located
|
|
217
|
+
message: "Located deposit outside of SpokePoolClient's search range",
|
|
212
218
|
deposit,
|
|
213
219
|
elapsedMs: tStop - tStart,
|
|
214
220
|
});
|