Merge pull request #1339 from chaotixkilla/fix-add-sweep-margin-to-avoid-failure-8.0

[8.0] Fix EIP-1559 fees
This commit is contained in:
Rafael Taranto 2022-08-05 23:28:55 +01:00 committed by GitHub
commit 21a798d08d
2 changed files with 8 additions and 6 deletions

View file

@ -210,12 +210,14 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
.then(([gas, gasPrice, txCount, baseFeePerGas]) => {
lastUsedNonces[fromAddress] = txCount
const toSend = includesFee
? amount.minus(gasPrice.times(gas))
: amount
const maxPriorityFeePerGas = new BN(web3.utils.toWei('2.5', 'gwei')) // web3 default value
const maxFeePerGas = new BN(2).times(baseFeePerGas).plus(maxPriorityFeePerGas)
const neededPriority = new BN(web3.utils.toWei('2.0', 'gwei'))
const maxFeePerGas = baseFeePerGas.plus(neededPriority)
const newGasPrice = BN.minimum(maxFeePerGas, baseFeePerGas.plus(maxPriorityFeePerGas))
const toSend = includesFee
? new BN(amount).minus(newGasPrice.times(gas))
: amount
const rawTx = {
chainId: 1,