@across-protocol/sdk 4.2.16-alpha.6 → 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/clients/BundleDataClient/BundleDataClient.d.ts +2 -3
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +27 -18
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.js +3 -2
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.d.ts +13 -0
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js +18 -0
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.js +1 -1
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +2 -3
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +28 -19
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +3 -5
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +1 -2
- package/dist/esm/clients/HubPoolClient.js +6 -12
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.d.ts +28 -0
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js +30 -0
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.js +1 -1
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +2 -3
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +1 -2
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClientManager.d.ts +29 -0
- package/dist/types/clients/SpokePoolClient/SpokePoolClientManager.d.ts.map +1 -0
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +37 -20
- package/src/clients/BundleDataClient/utils/FillUtils.ts +3 -5
- package/src/clients/HubPoolClient.ts +5 -9
- package/src/clients/SpokePoolClient/SpokePoolClientManager.ts +36 -0
- package/src/clients/mocks/MockHubPoolClient.ts +1 -1
- package/src/interfaces/HubPool.ts +0 -3
- package/src/utils/NetworkUtils.ts +1 -1
|
@@ -213,11 +213,9 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
213
213
|
return l2Token.l2Token;
|
|
214
214
|
}
|
|
215
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
|
|
218
216
|
// Returns the latest L1 token to use for an L2 token as of the input hub block.
|
|
219
217
|
getL1TokenForL2TokenAtBlock(
|
|
220
|
-
l2Token: Address,
|
|
218
|
+
l2Token: Address,
|
|
221
219
|
destinationChainId: number,
|
|
222
220
|
latestHubBlock = Number.MAX_SAFE_INTEGER
|
|
223
221
|
): EvmAddress {
|
|
@@ -225,11 +223,11 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
225
223
|
.filter((l1Token) => this.l2TokenEnabledForL1Token(EvmAddress.from(l1Token), destinationChainId))
|
|
226
224
|
.map((l1Token) => {
|
|
227
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.
|
|
228
227
|
return this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId].filter(
|
|
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
228
|
(dstTokenWithBlock) =>
|
|
232
|
-
dstTokenWithBlock.l2Token.
|
|
229
|
+
dstTokenWithBlock.l2Token.truncateToBytes20() === l2Token.truncateToBytes20() &&
|
|
230
|
+
dstTokenWithBlock.blockNumber <= latestHubBlock
|
|
233
231
|
);
|
|
234
232
|
})
|
|
235
233
|
.flat();
|
|
@@ -270,8 +268,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
270
268
|
return setPoolRebalanceRouteEvents.some((e) => {
|
|
271
269
|
return (
|
|
272
270
|
e.blockNumber <= hubPoolBlock &&
|
|
273
|
-
|
|
274
|
-
e.l2Token.eq(l2Token) &&
|
|
271
|
+
e.l2Token.truncateToBytes20() === l2Token.truncateToBytes20() &&
|
|
275
272
|
Number(_l2ChainId) === l2ChainId
|
|
276
273
|
);
|
|
277
274
|
});
|
|
@@ -822,7 +819,6 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
822
819
|
let runningBalance = toBN(0);
|
|
823
820
|
if (executedRootBundle) {
|
|
824
821
|
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
822
|
if (indexOfL1Token !== -1) {
|
|
827
823
|
runningBalance = executedRootBundle.runningBalances[indexOfL1Token];
|
|
828
824
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import winston from "winston";
|
|
2
|
+
import { SpokePoolClient } from "./SpokePoolClient";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SpokePoolClientManager is a wrapper around spokePoolClients. We want to use wrapper almost always
|
|
6
|
+
* instead of direct access to spokePoolClients because chainId can be invalid and we want to return undefined.
|
|
7
|
+
*/
|
|
8
|
+
export class SpokePoolManager {
|
|
9
|
+
private spokePoolClients: { [chainId: number]: SpokePoolClient };
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
readonly logger: winston.Logger,
|
|
13
|
+
spokePoolClients: { [chainId: number]: SpokePoolClient }
|
|
14
|
+
) {
|
|
15
|
+
this.spokePoolClients = spokePoolClients;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves a SpokePoolClient for a given chainId.
|
|
20
|
+
* @param chainId - The chainId of the spokePoolClient to retrieve.
|
|
21
|
+
* @returns SpokePoolClient | undefined
|
|
22
|
+
* @note This method returns SpokePoolClient for given chainId. If its not found, it returns undefined.
|
|
23
|
+
*/
|
|
24
|
+
getClient(chainId: number): SpokePoolClient | undefined {
|
|
25
|
+
return this.spokePoolClients[chainId];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves all SpokePoolClients
|
|
30
|
+
* @returns SpokePoolClient[]
|
|
31
|
+
* @note This method returns all SpokePoolClients.
|
|
32
|
+
*/
|
|
33
|
+
getSpokePoolClients(): { [chainId: number]: SpokePoolClient } {
|
|
34
|
+
return this.spokePoolClients;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -93,19 +93,16 @@ export interface LpToken {
|
|
|
93
93
|
liquidReserves: BigNumber;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
97
96
|
export interface CrossChainContractsSet extends SortableEvent {
|
|
98
97
|
l2ChainId: number;
|
|
99
98
|
spokePool: Address;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
103
101
|
export interface DestinationTokenWithBlock extends SortableEvent {
|
|
104
102
|
l2Token: Address;
|
|
105
103
|
l1Token: EvmAddress;
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
109
106
|
export interface SetPoolRebalanceRoot extends SortableEvent {
|
|
110
107
|
destinationChainId: number;
|
|
111
108
|
l1Token: EvmAddress;
|
|
@@ -21,7 +21,7 @@ export const hreNetworks: Record<number, string> = {
|
|
|
21
21
|
*/
|
|
22
22
|
export function getNetworkName(networkId: number | string): string {
|
|
23
23
|
networkId = Number(networkId);
|
|
24
|
-
return PUBLIC_NETWORKS[networkId]?.name ?? hreNetworks[networkId] ??
|
|
24
|
+
return PUBLIC_NETWORKS[networkId]?.name ?? hreNetworks[networkId] ?? `unknown (${networkId})`;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|