@exodus/ethereum-api 8.33.3 → 8.33.5

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,28 @@
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.33.5](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.33.4...@exodus/ethereum-api@8.33.5) (2025-03-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * fix: apply gas price multiplication at value entry point (#5267)
13
+
14
+ * fix: avoid returning staking rewards as a number unit (#5292)
15
+
16
+
17
+
18
+ ## [8.33.4](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.33.3...@exodus/ethereum-api@8.33.4) (2025-03-12)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+
24
+ * fix: ensure the tipGasPrice cannot exceed the maxFeePerGas (#5235)
25
+
26
+
27
+
6
28
  ## [8.33.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.33.2...@exodus/ethereum-api@8.33.3) (2025-03-11)
7
29
 
8
30
  **Note:** Version bump only for package @exodus/ethereum-api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.33.3",
3
+ "version": "8.33.5",
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": "daf913a8a92b372fa46daa3dd45668386540dbe0"
67
+ "gitHead": "95c7858f0e448608650ec560f0e0b179fa27c35f"
68
68
  }
package/src/fee-utils.js CHANGED
@@ -1,19 +1,53 @@
1
1
  import assert from 'minimalistic-assert'
2
2
 
3
+ const applyMultiplierToPriceInWei = ({ feeAsset, feeData, priceInWei }) => {
4
+ assert(typeof priceInWei === 'string', 'gasPriceInWei should be a string')
5
+
6
+ const multipler = feeData.gasPriceMultiplier || 1
7
+ return feeAsset.currency.parse(priceInWei).mul(multipler).toBaseString({ unit: true })
8
+ }
9
+
10
+ /**
11
+ * Returns augmented `feeConfig` values manipulated using the `feeData`,
12
+ * for example, like multiplying the `gasPrice`. This helps us to apply
13
+ * modifications to values before presenting them to the consumer.
14
+ *
15
+ * TODO: We shouldn't actually do this, lol. The closer we are to
16
+ * the node, the better!
17
+ */
18
+ export const rewriteFeeConfig = ({ feeAsset, feeConfig, feeData }) => {
19
+ try {
20
+ const { gasPrice, baseFeePerGas, ...extras } = feeConfig
21
+ return {
22
+ ...extras,
23
+ gasPrice: applyMultiplierToPriceInWei({
24
+ feeAsset,
25
+ feeData,
26
+ priceInWei: gasPrice,
27
+ }) /* required */,
28
+ baseFeePerGas: baseFeePerGas
29
+ ? applyMultiplierToPriceInWei({ feeAsset, feeData, priceInWei: baseFeePerGas })
30
+ : undefined,
31
+ }
32
+ } catch (e) {
33
+ console.error(
34
+ 'Unable to rewrite feeConfig - gas prices will not be amplified using the `gasPriceMultiplier`.',
35
+ e
36
+ )
37
+ return feeConfig
38
+ }
39
+ }
40
+
3
41
  export const resolveGasPrice = ({ feeData }) => {
4
42
  assert(feeData, 'feeData is required')
5
43
 
6
44
  const eip1559Enabled = feeData.eip1559Enabled
7
45
 
8
- const multipler = feeData.gasPriceMultiplier || 1
9
-
10
46
  if (eip1559Enabled && feeData.useBaseGasPrice) {
11
- const multipledBaseFeePerGas = feeData.baseFeePerGas.mul(multipler)
12
-
13
47
  return feeData.tipGasPrice
14
- ? multipledBaseFeePerGas.add(feeData.tipGasPrice)
15
- : multipledBaseFeePerGas
48
+ ? feeData.baseFeePerGas.add(feeData.tipGasPrice)
49
+ : feeData.baseFeePerGas
16
50
  }
17
51
 
18
- return feeData.gasPrice.mul(multipler)
52
+ return feeData.gasPrice
19
53
  }
package/src/get-fee.js CHANGED
@@ -36,7 +36,12 @@ export const getFeeFactory =
36
36
  }) => {
37
37
  const { eip1559Enabled, baseFeePerGas, tipGasPrice, useBaseGasPrice } = feeData
38
38
 
39
- const gasPrice = customFee || resolveGasPrice({ feeData })
39
+ let gasPrice = customFee || resolveGasPrice({ feeData })
40
+
41
+ // The `gasPrice` must be at least the `tipGasPrice`.
42
+ if (eip1559Enabled && tipGasPrice && gasPrice.lt(tipGasPrice)) {
43
+ gasPrice = tipGasPrice
44
+ }
40
45
 
41
46
  const gasLimit = providedGasLimit || asset.gasLimit || defaultGasLimit
42
47
 
@@ -1,6 +1,7 @@
1
1
  import { FeeMonitor } from '@exodus/asset-lib'
2
2
  import assert from 'minimalistic-assert'
3
3
 
4
+ import { rewriteFeeConfig } from './fee-utils.js'
4
5
  import { fromHexToString } from './number-utils.js'
5
6
 
6
7
  /**
@@ -39,7 +40,9 @@ export const serverBasedFeeMonitorFactoryFactory = ({ asset, interval, server, a
39
40
  server.getGasPrice().then((wei) => `${fromHexToString(wei)} wei`),
40
41
  eip1559Enabled ? server.getBaseFeePerGas().then((wei) => `${wei} wei`) : undefined,
41
42
  ])
42
- return { gasPrice, baseFeePerGas }
43
+
44
+ const feeConfig = { gasPrice, baseFeePerGas }
45
+ return rewriteFeeConfig({ feeAsset: asset, feeConfig, feeData })
43
46
  }
44
47
  }
45
48
  return (...args) => new FeeMonitorClass(...args)
@@ -2,6 +2,7 @@ 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 { rewriteFeeConfig } from '../fee-utils.js'
5
6
  import { fromHexToString } from '../number-utils.js'
6
7
  import { filterEffects, getLogItemsFromServerTx } from './clarity-utils/index.js'
7
8
  import {
@@ -264,11 +265,16 @@ export class ClarityMonitor extends BaseMonitor {
264
265
 
265
266
  async updateGasPrice({ gasPrice, baseGasPrice: baseFeePerGas }) {
266
267
  try {
268
+ const feeData = await this.aci.getFeeConfig({ assetName: this.asset.name })
269
+
267
270
  const feeConfig = {
268
271
  gasPrice: `${fromHexToString(gasPrice)} wei`,
269
272
  baseFeePerGas: baseFeePerGas ? `${fromHexToString(baseFeePerGas)} wei` : undefined,
270
273
  }
271
- await this.aci.updateFeeConfig({ assetName: this.asset.name, feeConfig })
274
+ await this.aci.updateFeeConfig({
275
+ assetName: this.asset.name,
276
+ feeConfig: rewriteFeeConfig({ feeAsset: this.asset, feeData, feeConfig }),
277
+ })
272
278
  } catch (e) {
273
279
  this.logger.warn('error updating gasPrice', e)
274
280
  }
@@ -2,6 +2,7 @@ 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 { rewriteFeeConfig } from '../fee-utils.js'
5
6
  import { fromHexToString } from '../number-utils.js'
6
7
  import {
7
8
  checkPendingTransactions,
@@ -219,7 +220,10 @@ export class EthereumMonitor extends BaseMonitor {
219
220
  gasPrice: `${fromHexToString(gasPrice)} wei`,
220
221
  baseFeePerGas: await resolveBaseFeePerGas(),
221
222
  }
222
- await this.aci.updateFeeConfig({ assetName: this.asset.name, feeConfig })
223
+ await this.aci.updateFeeConfig({
224
+ assetName: this.asset.name,
225
+ feeConfig: rewriteFeeConfig({ feeAsset: this.asset, feeConfig, feeData }),
226
+ })
223
227
  } catch (e) {
224
228
  this.logger.warn('error updating gasPrice', e)
225
229
  }
@@ -30,7 +30,7 @@ export const calculateRewardsFromStakeTx = ({ tx, currency }) => {
30
30
 
31
31
  if (rewards) {
32
32
  // cache rewards
33
- return currency.baseUnit(rewards)
33
+ return rewards
34
34
  }
35
35
 
36
36
  if (stakeTxContainsReward) {