@exodus/ethereum-lib 2.7.3 → 2.7.4
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": "2.7.
|
|
3
|
+
"version": "2.7.4",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@exodus/assets": "8.0.x"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "14b8266879ea622f272c94f98e71c1a16dd274f1"
|
|
27
27
|
}
|
|
@@ -79,8 +79,10 @@ const wrapResponseToObject = ({ bumpType = BumpType.NONE, errorMessage = null }
|
|
|
79
79
|
errorMessage,
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
+
const calculateTxGasPrice = (tx) => tx.feeAmount.div(tx.data.gasLimit)
|
|
83
|
+
|
|
82
84
|
export const calculateBumpedGasPrice = (tx, currentGasPrice) => {
|
|
83
|
-
const usedGasPrice =
|
|
85
|
+
const usedGasPrice = calculateTxGasPrice(tx)
|
|
84
86
|
const bumpedGasPrice = usedGasPrice.mul(12).div(10)
|
|
85
87
|
|
|
86
88
|
return currentGasPrice.gt(bumpedGasPrice) ? currentGasPrice : bumpedGasPrice
|
|
@@ -123,7 +125,7 @@ export default (
|
|
|
123
125
|
if (!['ethereum', 'bsc'].includes(baseAssetName))
|
|
124
126
|
return wrapResponseToObject({ errorMessage: `not an ETH/ERC20/BSC/BEP20 asset supplied` })
|
|
125
127
|
if (!tx.pending || !tx.sent)
|
|
126
|
-
return wrapResponseToObject({ errorMessage: 'can not bump a
|
|
128
|
+
return wrapResponseToObject({ errorMessage: 'can not bump a confirmed or received TX' })
|
|
127
129
|
if (!tx.data || !tx.data.gasLimit)
|
|
128
130
|
return wrapResponseToObject({ errorMessage: 'data object is missing or corrupted' })
|
|
129
131
|
const isExchangeTx = getIsExchangeTx(tx.txId)
|
|
@@ -134,7 +136,15 @@ export default (
|
|
|
134
136
|
if (isQueuedPendingTx(tx, baseAssetName, activeWalletAccount, getTxLog))
|
|
135
137
|
return wrapResponseToObject({ errorMessage: 'there is a stuck TX with lower nonce' })
|
|
136
138
|
|
|
137
|
-
const { gasPrice: currentGasPrice } = getFeeData(assetName)
|
|
139
|
+
const { gasPrice: currentGasPrice, gasPriceMinimumRate } = getFeeData(assetName)
|
|
140
|
+
// converting to the smallest unit to avoid rounding errors
|
|
141
|
+
if (
|
|
142
|
+
calculateTxGasPrice(tx)
|
|
143
|
+
.to('wei')
|
|
144
|
+
.gte(currentGasPrice.mul(gasPriceMinimumRate).to('wei'))
|
|
145
|
+
)
|
|
146
|
+
return wrapResponseToObject({ errorMessage: 'the used gas price is still high enough' })
|
|
147
|
+
|
|
138
148
|
const gasPriceToUse = calculateBumpedGasPrice(tx, currentGasPrice)
|
|
139
149
|
const replacementFee = gasPriceToUse.mul(tx.data.gasLimit)
|
|
140
150
|
const extraEthNeeded = replacementFee.sub(tx.feeAmount)
|