@across-protocol/sdk 4.1.46-beta.3 → 4.1.46
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/utils/FillUtils.js +2 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +3 -0
- package/dist/cjs/clients/HubPoolClient.js +10 -0
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +3 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +7 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +5 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +1 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.js +0 -2
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +2 -2
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +10 -0
- package/dist/esm/clients/HubPoolClient.js +18 -1
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +3 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js +7 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +10 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +1 -0
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/TokenUtils.js +0 -2
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +10 -0
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +3 -0
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -0
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +1 -0
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/utils/FillUtils.ts +9 -5
- package/src/clients/HubPoolClient.ts +23 -0
- package/src/clients/mocks/MockHubPoolClient.ts +9 -0
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +10 -0
- package/src/relayFeeCalculator/relayFeeCalculator.ts +1 -0
- package/src/utils/TokenUtils.ts +0 -2
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
toBN,
|
|
44
44
|
getTokenInfo,
|
|
45
45
|
getUsdcSymbol,
|
|
46
|
+
getL1TokenInfo,
|
|
46
47
|
compareAddressesSimple,
|
|
47
48
|
chainIsSvm,
|
|
48
49
|
getDeployedAddress,
|
|
@@ -284,6 +285,17 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
284
285
|
return tokenInfo;
|
|
285
286
|
}
|
|
286
287
|
|
|
288
|
+
/**
|
|
289
|
+
* @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw.
|
|
290
|
+
* @dev if the token matched in TOKEN_SYMBOLS_MAP does not have an L1 token address then this will throw.
|
|
291
|
+
* @param tokenAddress Token address on `chain`
|
|
292
|
+
* @param chain Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP.
|
|
293
|
+
* @returns Token info for the given token address on the Hub chain including symbol and decimal and L1 address.
|
|
294
|
+
*/
|
|
295
|
+
getL1TokenInfoForAddress(tokenAddress: string, chain: number): L1Token {
|
|
296
|
+
return getL1TokenInfo(tokenAddress, chain);
|
|
297
|
+
}
|
|
298
|
+
|
|
287
299
|
/**
|
|
288
300
|
* Resolve a given timestamp to a block number on the HubPool chain.
|
|
289
301
|
* @param timestamp A single timestamp to be resolved to a block number on the HubPool chain.
|
|
@@ -503,6 +515,17 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
503
515
|
return this.getTokenInfoForL1Token(l1TokenCounterpart);
|
|
504
516
|
}
|
|
505
517
|
|
|
518
|
+
getTokenInfoForDeposit(deposit: Pick<Deposit, "inputToken" | "originChainId">): L1Token | undefined {
|
|
519
|
+
return this.getTokenInfoForL1Token(
|
|
520
|
+
this.getL1TokenForL2TokenAtBlock(deposit.inputToken, deposit.originChainId, this.latestBlockSearched)
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
getTokenInfo(chainId: number | string, tokenAddress: string): L1Token | undefined {
|
|
525
|
+
const deposit = { originChainId: parseInt(chainId.toString()), inputToken: tokenAddress };
|
|
526
|
+
return this.getTokenInfoForDeposit(deposit);
|
|
527
|
+
}
|
|
528
|
+
|
|
506
529
|
areTokensEquivalent(
|
|
507
530
|
tokenA: string,
|
|
508
531
|
chainIdA: number,
|
|
@@ -23,6 +23,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
23
23
|
private realizedLpFeePctOverride = false;
|
|
24
24
|
|
|
25
25
|
private l1TokensMock: L1Token[] = []; // L1Tokens and their associated info.
|
|
26
|
+
private tokenInfoToReturn: L1Token = { address: "", decimals: 0, symbol: "" };
|
|
26
27
|
|
|
27
28
|
private spokePoolTokens: { [l1Token: string]: { [chainId: number]: string } } = {};
|
|
28
29
|
|
|
@@ -90,6 +91,10 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
90
91
|
return this.l1TokensMock;
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
getTokenInfoForDeposit() {
|
|
95
|
+
return this.tokenInfoToReturn;
|
|
96
|
+
}
|
|
97
|
+
|
|
93
98
|
setTokenMapping(l1Token: string, chainId: number, l2Token: string) {
|
|
94
99
|
this.spokePoolTokens[l1Token] ??= {};
|
|
95
100
|
this.spokePoolTokens[l1Token][chainId] = l2Token;
|
|
@@ -131,6 +136,10 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
131
136
|
return this.l1TokensMock.find((token) => token.address === l1Token);
|
|
132
137
|
}
|
|
133
138
|
|
|
139
|
+
setTokenInfoToReturn(tokenInfo: L1Token) {
|
|
140
|
+
this.tokenInfoToReturn = tokenInfo;
|
|
141
|
+
}
|
|
142
|
+
|
|
134
143
|
_update(eventNames: string[]): Promise<HubPoolUpdate> {
|
|
135
144
|
// Generate new "on chain" responses.
|
|
136
145
|
const latestBlockSearched = this.eventManager.blockNumber;
|
|
@@ -252,4 +252,14 @@ export class QueryBase implements QueryInterface {
|
|
|
252
252
|
);
|
|
253
253
|
return price;
|
|
254
254
|
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Resolves the number of decimal places a token can have
|
|
258
|
+
* @param tokenSymbol A valid Across-Enabled Token ID
|
|
259
|
+
* @returns The number of decimals of precision for the corresponding tokenSymbol
|
|
260
|
+
*/
|
|
261
|
+
getTokenDecimals(tokenSymbol: string): number {
|
|
262
|
+
if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
|
|
263
|
+
return this.symbolMapping[tokenSymbol].decimals;
|
|
264
|
+
}
|
|
255
265
|
}
|
|
@@ -34,6 +34,7 @@ export interface QueryInterface {
|
|
|
34
34
|
}>
|
|
35
35
|
) => Promise<TransactionCostEstimate>;
|
|
36
36
|
getTokenPrice: (tokenSymbol: string) => Promise<number>;
|
|
37
|
+
getTokenDecimals: (tokenSymbol: string) => number;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export const expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
|
package/src/utils/TokenUtils.ts
CHANGED
|
@@ -147,8 +147,6 @@ export function getUsdcSymbol(l2Token: string, chainId: number): string | undefi
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
export function getL1TokenInfo(l2TokenAddress: string, chainId: number): L1Token {
|
|
150
|
-
if (chainId === CHAIN_IDs.MAINNET)
|
|
151
|
-
throw new Error("chainId should be an L2 chainId because many mappings re-use the same L1 token address");
|
|
152
150
|
const tokenObject = Object.values(TOKEN_SYMBOLS_MAP).find(({ addresses }) => addresses[chainId] === l2TokenAddress);
|
|
153
151
|
const l1TokenAddress = tokenObject?.addresses[CHAIN_IDs.MAINNET];
|
|
154
152
|
if (!l1TokenAddress) {
|