| … | … | @@ -2939,7 +2939,20 @@ async function setMaxAmount() { |
| 2939 | 2939 | ? formatSats(estimatedFee) |
| 2940 | 2940 | : formatEthFee(estimatedFee) |
| 2941 | 2941 | |
| 2942 | | const unit = currentSendChain === 'bitcoin' ? 'sats' : 'wei' |
| 2942 | // For tokens, fee is in ETH (different currency), so show separately |
| 2943 | const isToken = currentSendChain.includes('usdt') || currentSendChain.includes('usdc') |
| 2944 | let totalDisplay |
| 2945 | if (currentSendChain === 'bitcoin') { |
| 2946 | totalDisplay = `${currentBalance.toLocaleString()} sats` |
| 2947 | } else if (isToken) { |
| 2948 | const tokenSymbol = currentSendChain.includes('usdt') ? 'USDT' : 'USDC' |
| 2949 | const tokenAmount = Number(maxAmount) / (currentSendChain.includes('usdt') ? 1e6 : 1e6) |
| 2950 | totalDisplay = `${tokenAmount.toFixed(2)} ${tokenSymbol} + ${feeFormatted} gas` |
| 2951 | } else { |
| 2952 | // Native ETH |
| 2953 | const totalEth = Number(currentBalance) / 1e18 |
| 2954 | totalDisplay = `${totalEth.toFixed(6)} ETH` |
| 2955 | } |
| 2943 | 2956 | |
| 2944 | 2957 | document.getElementById('fee-display').innerHTML = ` |
| 2945 | 2958 | <div class="fee-option"> |
| … | … | @@ -2948,7 +2961,7 @@ async function setMaxAmount() { |
| 2948 | 2961 | </div> |
| 2949 | 2962 | <div class="fee-option"> |
| 2950 | 2963 | <span class="fee-label">Total</span> |
| 2951 | | <span class="fee-value">${currentBalance.toLocaleString()} ${unit}</span> |
| 2964 | <span class="fee-value">${totalDisplay}</span> |
| 2952 | 2965 | </div> |
| 2953 | 2966 | <p class="help-text" style="margin-top: 0.5rem; color: #f59e0b;"> |
| 2954 | 2967 | ℹ️ Max amount is your balance minus transaction fees |
| … | … | @@ -3005,6 +3018,21 @@ async function estimateFee() { |
| 3005 | 3018 | ? formatSats(data.fee) |
| 3006 | 3019 | : formatEthFee(data.fee) |
| 3007 | 3020 | |
| 3021 | // For tokens, fee is in ETH (different currency), so show separately |
| 3022 | const isToken = currentSendChain.includes('usdt') || currentSendChain.includes('usdc') |
| 3023 | let totalDisplay |
| 3024 | if (currentSendChain === 'bitcoin') { |
| 3025 | totalDisplay = `${Number(amount) + Number(data.fee)} sats` |
| 3026 | } else if (isToken) { |
| 3027 | const tokenSymbol = currentSendChain.includes('usdt') ? 'USDT' : 'USDC' |
| 3028 | totalDisplay = `${amount} ${tokenSymbol} + ${feeFormatted} gas` |
| 3029 | } else { |
| 3030 | // Native ETH - convert both to ETH for total |
| 3031 | const totalWei = BigInt(amount) + BigInt(data.fee) |
| 3032 | const totalEth = Number(totalWei) / 1e18 |
| 3033 | totalDisplay = `${totalEth.toFixed(6)} ETH` |
| 3034 | } |
| 3035 | |
| 3008 | 3036 | document.getElementById('fee-display').innerHTML = ` |
| 3009 | 3037 | <div class="fee-option"> |
| 3010 | 3038 | <span class="fee-label">Estimated Fee</span> |
| … | … | @@ -3012,7 +3040,7 @@ async function estimateFee() { |
| 3012 | 3040 | </div> |
| 3013 | 3041 | <div class="fee-option"> |
| 3014 | 3042 | <span class="fee-label">Total</span> |
| 3015 | | <span class="fee-value">${Number(amount) + Number(data.fee)} ${currentSendChain === 'bitcoin' ? 'sats' : 'wei'}</span> |
| 3043 | <span class="fee-value">${totalDisplay}</span> |
| 3016 | 3044 | </div> |
| 3017 | 3045 | ` |
| 3018 | 3046 | } catch (err) { |