chore: better logs on sweep errors
This commit is contained in:
parent
e2c49ea43c
commit
38100a523e
1 changed files with 8 additions and 3 deletions
|
|
@ -269,10 +269,15 @@ function generateTx(_toAddress, wallet, amount, includesFee) {
|
||||||
|
|
||||||
const maxPriorityFeePerGas = new BN(web3.utils.toWei('1.0', 'gwei')) // web3 default value
|
const maxPriorityFeePerGas = new BN(web3.utils.toWei('1.0', 'gwei')) // web3 default value
|
||||||
const maxFeePerGas = baseFeePerGas.times(2).plus(maxPriorityFeePerGas)
|
const maxFeePerGas = baseFeePerGas.times(2).plus(maxPriorityFeePerGas)
|
||||||
|
const fee = maxFeePerGas.times(gas)
|
||||||
|
|
||||||
const toSend = includesFee
|
const toSend = includesFee ? new BN(amount).minus(fee) : amount
|
||||||
? new BN(amount).minus(maxFeePerGas.times(gas))
|
|
||||||
: amount
|
if (toSend.lt(0)) {
|
||||||
|
throw new Error(
|
||||||
|
`Fees (${fee.toString()}) are greater than available balance (${amount.toString()}); nonce: ${txCount}, gasLimit: ${gas.toString()}, maxFeePerGas: ${maxFeePerGas.toString()}, baseFeePerGas: ${baseFeePerGas.toString()}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const rawTx = {
|
const rawTx = {
|
||||||
chainId: 1,
|
chainId: 1,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue