@exodus/ethereum-api 8.33.4 → 8.33.6

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,32 @@
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.6](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.33.5...@exodus/ethereum-api@8.33.6) (2025-04-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * fix: [ETH] Estimate using the correct `tipGasPrice` for transactions that use a `customFee`. (#5351)
13
+
14
+ * fix: remove unused isSendAll param (#5310)
15
+
16
+ * fix: return the delegatedBalance in getStaked and subtract the activeStakedBalance from getStaking (#5363)
17
+
18
+
19
+
20
+ ## [8.33.5](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.33.4...@exodus/ethereum-api@8.33.5) (2025-03-19)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+
26
+ * fix: apply gas price multiplication at value entry point (#5267)
27
+
28
+ * fix: avoid returning staking rewards as a number unit (#5292)
29
+
30
+
31
+
6
32
  ## [8.33.4](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.33.3...@exodus/ethereum-api@8.33.4) (2025-03-12)
7
33
 
8
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.33.4",
3
+ "version": "8.33.6",
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": "c13d977ea0c99066b13258271555a74f3b8d3c07"
67
+ "gitHead": "323d88c01416cafbc90022d336d9062315f9322b"
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
  }
@@ -4,7 +4,7 @@ import BN from 'bn.js'
4
4
 
5
5
  import { estimateGas, isContractAddressCached } from './eth-like-util.js'
6
6
 
7
- export const EXTRA_PERCENTAGE = 20
7
+ export const EXTRA_PERCENTAGE = 29
8
8
 
9
9
  // 16 gas per non-zero byte (4 gas per zero byte) of "transaction input data"
10
10
  const GAS_PER_NON_ZERO_BYTE = 16
@@ -8,13 +8,13 @@ import { isRpcBalanceAsset } from '@exodus/ethereum-lib'
8
8
  import assert from 'minimalistic-assert'
9
9
 
10
10
  const getStaked = ({ accountState, asset }) => {
11
- return accountState?.staking?.[asset.name]?.activeStakedBalance || asset.currency.ZERO
11
+ return accountState?.staking?.[asset.name]?.delegatedBalance || asset.currency.ZERO
12
12
  }
13
13
 
14
14
  const getStaking = ({ accountState, asset }) => {
15
- return (accountState?.staking?.[asset.name]?.pendingBalance || asset.currency.ZERO).add(
16
- accountState?.staking?.[asset.name]?.pendingDepositedBalance || asset.currency.ZERO
17
- )
15
+ const activeStakedBalance =
16
+ accountState?.staking?.[asset.name]?.activeStakedBalance || asset.currency.ZERO
17
+ return getStaked({ accountState, asset }).sub(activeStakedBalance)
18
18
  }
19
19
 
20
20
  const getUnclaimedUndelegatedBalance = ({ accountState, asset }) => {
@@ -66,9 +66,7 @@ const getFeeAsyncFactory = ({
66
66
  isExchange,
67
67
  customFee,
68
68
  calculateEffectiveFee,
69
- isSendAll,
70
69
  gasLimit: providedGasLimit,
71
- isRbfAllowed = true, // Destkop, isRbfAllowed=true when advanced panel is on
72
70
  }) => {
73
71
  const fromAddress = providedFromAddress || ARBITRARY_ADDRESS // sending from a random address
74
72
  const toAddress = providedToAddress || ARBITRARY_ADDRESS // sending to a random address,
@@ -109,9 +107,7 @@ const getFeeAsyncFactory = ({
109
107
  feeData,
110
108
  gasLimit,
111
109
  isExchange,
112
- isSendAll,
113
110
  amount,
114
- isRbfAllowed,
115
111
  calculateEffectiveFee,
116
112
  customFee,
117
113
  })
package/src/get-fee.js CHANGED
@@ -29,12 +29,22 @@ export const getFeeFactory =
29
29
  customFee,
30
30
  gasLimit: providedGasLimit,
31
31
  isExchange,
32
- isSendAll,
33
32
  amount,
34
- isRbfAllowed = true, // Destkop, isRbfAllowed=true when advanced panel is on
35
33
  calculateEffectiveFee,
36
34
  }) => {
37
- const { eip1559Enabled, baseFeePerGas, tipGasPrice, useBaseGasPrice } = feeData
35
+ const { eip1559Enabled } = feeData
36
+
37
+ // HACK: For EIP-1559 transactions, we forcibly coerce the
38
+ // tipGasPrice to be the `customFee`, where defined:
39
+ // https://github.com/ExodusMovement/assets/blob/b805d1de0e67013ece2a1460389fb4328445eac1/ethereum/ethereum-api/src/tx-send/tx-send.js#L302C5-L311C6
40
+ //
41
+ // Therefore to compute the true fee at send time, we
42
+ // must also enforce the relationship here!
43
+ if (eip1559Enabled && customFee) {
44
+ feeData = { ...feeData, tipGasPrice: customFee }
45
+ }
46
+
47
+ const { baseFeePerGas, tipGasPrice, useBaseGasPrice } = feeData
38
48
 
39
49
  let gasPrice = customFee || resolveGasPrice({ feeData })
40
50
 
@@ -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) {