@across-protocol/sdk 3.1.2 → 3.1.4

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.
Files changed (92) hide show
  1. package/dist/cjs/clients/SpokePoolClient.d.ts +2 -1
  2. package/dist/cjs/clients/SpokePoolClient.js +9 -3
  3. package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
  4. package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +1 -1
  5. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +10 -8
  6. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  7. package/dist/cjs/gasPriceOracle/adapters/ethereum.js +4 -3
  8. package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
  9. package/dist/cjs/gasPriceOracle/adapters/linea.d.ts +3 -0
  10. package/dist/cjs/gasPriceOracle/adapters/linea.js +10 -0
  11. package/dist/cjs/gasPriceOracle/adapters/linea.js.map +1 -0
  12. package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +1 -1
  13. package/dist/cjs/gasPriceOracle/adapters/polygon.js +17 -27
  14. package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
  15. package/dist/cjs/gasPriceOracle/oracle.js +26 -22
  16. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  17. package/dist/cjs/interfaces/SpokePool.d.ts +2 -1
  18. package/dist/cjs/interfaces/SpokePool.js.map +1 -1
  19. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +16 -8
  20. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.d.ts +16 -8
  21. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +16 -8
  22. package/dist/cjs/utils/BlockUtils.js +1 -0
  23. package/dist/cjs/utils/BlockUtils.js.map +1 -1
  24. package/dist/cjs/utils/NetworkUtils.js +4 -4
  25. package/dist/cjs/utils/NetworkUtils.js.map +1 -1
  26. package/dist/cjs/utils/TokenUtils.d.ts +32 -16
  27. package/dist/esm/clients/SpokePoolClient.d.ts +8 -1
  28. package/dist/esm/clients/SpokePoolClient.js +15 -3
  29. package/dist/esm/clients/SpokePoolClient.js.map +1 -1
  30. package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +1 -1
  31. package/dist/esm/gasPriceOracle/adapters/arbitrum.js +9 -7
  32. package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  33. package/dist/esm/gasPriceOracle/adapters/ethereum.js +5 -4
  34. package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
  35. package/dist/esm/gasPriceOracle/adapters/linea.d.ts +3 -0
  36. package/dist/esm/gasPriceOracle/adapters/linea.js +5 -0
  37. package/dist/esm/gasPriceOracle/adapters/linea.js.map +1 -0
  38. package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +1 -1
  39. package/dist/esm/gasPriceOracle/adapters/polygon.js +15 -26
  40. package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
  41. package/dist/esm/gasPriceOracle/oracle.js +26 -22
  42. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  43. package/dist/esm/interfaces/SpokePool.d.ts +2 -1
  44. package/dist/esm/interfaces/SpokePool.js.map +1 -1
  45. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +16 -8
  46. package/dist/esm/relayFeeCalculator/chain-queries/polygon.d.ts +16 -8
  47. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +16 -8
  48. package/dist/esm/utils/BlockUtils.js +1 -0
  49. package/dist/esm/utils/BlockUtils.js.map +1 -1
  50. package/dist/esm/utils/NetworkUtils.js +4 -4
  51. package/dist/esm/utils/NetworkUtils.js.map +1 -1
  52. package/dist/esm/utils/TokenUtils.d.ts +34 -30
  53. package/dist/types/clients/SpokePoolClient.d.ts +8 -1
  54. package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
  55. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +1 -1
  56. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
  57. package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
  58. package/dist/types/gasPriceOracle/adapters/linea.d.ts +4 -0
  59. package/dist/types/gasPriceOracle/adapters/linea.d.ts.map +1 -0
  60. package/dist/types/gasPriceOracle/adapters/polygon.d.ts +1 -1
  61. package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
  62. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  63. package/dist/types/interfaces/SpokePool.d.ts +2 -1
  64. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  65. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +16 -8
  66. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  67. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts +16 -8
  68. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts.map +1 -1
  69. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +16 -8
  70. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  71. package/dist/types/utils/BlockUtils.d.ts.map +1 -1
  72. package/dist/types/utils/TokenUtils.d.ts +34 -30
  73. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  74. package/package.json +2 -2
  75. package/src/clients/SpokePoolClient.ts +17 -3
  76. package/src/gasPriceOracle/adapters/arbitrum.ts +10 -7
  77. package/src/gasPriceOracle/adapters/ethereum.ts +6 -5
  78. package/src/gasPriceOracle/adapters/linea.ts +11 -0
  79. package/src/gasPriceOracle/adapters/polygon.ts +10 -7
  80. package/src/gasPriceOracle/oracle.ts +20 -15
  81. package/src/interfaces/SpokePool.ts +2 -1
  82. package/src/utils/BlockUtils.ts +1 -0
  83. package/src/utils/NetworkUtils.ts +4 -4
  84. package/dist/cjs/gasPriceOracle/adapters/index.d.ts +0 -3
  85. package/dist/cjs/gasPriceOracle/adapters/index.js +0 -7
  86. package/dist/cjs/gasPriceOracle/adapters/index.js.map +0 -1
  87. package/dist/esm/gasPriceOracle/adapters/index.d.ts +0 -3
  88. package/dist/esm/gasPriceOracle/adapters/index.js +0 -4
  89. package/dist/esm/gasPriceOracle/adapters/index.js.map +0 -1
  90. package/dist/types/gasPriceOracle/adapters/index.d.ts +0 -4
  91. package/dist/types/gasPriceOracle/adapters/index.d.ts.map +0 -1
  92. package/src/gasPriceOracle/adapters/index.ts +0 -3
@@ -78,6 +78,14 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
78
78
  [x: number]: string;
79
79
  };
80
80
  };
81
+ LSK: {
82
+ name: string;
83
+ symbol: string;
84
+ decimals: number;
85
+ addresses: {
86
+ [x: number]: string;
87
+ };
88
+ };
81
89
  MATIC: {
82
90
  name: string;
83
91
  symbol: string;
@@ -86,6 +94,14 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
86
94
  [x: number]: string;
87
95
  };
88
96
  };
97
+ OP: {
98
+ name: string;
99
+ symbol: string;
100
+ decimals: number;
101
+ addresses: {
102
+ [x: number]: string;
103
+ };
104
+ };
89
105
  POOL: {
90
106
  name: string;
91
107
  symbol: string;
@@ -120,13 +136,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
120
136
  };
121
137
  "USDC.e": {
122
138
  name: string;
123
- symbol: string; /**
124
- * Returns the contract address for a given token symbol and chainId.
125
- * @param symbol A case-insensitive token symbol.
126
- * @param chainId The chainId to resolve the contract address for.
127
- * @param tokenMapping A parameter to determine where to source token information. Defaults to the constants variant.
128
- * @returns The contract address for the given token symbol and chainId, or undefined if the token symbol is not supported.
129
- */
139
+ symbol: string;
130
140
  decimals: number;
131
141
  addresses: {
132
142
  [x: number]: string;
@@ -172,14 +182,6 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
172
182
  [x: number]: string;
173
183
  };
174
184
  };
175
- OP: {
176
- name: string;
177
- symbol: string;
178
- decimals: number;
179
- addresses: {
180
- [x: number]: string;
181
- };
182
- };
183
185
  }) => string | undefined;
184
186
  export declare function getTokenInformationFromAddress(address: string, tokenMapping?: {
185
187
  ACX: {
@@ -238,6 +240,14 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
238
240
  [x: number]: string;
239
241
  };
240
242
  };
243
+ LSK: {
244
+ name: string;
245
+ symbol: string;
246
+ decimals: number;
247
+ addresses: {
248
+ [x: number]: string;
249
+ };
250
+ };
241
251
  MATIC: {
242
252
  name: string;
243
253
  symbol: string;
@@ -246,6 +256,14 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
246
256
  [x: number]: string;
247
257
  };
248
258
  };
259
+ OP: {
260
+ name: string;
261
+ symbol: string;
262
+ decimals: number;
263
+ addresses: {
264
+ [x: number]: string;
265
+ };
266
+ };
249
267
  POOL: {
250
268
  name: string;
251
269
  symbol: string;
@@ -280,13 +298,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
280
298
  };
281
299
  "USDC.e": {
282
300
  name: string;
283
- symbol: string; /**
284
- * Returns the contract address for a given token symbol and chainId.
285
- * @param symbol A case-insensitive token symbol.
286
- * @param chainId The chainId to resolve the contract address for.
287
- * @param tokenMapping A parameter to determine where to source token information. Defaults to the constants variant.
288
- * @returns The contract address for the given token symbol and chainId, or undefined if the token symbol is not supported.
289
- */
301
+ symbol: string;
290
302
  decimals: number;
291
303
  addresses: {
292
304
  [x: number]: string;
@@ -332,14 +344,6 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
332
344
  [x: number]: string;
333
345
  };
334
346
  };
335
- OP: {
336
- name: string;
337
- symbol: string;
338
- decimals: number;
339
- addresses: {
340
- [x: number]: string;
341
- };
342
- };
343
347
  }): L1Token | undefined;
344
348
  /**
345
349
  * Retrieves the ERC20 balance for a given address and token address.
@@ -1 +1 @@
1
- {"version":3,"file":"TokenUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/TokenUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE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AY,EAAE,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,GAAE,QAAmB,GAC5B,OAAO,CAAC,SAAS,CAAC,CAGpB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "3.1.2",
4
+ "version": "3.1.4",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "files": [
@@ -99,7 +99,7 @@
99
99
  },
100
100
  "dependencies": {
101
101
  "@across-protocol/across-token": "^1.0.0",
102
- "@across-protocol/constants": "^3.0.1",
102
+ "@across-protocol/constants": "^3.1.2",
103
103
  "@across-protocol/contracts": "^3.0.1",
104
104
  "@eth-optimism/sdk": "^3.3.1",
105
105
  "@pinata/sdk": "^2.1.0",
@@ -546,7 +546,8 @@ export class SpokePoolClient extends BaseAbstractClient {
546
546
  // Derive and append the common properties that are not part of the onchain event.
547
547
  const { quoteBlock: quoteBlockNumber } = dataForQuoteTime[index];
548
548
  const deposit = { ...(rawDeposit as DepositWithBlock), originChainId: this.chainId, quoteBlockNumber };
549
- deposit.originatesFromLiteChain = this.doesDepositOriginateFromLiteChain(deposit);
549
+ deposit.fromLiteChain = this.isOriginLiteChain(deposit);
550
+ deposit.toLiteChain = this.isDestinationLiteChain(deposit);
550
551
  if (deposit.outputToken === ZERO_ADDRESS) {
551
552
  deposit.outputToken = this.getDestinationTokenForDeposit(deposit);
552
553
  }
@@ -843,7 +844,8 @@ export class SpokePoolClient extends BaseAbstractClient {
843
844
  ? this.getDestinationTokenForDeposit({ ...partialDeposit, originChainId: this.chainId })
844
845
  : partialDeposit.outputToken,
845
846
  };
846
- deposit.originatesFromLiteChain = this.doesDepositOriginateFromLiteChain(deposit);
847
+ deposit.fromLiteChain = this.isOriginLiteChain(deposit);
848
+ deposit.toLiteChain = this.isDestinationLiteChain(deposit);
847
849
 
848
850
  this.logger.debug({
849
851
  at: "SpokePoolClient#findDeposit",
@@ -861,7 +863,19 @@ export class SpokePoolClient extends BaseAbstractClient {
861
863
  * @returns True if the deposit originates from a lite chain, false otherwise. If the hub pool client is not defined,
862
864
  * this method will return false.
863
865
  */
864
- protected doesDepositOriginateFromLiteChain(deposit: DepositWithBlock): boolean {
866
+ protected isOriginLiteChain(deposit: DepositWithBlock): boolean {
865
867
  return this.configStoreClient?.isChainLiteChainAtTimestamp(deposit.originChainId, deposit.quoteTimestamp) ?? false;
866
868
  }
869
+
870
+ /**
871
+ * Determines whether the deposit destination chain is a lite chain.
872
+ * @param deposit The deposit to evaluate.
873
+ * @returns True if the deposit is destined to a lite chain, false otherwise. If the hub pool client is not defined,
874
+ * this method will return false.
875
+ */
876
+ protected isDestinationLiteChain(deposit: DepositWithBlock): boolean {
877
+ return (
878
+ this.configStoreClient?.isChainLiteChainAtTimestamp(deposit.destinationChainId, deposit.quoteTimestamp) ?? false
879
+ );
880
+ }
867
881
  }
@@ -1,21 +1,24 @@
1
- import { ethers, providers, utils as ethersUtils } from "ethers";
1
+ import { providers, utils as ethersUtils } from "ethers";
2
+ import { bnOne } from "../../utils";
2
3
  import { GasPriceEstimate } from "../types";
3
- import { eip1559 } from "./ethereum";
4
+ import * as ethereum from "./ethereum";
5
+
6
+ const DEFAULT_PRIORITY_FEE = ethersUtils.parseUnits("1.5", 9);
4
7
 
5
8
  // Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller. Further,
6
9
  // ethers typically hardcodes the priority fee to 1.5 Gwei. So, confirm that the priority fee supplied was 1.5
7
10
  // Gwei, and then drop it to 1 Wei. Reference: https://developer.arbitrum.io/faqs/gas-faqs#q-priority
8
- export async function eip1559_arbitrum(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
9
- const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await eip1559(provider, chainId);
11
+ export async function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
12
+ const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await ethereum.eip1559(provider, chainId);
10
13
 
11
14
  // If this throws, ethers default behaviour has changed, or Arbitrum RPCs are returning something more sensible.
12
- if (!maxPriorityFeePerGas.eq(ethersUtils.parseUnits("1.5", 9))) {
15
+ if (!maxPriorityFeePerGas.eq(DEFAULT_PRIORITY_FEE)) {
13
16
  throw new Error(`Expected hardcoded 1.5 Gwei priority fee on Arbitrum, got ${maxPriorityFeePerGas}`);
14
17
  }
15
18
 
16
19
  // eip1559() sets maxFeePerGas = lastBaseFeePerGas + maxPriorityFeePerGas, so revert that.
17
20
  // The caller may apply scaling as they wish afterwards.
18
- const maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(1);
21
+ const maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(bnOne);
19
22
 
20
- return { maxPriorityFeePerGas: ethers.constants.One, maxFeePerGas };
23
+ return { maxPriorityFeePerGas: bnOne, maxFeePerGas };
21
24
  }
@@ -1,4 +1,5 @@
1
- import { BigNumber, providers, ethers } from "ethers";
1
+ import { BigNumber, providers } from "ethers";
2
+ import { bnZero } from "../../utils";
2
3
  import { GasPriceEstimate } from "../types";
3
4
  import { gasPriceError } from "../util";
4
5
 
@@ -6,7 +7,7 @@ export async function eip1559(provider: providers.Provider, chainId: number): Pr
6
7
  const feeData = await provider.getFeeData();
7
8
 
8
9
  [feeData.lastBaseFeePerGas, feeData.maxPriorityFeePerGas].forEach((field: BigNumber | null) => {
9
- if (!BigNumber.isBigNumber(field) || field.lt(0)) gasPriceError("getFeeData()", chainId, feeData);
10
+ if (!BigNumber.isBigNumber(field) || field.lt(bnZero)) gasPriceError("getFeeData()", chainId, feeData);
10
11
  });
11
12
 
12
13
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas as BigNumber;
@@ -16,12 +17,12 @@ export async function eip1559(provider: providers.Provider, chainId: number): Pr
16
17
  }
17
18
 
18
19
  export async function legacy(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
19
- const gasPrice: BigNumber = await provider.getGasPrice();
20
+ const gasPrice = await provider.getGasPrice();
20
21
 
21
- if (!BigNumber.isBigNumber(gasPrice) || gasPrice.lt(0)) gasPriceError("getGasPrice()", chainId, gasPrice);
22
+ if (!BigNumber.isBigNumber(gasPrice) || gasPrice.lt(bnZero)) gasPriceError("getGasPrice()", chainId, gasPrice);
22
23
 
23
24
  return {
24
25
  maxFeePerGas: gasPrice,
25
- maxPriorityFeePerGas: ethers.constants.Zero,
26
+ maxPriorityFeePerGas: bnZero,
26
27
  };
27
28
  }
@@ -0,0 +1,11 @@
1
+ // Linea recommend using the custom linea_estimateGas() RPC query.
2
+ // This query is currently only available on Linea Sepolia, ETA mainnet 30 July.
3
+ // Until then, just parrot the existing Ethereum EIP-1559 pricing strategy.
4
+ // See also: https://docs.linea.build/developers/reference/api/linea-estimategas
5
+ import { providers } from "ethers";
6
+ import { GasPriceEstimate } from "../types";
7
+ import * as ethereum from "./ethereum";
8
+
9
+ export function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
10
+ return ethereum.eip1559(provider, chainId);
11
+ }
@@ -1,6 +1,7 @@
1
1
  import { providers, utils as ethersUtils } from "ethers";
2
2
  import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "../../priceClient/adapters/baseAdapter";
3
- import { isDefined } from "../../utils/TypeGuards";
3
+ import { bnZero, isDefined } from "../../utils";
4
+ import { CHAIN_IDs } from "../../constants";
4
5
  import { GasPriceEstimate } from "../types";
5
6
  import { gasPriceError } from "../util";
6
7
  import { eip1559 } from "./ethereum";
@@ -24,13 +25,15 @@ type GasStationArgs = BaseHTTPAdapterArgs & {
24
25
  host?: string;
25
26
  };
26
27
 
28
+ const { POLYGON } = CHAIN_IDs;
29
+
27
30
  // @dev toBNWei() is not imported from ../utils because of a circular dependency loop.
28
31
  // The fix is probably to relocate the function estimateTotalGasRequiredByUnsignedTransaction().
29
32
  class PolygonGasStation extends BaseHTTPAdapter {
30
33
  readonly chainId: number;
31
34
 
32
- constructor({ chainId = 137, host, timeout = 1500, retries = 1 }: GasStationArgs = {}) {
33
- host = host ?? chainId === 137 ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
35
+ constructor({ chainId = POLYGON, host, timeout = 1500, retries = 1 }: GasStationArgs = {}) {
36
+ host = host ?? chainId === POLYGON ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
34
37
 
35
38
  super("Polygon Gas Station", host, { timeout, retries });
36
39
  this.chainId = chainId;
@@ -42,7 +45,7 @@ class PolygonGasStation extends BaseHTTPAdapter {
42
45
  const gasPrice: Polygon1559GasPrice = (gas as GasStationV2Response)?.[strategy];
43
46
  if (!this.isPolygon1559GasPrice(gasPrice)) {
44
47
  // @todo: generalise gasPriceError() to accept a reason/cause?
45
- gasPriceError("getFeeData()", this.chainId, ethersUtils.parseUnits("0"));
48
+ gasPriceError("getFeeData()", this.chainId, bnZero);
46
49
  }
47
50
 
48
51
  [gasPrice.maxFee, gasPrice.maxPriorityFee].forEach((gasPrice) => {
@@ -66,12 +69,12 @@ class PolygonGasStation extends BaseHTTPAdapter {
66
69
  }
67
70
  }
68
71
 
69
- export async function polygonGasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
72
+ export function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
70
73
  const gasStation = new PolygonGasStation({ chainId: chainId });
71
74
  try {
72
- return await gasStation.getFeeData();
75
+ return gasStation.getFeeData();
73
76
  } catch (err) {
74
77
  // Fall back to the RPC provider. May be less accurate.
75
- return await eip1559(provider, chainId);
78
+ return eip1559(provider, chainId);
76
79
  }
77
80
  }
@@ -1,6 +1,11 @@
1
1
  import { providers } from "ethers";
2
- import { eip1559, eip1559_arbitrum, legacy, polygonGasStation } from "./adapters";
2
+ import { CHAIN_IDs } from "../constants";
3
+ import { chainIsOPStack } from "../utils";
3
4
  import { GasPriceEstimate, GasPriceFeed } from "./types";
5
+ import * as arbitrum from "./adapters/arbitrum";
6
+ import * as ethereum from "./adapters/ethereum";
7
+ import * as linea from "./adapters/linea";
8
+ import * as polygon from "./adapters/polygon";
4
9
 
5
10
  /**
6
11
  * Provide an estimate for the current gas price for a particular chain.
@@ -14,29 +19,29 @@ export async function getGasPriceEstimate(
14
19
  chainId?: number,
15
20
  legacyFallback = true
16
21
  ): Promise<GasPriceEstimate> {
17
- if (!chainId) {
18
- const network: providers.Network = await provider.getNetwork();
19
- chainId = network.chainId;
22
+ if (chainId === undefined) {
23
+ ({ chainId } = await provider.getNetwork());
20
24
  }
21
25
 
22
26
  const gasPriceFeeds: { [chainId: number]: GasPriceFeed } = {
23
- 1: eip1559,
24
- 10: eip1559,
25
- 137: polygonGasStation,
26
- 288: legacy,
27
- 324: legacy,
28
- 8453: eip1559,
29
- 42161: eip1559_arbitrum,
27
+ [CHAIN_IDs.ARBITRUM]: arbitrum.eip1559,
28
+ [CHAIN_IDs.BASE]: ethereum.eip1559,
29
+ [CHAIN_IDs.BOBA]: ethereum.legacy,
30
+ [CHAIN_IDs.LINEA]: linea.eip1559, // @todo: Support linea_estimateGas in adapter.
31
+ [CHAIN_IDs.MAINNET]: ethereum.eip1559,
32
+ [CHAIN_IDs.MODE]: ethereum.eip1559,
33
+ [CHAIN_IDs.OPTIMISM]: ethereum.eip1559,
34
+ [CHAIN_IDs.POLYGON]: polygon.gasStation,
35
+ [CHAIN_IDs.ZK_SYNC]: ethereum.legacy,
30
36
  };
31
37
 
32
- let gasPriceFeed: GasPriceFeed = gasPriceFeeds[chainId];
38
+ let gasPriceFeed = gasPriceFeeds[chainId];
33
39
  if (gasPriceFeed === undefined) {
34
40
  if (!legacyFallback) {
35
41
  throw new Error(`No suitable gas price oracle for Chain ID ${chainId}`);
36
42
  }
37
- gasPriceFeed = legacy;
43
+ gasPriceFeed = chainIsOPStack(chainId) ? ethereum.eip1559 : ethereum.legacy;
38
44
  }
39
45
 
40
- const gasPriceEstimate: GasPriceEstimate = await gasPriceFeed(provider, chainId);
41
- return gasPriceEstimate;
46
+ return gasPriceFeed(provider, chainId);
42
47
  }
@@ -28,7 +28,8 @@ export interface Deposit extends RelayData {
28
28
  updatedRecipient?: string;
29
29
  updatedOutputAmount?: BigNumber;
30
30
  updatedMessage?: string;
31
- originatesFromLiteChain: boolean;
31
+ fromLiteChain: boolean;
32
+ toLiteChain: boolean;
32
33
  }
33
34
 
34
35
  export interface DepositWithBlock extends Deposit, SortableEvent {
@@ -36,6 +36,7 @@ const now = getCurrentTime(); // Seed the cache with initial values.
36
36
  const blockTimes: { [chainId: number]: BlockTimeAverage } = {
37
37
  [CHAIN_IDs.BASE]: { average: 2, timestamp: now, blockRange: 1 },
38
38
  [CHAIN_IDs.LINEA]: { average: 3, timestamp: now, blockRange: 1 },
39
+ [CHAIN_IDs.LISK]: { average: 2, timestamp: now, blockRange: 1 },
39
40
  [CHAIN_IDs.MAINNET]: { average: 12.5, timestamp: now, blockRange: 1 },
40
41
  [CHAIN_IDs.MODE]: { average: 2, timestamp: now, blockRange: 1 },
41
42
  [CHAIN_IDs.OPTIMISM]: { average: 2, timestamp: now, blockRange: 1 },
@@ -60,11 +60,11 @@ export function chainIsOPStack(chainId: number): boolean {
60
60
  return [
61
61
  CHAIN_IDs.OPTIMISM,
62
62
  CHAIN_IDs.BASE,
63
+ CHAIN_IDs.LISK,
63
64
  CHAIN_IDs.MODE,
64
- CHAIN_IDs.OPTIMISM_GOERLI,
65
- CHAIN_IDs.BASE_GOERLI,
66
65
  CHAIN_IDs.OPTIMISM_SEPOLIA,
67
66
  CHAIN_IDs.BASE_SEPOLIA,
67
+ CHAIN_IDs.LISK_SEPOLIA,
68
68
  CHAIN_IDs.MODE_SEPOLIA,
69
69
  ].includes(chainId);
70
70
  }
@@ -75,7 +75,7 @@ export function chainIsOPStack(chainId: number): boolean {
75
75
  * @returns True if chainId is an Arbitrum chain, otherwise false.
76
76
  */
77
77
  export function chainIsArbitrum(chainId: number): boolean {
78
- return [CHAIN_IDs.ARBITRUM, CHAIN_IDs.ARBITRUM_GOERLI, CHAIN_IDs.ARBITRUM_SEPOLIA].includes(chainId);
78
+ return [CHAIN_IDs.ARBITRUM, CHAIN_IDs.ARBITRUM_SEPOLIA].includes(chainId);
79
79
  }
80
80
 
81
81
  /**
@@ -84,7 +84,7 @@ export function chainIsArbitrum(chainId: number): boolean {
84
84
  * @returns True if chainId is a Linea chain, otherwise false.
85
85
  */
86
86
  export function chainIsLinea(chainId: number): boolean {
87
- return [CHAIN_IDs.LINEA, CHAIN_IDs.LINEA_GOERLI].includes(chainId);
87
+ return [CHAIN_IDs.LINEA].includes(chainId);
88
88
  }
89
89
 
90
90
  /**
@@ -1,3 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./ethereum"), exports);
5
- tslib_1.__exportStar(require("./arbitrum"), exports);
6
- tslib_1.__exportStar(require("./polygon"), exports);
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,qDAA2B;AAC3B,oDAA0B"}
@@ -1,3 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";
@@ -1,4 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from "./ethereum";
2
- export * from "./arbitrum";
3
- export * from "./polygon";