粉尘低于现货最小可卖量时忽略且不展示、不再重试卖回。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-07 11:16:13 +08:00
parent 80ef5ceccb
commit 030b237981
8 changed files with 183 additions and 19 deletions
+29 -9
View File
@@ -2317,15 +2317,33 @@
return n.toFixed(8).replace(/\.?0+$/, "");
}
function spotSellMinSz(ss, uly) {
const u = String(uly || "ETH").toUpperCase();
const fromApi = u === "BTC" ? Number(ss && ss.min_sz_btc) : Number(ss && ss.min_sz_eth);
if (Number.isFinite(fromApi) && fromApi > 0) return fromApi;
return u === "BTC" ? 0.00001 : 0.0001;
}
function shouldShowSpotSellBanner(d, positions) {
// 币本位下始终露出「重试卖回」(含有仓):便于清交易户残留,文案随选中/残留标的变化
// 仅当交易户有「可卖」(>= 现货 minSz)残留时展示;粉尘不展示、不提示重试
const ss = (d && d.spot_sell) || {};
const eth = Number(ss.trading_eth || 0);
const btc = Number(ss.trading_btc || 0);
const ethOk = eth >= spotSellMinSz(ss, "ETH");
const btcOk = btc >= spotSellMinSz(ss, "BTC");
if (ethOk || btcOk) return true;
const hasCoinPos = (positions || []).some(function (p) { return isCoinPos(p); });
const coinMode =
isCoinMarginMode() ||
hasCoinPos ||
(d && d.options_margin_mode === "coin") ||
!!(d && d.spot_sell);
return !!coinMode;
(d && d.options_margin_mode === "coin");
// 待卖回桥且仍有可卖数量时才露按钮(粉尘桥后端会关掉)
if (coinMode && ss.bridge_status === "pending_sell_spot") {
const bu = String(ss.bridge_underlying || "").toUpperCase();
const amt = bu === "BTC" ? btc : eth;
return amt >= spotSellMinSz(ss, bu || "ETH");
}
return false;
}
function spotSellUnderlying(ss) {
@@ -2334,14 +2352,16 @@
const bridgeUly = String(ss.bridge_underlying || "").trim().toUpperCase();
const eth = Number(ss.trading_eth || 0);
const btc = Number(ss.trading_btc || 0);
// 待卖回桥优先;否则优先当前选中标的上的残留,再比大小
const ethMin = spotSellMinSz(ss, "ETH");
const btcMin = spotSellMinSz(ss, "BTC");
// 待卖回桥优先;否则优先当前选中标的上的可卖残留
if (bridgeUly === "BTC" || bridgeUly === "ETH") {
if (ss.bridge_status === "pending_sell_spot") return bridgeUly;
}
if (selected === "BTC" && btc > 1e-12) return "BTC";
if (selected === "ETH" && eth > 1e-12) return "ETH";
if (btc > eth && btc > 1e-12) return "BTC";
if (eth > 1e-12) return "ETH";
if (selected === "BTC" && btc >= btcMin) return "BTC";
if (selected === "ETH" && eth >= ethMin) return "ETH";
if (btc >= btcMin && btc >= eth) return "BTC";
if (eth >= ethMin) return "ETH";
if (bridgeUly === "BTC" || bridgeUly === "ETH") return bridgeUly;
return (ss.default_underly || selected || "ETH").toUpperCase();
}