@exodus/ethereum-api 8.31.2 → 8.32.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.32.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.31.2...@exodus/ethereum-api@8.32.0) (2025-02-27)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat: useBaseGasPrice option (#5050)
13
+
14
+
15
+
6
16
  ## [8.31.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.31.1...@exodus/ethereum-api@8.31.2) (2025-02-27)
7
17
 
8
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.31.2",
3
+ "version": "8.32.0",
4
4
  "description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Ethereum and EVM-based blockchains",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -64,5 +64,5 @@
64
64
  "type": "git",
65
65
  "url": "git+https://github.com/ExodusMovement/assets.git"
66
66
  },
67
- "gitHead": "d6e4676a7a54f1f2a7a19b6d26d4a42bf433d320"
67
+ "gitHead": "4804c70533af0f7ee246de84926d4133eb0aa689"
68
68
  }
@@ -1,16 +1,17 @@
1
1
  import NumberUnit from '@exodus/currency'
2
2
 
3
+ import { resolveGasPrice } from './fee-utils.js'
4
+
3
5
  export const createCustomFeesApi = ({ baseAsset }) => {
4
6
  const Gwei = baseAsset.currency.units.Gwei
5
7
  return {
6
8
  getRecommendedMinMaxFeeUnitPrices: ({ feeData }) => {
7
- const { gasPrice, gasPriceMinimumRate, gasPriceMaximumRate } = feeData
9
+ const { gasPriceMinimumRate, gasPriceMaximumRate } = feeData
10
+
11
+ const gasPrice = resolveGasPrice({ feeData })
8
12
 
9
- const calculateFeeUnitPrice = (
10
- feeUnitPrice,
11
- multiplier = 1,
12
- toAdd = baseAsset.currency.ZERO
13
- ) => feeUnitPrice.mul(multiplier).add(toAdd).toNumber(Gwei)
13
+ const calculateFeeUnitPrice = (feeUnitPrice, multiplier = 1) =>
14
+ feeUnitPrice.mul(multiplier).toNumber(Gwei)
14
15
 
15
16
  return {
16
17
  recommended: calculateFeeUnitPrice(gasPrice),
@@ -0,0 +1,19 @@
1
+ import assert from 'minimalistic-assert'
2
+
3
+ export const resolveGasPrice = ({ feeData }) => {
4
+ assert(feeData, 'feeData is required')
5
+
6
+ const eip1559Enabled = feeData.eip1559Enabled
7
+
8
+ const multipler = feeData.gasPriceMultiplier || 1
9
+
10
+ if (eip1559Enabled && feeData.useBaseGasPrice) {
11
+ const multipledBaseFeePerGas = feeData.baseFeePerGas.mul(multipler)
12
+
13
+ return feeData.tipGasPrice
14
+ ? multipledBaseFeePerGas.add(feeData.tipGasPrice)
15
+ : multipledBaseFeePerGas
16
+ }
17
+
18
+ return feeData.gasPrice.mul(multipler)
19
+ }
package/src/get-fee.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { calculateBumpedGasPrice, calculateExtraEth } from '@exodus/ethereum-lib'
2
2
 
3
+ import { resolveGasPrice } from './fee-utils.js'
4
+
3
5
  // Move to meta?
4
6
  const taxes = {
5
7
  paxgold: 0.0002,
@@ -32,9 +34,9 @@ export const getFeeFactory =
32
34
  isRbfAllowed = true, // Destkop, isRbfAllowed=true when advanced panel is on
33
35
  calculateEffectiveFee,
34
36
  }) => {
35
- const { gasPrice: feeDataGasPrice, eip1559Enabled, baseFeePerGas, tipGasPrice } = feeData
37
+ const { eip1559Enabled, baseFeePerGas, tipGasPrice } = feeData
36
38
 
37
- const gasPrice = customFee || feeDataGasPrice
39
+ const gasPrice = customFee || resolveGasPrice({ feeData })
38
40
 
39
41
  const gasLimit = providedGasLimit || asset.gasLimit || defaultGasLimit
40
42
 
@@ -1,7 +1,6 @@
1
1
  import { FeeMonitor } from '@exodus/asset-lib'
2
2
  import assert from 'minimalistic-assert'
3
3
 
4
- import { resolveGasPrices } from './fee-monitor-utils.js'
5
4
  import { fromHexToString } from './number-utils.js'
6
5
 
7
6
  /**
@@ -40,7 +39,7 @@ export const serverBasedFeeMonitorFactoryFactory = ({ asset, interval, server, a
40
39
  server.getGasPrice().then((wei) => `${fromHexToString(wei)} wei`),
41
40
  eip1559Enabled ? server.getBaseFeePerGas().then((wei) => `${wei} wei`) : undefined,
42
41
  ])
43
- return resolveGasPrices({ asset, feeData, gasPrice, baseFeePerGas })
42
+ return { gasPrice, baseFeePerGas }
44
43
  }
45
44
  }
46
45
  return (...args) => new FeeMonitorClass(...args)
@@ -2,7 +2,6 @@ import { BaseMonitor } from '@exodus/asset-lib'
2
2
  import { getAssetAddresses, isRpcBalanceAsset } from '@exodus/ethereum-lib'
3
3
  import lodash from 'lodash'
4
4
 
5
- import { resolveGasPrices } from '../fee-monitor-utils.js'
6
5
  import { fromHexToString } from '../number-utils.js'
7
6
  import { filterEffects, getLogItemsFromServerTx } from './clarity-utils/index.js'
8
7
  import {
@@ -265,13 +264,10 @@ export class ClarityMonitor extends BaseMonitor {
265
264
 
266
265
  async updateGasPrice({ gasPrice, baseGasPrice: baseFeePerGas }) {
267
266
  try {
268
- const feeData = await this.aci.getFeeConfig({ assetName: this.asset.name })
269
- const feeConfig = resolveGasPrices({
270
- asset: this.asset,
271
- feeData,
267
+ const feeConfig = {
272
268
  gasPrice: `${fromHexToString(gasPrice)} wei`,
273
269
  baseFeePerGas: baseFeePerGas ? `${fromHexToString(baseFeePerGas)} wei` : undefined,
274
- })
270
+ }
275
271
  await this.aci.updateFeeConfig({ assetName: this.asset.name, feeConfig })
276
272
  } catch (e) {
277
273
  this.logger.warn('error updating gasPrice', e)
@@ -2,7 +2,6 @@ import { BaseMonitor } from '@exodus/asset-lib'
2
2
  import { getAssetAddresses, isRpcBalanceAsset } from '@exodus/ethereum-lib'
3
3
  import lodash from 'lodash'
4
4
 
5
- import { resolveGasPrices } from '../fee-monitor-utils.js'
6
5
  import { fromHexToString } from '../number-utils.js'
7
6
  import {
8
7
  checkPendingTransactions,
@@ -216,12 +215,10 @@ export class EthereumMonitor extends BaseMonitor {
216
215
  return `${fromHexToString(baseFeePerGas)} wei`
217
216
  }
218
217
 
219
- const feeConfig = resolveGasPrices({
220
- asset: this.asset,
221
- feeData,
218
+ const feeConfig = {
222
219
  gasPrice: `${fromHexToString(gasPrice)} wei`,
223
220
  baseFeePerGas: await resolveBaseFeePerGas(),
224
- })
221
+ }
225
222
  await this.aci.updateFeeConfig({ assetName: this.asset.name, feeConfig })
226
223
  } catch (e) {
227
224
  this.logger.warn('error updating gasPrice', e)
@@ -1,38 +0,0 @@
1
- import assert from 'minimalistic-assert'
2
-
3
- export const resolveGasPrices = ({
4
- asset,
5
- feeData,
6
- gasPrice: gasPriceString,
7
- baseFeePerGas: baseFeePerGasString,
8
- }) => {
9
- assert(asset, 'asset is required')
10
- assert(feeData, 'feeData is required')
11
- assert(gasPriceString, 'gasPrice is required')
12
-
13
- const zero = asset.currency.ZERO
14
- const eip1559Enabled = feeData.eip1559Enabled
15
- const gasPrice = asset.currency.parse(gasPriceString)
16
-
17
- if (eip1559Enabled) {
18
- assert(baseFeePerGasString, 'baseFeePerGasString is required')
19
- const baseFeePerGas = asset.currency.parse(baseFeePerGasString)
20
-
21
- const tipGasPrice = feeData.tipGasPrice ?? zero
22
-
23
- const resolvedGasPrice = baseFeePerGas.mul(feeData.gasPriceMultiplier || 1).add(tipGasPrice)
24
-
25
- return {
26
- serverGasPrice: gasPriceString, // for reference
27
- gasPrice: resolvedGasPrice.toBaseString({ unit: true }),
28
- baseFeePerGas: baseFeePerGasString,
29
- tipGasPrice: tipGasPrice.toBaseString({ unit: true }),
30
- }
31
- }
32
-
33
- const resolvedGasPrice = gasPrice.mul(feeData.gasPriceMultiplier || 1)
34
- return {
35
- serverGasPrice: gasPriceString, // for reference
36
- gasPrice: resolvedGasPrice.toBaseString({ unit: true }),
37
- }
38
- }