@across-protocol/sdk 3.3.31 → 3.4.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.
Files changed (163) hide show
  1. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +8 -2
  2. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  3. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
  4. package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +2 -1
  5. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +2 -2
  6. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  7. package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +6 -4
  8. package/dist/cjs/gasPriceOracle/adapters/ethereum.js +21 -13
  9. package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
  10. package/dist/cjs/gasPriceOracle/adapters/linea-viem.d.ts +2 -1
  11. package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +16 -10
  12. package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
  13. package/dist/cjs/gasPriceOracle/adapters/linea.d.ts +2 -1
  14. package/dist/cjs/gasPriceOracle/adapters/linea.js +2 -2
  15. package/dist/cjs/gasPriceOracle/adapters/linea.js.map +1 -1
  16. package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +21 -1
  17. package/dist/cjs/gasPriceOracle/adapters/polygon.js +45 -5
  18. package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
  19. package/dist/cjs/gasPriceOracle/oracle.d.ts +11 -3
  20. package/dist/cjs/gasPriceOracle/oracle.js +29 -27
  21. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  22. package/dist/cjs/providers/types.d.ts +3 -3
  23. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
  24. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.js +2 -12
  25. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.js.map +1 -1
  26. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +10 -5
  27. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +55 -11
  28. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  29. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  30. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +4 -5
  31. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  32. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
  33. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js +2 -12
  34. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js.map +1 -1
  35. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  36. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  37. package/dist/cjs/utils/DepositUtils.d.ts +1 -0
  38. package/dist/cjs/utils/DepositUtils.js +5 -1
  39. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  40. package/dist/cjs/utils/Multicall.js +0 -5
  41. package/dist/cjs/utils/Multicall.js.map +1 -1
  42. package/dist/cjs/utils/common.d.ts +1 -8
  43. package/dist/cjs/utils/common.js +1 -83
  44. package/dist/cjs/utils/common.js.map +1 -1
  45. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +16 -3
  46. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  47. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
  48. package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +10 -1
  49. package/dist/esm/gasPriceOracle/adapters/arbitrum.js +10 -4
  50. package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  51. package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +19 -6
  52. package/dist/esm/gasPriceOracle/adapters/ethereum.js +38 -16
  53. package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
  54. package/dist/esm/gasPriceOracle/adapters/linea-viem.d.ts +19 -1
  55. package/dist/esm/gasPriceOracle/adapters/linea-viem.js +33 -10
  56. package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
  57. package/dist/esm/gasPriceOracle/adapters/linea.d.ts +2 -1
  58. package/dist/esm/gasPriceOracle/adapters/linea.js +6 -2
  59. package/dist/esm/gasPriceOracle/adapters/linea.js.map +1 -1
  60. package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +27 -1
  61. package/dist/esm/gasPriceOracle/adapters/polygon.js +49 -5
  62. package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
  63. package/dist/esm/gasPriceOracle/oracle.d.ts +16 -8
  64. package/dist/esm/gasPriceOracle/oracle.js +35 -33
  65. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  66. package/dist/esm/providers/types.d.ts +3 -3
  67. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
  68. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.js +3 -13
  69. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.js.map +1 -1
  70. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +21 -7
  71. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +68 -15
  72. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  73. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  74. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +4 -5
  75. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  76. package/dist/esm/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
  77. package/dist/esm/relayFeeCalculator/chain-queries/polygon.js +3 -13
  78. package/dist/esm/relayFeeCalculator/chain-queries/polygon.js.map +1 -1
  79. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  80. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  81. package/dist/esm/utils/DepositUtils.d.ts +9 -0
  82. package/dist/esm/utils/DepositUtils.js +11 -0
  83. package/dist/esm/utils/DepositUtils.js.map +1 -1
  84. package/dist/esm/utils/Multicall.js +1 -6
  85. package/dist/esm/utils/Multicall.js.map +1 -1
  86. package/dist/esm/utils/common.d.ts +1 -19
  87. package/dist/esm/utils/common.js +3 -95
  88. package/dist/esm/utils/common.js.map +1 -1
  89. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  90. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +10 -10
  91. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +10 -1
  92. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
  93. package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +19 -6
  94. package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
  95. package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts +19 -1
  96. package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts.map +1 -1
  97. package/dist/types/gasPriceOracle/adapters/linea.d.ts +2 -1
  98. package/dist/types/gasPriceOracle/adapters/linea.d.ts.map +1 -1
  99. package/dist/types/gasPriceOracle/adapters/polygon.d.ts +27 -1
  100. package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
  101. package/dist/types/gasPriceOracle/oracle.d.ts +16 -8
  102. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  103. package/dist/types/providers/types.d.ts +3 -3
  104. package/dist/types/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -229
  105. package/dist/types/relayFeeCalculator/chain-queries/alephZero.d.ts.map +1 -1
  106. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +21 -7
  107. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  108. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
  109. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  110. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts +0 -229
  111. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts.map +1 -1
  112. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +1 -1
  113. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  114. package/dist/types/utils/DepositUtils.d.ts +9 -0
  115. package/dist/types/utils/DepositUtils.d.ts.map +1 -1
  116. package/dist/types/utils/Multicall.d.ts.map +1 -1
  117. package/dist/types/utils/common.d.ts +1 -19
  118. package/dist/types/utils/common.d.ts.map +1 -1
  119. package/package.json +1 -1
  120. package/src/clients/BundleDataClient/BundleDataClient.ts +17 -2
  121. package/src/gasPriceOracle/adapters/arbitrum.ts +13 -6
  122. package/src/gasPriceOracle/adapters/ethereum.ts +43 -12
  123. package/src/gasPriceOracle/adapters/linea-viem.ts +32 -6
  124. package/src/gasPriceOracle/adapters/linea.ts +7 -2
  125. package/src/gasPriceOracle/adapters/polygon.ts +46 -5
  126. package/src/gasPriceOracle/oracle.ts +53 -28
  127. package/src/relayFeeCalculator/chain-queries/alephZero.ts +1 -29
  128. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +73 -20
  129. package/src/relayFeeCalculator/chain-queries/factory.ts +6 -6
  130. package/src/relayFeeCalculator/chain-queries/polygon.ts +1 -29
  131. package/src/relayFeeCalculator/relayFeeCalculator.ts +6 -1
  132. package/src/utils/DepositUtils.ts +12 -0
  133. package/src/utils/Multicall.ts +1 -6
  134. package/src/utils/common.ts +2 -92
  135. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -3
  136. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js +0 -21
  137. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js.map +0 -1
  138. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -4
  139. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js +0 -26
  140. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js.map +0 -1
  141. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.d.ts +0 -3
  142. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js +0 -84
  143. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js.map +0 -1
  144. package/dist/cjs/package.json +0 -1
  145. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -3
  146. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js +0 -20
  147. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js.map +0 -1
  148. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -4
  149. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js +0 -21
  150. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js.map +0 -1
  151. package/dist/esm/gasPriceOracle/adapters/polygon-viem.d.ts +0 -3
  152. package/dist/esm/gasPriceOracle/adapters/polygon-viem.js +0 -82
  153. package/dist/esm/gasPriceOracle/adapters/polygon-viem.js.map +0 -1
  154. package/dist/esm/package.json +0 -1
  155. package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts +0 -4
  156. package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts.map +0 -1
  157. package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts +0 -5
  158. package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts.map +0 -1
  159. package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts +0 -4
  160. package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts.map +0 -1
  161. package/src/gasPriceOracle/adapters/arbitrum-viem.ts +0 -13
  162. package/src/gasPriceOracle/adapters/ethereum-viem.ts +0 -19
  163. package/src/gasPriceOracle/adapters/polygon-viem.ts +0 -86
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAA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,MAAM,GAAG,MAAU,EAC1B,QAAQ,SAAK,GACZ,MAAM,CAGR;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,GAAG,EAAE,CAE9E;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,gBAC5B,UAAU,aACZ,UAAU,kBACL,UAAU,kBACV,UAAU,KACzB,MAGF,CAAC;AACF;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,gBAC1B,UAAU,aACZ,UAAU,kBACL,UAAU,kBACV,UAAU,KACzB,MAaF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,gBACL,UAAU,aACZ,UAAU,kBACL,UAAU,kBACV,UAAU,KACzB,MAEF,CAAC;AACF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,QAAS,MAAM,OAAO,MAAM,QAAQ,MAAM,eAYvE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,oBAEpC;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ1F;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,SAAS,CAAC;IACzB,YAAY,EAAE,SAAS,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,aAAa,WAE5B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "3.3.31",
4
+ "version": "3.4.0",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "files": [
@@ -31,6 +31,7 @@ import {
31
31
  isSlowFill,
32
32
  mapAsync,
33
33
  bnUint32Max,
34
+ isZeroValueDeposit,
34
35
  } from "../../utils";
35
36
  import winston from "winston";
36
37
  import {
@@ -778,6 +779,9 @@ export class BundleDataClient {
778
779
  continue;
779
780
  }
780
781
  originClient.getDepositsForDestinationChain(destinationChainId).forEach((deposit) => {
782
+ if (isZeroValueDeposit(deposit)) {
783
+ return;
784
+ }
781
785
  depositCounter++;
782
786
  const relayDataHash = this.getRelayHashFromEvent(deposit);
783
787
  if (v3RelayHashes[relayDataHash]) {
@@ -793,6 +797,14 @@ export class BundleDataClient {
793
797
  slowFillRequest: undefined,
794
798
  };
795
799
 
800
+ // Once we've saved the deposit hash into v3RelayHashes, then we can exit early here if the inputAmount
801
+ // is 0 because there can be no expired amount to refund and no unexecutable slow fill amount to return
802
+ // if this deposit did expire. Input amount can only be zero at this point if the message is non-empty,
803
+ // but the message doesn't matter for expired deposits and unexecutable slow fills.
804
+ if (deposit.inputAmount.eq(0)) {
805
+ return;
806
+ }
807
+
796
808
  // If deposit block is within origin chain bundle block range, then save as bundle deposit.
797
809
  // If deposit is in bundle and it has expired, additionally save it as an expired deposit.
798
810
  // If deposit is not in the bundle block range, then save it as an older deposit that
@@ -840,7 +852,10 @@ export class BundleDataClient {
840
852
  await forEachAsync(
841
853
  destinationClient
842
854
  .getFillsForOriginChain(originChainId)
843
- .filter((fill) => fill.blockNumber <= destinationChainBlockRange[1]),
855
+ // We can remove fills for deposits with input amount equal to zero because these will result in 0 refunded
856
+ // tokens to the filler. We can't remove non-empty message deposit here in case there is a slow fill
857
+ // request for the deposit, we'd want to see the fill took place.
858
+ .filter((fill) => fill.blockNumber <= destinationChainBlockRange[1] && !isZeroValueDeposit(fill)),
844
859
  async (fill) => {
845
860
  const relayDataHash = this.getRelayHashFromEvent(fill);
846
861
  fillCounter++;
@@ -933,7 +948,7 @@ export class BundleDataClient {
933
948
  await forEachAsync(
934
949
  destinationClient
935
950
  .getSlowFillRequestsForOriginChain(originChainId)
936
- .filter((request) => request.blockNumber <= destinationChainBlockRange[1]),
951
+ .filter((request) => request.blockNumber <= destinationChainBlockRange[1] && !isZeroValueDeposit(request)),
937
952
  async (slowFillRequest: SlowFillRequestWithBlock) => {
938
953
  const relayDataHash = this.getRelayHashFromEvent(slowFillRequest);
939
954
 
@@ -2,14 +2,21 @@ import { providers } from "ethers";
2
2
  import { bnOne } from "../../utils";
3
3
  import { GasPriceEstimate } from "../types";
4
4
  import * as ethereum from "./ethereum";
5
+ import { GasPriceEstimateOptions } from "../oracle";
5
6
 
6
- // Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller.
7
- // Reference: https://docs.arbitrum.io/how-arbitrum-works/gas-fees
8
- export async function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
9
- const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await ethereum.eip1559(provider, chainId);
7
+ /**
8
+ * @notice Return Arbitrum orbit gas fees
9
+ * @dev Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller.
10
+ * Reference: https://docs.arbitrum.io/how-arbitrum-works/gas-fees so we hardcode the priority fee
11
+ * to 1 wei.
12
+ * @param provider Ethers Provider
13
+ * @returns GasPriceEstimate
14
+ */
15
+ export async function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate> {
16
+ const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await ethereum.eip1559(provider, opts);
10
17
 
11
- // eip1559() sets maxFeePerGas = lastBaseFeePerGas + maxPriorityFeePerGas, so revert that.
12
- // The caller may apply scaling as they wish afterwards.
18
+ // eip1559() sets maxFeePerGas = lastBaseFeePerGas + maxPriorityFeePerGas, so back out priority fee.
19
+ // The remaining maxFeePerGas should be scaled already.
13
20
  const maxFeePerGas = _maxFeePerGas.sub(maxPriorityFeePerGas).add(bnOne);
14
21
 
15
22
  return { maxPriorityFeePerGas: bnOne, maxFeePerGas };
@@ -1,26 +1,40 @@
1
1
  import assert from "assert";
2
2
  import { providers } from "ethers";
3
- import { BigNumber, bnZero, getNetworkName } from "../../utils";
3
+ import { BigNumber, bnZero, fixedPointAdjustment, getNetworkName } from "../../utils";
4
4
  import { GasPriceEstimate } from "../types";
5
5
  import { gasPriceError } from "../util";
6
+ import { GasPriceEstimateOptions } from "../oracle";
7
+
8
+ // TODO: We intend to remove `eip1559Bad()` as an option and make eip1559Raw the only option eventually. The reason
9
+ // they both exist currently is because eip1559Raw is new and untested on production so we will slowly roll it out
10
+ // by using the convenient environment variable safety guard.
6
11
 
7
12
  /**
13
+ * @dev If GAS_PRICE_EIP1559_RAW_${chainId}=true, then constructs total fee by adding
14
+ * eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas, otherwise calls the ethers provider's
15
+ * getFeeData() method which adds eth_getBlock("latest").baseFee to a hardcoded priority fee of 1.5 gwei.
8
16
  * @param provider ethers RPC provider instance.
9
- * @param chainId Chain ID of provider instance.
10
17
  * @returns Promise of gas price estimate object.
11
18
  */
12
- export function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
13
- const useRaw = process.env[`GAS_PRICE_EIP1559_RAW_${chainId}`] === "true";
14
- return useRaw ? eip1559Raw(provider, chainId) : eip1559Bad(provider, chainId);
19
+ export function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate> {
20
+ const useRaw = process.env[`GAS_PRICE_EIP1559_RAW_${opts.chainId}`] === "true";
21
+ return useRaw
22
+ ? eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier)
23
+ : eip1559Bad(provider, opts.chainId, opts.baseFeeMultiplier);
15
24
  }
16
25
 
17
26
  /**
18
27
  * @note Performs direct RPC calls to retrieve the RPC-suggested priority fee for the next block.
28
+ * @dev Constructs total fee by adding eth_getBlock("pending").baseFee to eth_maxPriorityFeePerGas
19
29
  * @param provider ethers RPC provider instance.
20
30
  * @param chainId Chain ID of the provider instance.
21
31
  * @returns Promise of gas price estimate object.
22
32
  */
23
- export async function eip1559Raw(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
33
+ export async function eip1559Raw(
34
+ provider: providers.Provider,
35
+ chainId: number,
36
+ baseFeeMultiplier: BigNumber
37
+ ): Promise<GasPriceEstimate> {
24
38
  const [{ baseFeePerGas }, _maxPriorityFeePerGas] = await Promise.all([
25
39
  provider.getBlock("pending"),
26
40
  (provider as providers.JsonRpcProvider).send("eth_maxPriorityFeePerGas", []),
@@ -28,19 +42,27 @@ export async function eip1559Raw(provider: providers.Provider, chainId: number):
28
42
  const maxPriorityFeePerGas = BigNumber.from(_maxPriorityFeePerGas);
29
43
  assert(BigNumber.isBigNumber(baseFeePerGas), `No baseFeePerGas received on ${getNetworkName(chainId)}`);
30
44
 
45
+ const scaledBaseFee = baseFeePerGas.mul(baseFeeMultiplier).div(fixedPointAdjustment);
31
46
  return {
32
- maxFeePerGas: maxPriorityFeePerGas.add(baseFeePerGas),
47
+ maxFeePerGas: maxPriorityFeePerGas.add(scaledBaseFee),
33
48
  maxPriorityFeePerGas,
34
49
  };
35
50
  }
36
51
 
37
52
  /**
38
- * @note Resolves priority gas pricing poorly, because the priority fee is hardcoded to 1.5 Gwei in ethers v5.
53
+ * @notice Returns fee data using provider's getFeeData() method.
54
+ * @note Resolves priority gas pricing poorly, because the priority fee is hardcoded to 1.5 Gwei in ethers v5's
55
+ * getFeeData() method
56
+ * @dev TODO: Remove this function soon. See note above about slowly rolling out eip1559Raw.
39
57
  * @param provider ethers RPC provider instance.
40
58
  * @param chainId Chain ID of the provider instance.
41
59
  * @returns Promise of gas price estimate object.
42
60
  */
43
- export async function eip1559Bad(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
61
+ export async function eip1559Bad(
62
+ provider: providers.Provider,
63
+ chainId: number,
64
+ baseFeeMultiplier: BigNumber
65
+ ): Promise<GasPriceEstimate> {
44
66
  const feeData = await provider.getFeeData();
45
67
 
46
68
  [feeData.lastBaseFeePerGas, feeData.maxPriorityFeePerGas].forEach((field: BigNumber | null) => {
@@ -48,18 +70,27 @@ export async function eip1559Bad(provider: providers.Provider, chainId: number):
48
70
  });
49
71
 
50
72
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas as BigNumber;
51
- const maxFeePerGas = maxPriorityFeePerGas.add(feeData.lastBaseFeePerGas as BigNumber);
73
+ const scaledLastBaseFeePerGas = (feeData.lastBaseFeePerGas as BigNumber)
74
+ .mul(baseFeeMultiplier)
75
+ .div(fixedPointAdjustment);
76
+ const maxFeePerGas = maxPriorityFeePerGas.add(scaledLastBaseFeePerGas);
52
77
 
53
78
  return { maxPriorityFeePerGas, maxFeePerGas };
54
79
  }
55
80
 
56
- export async function legacy(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
81
+ /**
82
+ * @notice Returns result of eth_gasPrice RPC call
83
+ * @dev Its recommended to use the eip1559Raw method over this one where possible as it will be more accurate.
84
+ * @returns GasPriceEstimate
85
+ */
86
+ export async function legacy(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate> {
87
+ const { chainId, baseFeeMultiplier } = opts;
57
88
  const gasPrice = await provider.getGasPrice();
58
89
 
59
90
  if (!BigNumber.isBigNumber(gasPrice) || gasPrice.lt(bnZero)) gasPriceError("getGasPrice()", chainId, gasPrice);
60
91
 
61
92
  return {
62
- maxFeePerGas: gasPrice,
93
+ maxFeePerGas: gasPrice.mul(baseFeeMultiplier).div(fixedPointAdjustment),
63
94
  maxPriorityFeePerGas: bnZero,
64
95
  };
65
96
  }
@@ -1,14 +1,40 @@
1
- import { PublicClient } from "viem";
1
+ import { Address, Hex, PublicClient } from "viem";
2
2
  import { estimateGas } from "viem/linea";
3
3
  import { DEFAULT_SIMULATED_RELAYER_ADDRESS as account } from "../../constants";
4
4
  import { InternalGasPriceEstimate } from "../types";
5
+ import { GasPriceEstimateOptions } from "../oracle";
6
+ import { fixedPointAdjustment } from "../../utils";
5
7
 
6
- export async function eip1559(provider: PublicClient, _chainId?: number): Promise<InternalGasPriceEstimate> {
7
- const { baseFeePerGas, priorityFeePerGas } = await estimateGas(provider, {
8
- account,
9
- to: account,
10
- value: BigInt(1),
8
+ /**
9
+ * @notice The Linea viem provider calls the linea_estimateGas RPC endpoint to estimate gas. Linea is unique
10
+ * in that the recommended fee per gas is hardcoded to 7 wei while the priority fee is dynamic based on the
11
+ * compressed transaction size, layer 1 verification costs and capacity, gas price ratio between layer 1 and layer 2,
12
+ * the transaction's gas usage, the minimum gas price on layer 2,
13
+ * and a minimum margin (for error) for gas price estimation.
14
+ * Source: https://docs.linea.build/get-started/how-to/gas-fees#how-gas-works-on-linea
15
+ * @dev Because the Linea priority fee is more volatile than the base fee, the base fee multiplier will be applied
16
+ * to the priority fee.
17
+ * @param provider Viem PublicClient
18
+ * @param _chainId Unused in this adapter
19
+ * @param baseFeeMultiplier Amount to multiply priority fee, since Linea's base fee is hardcoded while its priority
20
+ * fee is dynamic
21
+ * @param _unsignedTx Should contain any params passed to linea_estimateGas, which are listed
22
+ * here: https://docs.linea.build/api/reference/linea-estimategas#parameters
23
+ * @returns
24
+ */
25
+ export async function eip1559(
26
+ provider: PublicClient,
27
+ opts: GasPriceEstimateOptions
28
+ ): Promise<InternalGasPriceEstimate> {
29
+ const { unsignedTx, baseFeeMultiplier } = opts;
30
+ const { baseFeePerGas, priorityFeePerGas: _priorityFeePerGas } = await estimateGas(provider, {
31
+ account: (unsignedTx?.from as Address) ?? account,
32
+ to: (unsignedTx?.to as Address) ?? account,
33
+ value: BigInt(unsignedTx?.value?.toString() ?? "1"),
34
+ data: (unsignedTx?.data as Hex) ?? "0x",
11
35
  });
36
+ const priorityFeePerGas =
37
+ (_priorityFeePerGas * BigInt(baseFeeMultiplier.toString())) / BigInt(fixedPointAdjustment.toString());
12
38
 
13
39
  return {
14
40
  maxFeePerGas: baseFeePerGas + priorityFeePerGas,
@@ -5,7 +5,12 @@
5
5
  import { providers } from "ethers";
6
6
  import { GasPriceEstimate } from "../types";
7
7
  import * as ethereum from "./ethereum";
8
+ import { GasPriceEstimateOptions } from "../oracle";
8
9
 
9
- export function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
10
- return ethereum.legacy(provider, chainId);
10
+ export function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate> {
11
+ // We use the legacy method to call `eth_gasPrice` which empirically returns a more accurate
12
+ // gas price estimate than `eth_maxPriorityFeePerGas` or ethersProvider.getFeeData in the EIP1559 "raw" or "bad"
13
+ // cases. Based on testing, `eth_gasPrice` returns the closest price to the Linea-specific `linea_estimateGas`
14
+ // endpoint which the Viem Linea adapter queries.
15
+ return ethereum.legacy(provider, opts);
11
16
  }
@@ -1,10 +1,11 @@
1
1
  import { providers } from "ethers";
2
2
  import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "../../priceClient/adapters/baseAdapter";
3
- import { BigNumber, bnZero, isDefined, parseUnits } from "../../utils";
3
+ import { BigNumber, bnZero, fixedPointAdjustment, isDefined, parseUnits } from "../../utils";
4
4
  import { CHAIN_IDs } from "../../constants";
5
5
  import { GasPriceEstimate } from "../types";
6
6
  import { gasPriceError } from "../util";
7
7
  import { eip1559 } from "./ethereum";
8
+ import { GasPriceEstimateOptions } from "../oracle";
8
9
 
9
10
  type Polygon1559GasPrice = {
10
11
  maxPriorityFee: number | string;
@@ -27,7 +28,7 @@ type GasStationArgs = BaseHTTPAdapterArgs & {
27
28
 
28
29
  const { POLYGON } = CHAIN_IDs;
29
30
 
30
- class PolygonGasStation extends BaseHTTPAdapter {
31
+ export class PolygonGasStation extends BaseHTTPAdapter {
31
32
  readonly chainId: number;
32
33
 
33
34
  constructor({ chainId = POLYGON, host, timeout = 1500, retries = 1 }: GasStationArgs = {}) {
@@ -67,15 +68,55 @@ class PolygonGasStation extends BaseHTTPAdapter {
67
68
  }
68
69
  }
69
70
 
70
- export async function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
71
- const gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
71
+ class MockRevertingPolygonGasStation extends PolygonGasStation {
72
+ getFeeData(): Promise<GasPriceEstimate> {
73
+ throw new Error();
74
+ }
75
+ }
76
+
77
+ export const MockPolygonGasStationBaseFee = () => parseUnits("12", 9);
78
+ export const MockPolygonGasStationPriorityFee = () => parseUnits("1", 9);
79
+
80
+ class MockPolygonGasStation extends PolygonGasStation {
81
+ getFeeData(): Promise<GasPriceEstimate> {
82
+ return Promise.resolve({
83
+ maxPriorityFeePerGas: MockPolygonGasStationPriorityFee(),
84
+ maxFeePerGas: MockPolygonGasStationBaseFee().add(MockPolygonGasStationPriorityFee()),
85
+ });
86
+ }
87
+ }
88
+
89
+ /**
90
+ * @notice Returns the gas price suggested by the Polygon GasStation API or reconstructs it using
91
+ * the eip1559() method as a fallback.
92
+ * @param provider Ethers Provider.
93
+ * @returns GasPriceEstimate
94
+ */
95
+ export async function gasStation(
96
+ provider: providers.Provider,
97
+ opts: GasPriceEstimateOptions
98
+ ): Promise<GasPriceEstimate> {
99
+ const { chainId, baseFeeMultiplier } = opts;
100
+ let gasStation: PolygonGasStation;
101
+ if (process.env.TEST_POLYGON_GAS_STATION === "true") {
102
+ gasStation = new MockPolygonGasStation();
103
+ } else if (process.env.TEST_REVERTING_POLYGON_GAS_STATION === "true") {
104
+ gasStation = new MockRevertingPolygonGasStation();
105
+ } else {
106
+ gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
107
+ }
72
108
  let maxPriorityFeePerGas: BigNumber;
73
109
  let maxFeePerGas: BigNumber;
74
110
  try {
75
111
  ({ maxPriorityFeePerGas, maxFeePerGas } = await gasStation.getFeeData());
112
+ // Assume that the maxFeePerGas already includes the priority fee, so back out the priority fee before applying
113
+ // the baseFeeMultiplier.
114
+ const baseFeeMinusPriorityFee = maxFeePerGas.sub(maxPriorityFeePerGas);
115
+ const scaledBaseFee = baseFeeMinusPriorityFee.mul(baseFeeMultiplier).div(fixedPointAdjustment);
116
+ maxFeePerGas = scaledBaseFee.add(maxPriorityFeePerGas);
76
117
  } catch (err) {
77
118
  // Fall back to the RPC provider. May be less accurate.
78
- ({ maxPriorityFeePerGas, maxFeePerGas } = await eip1559(provider, chainId));
119
+ ({ maxPriorityFeePerGas, maxFeePerGas } = await eip1559(provider, opts));
79
120
 
80
121
  // Per the GasStation docs, the minimum priority fee on Polygon is 30 Gwei.
81
122
  // https://docs.polygon.technology/tools/gas/polygon-gas-station/#interpretation
@@ -1,37 +1,61 @@
1
1
  import assert from "assert";
2
2
  import { Transport } from "viem";
3
- import { providers } from "ethers";
3
+ import { PopulatedTransaction, providers } from "ethers";
4
4
  import { CHAIN_IDs } from "../constants";
5
- import { BigNumber, chainIsOPStack } from "../utils";
5
+ import { BigNumber, chainIsOPStack, fixedPointAdjustment, toBNWei } from "../utils";
6
6
  import { GasPriceEstimate } from "./types";
7
7
  import { getPublicClient } from "./util";
8
8
  import * as arbitrum from "./adapters/arbitrum";
9
9
  import * as ethereum from "./adapters/ethereum";
10
10
  import * as linea from "./adapters/linea";
11
11
  import * as polygon from "./adapters/polygon";
12
- import * as arbitrumViem from "./adapters/arbitrum-viem";
13
12
  import * as lineaViem from "./adapters/linea-viem";
14
- import * as polygonViem from "./adapters/polygon-viem";
13
+
14
+ export interface GasPriceEstimateOptions {
15
+ // baseFeeMultiplier Multiplier applied to base fee for EIP1559 gas prices (or total fee for legacy).
16
+ baseFeeMultiplier: BigNumber;
17
+ // legacyFallback In the case of an unrecognized chain, fall back to type 0 gas estimation.
18
+ legacyFallback: boolean;
19
+ // chainId The chain ID to query for gas prices. If omitted can be inferred by provider.
20
+ chainId: number;
21
+ // unsignedTx The unsigned transaction used for simulation by Linea's Viem provider to produce the priority gas fee.
22
+ unsignedTx?: PopulatedTransaction;
23
+ // transport Viem Transport object to use for querying gas fees used for testing.
24
+ transport?: Transport;
25
+ }
26
+
27
+ const GAS_PRICE_ESTIMATE_DEFAULTS = {
28
+ legacyFallback: true,
29
+ };
15
30
 
16
31
  /**
17
32
  * Provide an estimate for the current gas price for a particular chain.
18
- * @param chainId The chain ID to query for gas prices.
19
33
  * @param provider A valid ethers provider.
20
- * @param legacyFallback In the case of an unrecognised chain, fall back to type 0 gas estimation.
21
- * @returns Am object of type GasPriceEstimate.
34
+ * @param {opts} GasPriceEstimateOptions optional parameters.
35
+ * @returns An object of type GasPriceEstimate.
22
36
  */
23
37
  export async function getGasPriceEstimate(
24
38
  provider: providers.Provider,
25
- chainId?: number,
26
- transport?: Transport,
27
- legacyFallback = true
39
+ opts: Partial<GasPriceEstimateOptions> = {}
28
40
  ): Promise<GasPriceEstimate> {
29
- chainId ?? ({ chainId } = await provider.getNetwork());
41
+ const baseFeeMultiplier = opts.baseFeeMultiplier ?? toBNWei("1");
42
+ assert(
43
+ baseFeeMultiplier.gte(toBNWei("1.0")) && baseFeeMultiplier.lte(toBNWei("5")),
44
+ `Require 1.0 < base fee multiplier (${baseFeeMultiplier}) <= 5.0 for a total gas multiplier within [+1.0, +5.0]`
45
+ );
46
+ const chainId = opts.chainId ?? (await provider.getNetwork()).chainId;
47
+ const optsWithDefaults: GasPriceEstimateOptions = {
48
+ ...GAS_PRICE_ESTIMATE_DEFAULTS,
49
+ baseFeeMultiplier,
50
+ ...opts,
51
+ chainId,
52
+ };
30
53
 
54
+ // We only use the unsignedTx in the viem flow.
31
55
  const useViem = process.env[`NEW_GAS_PRICE_ORACLE_${chainId}`] === "true";
32
56
  return useViem
33
- ? getViemGasPriceEstimate(chainId, transport)
34
- : getEthersGasPriceEstimate(provider, chainId, legacyFallback);
57
+ ? _getViemGasPriceEstimate(chainId, optsWithDefaults)
58
+ : _getEthersGasPriceEstimate(provider, optsWithDefaults);
35
59
  }
36
60
 
37
61
  /**
@@ -39,13 +63,14 @@ export async function getGasPriceEstimate(
39
63
  * @param chainId The chain ID to query for gas prices.
40
64
  * @param provider A valid ethers provider.
41
65
  * @param legacyFallback In the case of an unrecognised chain, fall back to type 0 gas estimation.
42
- * @returns Am object of type GasPriceEstimate.
66
+ * @returns An object of type GasPriceEstimate.
43
67
  */
44
- function getEthersGasPriceEstimate(
68
+ function _getEthersGasPriceEstimate(
45
69
  provider: providers.Provider,
46
- chainId: number,
47
- legacyFallback = true
70
+ opts: GasPriceEstimateOptions
48
71
  ): Promise<GasPriceEstimate> {
72
+ const { chainId, legacyFallback } = opts;
73
+
49
74
  const gasPriceFeeds = {
50
75
  [CHAIN_IDs.ALEPH_ZERO]: arbitrum.eip1559,
51
76
  [CHAIN_IDs.ARBITRUM]: arbitrum.eip1559,
@@ -60,39 +85,39 @@ function getEthersGasPriceEstimate(
60
85
  assert(gasPriceFeed || legacyFallback, `No suitable gas price oracle for Chain ID ${chainId}`);
61
86
  gasPriceFeed ??= chainIsOPStack(chainId) ? ethereum.eip1559 : ethereum.legacy;
62
87
 
63
- return gasPriceFeed(provider, chainId);
88
+ return gasPriceFeed(provider, opts);
64
89
  }
65
90
 
66
91
  /**
67
92
  * Provide an estimate for the current gas price for a particular chain.
68
93
  * @param providerOrChainId A valid ethers provider or a chain ID.
69
- * @param transport An optional transport object for custom gas price retrieval.
70
- * @returns Am object of type GasPriceEstimate.
94
+ * @param transport An optional Viem Transport object for custom gas price retrieval.
95
+ * @param unsignedTx Only used in Linea provider to estimate priority gas fee.
96
+ * @returns An object of type GasPriceEstimate.
71
97
  */
72
- export async function getViemGasPriceEstimate(
98
+ export async function _getViemGasPriceEstimate(
73
99
  providerOrChainId: providers.Provider | number,
74
- transport?: Transport
100
+ opts: GasPriceEstimateOptions
75
101
  ): Promise<GasPriceEstimate> {
102
+ const { baseFeeMultiplier, transport } = opts;
103
+
76
104
  const chainId =
77
105
  typeof providerOrChainId === "number" ? providerOrChainId : (await providerOrChainId.getNetwork()).chainId;
78
106
  const viemProvider = getPublicClient(chainId, transport);
79
107
 
80
108
  const gasPriceFeeds = {
81
- [CHAIN_IDs.ALEPH_ZERO]: arbitrumViem.eip1559,
82
- [CHAIN_IDs.ARBITRUM]: arbitrumViem.eip1559,
83
109
  [CHAIN_IDs.LINEA]: lineaViem.eip1559,
84
- [CHAIN_IDs.POLYGON]: polygonViem.gasStation,
85
- } as const;
110
+ };
86
111
 
87
112
  let maxFeePerGas: bigint;
88
113
  let maxPriorityFeePerGas: bigint;
89
114
  if (gasPriceFeeds[chainId]) {
90
- ({ maxFeePerGas, maxPriorityFeePerGas } = await gasPriceFeeds[chainId](viemProvider, chainId));
115
+ ({ maxFeePerGas, maxPriorityFeePerGas } = await gasPriceFeeds[chainId](viemProvider, opts));
91
116
  } else {
92
117
  let gasPrice: bigint | undefined;
93
118
  ({ maxFeePerGas, maxPriorityFeePerGas, gasPrice } = await viemProvider.estimateFeesPerGas());
94
119
 
95
- maxFeePerGas ??= gasPrice!;
120
+ maxFeePerGas ??= (gasPrice! * BigInt(baseFeeMultiplier.toString())) / BigInt(fixedPointAdjustment.toString());
96
121
  maxPriorityFeePerGas ??= BigInt(0);
97
122
  }
98
123
 
@@ -1,36 +1,8 @@
1
- import assert from "assert";
2
- import { getDeployedAddress } from "../../utils/DeploymentUtils";
3
- import { DEFAULT_LOGGER, Logger } from "../relayFeeCalculator";
4
- import { providers } from "ethers";
5
- import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS, TOKEN_SYMBOLS_MAP } from "../../constants";
1
+ import { CHAIN_IDs } from "../../constants";
6
2
  import { Coingecko } from "../../coingecko/Coingecko";
7
- import { isDefined } from "../../utils";
8
3
  import { QueryBase } from "./baseQuery";
9
4
 
10
5
  export class AlephZeroQueries extends QueryBase {
11
- constructor(
12
- provider: providers.Provider,
13
- symbolMapping = TOKEN_SYMBOLS_MAP,
14
- spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.ALEPH_ZERO),
15
- simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
16
- coingeckoProApiKey?: string,
17
- logger: Logger = DEFAULT_LOGGER,
18
- gasMarkup = 0
19
- ) {
20
- assert(isDefined(spokePoolAddress));
21
- super(
22
- provider,
23
- symbolMapping,
24
- spokePoolAddress,
25
- simulatedRelayerAddress,
26
- gasMarkup,
27
- logger,
28
- coingeckoProApiKey,
29
- undefined,
30
- "usd"
31
- );
32
- }
33
-
34
6
  override async getTokenPrice(tokenSymbol: string): Promise<number> {
35
7
  if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
36
8
  const coingeckoInstance = Coingecko.get(this.logger, this.coingeckoProApiKey);