币本位隐藏 USDT↔USDC 兑换,持仓区与设置仅保留划转。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-20 15:45:11 +08:00
parent a257d7e369
commit 7ca31b74fb
5 changed files with 51 additions and 20 deletions
+20 -14
View File
@@ -42,9 +42,13 @@
return window.confirm(message);
}
function roundAvail(v) {
function roundAvail(v, ccy) {
const n = Number(v);
if (!Number.isFinite(n) || n <= 0) return null;
const u = String(ccy || "").toUpperCase();
if (u === "ETH" || u === "BTC") {
return Math.round(n * 1e8) / 1e8;
}
return Math.round(n * 100) / 100;
}
@@ -63,7 +67,7 @@
const c = String(ccy || "").toLowerCase();
const availKey = acct + "_" + c + "_avail";
const totalKey = acct + "_" + c;
return roundAvail(bal[availKey] != null ? bal[availKey] : bal[totalKey]);
return roundAvail(bal[availKey] != null ? bal[availKey] : bal[totalKey], ccy);
}
async function resolveSwapMaxAmount(dir) {
@@ -130,10 +134,11 @@
function bindFundsUi(ids) {
const swapBtn = document.getElementById(ids.swapBtn);
if (!swapBtn) return;
const intBtn = document.getElementById(ids.intBtn);
if (!swapBtn && !intBtn) return;
const swapBtns = [ids.swapBtn, ids.swapAllBtn];
const intBtns = [ids.intBtn, ids.intAllBtn];
const swapBtns = [ids.swapBtn, ids.swapAllBtn].filter(Boolean);
const intBtns = [ids.intBtn, ids.intAllBtn].filter(Boolean);
async function submitSwap(amount) {
setButtonsBusy(swapBtns, ids.swapAmount, true, "兑换中…");
@@ -191,14 +196,16 @@
}
}
swapBtn.addEventListener("click", async function () {
const amount = parseFloat(document.getElementById(ids.swapAmount).value);
if (!amount || amount <= 0) {
setMsg(ids.swapMsg, "请输入有效数量", true);
return;
}
await submitSwap(amount);
});
if (swapBtn) {
swapBtn.addEventListener("click", async function () {
const amount = parseFloat(document.getElementById(ids.swapAmount).value);
if (!amount || amount <= 0) {
setMsg(ids.swapMsg, "请输入有效数量", true);
return;
}
await submitSwap(amount);
});
}
const swapAllBtn = document.getElementById(ids.swapAllBtn);
if (swapAllBtn) {
@@ -247,7 +254,6 @@
});
}
const intBtn = document.getElementById(ids.intBtn);
if (intBtn) {
intBtn.addEventListener("click", async function () {
const amount = parseFloat(document.getElementById(ids.intAmount).value);