@exodus/ethereum-lib 1.1.4 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "author": "Exodus Movement, Inc.",
@@ -21,5 +21,5 @@
21
21
  "peerDependencies": {
22
22
  "@exodus/assets": "8.0.x"
23
23
  },
24
- "gitHead": "6e317e67acad8dff592860f0bd6730fc2c492cbe"
24
+ "gitHead": "f2d589b14c9093d385ff63c8790a004fc4c6c5ed"
25
25
  }
@@ -28,15 +28,14 @@ export default (
28
28
 
29
29
  const walletAccountBalances = getWalletAccountBalances(activeWalletAccount)
30
30
  const assetName = tx.coinName
31
- const { gasPrice } = getFeeData(assetName)
31
+ const { gasPrice: currentGasPrice } = getFeeData(assetName)
32
32
  const usedGasPrice = tx.feeAmount.div(tx.data.gasLimit)
33
- if (usedGasPrice.gte(gasPrice)) {
34
- return BumpType.NONE
35
- }
36
- const fee = getFee(assetName, { gasLimit: tx.data.gasLimit })
37
- .mul(12) // new gas price should be at least 20% higher
38
- .div(10)
39
- if (walletAccountBalances[assetName].lt(fee)) return BumpType.NONE
33
+ // new gas price should be at least 20% higher and not less than the current gas price
34
+ const bumpedGasPrice = usedGasPrice.mul(12).div(10)
35
+ const gasPriceToUse = currentGasPrice.gt(bumpedGasPrice) ? currentGasPrice : bumpedGasPrice
36
+ const replacementFee = gasPriceToUse.mul(tx.data.gasLimit)
37
+ const extraEthNeeded = replacementFee.sub(tx.feeAmount)
38
+ if (walletAccountBalances[assetName].lt(extraEthNeeded)) return BumpType.NONE
40
39
 
41
40
  return BumpType.RBF
42
41
  }