Skip to content

Commit

Permalink
Update account.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Nov 20, 2024
1 parent 5cb2450 commit c7c91a8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,20 +529,20 @@ export async function sweepToMainWallet(
}
}

if (cumulativeGasLimit.mul(gasPrice).mul(120).div(100).gt(fromWallet.BALANCE)) {
if (cumulativeGasLimit.mul(gasPrice).mul(125).div(100).gt(fromWallet.BALANCE)) {
const span = tracer?.startSpan("fund-wallet-to-sweep", undefined, mainCtx);
span?.setAttribute("details.wallet", fromWallet.account.address);
try {
const transferAmount = cumulativeGasLimit
.mul(gasPrice)
.mul(120)
.mul(125)
.div(100)
.sub(fromWallet.BALANCE);
span?.setAttribute("details.amount", ethers.utils.formatUnits(transferAmount));
const hash = await toWallet.sendTransaction({
to: fromWallet.account.address,
value: transferAmount.toBigInt(),
nonce: await getNonce(fromWallet),
nonce: await getNonce(toWallet),
});
const receipt = await toWallet.waitForTransactionReceipt({
hash,
Expand Down Expand Up @@ -640,6 +640,7 @@ export async function sweepToMainWallet(
if (transferAmount.gt(0)) {
span?.setAttribute("details.amount", ethers.utils.formatUnits(transferAmount));
const hash = await fromWallet.sendTransaction({
gasPrice,
to: toWallet.account.address,
value: transferAmount.toBigInt(),
gas: gasLimit.toBigInt(),
Expand Down

0 comments on commit c7c91a8

Please sign in to comment.