Merge pull request #1338 from chaotixkilla/fix-add-sweep-margin-to-avoid-failure
[8.1] Fix EIP-1559 fees
This commit is contained in:
commit
6cde7f3c98
2 changed files with 10 additions and 8 deletions
|
|
@ -263,7 +263,7 @@ settingsLoader.loadLatest()
|
||||||
}
|
}
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
chainId: 3,
|
chainId: 1,
|
||||||
nonce: 0,
|
nonce: 0,
|
||||||
includesFee: true
|
includesFee: true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,18 +210,20 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
|
||||||
.then(([gas, gasPrice, txCount, baseFeePerGas]) => {
|
.then(([gas, gasPrice, txCount, baseFeePerGas]) => {
|
||||||
lastUsedNonces[fromAddress] = txCount
|
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 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 = {
|
const rawTx = {
|
||||||
chainId: 1,
|
chainId: 1,
|
||||||
nonce: txCount,
|
nonce: txCount,
|
||||||
maxPriorityFeePerGas: web3.utils.toHex(web3.utils.toWei(maxPriorityFeePerGas.toString(), 'gwei')),
|
maxPriorityFeePerGas: web3.utils.toHex(maxPriorityFeePerGas),
|
||||||
maxFeePerGas: web3.utils.toHex(web3.utils.toWei(maxFeePerGas.toString(), 'gwei')),
|
maxFeePerGas: web3.utils.toHex(maxFeePerGas),
|
||||||
gasLimit: hex(gas),
|
gasLimit: hex(gas),
|
||||||
to: toAddress,
|
to: toAddress,
|
||||||
from: fromAddress,
|
from: fromAddress,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue