From 38100a523ec6473bd34ee65275072900f202c439 Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Wed, 10 Dec 2025 16:30:40 +0000 Subject: [PATCH] chore: better logs on sweep errors --- packages/server/lib/plugins/wallet/geth/base.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/server/lib/plugins/wallet/geth/base.js b/packages/server/lib/plugins/wallet/geth/base.js index e8290f8..16880ad 100644 --- a/packages/server/lib/plugins/wallet/geth/base.js +++ b/packages/server/lib/plugins/wallet/geth/base.js @@ -269,10 +269,15 @@ function generateTx(_toAddress, wallet, amount, includesFee) { const maxPriorityFeePerGas = new BN(web3.utils.toWei('1.0', 'gwei')) // web3 default value const maxFeePerGas = baseFeePerGas.times(2).plus(maxPriorityFeePerGas) + const fee = maxFeePerGas.times(gas) - const toSend = includesFee - ? new BN(amount).minus(maxFeePerGas.times(gas)) - : amount + const toSend = includesFee ? new BN(amount).minus(fee) : 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 = { chainId: 1,