fix: ETH fees

This commit is contained in:
Sérgio Salgado 2022-08-03 19:26:14 +01:00
parent 5c8b311c88
commit 3bd7e3463e

View file

@ -205,12 +205,14 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
.then(([gas, gasPrice, txCount, baseFeePerGas]) => {
lastUsedNonces[fromAddress] = txCount
const toSend = includesFee
? new BN(amount.times(0.99999).toFixed(0, BigNumber.ROUND_DOWN)).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 = BigNumber.minimum(maxFeePerGas, baseFeePerGas.plus(maxPriorityFeePerGas))
const toSend = includesFee
? new BN(amount).minus(newGasPrice.times(gas))
: amount
const rawTx = {
chainId: 1,