@exodus/ethereum-api 8.22.3 → 8.22.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,26 @@
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.22.5](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.22.4...@exodus/ethereum-api@8.22.5) (2024-12-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * fix: remove gasPriceEconomicalRate (#4659)
13
+
14
+
15
+
16
+ ## [8.22.4](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.22.3...@exodus/ethereum-api@8.22.4) (2024-12-09)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+
22
+ * fix: use multipled gasPrice when sending (#4628)
23
+
24
+
25
+
6
26
  ## [8.22.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.22.2...@exodus/ethereum-api@8.22.3) (2024-12-09)
7
27
 
8
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.22.3",
3
+ "version": "8.22.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",
@@ -28,7 +28,7 @@
28
28
  "@exodus/bip44-constants": "^195.0.0",
29
29
  "@exodus/crypto": "^1.0.0-rc.13",
30
30
  "@exodus/currency": "^6.0.1",
31
- "@exodus/ethereum-lib": "^5.4.0",
31
+ "@exodus/ethereum-lib": "^5.8.1",
32
32
  "@exodus/ethereum-meta": "^2.1.5",
33
33
  "@exodus/ethereumholesky-meta": "^2.0.0",
34
34
  "@exodus/ethereumjs": "^1.0.0",
@@ -64,5 +64,5 @@
64
64
  "type": "git",
65
65
  "url": "git+https://github.com/ExodusMovement/assets.git"
66
66
  },
67
- "gitHead": "baff21e8431ee823250984b91dd5c3f4bb51ba32"
67
+ "gitHead": "2a5e9f37cb3694f7fc17f8760c69cbccda13e462"
68
68
  }
@@ -5,7 +5,6 @@ const createFeeDataConfigDefaults = ({ currency, feeDataConfig }) => {
5
5
  const shared = {
6
6
  tipGasPrice: '0 Gwei',
7
7
  fuelThreshold: '0 Gwei',
8
- gasPriceEconomicalRate: 0.8,
9
8
  gasPriceMinimumRate: 0.6,
10
9
  gasPriceMaximumRate: 1.3,
11
10
  }
@@ -104,6 +104,18 @@ const getFeeAsyncFactory = ({
104
104
 
105
105
  const feeData = await assetClientInterface.getFeeConfig({ assetName: asset.baseAsset.name })
106
106
 
107
+ const { fee, gasPrice, ...rest } = getFee({
108
+ asset,
109
+ feeData,
110
+ gasLimit,
111
+ isExchange,
112
+ isSendAll,
113
+ amount,
114
+ isRbfAllowed,
115
+ calculateEffectiveFee,
116
+ customFee,
117
+ })
118
+
107
119
  const optimismL1DataFee = asset.baseAsset.estimateL1DataFee
108
120
  ? await asset.baseAsset.estimateL1DataFee({
109
121
  unsignedTx: createUnsignedTx({
@@ -113,24 +125,12 @@ const getFeeAsyncFactory = ({
113
125
  amount,
114
126
  nonce: 0,
115
127
  txInput,
116
- gasPrice: feeData.gasPrice,
128
+ gasPrice,
117
129
  gasLimit,
118
130
  }),
119
131
  })
120
132
  : undefined
121
133
 
122
- const { fee, ...rest } = getFee({
123
- asset,
124
- feeData,
125
- gasLimit,
126
- isExchange,
127
- isSendAll,
128
- amount,
129
- isRbfAllowed,
130
- calculateEffectiveFee, // BE
131
- customFee, // BE
132
- })
133
-
134
134
  const l1DataFee = optimismL1DataFee
135
135
  ? asset.baseAsset.currency.baseUnit(optimismL1DataFee)
136
136
  : asset.baseAsset.currency.ZERO
@@ -138,6 +138,7 @@ const getFeeAsyncFactory = ({
138
138
  fee: fee.add(l1DataFee),
139
139
  optimismL1DataFee,
140
140
  gasLimit,
141
+ gasPrice,
141
142
  ...rest,
142
143
  }
143
144
  }
package/src/get-fee.js CHANGED
@@ -1,27 +1,10 @@
1
- import { calculateBumpedGasPrice, calculateExtraEth, isEthereumLike } from '@exodus/ethereum-lib'
1
+ import { calculateBumpedGasPrice, calculateExtraEth } from '@exodus/ethereum-lib'
2
2
 
3
3
  // Move to meta?
4
4
  const taxes = {
5
5
  paxgold: 0.0002,
6
6
  }
7
7
 
8
- const getGasPriceMultiplier = ({ asset, feeData, isExchange, isSendAll, isRbfAllowed }) => {
9
- // exchanges quotes expire, do not risk having a stuck tx
10
-
11
- const gasPriceMultiplier = feeData.gasPriceMultiplier || 1
12
-
13
- if (isExchange) return gasPriceMultiplier
14
-
15
- // if eip1559 enabled, do not risk not leaving enough ETH to cover base fee (applies only for native asset)
16
- // (gasPrice difference will be reimbursed anyway: users do not overpay)
17
- if (isSendAll && isEthereumLike(asset) && feeData.eip1559Enabled) return gasPriceMultiplier
18
-
19
- // do not risk having a stuck tx if we're not able to accelerate it
20
- if (!isRbfAllowed || !feeData.rbfEnabled) return gasPriceMultiplier
21
-
22
- return feeData.gasPriceEconomicalRate || gasPriceMultiplier
23
- }
24
-
25
8
  const getExtraFeeData = ({ asset, amount }) => {
26
9
  const tax = taxes[asset.name]
27
10
  if (!amount || !tax || amount.isZero) {
@@ -49,29 +32,26 @@ export const getFeeFactory =
49
32
  isRbfAllowed = true, // Destkop, isRbfAllowed=true when advanced panel is on
50
33
  calculateEffectiveFee,
51
34
  }) => {
52
- const { gasPrice, eip1559Enabled, baseFeePerGas, tipGasPrice } = feeData
53
- const gasPriceMultiplier = getGasPriceMultiplier({
54
- asset,
55
- isRbfAllowed,
56
- feeData,
57
- isExchange,
58
- isSendAll,
59
- })
35
+ const { gasPrice: feeDataGasPrice, eip1559Enabled, baseFeePerGas, tipGasPrice } = feeData
36
+
37
+ const gasPriceMultiplier = feeData.gasPriceMultiplier || 1
38
+
39
+ const gasPrice = customFee || feeDataGasPrice.mul(gasPriceMultiplier)
60
40
 
61
41
  const gasLimit = providedGasLimit || asset.gasLimit || defaultGasLimit
62
42
 
63
43
  const extraFeeData = getExtraFeeData({ asset, amount })
64
44
  if (calculateEffectiveFee && eip1559Enabled) {
65
- const maxFeePerGas = customFee || gasPrice
45
+ const maxFeePerGas = gasPrice
66
46
  // effective_gas_price = min(base_fee_per_gas + tip_gas_price, max_fee_per_gas)
67
47
  const feePerGas = baseFeePerGas.add(tipGasPrice)
68
48
  const effectiveGasPrice = feePerGas.lt(maxFeePerGas) ? feePerGas : maxFeePerGas
69
49
 
70
- return { fee: effectiveGasPrice.mul(gasLimit), extraFeeData }
50
+ return { fee: effectiveGasPrice.mul(gasLimit), gasPrice, extraFeeData }
71
51
  }
72
52
 
73
- const fee = (customFee || gasPrice.mul(gasPriceMultiplier)).mul(gasLimit)
74
- return { fee, extraFeeData }
53
+ const fee = gasPrice.mul(gasLimit)
54
+ return { fee, gasPrice, extraFeeData }
75
55
  }
76
56
 
77
57
  // Used in BE
@@ -6,15 +6,10 @@ const getFeeInfo = async function getFeeInfo({
6
6
  fromAddress,
7
7
  toAddress,
8
8
  amount,
9
- isExchange,
10
9
  txInput,
11
10
  feeOpts = {},
12
11
  }) {
13
- const {
14
- gasPrice: gasPrice_,
15
- tipGasPrice: tipGasPrice_,
16
- gasPriceEconomicalRate,
17
- } = await assetClientInterface.getFeeData({
12
+ const { gasPrice: gasPrice_, tipGasPrice: tipGasPrice_ } = await assetClientInterface.getFeeData({
18
13
  assetName: asset.name,
19
14
  })
20
15
 
@@ -31,10 +26,7 @@ const getFeeInfo = async function getFeeInfo({
31
26
  })
32
27
  }
33
28
 
34
- const economicalFeeMultiplier = isExchange ? 1 : gasPriceEconomicalRate || 1
35
-
36
- const fee = gasPrice.mul(economicalFeeMultiplier).mul(gasLimit)
37
- return { gasPrice, gasLimit, fee, tipGasPrice }
29
+ return { gasPrice, gasLimit, tipGasPrice }
38
30
  }
39
31
 
40
32
  export default getFeeInfo
@@ -13,16 +13,8 @@ const txSendFactory = ({ assetClientInterface, createUnsignedTx }) => {
13
13
  assert(assetClientInterface, 'assetClientInterface is required')
14
14
  assert(createUnsignedTx, 'createUnsignedTx is required')
15
15
  return async ({ asset, walletAccount, address, amount, options = {} }) => {
16
- const {
17
- nft,
18
- isExchange,
19
- bumpTxId,
20
- nonce: providedNonce,
21
- customFee,
22
- keepTxInput,
23
- isSendAll,
24
- } = options
25
- let { txInput, feeAmount } = options // avoid let!
16
+ const { nft, bumpTxId, nonce: providedNonce, customFee, keepTxInput, isSendAll } = options
17
+ let { txInput } = options // avoid let!
26
18
 
27
19
  const feeOpts = {
28
20
  gasPrice: options.gasPrice,
@@ -35,12 +27,6 @@ const txSendFactory = ({ assetClientInterface, createUnsignedTx }) => {
35
27
 
36
28
  const assets = await assetClientInterface.getAssetsForNetwork({ baseAssetName: baseAsset.name })
37
29
 
38
- // Using a default zero value to not break code relying on the `tx.feeAmount` property.
39
- // For example, some exchange providers don't supply this.
40
- if (!feeAmount) {
41
- feeAmount = asset.baseAsset.currency.ZERO
42
- }
43
-
44
30
  const fromAddress = await assetClientInterface.getReceiveAddress({
45
31
  assetName: baseAsset.name,
46
32
  walletAccount,
@@ -103,7 +89,6 @@ const txSendFactory = ({ assetClientInterface, createUnsignedTx }) => {
103
89
  eip1559Enabled = feeData.eip1559Enabled && feeOpts.tipGasPrice
104
90
  bumpNonce = replacedTx.data.nonce
105
91
  txInput = replacedTokenTx ? null : replacedTx.data.data || '0x'
106
- feeAmount = feeOpts.gasPrice.mul(feeOpts.gasLimit)
107
92
  if (bumpNonce === undefined) {
108
93
  throw new Error(`Cannot bump transaction ${bumpTxId}: data object seems to be corrupted`)
109
94
  }
@@ -127,10 +112,11 @@ const txSendFactory = ({ assetClientInterface, createUnsignedTx }) => {
127
112
  txInput,
128
113
  keepTxInput,
129
114
  isSendAll,
130
- isExchange,
131
115
  createUnsignedTx,
132
116
  }
133
- let { txId, rawTx, nonce, gasLimit, tipGasPrice } = await createTx(createTxParams)
117
+ let { txId, rawTx, nonce, gasLimit, tipGasPrice, gasPrice } = await createTx(createTxParams)
118
+
119
+ const feeAmount = gasPrice.mul(gasLimit)
134
120
 
135
121
  try {
136
122
  await baseAsset.api.broadcastTx(rawTx.toString('hex'))
@@ -275,7 +261,6 @@ const createTx = async ({
275
261
  keepTxInput = false,
276
262
  customFee: customGasPrice,
277
263
  isSendAll,
278
- isExchange,
279
264
  fromAddress,
280
265
  feeOpts,
281
266
  createUnsignedTx,
@@ -300,7 +285,6 @@ const createTx = async ({
300
285
  fromAddress,
301
286
  toAddress,
302
287
  amount,
303
- isExchange,
304
288
  txInput,
305
289
  feeOpts,
306
290
  })