Skip to content

Commit

Permalink
Correct USDC max transfer amount calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Jan 5, 2024
1 parent 2b4a4ac commit 0a3e72b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,8 @@ export async function createTransactionRequest(
const { fee, gasPrice, gasLimit, relay } = await calculateFee(token, method, forceRelay);

// Ensure we send only what's possible with the updated fee
amount = Math.min(amount, (addressInfo.balance || 0) - fee.toNumber());
const accountBalance = token === config.usdc.usdcContract ? addressInfo.balance : addressInfo.nativeBalance;
amount = Math.min(amount, (accountBalance || 0) - fee.toNumber());

// // To be safe, we still check that amount + fee fits into the current allowance
// if (method === 'transfer' && usdcAllowance.lt(fee.add(amount))) {
Expand Down

0 comments on commit 0a3e72b

Please sign in to comment.